C# Maui ListView 實作Select Item 改變顏色 [VisualState + Event Function]
C# Maui ListView 實作Select Item 改變顏色 [VisualState + Event Function]
資料來源: 公司專案(起因:因為VisualStateGroupList對於Selected 事件無反應)
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:VPOS.CustomControls"
x:Class="VPOS.MainPage"
Background="#194a6e"
Title=""><!-- 隱藏標題 -->
<ContentPage.Resources> <!-- https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/selection -->
<Style TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="#FF0000" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ContentPage.Resources>
<Grid x:Name="FullGrid"
Padding="3"
RowSpacing="2" ColumnSpacing="2" >
<Grid.RowDefinitions>
<RowDefinition /><!--Workspace -->
<RowDefinition Height="40" /><!--status column -->
</Grid.RowDefinitions>
<Grid x:Name="WorkspaceGrid"
RowSpacing="2" ColumnSpacing="2"
Grid.Row="0" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/><!-- Menu -->
<ColumnDefinition /><!-- Content -->
</Grid.ColumnDefinitions>
<Grid x:Name="MenuGrid"
RowSpacing="2" ColumnSpacing="2"
Grid.Row="0" Grid.Column="0">
<Border x:Name="MenuBorder"
Stroke="#194a6e"
StrokeThickness="0"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<VerticalStackLayout Spacing="5">
<ImageButton x:Name="SettingsBtn"
BorderColor="White"
BorderWidth="2"
CornerRadius="5"
BackgroundColor="#194a6e"
Source = "settings.png"
Clicked="SettingsBtn_Clicked"
HorizontalOptions="Fill"
VerticalOptions="Fill">
</ImageButton>
<ImageButton x:Name="DevicesBtn"
BorderColor="White"
BorderWidth="2"
CornerRadius="5"
BackgroundColor="#194a6e"
Source = "device.png"
Clicked="DevicesBtn_Clicked"
HorizontalOptions="Fill"
VerticalOptions="Fill">
</ImageButton>
<ImageButton x:Name="SynchronizeBtn"
BorderColor="White"
BorderWidth="2"
CornerRadius="5"
BackgroundColor="#194a6e"
Source = "synchronize.png"
Clicked="SynchronizeBtn_Clicked"
HorizontalOptions="Fill"
VerticalOptions="Fill">
</ImageButton>
<ImageButton x:Name="LogoutBtn"
BorderColor="White"
BorderWidth="2"
CornerRadius="5"
BackgroundColor="#194a6e"
Source = "logout.png"
Clicked="LogoutBtn_Clicked"
HorizontalOptions="Fill"
VerticalOptions="Fill">
</ImageButton>
</VerticalStackLayout>
</Border><!--MenuBorder-->
</Grid><!--MenuGrid-->
<Grid x:Name="ContentGrid"
RowSpacing="2" ColumnSpacing="2"
Grid.Row="0" Grid.Column="1"
ColumnDefinitions="5.2*,0.8*,6*">
<Border x:Name="LeftContentBorder"
Grid.Row="0" Grid.Column="0"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="LeftContentGrid"
RowDefinitions="3.5*,5.5*,2*">
<Border x:Name="LeftContentBorder00"
Grid.Row="0" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="ShowInfoGrid"
RowDefinitions="1.3*,1.2*,*">
<Grid x:Name="ShowInfoGrid00"
Margin="4,0"
RowSpacing="0" ColumnSpacing="0"
Grid.Row="0" Grid.Column="0"
RowDefinitions="0.4*,0.3*,0.3*"
ColumnDefinitions="*,*,*,*,*,*" IsEnabled="True">
<Label x:Name="OrderStatusLable"
Grid.Row="0" Grid.ColumnSpan="6"
Text="訂購中"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Large"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="QuantityTextLable"
Grid.Row="1" Grid.Column="0"
Text="商品數量:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="QuantityValueLable"
Grid.Row="1" Grid.Column="1"
Text="10000"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Medium"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="DiscountTextLable"
Grid.Row="1" Grid.Column="2"
Text="優惠金額:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="DiscountValueLable"
Grid.Row="1" Grid.Column="3"
Text="10000"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Medium"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ServiceTextLable"
Grid.Row="1" Grid.Column="4"
Text="服務費:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ServiceValueLable"
Grid.Row="1" Grid.Column="5"
Text="10000"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Medium"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ReceivableTextLable"
Grid.Row="2" Grid.Column="0"
Text="應收總額:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ReceivableValueLable"
Grid.Row="2" Grid.Column="1"
Text="30000"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Medium"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ChangeTextLable"
Grid.Row="2" Grid.Column="2"
Text="找零金額:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ChangeValueLable"
Grid.Row="2" Grid.Column="3"
Text="10000"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Medium"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
</Grid>
<Grid x:Name="ShowInfoGrid01"
Margin="4,0"
RowSpacing="0" ColumnSpacing="0"
Grid.Row="1" Grid.Column="0"
RowDefinitions="2,*,*,*"
ColumnDefinitions="1.09*,1.99*,1.09*,1.5*,0.9*,0.6*">
<Border x:Name="ShowInfoLine00"
Grid.Row="0" Grid.ColumnSpan="6"
Stroke="Black"
StrokeThickness="0.5"/>
<Label x:Name="OrderNoTextLable"
Grid.Row="1" Grid.Column="0"
Text="訂單編號:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="OrderNoValueLable"
Grid.Row="1" Grid.Column="1"
Text="20230927-0001"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="PickupNoTextLable"
Grid.Row="1" Grid.Column="2"
Text="取餐號:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="PickupNoValueLable"
Grid.Row="1" Grid.Column="3"
Text="00000001"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="VisitorsTextLable"
Grid.Row="1" Grid.Column="4"
Text="來客數:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="VisitorsValueLable"
Grid.Row="1" Grid.Column="5"
Text="0001"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="OrderTypeTextLable"
Grid.Row="2" Grid.Column="0"
Text="訂單類型:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="OrderTypeValueLable"
Grid.Row="2" Grid.Column="1"
Text="Uber Eats"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="TableNoTextLable"
Grid.Row="2" Grid.Column="2"
Text="桌號:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="TableNoValueLable"
Grid.Row="2" Grid.Column="3"
Text="豪華廳A0001"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ShopNoTextLable"
Grid.Row="2" Grid.Column="4"
Text="牌號:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="ShopNoValueLable"
Grid.Row="2" Grid.Column="5"
Text="100"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="MemberNameTextLable"
Grid.Row="3" Grid.Column="0"
Text="會員名稱:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="MemberNameValueLable"
Grid.Row="3" Grid.Column="1"
Text="合用系統有限公司"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="MemberTelTextLable"
Grid.Row="3" Grid.Column="2"
Text="會員電話:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="MemberTelValueLable"
Grid.Row="3" Grid.Column="3"
Text="04-22216292"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
</Grid>
<Grid x:Name="ShowInfoGrid02"
Margin="4,0"
RowSpacing="1" ColumnSpacing="0"
Grid.Row="2" Grid.Column="0"
RowDefinitions="2,*,*"
ColumnDefinitions="1*,1.3*,0.6*,1.31*,1.19*,0.6*">
<Border x:Name="ShowInfoLine01"
Grid.Row="0" Grid.ColumnSpan="6"
Stroke="Black"
StrokeThickness="0.5"/>
<Label x:Name="InvoiceNoTextLable"
Grid.Row="1" Grid.Column="0"
Text="發票號碼:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="InvoiceNoValueLable"
Grid.Row="1" Grid.Column="1"
Text="AB14433816"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="InvoiceNoBtn"
Grid.Row="1" Grid.Column="2" Grid.RowSpan="2"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="InvoiceCountTextLable"
Grid.Row="1" Grid.Column="3"
Text="發票剩餘張數:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="InvoiceCountValueLable"
Grid.Row="1" Grid.Column="4"
Text="100"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="CarrierBtn"
Grid.Row="1" Grid.Column="5" Grid.RowSpan="2"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="TaxIDTextLable"
Grid.Row="2" Grid.Column="0"
Text="客戶統編:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="TaxIDValueLable"
Grid.Row="2" Grid.Column="1"
Text="42897648"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Small"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="CarrierTextLable"
Grid.Row="2" Grid.Column="3"
Text="發票載具:"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<Label x:Name="CarrierValueLable"
Grid.Row="2" Grid.Column="4"
Text="/RZDFEP2"
LineBreakMode="WordWrap"
TextColor="Black"
FontSize="Micro"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
</Grid>
</Grid><!--ShowInforGrid-->
</Border><!--LeftContentBorder00-->
<Border x:Name="LeftContentBorder01"
Grid.Row="1" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="ShopcartGrid"
RowSpacing="2" ColumnSpacing="2"
ColumnDefinitions="5.2*,0.8*">
<Grid x:Name="ShopcartMainGrid"
Grid.Row="0" Grid.Column="0"
RowDefinitions="*" ColumnDefinitions="*">
<ListView x:Name="ShopcartListView"
Grid.Row="0" Grid.Column="0"
SelectionMode="Single"
BackgroundColor="White"
IsPullToRefreshEnabled="True" IsRefreshing="True"
VerticalScrollBarVisibility="Never"
ItemSelected="ShopcartListView_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<!-- ListView 資料結構標準: ListView.ItemTemplate -> DataTemplate -> ViewCell-->
<Grid BackgroundColor="{Binding BColor}" ColumnDefinitions="30,15,4.6*,0.5*,1*,1.2*" Margin="8,0,7,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="White" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<Image Source="{Binding Image00}" WidthRequest="20" HeightRequest="20" Grid.Column="0" >
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="ShopcartListViewImage00_Clicked" />
</Image.GestureRecognizers>
</Image>
<Image Source="{Binding Image01}" WidthRequest="10" HeightRequest="10" Grid.Column="1" >
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="ShopcartListViewImage01_Clicked" />
</Image.GestureRecognizers>
</Image>
<Label Text="{Binding Name}" FontSize="{Binding Font_Size}" FontAutoScalingEnabled="True" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" TextColor="{Binding Font_Color}" Grid.Column="2" />
<Label Text="{Binding Amount}" FontSize="{Binding Font_Size}" FontAutoScalingEnabled="True" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" TextColor="{Binding Font_Color}" Grid.Column="3" />
<Label Text="{Binding Price}" FontSize="{Binding Font_Size}" FontAutoScalingEnabled="True" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" TextColor="{Binding Font_Color}" Grid.Column="4" />
<Label Text="{Binding Sum}" FontSize="{Binding Font_Size}" FontAutoScalingEnabled="True" HorizontalTextAlignment="End" VerticalTextAlignment="Center" TextColor="{Binding Font_Color}" Grid.Column="5" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<Border x:Name="ShopcartBtnBorder"
Grid.Row="0" Grid.Column="1"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<VerticalStackLayout
x:Name="ShopcartBtnVertical"
Padding="3" Spacing="10">
<local:CustBtn x:Name="ModifiedBtn"
HorizontalOptions="Fill"
VerticalOptions="Center">
</local:CustBtn>
<local:CustBtn x:Name="PlusBtn"
HorizontalOptions="Fill"
VerticalOptions="Center">
</local:CustBtn>
<local:CustBtn x:Name="MinusBtn"
HorizontalOptions="Fill"
VerticalOptions="Center">
</local:CustBtn>
</VerticalStackLayout>
</Border>
</Grid><!--ShopcartGrid-->
</Border><!--LeftContentBorder01-->
<Border x:Name="LeftContentBorder02"
Grid.Row="2" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="ShopcartBtnGrid"
Margin="1,2"
RowSpacing="1" ColumnSpacing="1"
RowDefinitions="*,*"
ColumnDefinitions="*,*,*,*,*">
<local:CustBtn x:Name="ShopcartBtn00"
Grid.Row="0" Grid.Column="0"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn01"
Grid.Row="0" Grid.Column="1"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn02"
Grid.Row="0" Grid.Column="2"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn03"
Grid.Row="0" Grid.Column="3"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn04"
Grid.Row="0" Grid.Column="4" Grid.RowSpan="2"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn05"
Grid.Row="1" Grid.Column="0"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn06"
Grid.Row="1" Grid.Column="1"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn07"
Grid.Row="1" Grid.Column="2"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ShopcartBtn08"
Grid.Row="1" Grid.Column="3"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
</Grid>
</Border><!--LeftContentBorder02-->
</Grid><!--LeftContentGrid-->
</Border><!--LeftContentBorder-->
<Border x:Name="MiddleContentBorder"
Grid.Row="0" Grid.Column="1"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<VerticalStackLayout x:Name="MiddleVerticalStackLayout"
Spacing="5" Margin="5,10,5,10">
</VerticalStackLayout>
</Border><!--MiddleContentBorder-->
<Border x:Name="RightContentBorder"
Grid.Row="0" Grid.Column="2"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="RightContentGrid"
RowSpacing="2" ColumnSpacing="2"
RowDefinitions="2*,7*,2*">
<Border x:Name="RightContentBorder00"
Grid.Row="0" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="CategoryBtnGrid"
ColumnDefinitions="5*,0.5*">
<Border x:Name="CategoryBtnBorder01"
Grid.Row="0" Grid.Column="1"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid RowDefinitions="*,0.85*,*" Margin="0,3,0,3">
<local:CustBtn x:Name="CategoryUpBtn"
Grid.Row="0" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="Start">
</local:CustBtn>
<Label x:Name="CategoryTextLable"
Grid.Row="1" Grid.Column="0"
Text="1/2"
LineBreakMode="WordWrap"
TextColor="White"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="CategoryDownBtn"
Grid.Row="2" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="End">
</local:CustBtn>
</Grid>
</Border>
</Grid>
</Border><!--RightContentBorder00-->
<Border x:Name="RightContentBorder01"
Grid.Row="1" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="ProductBtnGrid"
ColumnDefinitions="5*,0.5*">
<Border x:Name="ProductBtnBorder01"
Grid.Row="0" Grid.Column="1"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid RowDefinitions="*,0.3*,*">
<local:CustBtn x:Name="ProductUpBtn"
Grid.Row="0" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="End">
</local:CustBtn>
<Label x:Name="ProductTextLable"
Grid.Row="1" Grid.Column="0"
Text="1/2"
LineBreakMode="WordWrap"
TextColor="White"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="ProductDownBtn"
Grid.Row="2" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="Start">
</local:CustBtn>
</Grid>
</Border>
</Grid>
</Border><!--RightContentBorder01-->
<Border x:Name="RightContentBorder02"
Grid.Row="2" Grid.Column="0"
Stroke="#194a6e"
StrokeThickness="1"
Background="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid x:Name="CondimentBtnGrid"
ColumnDefinitions="5*,0.5*">
<Border x:Name="CondimentBtnBorder01"
Grid.Row="0" Grid.Column="1"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid RowDefinitions="*,0.85*,*" Margin="0,3,0,3">
<local:CustBtn x:Name="CondimentUpBtn"
Grid.Row="0" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="Start">
</local:CustBtn>
<Label x:Name="CondimentTextLable"
Grid.Row="1" Grid.Column="0"
Text="1/2"
LineBreakMode="WordWrap"
TextColor="White"
FontSize="Default"
FontAutoScalingEnabled="True"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
<local:CustBtn x:Name="CondimentDownBtn"
Grid.Row="2" Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="End">
</local:CustBtn>
</Grid>
</Border>
</Grid>
</Border><!--RightContentBorder02-->
</Grid><!--RightContentGrid-->
</Border><!--RightContentBorder-->
</Grid><!--ContentGrid-->
</Grid><!--WorkspaceGrid-->
<Grid x:Name="StatusGrid"
Grid.Row="1" Grid.Column="0">
<Border x:Name="StatusBorder"
Stroke="White"
StrokeThickness="1"
Background="#194a6e">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
</Border><!--StatusBorder-->
</Grid><!--StatusGrid-->
</Grid><!--FullGrid-->
</ContentPage>
MainPage.xaml.cs
using CommunityToolkit.Maui.Views;
using System.Data;
using System.Diagnostics;
using System.Reflection;
using VPOS.CustomControls;
using VPOS.Views;
using System.Collections.ObjectModel;
using Microsoft.Maui.Platform;
namespace VPOS
{
public class ShopcartItem
{
public string id { get; set; }
public string Image00 { get; set; }
public string Image01 { get; set; }
public string Name { get; set; }
public string Amount { get; set; }
public string Price { get; set; }
public string Sum { get; set; }
public string image_id { get; set; }
public Color Font_Color { get; set; }
public double Font_Size { get; set; }
public string State { get; set; }
public Color BColor { get; set; }
}
public partial class MainPage : ContentPage
{
private String m_StrTab = " ";
public static String m_StrVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
public static String m_StrDeviceCode = FileLib.GetDeviceCode();
//---
//建立購物車相關變數區
public static ShopCart m_ShopCart = null;
//---建立購物車相關變數區
public static List<func_mainData> m_funcMain = new List<func_mainData>();
//---
//訂單號相關變數
private int m_intOrderState = 0;//0:new,1已結帳,2暫存
public static String m_StrPosOrderNumber = "";//紀錄訂單號的成員變數
public static String m_StrCustEinNumber = "";//紀錄客戶統一編號
public static String m_StrCustCarrierNumber = "";//紀錄客戶發票載具
public static bool m_blnMobileCarrier = false;//紀錄客戶發票載具類型
public static String m_StrEasyCardPhysicalID = "";//紀錄交易悠遊卡內碼(發票載具)
public static String m_StrLinePayCarrierNumber = "";//紀錄LinePay的paymentSID(發票載具)
public static int m_intClassSid = 0;
public static String m_StrClassName = "";//紀錄顯示用的班別資訊
public static String m_StrGuestsNumber = "0";//來客數
public static String m_StrEmployeeNo = "";//紀錄登入帳號的employee_no值
public static String m_StrUserAccount = "";//紀錄登入帳號的user_account值
public static String m_StrUserSID = "";//紀錄登入帳號的user_sid值
private const int m_intOrderNumberTestMaxCount = 50;//建立訂單號最大嘗試次數
//---訂單號相關變數
//---
//建立orderButton陣列
public order_type_data_params m_order_type_data_params = null;
public static int m_intOrderTypeIdSelected = 0;
public static String m_StrOrderTypeNameSelected = "";
public static String m_StrOrderTypeCodeSelected = "";
public static int m_intOrderTypeInvoiceState = 0;//開立發票選項 0:預設 1:暫停不開 2:詢問
public static int m_intVTS_TOGOInvoiceState = 0;//開立發票選項 0:預設 1:暫停不開 2:詢問
public static int m_intFOODPANDAInvoiceState = 0;//開立發票選項 0:預設 1:暫停不開 2:詢問
public static int m_intUBER_EATSInvoiceState = 0;//開立發票選項 0:預設 1:暫停不開 2:詢問
CustBtn[] m_OrderBtn;
private void MiddleRowButtonInit()//中間按鈕
{
bool blnTakeawayOrdersButton = false;//紀錄是否顯示[外賣接單]按鈕
m_intOrderTypeIdSelected = -1;
m_StrOrderTypeNameSelected = "";
m_StrOrderTypeCodeSelected = "";
m_OrderBtn = new CustBtn[10];
int j = 0;
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
var tapGestureRecognizer00 = new TapGestureRecognizer();
tapGestureRecognizer00.Tapped += OrderBtn_Click;
//---
//顯示POS訂單類型
for (int i = 0; i < SqliteDataAccess.m_order_type_data.Count; i++)
{
if (SqliteDataAccess.m_order_type_data[i].display_state == "Y")
{
m_OrderBtn[j] = new CustBtn();
m_OrderBtn[j].IsVisible = true;
m_OrderBtn[j].InitData(SqliteDataAccess.m_order_type_data[i].SID);
m_OrderBtn[j].m_intPrice = SqliteDataAccess.m_order_type_data[i].price_type_sid;
m_OrderBtn[j].m_StrProductCode = SqliteDataAccess.m_order_type_data[i].order_type_code;
m_OrderBtn[j].InitDisplay(Colors.White, new Color(204, 102, 0), new Color(255, 153, 91), SqliteDataAccess.m_order_type_data[i].type_name, dblFontSize);
m_OrderBtn[j].m_min_count = SqliteDataAccess.m_order_type_data[i].invoice_state;//開立發票選項 0:預設 1:暫停不開 2:詢問
m_OrderBtn[j].GestureRecognizers.Add(tapGestureRecognizer00);
MiddleVerticalStackLayout.Add(m_OrderBtn[j]);//把所有按鈕放到Layout上
j++;
}
if ((SqliteDataAccess.m_order_type_data[i].order_type_code == "UBER_EATS") || (SqliteDataAccess.m_order_type_data[i].order_type_code == "FOODPANDA"))
{
blnTakeawayOrdersButton = true;//紀錄是否顯示[外賣接單]按鈕
if (SqliteDataAccess.m_order_type_data[i].order_type_code == "UBER_EATS")
{
m_intUBER_EATSInvoiceState = SqliteDataAccess.m_order_type_data[i].invoice_state;//開立發票選項 0:預設 1:暫停不開 2:詢問
}
if (SqliteDataAccess.m_order_type_data[i].order_type_code == "FOODPANDA")
{
m_intFOODPANDAInvoiceState = SqliteDataAccess.m_order_type_data[i].invoice_state;//開立發票選項 0:預設 1:暫停不開 2:詢問
}
}
else if ((SqliteDataAccess.m_order_type_data[i].order_type_code == "VTS-TOGO"))
{
m_intVTS_TOGOInvoiceState = SqliteDataAccess.m_order_type_data[i].invoice_state;//開立發票選項 0:預設 1:暫停不開 2:詢問
}
}
//---顯示POS訂單類型
//---
//顯示外接平台訂單類型
if (SQLDataTableModel.m_takeaways_params != null)
{
for (int i = 0; i < SQLDataTableModel.m_takeaways_params.Rows.Count; i++)
{
switch (SQLDataTableModel.m_takeaways_params.Rows[i]["SID"].ToString())
{
case "VTSTORE":
/* jash stop
m_OrderBtn[j].Visible = true;
m_OrderBtn[j].m_intSID = -1;
m_OrderBtn[j].m_intPrice = -2;
m_OrderBtn[j].m_StrProductCode = SQLDataTableModel.m_takeaways_params.Rows[i]["SID"].ToString();
m_OrderBtn[j].Text = "";// SQLDataTableModel.m_takeaways_params.Rows[i]["platform_name"].ToString();
m_OrderBtn[j].DisNormalColor = System.Drawing.Color.FromArgb(136, 222, 255);
m_OrderBtn[j].NormalColor = System.Drawing.Color.FromArgb(36, 112, 160);
m_OrderBtn[j].HoverColor = System.Drawing.Color.FromArgb(36, 112, 160);
m_OrderBtn[j].PressedColor = System.Drawing.Color.FromArgb(36, 112, 160);
m_OrderBtn[j].ImageIndex = 0;//m_OrderBtn[j].Image = imlbutt.Images[0];
VTSTOREAPI.m_intVTSTOREButtonIndex = j;
j++;
*/
break;
case "NIDIN_POS":
break;
case "UBER_EATS":
break;
case "FOODPANDA":
break;
case "YORES_POS":
break;
}
}
}
if (blnTakeawayOrdersButton)
{
m_OrderBtn[j] = new CustBtn();
m_OrderBtn[j].IsVisible = true;
m_OrderBtn[j].InitData(-3);
m_OrderBtn[j].m_intPrice = -4;
m_OrderBtn[j].m_StrProductCode = "TAKEAWAYORDERS";
m_OrderBtn[j].InitDisplay(Colors.White, new Color(36, 112, 160), new Color(36, 112, 160), "外賣訂單", dblFontSize);
MiddleVerticalStackLayout.Add(m_OrderBtn[j]);//把所有按鈕放到Layout上
VTSTOREAPI.m_intTakeawayOrdersButtonIndex = j;//紀錄外賣接單按鈕在主畫面中間按鈕的陣列位置
j++;
}
//---顯示外接平台訂單類型
//---
//掃碼點單POS結帳按鈕
if ((VTEAMQrorderAPI.m_get_qrorder_params != null) &&
(VTEAMQrorderAPI.m_get_qrorder_params.data != null) &&
(VTEAMQrorderAPI.m_get_qrorder_params.data.terminal_flag != null) &&
(VTEAMQrorderAPI.m_get_qrorder_params.data.terminal_flag == "Y"))// && SQLDataTableModel.m_blnVTEAMQrorderOpen)
{
m_OrderBtn[j] = new CustBtn();
m_OrderBtn[j].IsVisible = true;
m_OrderBtn[j].InitData(-5);
m_OrderBtn[j].m_intPrice = -6;
m_OrderBtn[j].m_StrProductCode = "VTEAMQrorder";
m_OrderBtn[j].InitDisplay(Colors.White, new Color(36, 112, 160), new Color(36, 112, 160), "掃碼點單結帳", dblFontSize);
MiddleVerticalStackLayout.Add(m_OrderBtn[j]);//把所有按鈕放到Layout上
VTEAMQrorderAPI.m_intQrorderButtonIndex = j;//掃碼點單POS結帳按鈕在主畫面中間按鈕的陣列位置
j++;
}
//---掃碼點單POS結帳按鈕
//---
//包材按鈕顯示
if (SqliteDataAccess.m_packaging_data.Count > 0)
{
m_OrderBtn[j] = new CustBtn();
m_OrderBtn[j].IsVisible = true;
m_OrderBtn[j].InitData(0);
m_OrderBtn[j].m_intPrice = 0;
m_OrderBtn[j].m_StrProductCode = "packaging_data";
m_OrderBtn[j].InitDisplay(Colors.White, new Color(36, 112, 160), new Color(36, 112, 160), "包材選擇", dblFontSize);
MiddleVerticalStackLayout.Add(m_OrderBtn[j]);//把所有按鈕放到Layout上
j++;
}
//---包材按鈕顯示
orderButtonInitShow();
}
public CustBtn m_OrderBtnSelected = null;
public void OrderBtnClickShow(object sender = null)
{
if (sender != null)
{
m_OrderBtnSelected = (CustBtn)sender;
}
else
{
//m_OrderBtnSelected = null;
}
for (int i = 0; i < m_OrderBtn.Length; i++)
{
if(m_OrderBtn[i] != null)
{
if (m_OrderBtnSelected != m_OrderBtn[i])
{
m_OrderBtn[i].SetBackgroundColor(false);
}
else
{
m_OrderBtn[i].SetBackgroundColor(true);
}
}
}
if (m_OrderBtnSelected != null)
{
if (m_OrderBtnSelected.m_intSID < 0)
{
return;
}
m_order_type_data_params = null;
for (int i = 0; i < SqliteDataAccess.m_order_type_data.Count; i++)
{
if (m_OrderBtnSelected.m_intSID == SqliteDataAccess.m_order_type_data[i].SID)
{
m_order_type_data_params = JsonClassConvert.order_type_data_params2Class(SqliteDataAccess.m_order_type_data[i].@params);//取出 訂單類型資料表 params 並 JSON2Class
if (m_order_type_data_params != null)
{
/*jash stop
buttmain064.Visible = (m_order_type_data_params.table_num_param.use_flag == "Y") ? true : false; //新增 訂單類型資料表 params 欄位 - [桌號檢查]
buttmain065.Visible = (m_order_type_data_params.meal_num_param.use_flag == "Y") ? true : false;//新增 訂單類型資料表 params 欄位 - [牌號檢查]
buttmain078.Visible = (m_order_type_data_params.guests_num_param.use_flag == "Y") ? true : false;//新增 訂單類型資料表 params 欄位 - [來客數檢查]
*/
}
break;
}
}
m_intOrderTypeIdSelected = m_OrderBtnSelected.m_intSID;
m_StrOrderTypeNameSelected = m_OrderBtnSelected.GetText();
m_StrOrderTypeCodeSelected = m_OrderBtnSelected.m_StrProductCode;
m_intOrderTypeInvoiceState = m_OrderBtnSelected.m_min_count;//開立發票選項 0:預設 1:暫停不開 2:詢問
String SQL = String.Format("SELECT product_sid,price FROM product_price_type_relation WHERE price_type_sid='{0}'", m_OrderBtnSelected.m_intPrice);
SQLDataTableModel.m_product_price_type_relationDataTable = SQLDataTableModel.GetDataTable(SQL);
if ((m_StrPosOrderNumber.Length > 0) && (m_intOrderState == 0))
{
SQL = String.Format("UPDATE order_data SET order_type='{0}',order_type_name='{1}',order_type_code='{2}',updated_time='{3}' WHERE order_no='{4}';"
, m_intOrderTypeIdSelected, m_StrOrderTypeNameSelected, m_StrOrderTypeCodeSelected, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), m_StrPosOrderNumber);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
}
if (m_ShopCart != null)
{
m_ShopCart.m_intOrderType = m_intOrderTypeIdSelected;
}
OrderTypeValueLable.Text = m_OrderBtnSelected.GetText();
}
else
{
OrderTypeValueLable.Text = "";
}
}
//---訂單類型按鈕顯示函數
//---
//訂單類型按鈕預設顯示函數
public void orderButtonInitShow()
{
m_intOrderTypeIdSelected = -1;
m_StrOrderTypeNameSelected = "";
m_StrOrderTypeCodeSelected = "";
if (SqliteDataAccess.m_company.Count > 0)
{
for (int i = 0; i < m_OrderBtn.Length; i++)
{
if ((m_OrderBtn[i]!=null) && (SqliteDataAccess.m_company[0].def_order_type == m_OrderBtn[i].m_intSID))
{
m_OrderBtnSelected = m_OrderBtn[i];//設定特定按鈕已被選取
OrderBtnClickShow();
break;
}
}
}
}
//---訂單類型按鈕預設顯示函數
private async void OrderBtn_Click(object sender, EventArgs e)//建立訂單類型按鈕事件
{
if (AfterPaymentUIInit() != 0)
{
return;
}
OrderBtnClickShow(sender);
if (m_OrderBtnSelected.m_intSID >= 0)
{//POS訂單類型
//---
//整合建立訂單編號字串功能
if (await PosOrderNumberCreatUIInitAsync() != 0)
{
return;//跳出程序
}
//---整合建立訂單編號字串功能
/*jash stop
ChangeOrderTypeCalculate();
dgvmain001_SelectionChangedCall();
*/
}
else
{//顯示外接平台訂單類型
switch (m_OrderBtnSelected.m_StrProductCode)
{
case "VTSTORE"://點點按鈕
/* jash stop
TransitionsFun.ShowUI("正在載入點點食訂單資訊,請稍後...");
SyncThread.m_blnGetVTSTOREData = false;//停止背景抓取資料
VTSTORE VTSTOREBuf = new VTSTORE();
VTSTOREBuf.ShowDialog();
SyncThread.m_blnGetVTSTOREData = true;//開啟背景抓取資料
*/
break;
case "TAKEAWAYORDERS"://外賣接單按鈕
/* jash stop
TransitionsFun.ShowUI("正在載入外賣訂單資訊,請稍後...");
SyncThread.m_blnGetUbereatsData = false;//停止背景抓取資料
SyncThread.m_blnGetFoodpandaData = false;//停止背景抓取資料
TakeawayOrderList TakeawayOrderListBuf = new TakeawayOrderList();
TakeawayOrderListBuf.ShowDialog();
SyncThread.m_blnGetUbereatsData = true;//開啟背景抓取資料
SyncThread.m_blnGetFoodpandaData = true;//開啟背景抓取資料
*/
break;
case "VTEAMQrorder"://掃碼點單結帳
/* jash stop
TransitionsFun.ShowUI("正在載入掃碼點單結帳資訊,請稍後...");
VTEAMQrorderAPI.m_get_qrorder_order_data = null;
SyncThread.m_blnGetQrorderData = false;//停止背景抓取資料
VTEAMQrorderAPI.get_order_list();//讀取待結帳的掃碼訂單清單
Qrorder QrorderBuf = new Qrorder();
QrorderBuf.ShowDialog();
SyncThread.m_blnGetQrorderData = true;//開啟背景抓取資料
//---
//載物購物車進行結帳
if ((VTEAMQrorderAPI.m_get_qrorder_order_data != null) && (VTEAMQrorderAPI.m_get_qrorder_order_data.data != null))
{
buttmain054.PerformClick();//將購物車尚未結帳訂單放入暫存
//---
//整合建立訂單編號字串功能
if (PosOrderNumberCreatUIInit() != 0)
{
return;//跳出程序
}
//---整合建立訂單編號字串功能
Qrorder2ShopCart();
Qrorder2DB();
orderLoadEdit();//載入最後一筆可編輯的訂單
}
//---載物購物車進行結帳
*/
break;
case "NIDIN_POS":
break;
case "UBER_EATS":
break;
case "FOODPANDA":
break;
case "YORES_POS":
break;
}
}
}
//---建立orderButton陣列
//---
//客顯資料相關變數
public int m_intcmb006LastSelectedIndex = -1;
public cust_display_data m_cust_display_dataNew = null;//新增資料
//---客顯資料相關變數
//---
//報表號相關變數
public static String m_StrPosReportNumber = "";//紀錄報表號的成員變數
private const int m_intReportNumberTestMaxCount = 50;//建立報表號最大嘗試次數
//---報表號相關變數
//---
//收支號相關變數
public static String m_StrPosExpenseNumber = "";//紀錄報表號的成員變數
private const int m_intExpenseNumberTestMaxCount = 50;//建立報表號最大嘗試次數
//---收支號相關變數
//---
private bool m_blnBillDiscount = false;//自訂義折扣/折讓 啟動與否
private bool m_blnBillDiscountArea = false;//優惠專區折扣/讓 啟動與否
//---
public void ShopCartListChangeCondimentBtnInitShow()
{
if (m_ShopcartItemSelected!=null)
{
m_CustBtnProductSelected = null;
String StrBuf = m_ShopcartItemSelected.id;
if ((StrBuf != null) && (StrBuf.Length > 0))
{
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
int intMainSID = m_ShopCart.m_ShopMainList[intMainindex].m_intSID;
if (m_ShopCart.m_ShopMainList[intMainindex].m_Stritem_type == "K")
{
CondimentBtnInitHide();//調味品按鈕初始化
}
else
{
CondimentBtnInitShow(true, intMainSID);
}
}
}
}
void QuantityBtnEnableStateSet(int intItemState = -1, int intDiscountState = -1, int intSubtotalState = -1, String StrTs = "")
{
/*jash stop
buttmain079.Visible = false;//修改套餐按鈕
buttmain049.Enabled = false;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = false;//刪除
buttmain054.Enabled = false;//暫存訂單
buttmain055.Enabled = true;//取回訂單
if ((m_intOrderState == 0) && (m_StrPosOrderNumber.Length > 0)) //0:new
{
buttmain049.Enabled = true; //訂單備註按鈕
//判斷項目內容-產品/調味品/折扣讓/小計
//state0
//0[產品]
//1[折扣讓]
//2[小計]
//3[調味品合併]
//4[調味品單一]
//判斷有折扣/折讓
//state1 0/1
//判斷有無小計
//state2 0/1
//套餐相關標籤
//T -套餐
//TP -套餐產品
//TPC -(套餐產品)配料
//TS -小計
//TD -套餐折扣讓
if (StrTs.Length > 0)//套餐處理
{
int intItemState01 = intItemState;
if (StrTs == "T")
{
intItemState01 = 0;
}
else if (StrTs == "TP")
{
intItemState01 = 3;
}
else if (StrTs == "TPC")
{
intItemState01 = 3;
}
if ((intDiscountState == 0) && (intSubtotalState == 0))//無折扣讓+無小記
{
switch (intItemState01)
{
case 0://0[產品] ~ 有選擇產品清單 - 取回暫存Disable,其他都是 Enable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = true;//修改數量
buttmain051.Enabled = true;//+1
buttmain052.Enabled = true;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
buttmain079.Visible = true;//修改套餐按鈕
break;
case 1://1[折扣讓] ~ 折扣讓本身 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 2://2[小計] ~ 小計本身 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 3://3[調味品合併] ~ 有選擇配料複合清單 - 除了 暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = false;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 4://4[調味品單一] ~ 有選擇配料單一清單 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
}
}
else
{
if (intDiscountState == 1)//判斷有折扣/折讓 ~ 折扣讓(之前) 不能 數量
{
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = true;//取回訂單
}
if (intSubtotalState == 1)//判斷有無小計 ~ 小計後(之前) 不能 刪除/數量
{
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = false;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = true;//取回訂單
}
}
return;
}
//一般處理
if ((intDiscountState == 0) && (intSubtotalState == 0))//無折扣讓+無小記
{
switch (intItemState)
{
case 0://0[產品] ~ 有選擇產品清單 - 取回暫存Disable,其他都是 Enable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = true;//修改數量
buttmain051.Enabled = true;//+1
buttmain052.Enabled = true;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 1://1[折扣讓] ~ 折扣讓本身 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 2://2[小計] ~ 小計本身 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 3://3[調味品合併] ~ 有選擇配料複合清單 - 除了 暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = false;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
case 4://4[調味品單一] ~ 有選擇配料單一清單 - 除了 刪除/暫存訂單/訂單備註 Enable,其他都是Disable
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = false;//取回訂單
break;
}
}
else
{
if (intDiscountState == 1)//判斷有折扣/折讓 ~ 折扣讓(之前) 不能 數量
{
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = true;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = true;//取回訂單
}
if (intSubtotalState == 1)//判斷有無小計 ~ 小計後(之前) 不能 刪除/數量
{
buttmain049.Enabled = true;//訂單備註按鈕
buttmain050.Enabled = false;//修改數量
buttmain051.Enabled = false;//+1
buttmain052.Enabled = false;//-1
buttmain053.Enabled = false;//刪除
buttmain054.Enabled = true;//暫存訂單
buttmain055.Enabled = true;//取回訂單
}
}
}
*/
}
public void order_dataModify()//更新order_data 金額&數量&稅金
{
String SQL = "";
int intODsubtotal = 0;//未刪除所有該訂單項目單筆小計(item_subtotal)的加總
int intODdiscount_fee = 0;//未刪除所有該訂單項目折扣金額(discount_fee)的加總
int intODtax_fee = 0;//找出order_content_data應稅商品總金額(item_subtotal)加總並計算
//List<int> ListProductID = new List<int>();
double dblODpromotion_fee = 0;
String StrPromotionValue = "";
//---
//新增 訂單類型資料表 params 欄位 流程圖 - [服務費計算]
int intODservice_fee = 0;
int intODservice_rate = 0;
//---新增 訂單類型資料表 params 欄位 流程圖 - [服務費計算]
int intODamount = 0;//intODsubtotal - intODdiscount_fee + intODservice_fee
int intODtrans_reversal = 0;//交易沖正 (amount為負數值;trans_reversal=Math.Abs(amount);amount設為0)
int intODitem_count = 0;
//---
//計算訂單產品數量
for (int i = 0; i < m_ShopCart.m_ShopMainList.Count; i++)
{
if (!((m_ShopCart.m_ShopMainList[i].m_Strdel_flag == "Y") || (m_ShopCart.m_ShopMainList[i].m_Stritem_type == "S") || (m_ShopCart.m_ShopMainList[i].m_intparent_item_no > 0)))//剃除刪除、套餐下的產品和小計
{
//ListProductID.Add(m_ShopCart.m_ShopMainList[i].m_intSID);//記錄所有購物車產品編號,為了促銷運算使用
intODitem_count += m_ShopCart.m_ShopMainList[i].m_intAmount;
}
}
//---計算訂單產品數量
//---
//更新 order_data
//SQL = String.Format("SELECT item_subtotal,discount_fee,tax_fee FROM order_content_data WHERE order_no='{0}' AND del_flag='N';", m_StrPosOrderNumber);
SQL = String.Format("SELECT item_subtotal,discount_fee,tax_rate,item_type FROM order_content_data WHERE order_no='{0}' AND del_flag='N';", m_StrPosOrderNumber);
DataTable m_order_content_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
int inttax_rateSum = 0;
int inttax_rateCount = 0;
for (int i = 0; i < m_order_content_dataDataTable.Rows.Count; i++)
{
if (m_order_content_dataDataTable.Rows[i][3].ToString() != "S")//小計金額&稅金&稅金 不列入計算
{
intODsubtotal += Int32.Parse(m_order_content_dataDataTable.Rows[i][0].ToString());
if (Int32.Parse(m_order_content_dataDataTable.Rows[i][2].ToString()) > 0)//找出order_content_data應稅商品總金額(item_subtotal)加總
{
intODtax_fee += Int32.Parse(m_order_content_dataDataTable.Rows[i][0].ToString());
inttax_rateSum += Int32.Parse(m_order_content_dataDataTable.Rows[i][2].ToString());
inttax_rateCount++;
}
}
intODdiscount_fee += Int32.Parse(m_order_content_dataDataTable.Rows[i][1].ToString());//小計折扣列入計算
}
//---
//計算促銷
//ListProductID = ListProductID.Distinct().ToList();
//int[] arr = ListProductID.ToArray();
ODPromotionValue ODPromotionValueBuf = new ODPromotionValue();
//jash stop txtmain002.Visible = false;//隱藏元件促銷資訊
dblODpromotion_fee = Promotion_fun.calculate(m_intOrderTypeIdSelected, m_StrPosOrderNumber, ref ODPromotionValueBuf);
if (dblODpromotion_fee > 0)
{
//jash stop txtmain002ShowMsg(ODPromotionValueBuf);
StrPromotionValue = JsonClassConvert.ODPromotionValue2String(ODPromotionValueBuf);
}
//---計算促銷
//---
//新增 訂單類型資料表 params 欄位 流程圖 - [服務費計算]
if ((m_order_type_data_params != null) && (m_order_type_data_params.service_fee_param != null) && (m_order_type_data_params.service_fee_param.use_flag == "Y"))
{
intODservice_rate = Convert.ToInt32(m_order_type_data_params.service_fee_param.calc_val.ToString());
if (m_order_type_data_params.service_fee_param.calc_type == "P")
{
//service_fee=subtotal*service_rate/100
intODservice_fee = (int)Service_fun.calculate(intODsubtotal, intODservice_rate, 0);
}
else
{
//service_fee=(subtotal-discount_fee)*service_rate/100
intODservice_fee = (int)Service_fun.calculate((intODsubtotal - intODdiscount_fee - dblODpromotion_fee), intODservice_rate, 0);
}
}
//---新增 訂單類型資料表 params 欄位 流程圖 - [服務費計算]
intODamount = intODsubtotal - intODdiscount_fee - (int)dblODpromotion_fee + intODservice_fee;
if (intODamount < 0)
{
intODtrans_reversal = Math.Abs(intODamount);//交易沖正計算
intODamount = 0;
}
else
{
intODtrans_reversal = 0;
}
if (inttax_rateCount > 0)//找出order_content_data應稅商品總金額(item_subtotal)加總並計算
{
intODtax_fee = (int)Tax_fun.calculate(intODtax_fee, (inttax_rateSum / inttax_rateCount), 0);//intODtax_fee * (inttax_rateSum / inttax_rateCount) / 100;
intODtax_fee = (intODtax_fee > 0) ? intODtax_fee : 0;
}
SQL = String.Format("UPDATE order_data SET item_count='{0}', subtotal='{1}', discount_fee='{2}',tax_fee='{3}',amount='{4}',updated_time='{5}',service_fee='{6}',service_rate='{7}',promotion_fee='{8}',promotion_value='{9}',trans_reversal='{10}' WHERE order_no='{11}';",
intODitem_count, intODsubtotal, intODdiscount_fee, intODtax_fee, intODamount, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), intODservice_fee, intODservice_rate, dblODpromotion_fee, StrPromotionValue, intODtrans_reversal, m_StrPosOrderNumber);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
//---更新 order_data
}
public void ShopcartListViewMainTotalSumChange(int intMainArrayIndex)
{
for (int i = 0; i < m_ShopcartItems.Count; i++)
{
String StrBuf = m_ShopcartItems[i].id;
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if (intMainArrayIndex > 0)//指定主項目修改
{
if ((intMainindex == intMainArrayIndex) && (intSubindex == -1))
{
m_ShopcartItems[i].Amount = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount.ToString();
m_ShopcartItems[i].Price = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice.ToString();
m_ShopcartItems[i].Sum = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum.ToString();
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
String SQL = String.Format("SELECT promotion_value,promotion_fee,discount_fee, item_count, amount, order_type_name, class_name, call_num, table_name, meal_num, paid_info, change_fee,remarks,order_state,service_fee,guests_num FROM order_data WHERE order_no = '{0}' LIMIT 0,1", m_StrPosOrderNumber);
DataTable order_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
//---
//UDP訂單主資訊異動
if (order_dataDataTable.Rows.Count > 0)
{
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.order_no = OrderNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.status = OrderStatusLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.amount = Convert.ToInt32(order_dataDataTable.Rows[0]["amount"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ordercount = Convert.ToInt32(order_dataDataTable.Rows[0]["item_count"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PaidCash = ChangeValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayStateLabel = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayState = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Cust_EIN = TaxIDTextLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Inv_Carrier_Value = CarrierValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Table_Name = TableNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Meal_Num = ShopNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Name = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Phone = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ORDERFINISH = (order_dataDataTable.Rows[0]["order_state"].ToString() == "1") ? "Y" : "N";
CustomerDisplayUDP.ToUdp();
}
//---UDP訂單主資訊異動
break;
}
}
else//修改全部主項目
{
if ((intMainindex >= 0) && (intSubindex == -1))
{
m_ShopcartItems[i].Amount = m_ShopCart.m_ShopMainList[intMainindex].m_intAmount.ToString();
m_ShopcartItems[i].Price = m_ShopCart.m_ShopMainList[intMainindex].m_dblPrice.ToString();
m_ShopcartItems[i].Sum = m_ShopCart.m_ShopMainList[intMainindex].m_dblSum.ToString();
}
if ((intMainindex >= 0) && (intSubindex == -3))
{
m_ShopcartItems[i].Sum = m_ShopCart.m_ShopMainList[intMainindex].m_dblSum.ToString();
}
if ((intMainindex >= 0) && ((intSubindex == -3) || (intSubindex == -1)))
{
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainindex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainindex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainindex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainindex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainindex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainindex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainindex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
String SQL = String.Format("SELECT promotion_value,promotion_fee,discount_fee, item_count, amount, order_type_name, class_name, call_num, table_name, meal_num, paid_info, change_fee,remarks,order_state,service_fee,guests_num FROM order_data WHERE order_no = '{0}' LIMIT 0,1", m_StrPosOrderNumber);
DataTable order_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
//---
//UDP訂單主資訊異動
if (order_dataDataTable.Rows.Count > 0)
{
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.order_no = OrderNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.status = OrderStatusLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.amount = Convert.ToInt32(order_dataDataTable.Rows[0]["amount"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ordercount = Convert.ToInt32(order_dataDataTable.Rows[0]["item_count"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PaidCash = ChangeValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayStateLabel = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayState = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Cust_EIN = TaxIDTextLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Inv_Carrier_Value = CarrierValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Table_Name = TableNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Meal_Num = ShopNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Name = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Phone = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ORDERFINISH = (order_dataDataTable.Rows[0]["order_state"].ToString() == "1") ? "Y" : "N";
CustomerDisplayUDP.ToUdp();
}
//---UDP訂單主資訊異動
}//if((intMainindex >= 0) && ((intSubindex == -3) || (intSubindex == -1)))
}
}
}
public void MainTotalSumCalculate(int index = -1)//新增模式[不考慮折扣/折讓情況下] 計算每筆產品的總金額 更新變數 & DB對應值 [order_content_data]
{
/// 01.更新DB資料 - order_content_data
/// 01-1.使用迴圈將購物車還未標註刪除的產品資料取出(並且剔除套餐下的產品資訊)
/// 01-2.使用迴圈將取出該產品下非刪除狀態的配料價格
/// 01-3.整理要更新到DB的變數值
/// 02.更新DB資料 - order_data [order_dataModify()]
/// 02-1.使用迴圈將購物車還未標註刪除的產品資料取出統計數量
/// 02-2.統計order_content_data對應資料
//當新增折扣折讓後 該筆產品就不得再被修改數量和內容 (這是規定)
String SQL = "";
//---
//修改order_content_data中 產品的 item_subtotal、discount_fee、item_amount、tax_fee
if (index > -1)
{
if ((m_ShopCart.m_ShopMainList[index].m_Strdel_flag != "Y") && (m_ShopCart.m_ShopMainList[index].m_intparent_item_no == 0))//判斷該筆資料非刪除狀態(並且剔除套餐下的產品資訊)
{
int item_count = 0, condiment_price = 0, item_cost = 0, item_subtotal = 0, discount_fee = 0, item_amount = 0, tax_fee = 0;
for (int j = 0; j < m_ShopCart.m_ShopMainList[index].m_ShopSubList.Count; j++)//
{
if (m_ShopCart.m_ShopMainList[index].m_ShopSubList[j].m_Strdel_flag != "Y")
{
condiment_price += (int)m_ShopCart.m_ShopMainList[index].m_ShopSubList[j].m_dblSum;
}//if (m_ShopCart.m_ShopMainList[i].m_ShopSubList[j].m_Strdel_flag != "Y")
}
item_cost = (int)m_ShopCart.m_ShopMainList[index].m_dblPrice;
item_count = m_ShopCart.m_ShopMainList[index].m_intAmount;
discount_fee = m_ShopCart.m_ShopMainList[index].m_intdiscount_fee;
item_subtotal = (int)(m_ShopCart.m_ShopMainList[index].m_intAmount * (m_ShopCart.m_ShopMainList[index].m_dblPrice + condiment_price));
item_amount = item_subtotal - discount_fee;
tax_fee = (int)Tax_fun.calculate(item_amount, m_ShopCart.m_ShopMainList[index].m_inttax_rate, 0);//item_amount * m_ShopCart.m_ShopMainList[i].m_inttax_rate / 100;
m_ShopCart.m_ShopMainList[index].m_dblSum = item_subtotal;
SQL = String.Format("UPDATE order_content_data SET condiment_price='{0}', item_subtotal='{1}', discount_fee='{2}', item_amount='{3}',tax_fee='{4}',item_count='{5}',item_cost='{6}' WHERE order_no='{7}' AND item_no='{8}';",
condiment_price, item_subtotal, discount_fee, item_amount, tax_fee, item_count, item_cost, m_StrPosOrderNumber, m_ShopCart.m_ShopMainList[index].m_intitem_no);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
}//if(m_ShopCart.m_ShopMainList[i].m_Strdel_flag!="Y")
}
else
{
for (int i = 0; i < m_ShopCart.m_ShopMainList.Count; i++)//使用迴圈將購物車內每筆產品資料取出
{
if ((m_ShopCart.m_ShopMainList[i].m_Strdel_flag != "Y") && (m_ShopCart.m_ShopMainList[i].m_intparent_item_no == 0))//判斷該筆資料非刪除狀態(並且剔除套餐下的產品資訊)
{
int item_count = 0, condiment_price = 0, item_cost = 0, item_subtotal = 0, discount_fee = 0, item_amount = 0, tax_fee = 0;
for (int j = 0; j < m_ShopCart.m_ShopMainList[i].m_ShopSubList.Count; j++)//
{
if (m_ShopCart.m_ShopMainList[i].m_ShopSubList[j].m_Strdel_flag != "Y")
{
condiment_price += (int)m_ShopCart.m_ShopMainList[i].m_ShopSubList[j].m_dblSum;
}//if (m_ShopCart.m_ShopMainList[i].m_ShopSubList[j].m_Strdel_flag != "Y")
}
item_cost = (int)m_ShopCart.m_ShopMainList[i].m_dblPrice;
item_count = m_ShopCart.m_ShopMainList[i].m_intAmount;
discount_fee = m_ShopCart.m_ShopMainList[i].m_intdiscount_fee;
item_subtotal = (int)(m_ShopCart.m_ShopMainList[i].m_intAmount * (m_ShopCart.m_ShopMainList[i].m_dblPrice + condiment_price));
item_amount = item_subtotal - discount_fee;
tax_fee = (int)Tax_fun.calculate(item_amount, m_ShopCart.m_ShopMainList[i].m_inttax_rate, 0);//item_amount * m_ShopCart.m_ShopMainList[i].m_inttax_rate / 100;
m_ShopCart.m_ShopMainList[i].m_dblSum = item_subtotal;
SQL = String.Format("UPDATE order_content_data SET condiment_price='{0}', item_subtotal='{1}', discount_fee='{2}', item_amount='{3}',tax_fee='{4}',item_count='{5}',item_cost='{6}' WHERE order_no='{7}' AND item_no='{8}';",
condiment_price, item_subtotal, discount_fee, item_amount, tax_fee, item_count, item_cost, m_StrPosOrderNumber, m_ShopCart.m_ShopMainList[i].m_intitem_no);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
}//if(m_ShopCart.m_ShopMainList[i].m_Strdel_flag!="Y")
}
}
//---修改order_content_data中 產品的 item_subtotal、discount_fee、item_amount、tax_fee
order_dataModify();
}
void ShopcartListViewShow(int intAction, int intMainArrayIndex, int intSubArrayIndex, int intFontSize, bool blnOnlyShow = false)
{
//dgvmain001.Columns[0].Visible = true;
String SQL = "";
//陣列ID-[M,S],圖1,圖2,產品名,數量,價格,總價,圖編號,字型大小
switch (intAction)
{
case 0://主項(產品)新增
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdel_flag != "Y")
{
ShopcartItem ShopcartItemMain = new ShopcartItem();
ShopcartItemMain.id = intMainArrayIndex + "," + intSubArrayIndex;//陣列ID-[M,S]
ShopcartItemMain.Image00 = m_StrShopcartIcons[0];//"checkbox00.png"
ShopcartItemMain.Image01 = m_StrShopcartIcons[2];//"blank.png"
ShopcartItemMain.Name = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
ShopcartItemMain.Amount = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount.ToString();
ShopcartItemMain.Price = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice.ToString();
ShopcartItemMain.Sum = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum.ToString();
ShopcartItemMain.image_id = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId.ToString();
ShopcartItemMain.Font_Color = Colors.Black;
ShopcartItemMain.Font_Size = Device.GetNamedSize(NamedSize.Subtitle, typeof(Label));
ShopcartItemMain.State = "0";
ShopcartItemMain.BColor = Colors.Transparent;
m_ShopcartItems.Add(ShopcartItemMain);
ShopcartListView.ScrollTo(m_ShopcartItems[m_ShopcartItems.Count - 1], ScrollToPosition.End, false);
ShopcartListView.SelectedItem = m_ShopcartItems[m_ShopcartItems.Count - 1];//選擇在最後一筆
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
break;
case 1://主項(產品)選取狀態修改
//因為元件不同所以不用在此實作
break;
case 2://調味品[唯一]新增
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
//---
//計算新增調味品位置
int index = m_intShopcartSelectedIndex;
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y")
{
index += 2;//因為 折扣/折讓 顯示在加1的位置
}
else
{
index += 1;//
}
//---計算新增調味品位置
ShopcartItem ShopcartItemSub = new ShopcartItem();
ShopcartItemSub.id = intMainArrayIndex + "," + intSubArrayIndex;//陣列ID-[M,S]
ShopcartItemSub.Image00 = m_StrShopcartIcons[2];//"blank.png"
ShopcartItemSub.Image01 = m_StrShopcartIcons[2];//"blank.png"
ShopcartItemSub.Name = m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_StrName;
ShopcartItemSub.Amount = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_intAmount.ToString();
ShopcartItemSub.Price = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_dblPrice.ToString();
ShopcartItemSub.Sum = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_dblSum.ToString();
ShopcartItemSub.image_id = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_intImgId.ToString();
ShopcartItemSub.Font_Color = Colors.Black;
ShopcartItemSub.Font_Size = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
ShopcartItemSub.State = "0";
ShopcartItemSub.BColor = Colors.Transparent;
m_ShopcartItems.Insert(index, ShopcartItemSub);
ShopcartListView.ScrollTo(m_ShopcartItems[m_ShopcartItems.Count - 1], ScrollToPosition.End, false);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
break;
case 3://調味品[多筆顯示成一筆]新增
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubName = m_StrTab;
int intAllAmount = 0;
double dblAllSum = 0;
int intStringCount = m_StrTab.Length / 2;
int intItemNo = -1;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")
{
intItemNo = (intItemNo < 0) ? m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intitem_no : intItemNo;
intAllAmount += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount;
if ((intStringCount + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length) < 17)
{
StrAllSubName += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + ",";
intStringCount += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
else
{
StrAllSubName += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + ",";
intStringCount = m_StrTab.Length / 2;
intStringCount += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
dblAllSum += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum;
}
}
//---產生調味品多筆合併一筆的顯示資訊
//---
//更新對應顯示欄位
int index1 = m_intShopcartSelectedIndex;
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y")
{
index1 += 2;//因為 折扣/折讓 顯示在加1的位置
}
else
{
index1 += 1;//
}
ShopcartItem ShopcartItemSub01 = new ShopcartItem();
ShopcartItemSub01.id = intMainArrayIndex + "," + intSubArrayIndex;//陣列ID-[M,S]
ShopcartItemSub01.Image00 = m_StrShopcartIcons[2];//"blank.png"
ShopcartItemSub01.Image01 = m_StrShopcartIcons[2];//"blank.png"
ShopcartItemSub01.Name = StrAllSubName.Substring(0, StrAllSubName.Length - 1);
ShopcartItemSub01.Amount = intAllAmount.ToString(); ;
ShopcartItemSub01.Price = "";
ShopcartItemSub01.Sum = dblAllSum.ToString();
ShopcartItemSub01.image_id = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[intSubArrayIndex].m_intImgId.ToString();
ShopcartItemSub01.Font_Color = Colors.Black;
ShopcartItemSub01.Font_Size = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
ShopcartItemSub01.State = "0";
ShopcartItemSub01.BColor = Colors.Transparent;
m_ShopcartItems.Insert(index1, ShopcartItemSub01);
m_ShopcartItems.RemoveAt((index1+1));
ShopcartListView.ScrollTo(m_ShopcartItems[m_ShopcartItems.Count - 1], ScrollToPosition.End, false);
//---更新對應顯示欄位
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = StrAllSubName.Substring(0, StrAllSubName.Length - 1);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = intItemNo;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = "C";
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = intAllAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(dblAllSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(dblAllSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
break;
case 4://調味品[多筆顯示多筆]新增
//5+6
break;
case 5://清除特定產品下既有的調味品相關選項
/*jash stop
int intIndexX5 = dgvmain001.SelectedRows[0].Index;//取得被選取的第一列旗標位置
for (int i = dgvmain001.SelectedRows[0].Index; i < dgvmain001.Rows.Count; i++)
{
String StrBuf = dgvmain001.Rows[i].Cells[0].Value.ToString();
String StrBufName = dgvmain001.Rows[i].Cells[3].Value.ToString();
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if ((intMainArrayIndex == intMainindex) && (intSubindex >= 0))
{
dgvmain001.Rows.Remove(dgvmain001.Rows[i]);
i--;
}
}
*/
break;
case 6://產生調味品多筆合併一筆 轉 多筆顯示資訊 [展開]
/*jash stop
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
int intInsertX6 = dgvmain001.SelectedRows[0].Index;//取得被選取的第一列旗標位置
int intShiftX6 = 0;
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y")
{
intShiftX6 += 2;//因為 折扣/折讓 顯示在加1的位置
}
else
{
intShiftX6 += 1;//
}
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")//if(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_time!="Y")
{
intSubArrayIndex = i;
if (((m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "N") && (intShiftX6 == 1)) || ((m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y") && (intShiftX6 == 2)))//if (i == 0)//
{
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小, 顏色,狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX6 + intShiftX6), intMainArrayIndex + "," + intSubArrayIndex, null, imlmain001.Images[m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intImgId], m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblPrice, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intImgId, intFontSize, "Black", 0);
}
else
{
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小, 顏色,狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX6 + intShiftX6), intMainArrayIndex + "," + intSubArrayIndex, null, null, m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblPrice, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intImgId, intFontSize, "Black", 0);
}
//jash stop dgvmainSetRow(intInsertX6 + intShiftX6);
intShiftX6++;
}
}
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubName06 = m_StrTab;
int intAllAmount06 = 0;
double dblAllSum06 = 0;
int intStringCount06 = m_StrTab.Length / 2;
int intItemNo06 = -1;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")
{
intItemNo06 = (intItemNo06 < 0) ? m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intitem_no : intItemNo06;
intAllAmount06 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount;
if ((intStringCount06 + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length) < 17)
{
StrAllSubName06 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + ",";
intStringCount06 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
else
{
StrAllSubName06 += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + ",";
intStringCount06 = m_StrTab.Length / 2;
intStringCount06 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
dblAllSum06 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum;
}
}
//---產生調味品多筆合併一筆的顯示資訊
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = StrAllSubName06.Substring(0, StrAllSubName06.Length - 1);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = intItemNo06;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = "C";
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = intAllAmount06;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(dblAllSum06);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(dblAllSum06);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
*/
break;
case 7://產生調味品多筆 轉 多筆合併一筆顯示資訊
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
int intInsertX7 = dgvmain001.SelectedRows[0].Index;//取得被選取的第一列旗標位置
int intShiftX7 = 0;
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y")
{
intShiftX7 += 2;//因為 折扣/折讓 顯示在加1的位置
}
else
{
intShiftX7 += 1;//
}
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubNameX7 = m_StrTab;
int intAllAmountX7 = 0;
double dblAllSumX7 = 0;
int intStringCountX7 = m_StrTab.Length / 2;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")//if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_time != "Y")
{
intAllAmountX7 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount;
dblAllSumX7 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum;
String StrPrice = (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum > 0) ? $"(${m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum})" : "";
if ((intStringCountX7 + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length) < 17)
{
StrAllSubNameX7 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX7 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
else
{
StrAllSubNameX7 += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX7 = m_StrTab.Length / 2;
intStringCountX7 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
}
}
//---產生調味品多筆合併一筆的顯示資訊
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小, 顏色, 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX7 + intShiftX7), intMainArrayIndex + "," + intSubArrayIndex, null, imlmain001.Images[m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_intImgId], StrAllSubNameX7.Substring(0, StrAllSubNameX7.Length - 1), intAllAmountX7, "", dblAllSumX7, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_intImgId, intFontSize, "Black", 0);
//jash stop dgvmainSetRow(intInsertX7 + intShiftX7);
*/
break;
case 8://新增 折扣/折讓的資料列 顯示 intMainArrayIndex + ","+ -2
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
int intInsertX8 = 0;//取得被選取的第一列旗標位置
int intShiftX8 = 1;
int intitem_no = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type = "Y";
SQL = String.Format("SELECT discount_name,discount_fee,discount_type,discount_rate FROM order_content_data WHERE order_no='{0}' AND item_no='{1}';", m_StrPosOrderNumber, intitem_no);
DataTable order_content_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
if (((order_content_dataDataTable != null) && (order_content_dataDataTable.Rows.Count > 0)))
{
for (int i = 0; i < dgvmain001.Rows.Count; i++)
{
String StrBuf01 = intMainArrayIndex + ",-1";//產品折扣/折讓判斷式
String StrBuf02 = intMainArrayIndex + ",-3";//小計折扣/折讓判斷式
if ((dgvmain001.Rows[i].Cells[0].Value.ToString() == StrBuf01) || (dgvmain001.Rows[i].Cells[0].Value.ToString() == StrBuf02))
{
intInsertX8 = i;
break;
}
}
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量,價格, 總價, 圖編號,字型大小, 顏色, 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX8 + intShiftX8), intMainArrayIndex + "," + intSubArrayIndex, null, null, order_content_dataDataTable.Rows[0][0].ToString(), "", "", Int32.Parse(order_content_dataDataTable.Rows[0][1].ToString()) * -1, -1, intFontSize, "Red", 1);
//jash stop dgvmainSetRow(intInsertX8 + intShiftX8);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountType = order_content_dataDataTable.Rows[0]["discount_type"].ToString();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountRate = Convert.ToInt32(order_content_dataDataTable.Rows[0]["discount_rate"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountFee = Convert.ToInt32(order_content_dataDataTable.Rows[0]["discount_fee"].ToString());
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
*/
break;
case 9://新增 小計資料列
/*jash stop
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdel_flag != "Y")
{
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量,價格, 總價, 圖編號, 字型大小 顏色 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Add(intMainArrayIndex + "," + intSubArrayIndex, null, null, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName, "", "", m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId, intFontSize, "Blue", 2);
dgvmain001.Rows[(dgvmain001.Rows.Count - 1)].Selected = true;//設定選擇游標都在最後一筆 / 指定哪一列被選取
//jash stop dgvmainSetRow(dgvmain001.Rows.Count - 1);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
*/
break;
case 10://主項(產品)+折扣讓+調味品 UI刪除
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
for (int i = 0; i < dgvmain001.Rows.Count; i++)
{
String StrBuf = dgvmain001.Rows[i].Cells[0].Value.ToString();
String StrBufName = dgvmain001.Rows[i].Cells[3].Value.ToString();
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if (intMainArrayIndex == intMainindex)
{
dgvmain001.Rows.Remove(dgvmain001.Rows[i]);
i = -1;//從頭開始檢查
}
if ((intSubindex == 0) && (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count > 0))
{
//---
//UDP購物車配料刪除
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "D";//N:新增 U:修改 D:刪除
//CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車配料刪除
SQL = String.Format("SELECT promotion_value,promotion_fee,discount_fee, item_count, amount, order_type_name, class_name, call_num, table_name, meal_num, paid_info, change_fee,remarks,order_state,service_fee,guests_num FROM order_data WHERE order_no = '{0}' LIMIT 0,1", m_StrPosOrderNumber);
DataTable order_dataDataTable01 = SQLDataTableModel.GetDataTable(SQL);
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.order_no = OrderNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.status = OrderStatusLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.amount = Convert.ToInt32(order_dataDataTable01.Rows[0]["amount"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ordercount = Convert.ToInt32(order_dataDataTable01.Rows[0]["item_count"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PaidCash = ChangeValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayStateLabel = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayState = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Cust_EIN = TaxIDTextLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Inv_Carrier_Value = CarrierValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Table_Name = TableNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Meal_Num = ShopNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Name = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Phone = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ORDERFINISH = (order_dataDataTable01.Rows[0]["order_state"].ToString() == "1") ? "Y" : "N";
CustomerDisplayUDP.ToUdp();
}
}
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "D";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
*/
break;
case 11://折扣讓 UI刪除
/*jash stop
for (int i = 0; i < dgvmain001.Rows.Count; i++)
{
String StrBuf = dgvmain001.Rows[i].Cells[0].Value.ToString();
String StrBufName = dgvmain001.Rows[i].Cells[3].Value.ToString();
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if ((intMainArrayIndex == intMainindex) && (intSubindex == -2))
{
dgvmain001.Rows.Remove(dgvmain001.Rows[i]);
i = -1;//從頭開始檢查
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountType = "N";
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountRate = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.DiscountFee = 0;
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
}
*/
break;
case 12://小計 UI刪除
/*jash stop
for (int i = 0; i < dgvmain001.Rows.Count; i++)
{
String StrBuf = dgvmain001.Rows[i].Cells[0].Value.ToString();
String StrBufName = dgvmain001.Rows[i].Cells[3].Value.ToString();
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if (intMainArrayIndex == intMainindex)
{
dgvmain001.Rows.Remove(dgvmain001.Rows[i]);
i = -1;//從頭開始檢查
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "D";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
}
*/
break;
case 13://單一調味品 UI刪除
/*jash stop
for (int i = 0; i < dgvmain001.Rows.Count; i++)
{
String StrBuf = dgvmain001.Rows[i].Cells[0].Value.ToString();
String StrBufName = dgvmain001.Rows[i].Cells[3].Value.ToString();
string[] strs = StrBuf.Split(',');
int intMainindex = Int32.Parse(strs[0]);
int intSubindex = Int32.Parse(strs[1]);
if ((intMainArrayIndex == intMainindex) && (intSubindex == intSubArrayIndex))
{
dgvmain001.Rows.Remove(dgvmain001.Rows[i]);
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubName01 = m_StrTab;
int intAllAmount01 = 0;
double dblAllSum01 = 0;
int intStringCount01 = m_StrTab.Length / 2;
int intItemNo01 = -1;
for (int j = 0; j < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; j++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_Strdel_flag != "Y")
{
intItemNo01 = (intItemNo01 < 0) ? m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_intitem_no : intItemNo01;
intAllAmount01 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_intAmount;
if ((intStringCount01 + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_StrName.Length) < 17)
{
StrAllSubName01 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_StrName + ",";
intStringCount01 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_StrName.Length;
}
else
{
StrAllSubName01 += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_StrName + ",";
intStringCount01 = m_StrTab.Length / 2;
intStringCount01 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_StrName.Length;
}
dblAllSum01 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[j].m_dblSum;
}
}
//---產生調味品多筆合併一筆的顯示資訊
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = StrAllSubName01.Substring(0, StrAllSubName01.Length - 1);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = intItemNo01;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = "C";
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = intAllAmount01;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = 0;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(dblAllSum01);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(dblAllSum01);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
break;
}
}
*/
break;
case 14://新增結帳完成資訊
/*jash stop
dgvmain001.Rows.Add(intMainArrayIndex + "," + intSubArrayIndex, null, null, "訂單已結帳", "", "", "", -1, intFontSize, "Black", 0);
//jash stop dgvmainSetRow(dgvmain001.Rows.Count - 1);
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_intApiState = 1;//更新客顯示訊0;結帳完成時1;清除客顯2
*/
break;
case 15://主項(套餐)新增
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdel_flag != "Y")
{
// 陣列ID-[M,S],'T' 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小 顏色 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Add(intMainArrayIndex + "," + intSubArrayIndex + ",T", imlmain001.Images[m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId], null, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId, intFontSize, "Black", 0);
dgvmain001.Rows[(dgvmain001.Rows.Count - 1)].Selected = true;//設定選擇游標都在最後一筆 / 指定哪一列被選取
//jash stop dgvmainSetRow(dgvmain001.Rows.Count - 1);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
*/
break;
case 16://主項(套餐-產品)新增
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdel_flag != "Y")
{
// 陣列ID-[M,S],'TP' 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小 顏色 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Add(intMainArrayIndex + "," + intSubArrayIndex + ",TP", null, null, m_StrHalfTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId, intFontSize, "Blue", 0);
dgvmain001.Rows[(dgvmain001.Rows.Count - 1)].Selected = true;//設定選擇游標都在最後一筆 / 指定哪一列被選取
//jash stop dgvmainSetRow(dgvmain001.Rows.Count - 1);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intparent_item_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
*/
break;
case 17://(套餐-產品)的調味品[多筆顯示成一筆]新增
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
int intInsertX17 = dgvmain001.SelectedRows[0].Index;//取得被選取的第一列旗標位置
int intShiftX17 = 0;
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdiscount_type == "Y")
{
intShiftX17 += 2;//因為 折扣/折讓 顯示在加1的位置
}
else
{
intShiftX17 += 1;//
}
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubNameX17 = m_StrTab;
int intAllAmountX17 = 0;
double dblAllSumX17 = 0;
int intStringCountX17 = m_StrTab.Length / 2;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")//if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_time != "Y")
{
intAllAmountX17 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount;
dblAllSumX17 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum;
String StrPrice = (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum > 0) ? $"(${m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum})" : "";
if ((intStringCountX17 + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length) < 17)
{
StrAllSubNameX17 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX17 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
else
{
StrAllSubNameX17 += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX17 = m_StrTab.Length / 2;
intStringCountX17 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
}
}
//---產生調味品多筆合併一筆的顯示資訊
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小, 顏色, 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX17 + intShiftX17), intMainArrayIndex + "," + intSubArrayIndex + ",TPC", null, null, StrAllSubNameX17.Substring(0, StrAllSubNameX17.Length - 1), intAllAmountX17, "", dblAllSumX17, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_intImgId, intFontSize, "Black", 0);
//jash stop dgvmainSetRow(intInsertX17 + intShiftX17);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intparent_item_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.CONDIMENTINFO = StrAllSubNameX17.Substring(0, StrAllSubNameX17.Length - 1);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
*/
break;
case 18://主項(套餐)修改
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
dgvmain001.Rows[intSubArrayIndex].Cells[3].Value = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
dgvmain001.Rows[intSubArrayIndex].Cells[4].Value = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
dgvmain001.Rows[intSubArrayIndex].Cells[5].Value = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice;
dgvmain001.Rows[intSubArrayIndex].Cells[6].Value = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum;
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
*/
break;
case 19://主項(套餐-產品)插入
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Strdel_flag != "Y")
{
// 陣列ID-[M,S],'TP' 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小 顏色 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intSubArrayIndex + 0), intMainArrayIndex + "," + -1 + ",TP", null, null, m_StrHalfTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intImgId, intFontSize, "Blue", 0);
//jash stop dgvmainSetRow(intSubArrayIndex + 0);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "N";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intparent_item_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
}
*/
break;
case 20://(套餐-產品)的調味品[多筆顯示成一筆]新增
/*jash stop
if (!blnOnlyShow)
{
//---
//修改主項(產品)總金額
MainTotalSumCalculate(intMainArrayIndex);
ShopcartListViewMainTotalSumChange(intMainArrayIndex);
//---修改主項(產品)總金額
}
int intInsertX20 = intSubArrayIndex;
//---
//產生調味品多筆合併一筆的顯示資訊
String StrAllSubNameX20 = m_StrTab;
int intAllAmountX20 = 0;
double dblAllSumX20 = 0;
int intStringCountX20 = m_StrTab.Length / 2;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_flag != "Y")//if (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_Strdel_time != "Y")
{
intAllAmountX20 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_intAmount;
dblAllSumX20 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum;
String StrPrice = (m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum > 0) ? $"(${m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_dblSum})" : "";
if ((intStringCountX20 + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length) < 17)
{
StrAllSubNameX20 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX20 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
else
{
StrAllSubNameX20 += "\n" + m_StrTab + m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName + StrPrice + ",";
intStringCountX20 = m_StrTab.Length / 2;
intStringCountX20 += m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[i].m_StrName.Length;
}
}
}
//---產生調味品多筆合併一筆的顯示資訊
// 陣列ID-[M,S], 圖1, 圖2, 產品名, 數量, 價格, 總價, 圖編號, 字型大小, 顏色, 狀態 - 無,小計,折讓/折扣 [State] 0,1,2
dgvmain001.Rows.Insert((intInsertX20 + 0), intMainArrayIndex + "," + 0 + ",TPC", null, null, StrAllSubNameX20.Substring(0, StrAllSubNameX20.Length - 1), intAllAmountX20, "", dblAllSumX20, m_ShopCart.m_ShopMainList[intMainArrayIndex].m_ShopSubList[0].m_intImgId, intFontSize, "Black", 0);
//jash stop dgvmainSetRow(intInsertX20 + 0);
//---
//UDP購物車商品異動資訊
CustomerDisplayUDP.m_CustomerDisplay = new CustomerDisplay();
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ITEMSTATE = "U";//N:新增 U:修改 D:刪除
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ProductName = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_StrName;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intitem_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ParentItemNo = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intparent_item_no;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.ItemType = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_Stritem_type;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Count = m_ShopCart.m_ShopMainList[intMainArrayIndex].m_intAmount;
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Cost = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblPrice);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.SubTotal = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.Amount = (int)(m_ShopCart.m_ShopMainList[intMainArrayIndex].m_dblSum);
CustomerDisplayUDP.m_CustomerDisplay.ItemInfo.CONDIMENTINFO = StrAllSubNameX20.Substring(0, StrAllSubNameX20.Length - 1);
CustomerDisplayUDP.m_intApiState = 0;//更新客顯示訊0;結帳完成時1;清除客顯2
//---UDP購物車商品異動資訊
*/
break;
}
//---
//訂單 數量&總價 資訊顯示
SQL = String.Format("SELECT promotion_value,promotion_fee,discount_fee, item_count, amount, order_type_name, class_name, call_num, table_name, meal_num, paid_info, change_fee,remarks,order_state,service_fee,guests_num FROM order_data WHERE order_no = '{0}' LIMIT 0,1", m_StrPosOrderNumber);
DataTable order_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
if (order_dataDataTable.Rows.Count > 0)
{
DiscountValueLable.Text = String.Format("{1}", "促銷/折扣", Convert.ToDouble(order_dataDataTable.Rows[0]["discount_fee"].ToString()) + Convert.ToDouble(order_dataDataTable.Rows[0]["promotion_fee"].ToString()));
QuantityValueLable.Text = String.Format("{1}", "訂單數量", order_dataDataTable.Rows[0]["item_count"].ToString());
ReceivableValueLable.Text = String.Format("{1}", "應收金額", order_dataDataTable.Rows[0]["amount"].ToString());
ServiceValueLable.Text = String.Format("{1}", "服務費", order_dataDataTable.Rows[0]["service_fee"].ToString());
if (order_dataDataTable.Rows[0]["remarks"].ToString().Length > 0)
{
/* jash stop
txtmain001.Visible = true;
txtmain001.Text = order_dataDataTable.Rows[0]["remarks"].ToString();
*/
}
if (order_dataDataTable.Rows[0]["promotion_value"].ToString().Length > 0)
{
ODPromotionValue ODPromotionValueBuf = JsonClassConvert.ODPromotionValue2Class(order_dataDataTable.Rows[0]["promotion_value"].ToString());
//jash stop txtmain002ShowMsg(ODPromotionValueBuf);
}
//jash stop dgvmain001SizeChange();
if (blnOnlyShow)
{
OrderNoValueLable.Text = m_StrPosOrderNumber;
OrderTypeValueLable.Text = order_dataDataTable.Rows[0]["order_type_name"].ToString();
VisitorsValueLable.Text = order_dataDataTable.Rows[0]["guests_num"].ToString();
PickupNoValueLable.Text = order_dataDataTable.Rows[0]["call_num"].ToString();
TableNoValueLable.Text = order_dataDataTable.Rows[0]["table_name"].ToString();
ShopNoValueLable.Text = order_dataDataTable.Rows[0]["meal_num"].ToString();
if (order_dataDataTable.Rows[0]["order_state"].ToString() == "1")
{
ChangeValueLable.Text = String.Format("實收金額 : {0}({1}),找零 : {2}", order_dataDataTable.Rows[0]["amount"].ToString(), order_dataDataTable.Rows[0]["paid_info"].ToString(), order_dataDataTable.Rows[0]["change_fee"].ToString());
}
}
//UDP訂單主資訊異動
if (CustomerDisplayUDP.m_CustomerDisplay != null)
{
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.order_no = OrderNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.status = OrderStatusLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.amount = Convert.ToInt32(order_dataDataTable.Rows[0]["amount"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ordercount = Convert.ToInt32(order_dataDataTable.Rows[0]["item_count"].ToString());
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PaidCash = ChangeValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayStateLabel = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.PayState = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Cust_EIN = TaxIDTextLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Inv_Carrier_Value = CarrierValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Table_Name = TableNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Meal_Num = ShopNoValueLable.Text;
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Name = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.Member_Phone = "";
CustomerDisplayUDP.m_CustomerDisplay.OrderInfo.ORDERFINISH = (order_dataDataTable.Rows[0]["order_state"].ToString() == "1") ? "Y" : "N";
CustomerDisplayUDP.ToUdp();
}
//---UDP訂單主資訊異動
}
/*jash stop
roundPanel1.Refresh();//訂購金額面板立即重繪
txtmain001.Refresh();//顯示在購物車上的促銷優惠折扣資訊立即重繪
*/
//---訂單 數量&總價 資訊顯示
try
{
if (intMainArrayIndex > 0)
{
ShopcartListView.ScrollTo(m_ShopcartItems[m_ShopcartItems.Count - 1], ScrollToPosition.End, false);//C# datagridview scrollbar 移動 最後
}
}
catch
{
}
}
public void ShopCartMainListAdd()
{
if (m_ShopCart == null)
{
m_ShopCart = new ShopCart(m_intOrderTypeIdSelected);
m_ShopCart.m_StrOrderTypeName = m_StrOrderTypeNameSelected;
m_ShopCart.m_StrOrderTypeCode = m_StrOrderTypeCodeSelected;
m_ShopCart.m_StrOrderNumber = m_StrPosOrderNumber;
}
else
{
m_ShopCart.m_intOrderType = m_intOrderTypeIdSelected;
m_ShopCart.m_StrOrderTypeName = m_StrOrderTypeNameSelected;
m_ShopCart.m_StrOrderTypeCode = m_StrOrderTypeCodeSelected;
m_ShopCart.m_StrOrderNumber = m_StrPosOrderNumber;
}
if (m_CustBtnProductSelected != null)
{
ShopMainList SoptMainListBuf = new ShopMainList();
SoptMainListBuf.m_intImgId = 1;//1=checked,2=not checked
SoptMainListBuf.m_intSID = m_CustBtnProductSelected.m_intSID;
SoptMainListBuf.m_StrName = m_CustBtnProductSelected.GetText();
SoptMainListBuf.m_dblPrice = (double)m_CustBtnProductSelected.m_intPrice;
SoptMainListBuf.m_intAmount = 1;
SoptMainListBuf.m_dblSum = SoptMainListBuf.m_intAmount * SoptMainListBuf.m_dblPrice;
SoptMainListBuf.m_intitem_no = m_ShopCart.m_intItemNoCount;
SoptMainListBuf.m_Strproduct_code = m_CustBtnProductSelected.m_StrProductCode;
SoptMainListBuf.m_Strdel_flag = "N";
SoptMainListBuf.m_Stritem_type = m_CustBtnProductSelected.m_Strproduct_type;
if (m_CustBtnProductSelected.m_inttax_sid != 0)
{
SoptMainListBuf.m_inttax_sid = m_CustBtnProductSelected.m_inttax_sid;
SoptMainListBuf.m_inttax_rate = m_CustBtnProductSelected.m_inttax_rate;
SoptMainListBuf.m_Strtax_type = m_CustBtnProductSelected.m_Strtax_type;
}
else
{
for (int i = 0; i < SqliteDataAccess.m_tax_data.Count; i++)
{
if (SqliteDataAccess.m_company[0].def_tax_sid == SqliteDataAccess.m_tax_data[i].SID)
{
SoptMainListBuf.m_inttax_sid = SqliteDataAccess.m_tax_data[i].SID;
SoptMainListBuf.m_inttax_rate = (int)SqliteDataAccess.m_tax_data[i].tax_rate;
SoptMainListBuf.m_Strtax_type = SqliteDataAccess.m_tax_data[i].tax_type;
break;
}
}
}
m_ShopCart.m_ShopMainList.Add(SoptMainListBuf);
m_ShopCart.m_intItemNoCount++;
/*
String SQL = String.Format("INSERT INTO order_content_data (order_no,item_no,item_type,item_code,item_sid,item_name,item_cost,item_count,item_subtotal,tax_sid,tax_rate,tax_type) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}');",
m_StrPosOrderNumber, SoptMainListBuf.m_intitem_no, SoptMainListBuf.m_Stritem_type, SoptMainListBuf.m_Strproduct_code, SoptMainListBuf.m_intSID, SoptMainListBuf.m_StrName, SoptMainListBuf.m_dblPrice, SoptMainListBuf.m_intAmount, SoptMainListBuf.m_dblSum, SoptMainListBuf.m_inttax_sid, SoptMainListBuf.m_inttax_rate, SoptMainListBuf.m_Strtax_type);
*/
String Strsubtotal_flag = "N";
int intcondiment_price = 0;
int intitem_subtotal = (int)(SoptMainListBuf.m_intAmount * SoptMainListBuf.m_dblPrice) + intcondiment_price;
int intdiscount_fee = 0;
int intitem_amount = intitem_subtotal - intdiscount_fee;
int inttax_fee = (int)Tax_fun.calculate(intitem_amount, SoptMainListBuf.m_inttax_rate, 0);//intitem_amount * SoptMainListBuf.m_inttax_rate / 100;
String SQL = String.Format("INSERT INTO order_content_data (order_no,item_no,item_type,item_code,item_sid,item_name,item_cost,item_count,item_subtotal,tax_sid,tax_rate,tax_type,condiment_price,discount_fee,item_amount,tax_fee,subtotal_flag) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}');",
m_StrPosOrderNumber, SoptMainListBuf.m_intitem_no, SoptMainListBuf.m_Stritem_type, SoptMainListBuf.m_Strproduct_code, SoptMainListBuf.m_intSID, SoptMainListBuf.m_StrName, SoptMainListBuf.m_dblPrice, SoptMainListBuf.m_intAmount, intitem_subtotal, SoptMainListBuf.m_inttax_sid, SoptMainListBuf.m_inttax_rate, SoptMainListBuf.m_Strtax_type, intcondiment_price, intdiscount_fee, intitem_amount, inttax_fee, Strsubtotal_flag);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
}
}
public void ShopCartSubListAdd()
{
String Strsubtotal_flag = "N";
int intcondiment_price = 0;
int intitem_subtotal = 0;
int intdiscount_fee = 0;
int intitem_amount = 0;
int inttax_fee = 0;
if (m_ShopcartItemSelected!=null)
{
int intMainindex = -1;
int intSubindex = -1;
String StrBuf = m_ShopcartItemSelected.id;
if ((StrBuf != null) && (StrBuf.Length > 0))
{
string[] strs = StrBuf.Split(',');
intMainindex = Int32.Parse(strs[0]);
intSubindex = Int32.Parse(strs[1]);
}
if (intMainindex > -1)
{
if (m_CustBtnCondimentSelected != null)
{
ShopSubList ShopSubListBuf = new ShopSubList();
ShopSubListBuf.m_intImgId = 3;//3=not expand,4=expand
ShopSubListBuf.m_intSID = m_CustBtnCondimentSelected.m_intSID;
ShopSubListBuf.m_StrName = m_CustBtnCondimentSelected.GetText();
ShopSubListBuf.m_dblPrice = (double)m_CustBtnCondimentSelected.m_intPrice;
ShopSubListBuf.m_intAmount = 1;
ShopSubListBuf.m_dblSum = ShopSubListBuf.m_intAmount * ShopSubListBuf.m_dblPrice;
ShopSubListBuf.m_intitem_no = m_ShopCart.m_intItemNoCount;
ShopSubListBuf.m_Strcondiment_code = m_CustBtnCondimentSelected.m_StrProductCode;
ShopSubListBuf.m_Stritem_type = m_CustBtnCondimentSelected.m_Strproduct_type;//類型
ShopSubListBuf.m_inttax_sid = m_CustBtnCondimentSelected.m_inttax_sid; //稅率編號 ; 產品若沒有稅率資料[m_tax_sid=0],就直接從company和tax_data取出預設值
ShopSubListBuf.m_inttax_rate = m_CustBtnCondimentSelected.m_inttax_rate; //稅率
ShopSubListBuf.m_Strtax_type = m_CustBtnCondimentSelected.m_Strtax_type;//稅率類型
bool blnRepeat = false;//重複項目判斷旗標
//---
//修正購物車中產品旗下調味品新增判斷是否為第一次的機制 at 202211101043
bool blnfirst = true;//UI畫面判斷是否為第一次新增配料旗標
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count; i++)
{
if (m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[i].m_Strdel_flag != "Y")
{
blnfirst = false;
break;
}
}
//---修正購物車中產品旗下調味品新增判斷是否為第一次的機制
if (blnfirst)//第一次增調味品
{
blnRepeat = false;
ShopSubListBuf.m_intparent_item_no = m_ShopCart.m_ShopMainList[intMainindex].m_intitem_no;
ShopSubListBuf.m_Strdel_flag = "N";
m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Add(ShopSubListBuf);
m_ShopCart.m_intItemNoCount++;
String SQL = String.Format("INSERT INTO order_content_data (order_no,item_no,item_type,item_code,item_sid,item_name,item_cost,item_count,item_subtotal,parent_item_no,condiment_price,tax_sid,tax_rate,tax_type,discount_fee,item_amount,tax_fee,subtotal_flag) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}');",
m_StrPosOrderNumber, ShopSubListBuf.m_intitem_no, ShopSubListBuf.m_Stritem_type, ShopSubListBuf.m_Strcondiment_code, ShopSubListBuf.m_intSID, ShopSubListBuf.m_StrName, ShopSubListBuf.m_dblPrice, ShopSubListBuf.m_intAmount, intitem_subtotal, ShopSubListBuf.m_intparent_item_no, intcondiment_price, ShopSubListBuf.m_inttax_sid, ShopSubListBuf.m_inttax_rate, ShopSubListBuf.m_Strtax_type, intdiscount_fee, intitem_amount, inttax_fee, Strsubtotal_flag);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
ShopcartListViewShow(2, intMainindex, m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count - 1, 12);
}
else
{
//---
//相同群組調味品最大上限計數與相對限制功能
int intSameGroupCount = 0;
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count; i++)//計算目前相同群組調味品已選數量
{
if (m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[i].m_Strdel_flag != "Y")
{
for (int j = 0; j < m_CustBtnCondimentSelected.m_same_group_sid.Count; j++)
{
if (m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[i].m_intSID == m_CustBtnCondimentSelected.m_same_group_sid[j])
{
intSameGroupCount++;
break;
}
}
}
}
for (int i = 0; i < m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count; i++)//判斷調味品是否重複
{
if (m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[i].m_Strdel_flag != "Y")
{
if (m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[i].m_intSID == ShopSubListBuf.m_intSID)
{
blnRepeat = true;
break;
}
}
}
//---相同群組調味品最大上限計數與相對限制功能
if ((!blnRepeat) && (intSameGroupCount < m_CustBtnCondimentSelected.m_max_count))//if (!blnRepeat)
{
ShopSubListBuf.m_intImgId = m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList[0].m_intImgId;
ShopSubListBuf.m_intparent_item_no = m_ShopCart.m_ShopMainList[intMainindex].m_intitem_no;
ShopSubListBuf.m_Strdel_flag = "N";
m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Add(ShopSubListBuf);
m_ShopCart.m_intItemNoCount++;
String SQL = String.Format("INSERT INTO order_content_data (order_no,item_no,item_type,item_code,item_sid,item_name,item_cost,item_count,item_subtotal,parent_item_no,condiment_price,tax_sid,tax_rate,tax_type,discount_fee,item_amount,tax_fee,subtotal_flag) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}');",
m_StrPosOrderNumber, ShopSubListBuf.m_intitem_no, ShopSubListBuf.m_Stritem_type, ShopSubListBuf.m_Strcondiment_code, ShopSubListBuf.m_intSID, ShopSubListBuf.m_StrName, ShopSubListBuf.m_dblPrice, ShopSubListBuf.m_intAmount, intitem_subtotal, ShopSubListBuf.m_intparent_item_no, intcondiment_price, ShopSubListBuf.m_inttax_sid, ShopSubListBuf.m_inttax_rate, ShopSubListBuf.m_Strtax_type, intdiscount_fee, intitem_amount, inttax_fee, Strsubtotal_flag);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
if (ShopSubListBuf.m_intImgId == 3)
{
ShopcartListViewShow(3, intMainindex, m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count - 1, 12);
}
else
{
String StrCheckBuf = intMainindex + ",-1";
int intCheckIndex = -1;
for (int i = 0; i < m_ShopcartItems.Count; i++)
{
String StrBuf00 = m_ShopcartItems[i].image_id;
if (StrBuf00 == StrCheckBuf)
{
intCheckIndex = i;
break;
}
}
if (intCheckIndex >= 0)
{
/*jash stop
dgvmain001.Rows[intCheckIndex].Selected = true;
dgvmain001Show(5, intMainindex, -1, 12);//刪除全部調味品
dgvmain001.Rows[intCheckIndex].Selected = true;
dgvmain001Show(6, intMainindex, -1, 12);//顯示展開全部調味品
*/
}
}
}//if(!blnRepeat)
}//if(m_ShopCart.m_ShopMainList[intMainindex].m_ShopSubList.Count==0) else
}//if (m_CustBtnCondimentSelected != null)
}//if(intMainindex>-1)
}//if(dgvmain001.SelectedRows.Count>0)
}
public void PosOrderNumberUIShow()
{
VisitorsValueLable.Text = m_StrGuestsNumber;
OrderNoValueLable.Text = m_StrPosOrderNumber;
TaxIDValueLable.Text = m_StrCustEinNumber;
/*jash stop
buttmain064.Enabled = true;//桌號
buttmain065.Enabled = true;//牌號
buttmain066.Enabled = true;//取消交易
buttmain068.Enabled = false;//清除畫面
buttmain057.Enabled = false;//訂單作廢
buttmain058.Enabled = false;//訂單補印
buttmain067.Enabled = true; //折扣/折讓
buttmain070.Enabled = true; //小計
buttmain071.Enabled = true; //結算
buttmain080.Visible = true;//發票載具
buttmain081.Visible = true;//買受人統編
*/
}
//---顯示訂單號參數
public static bool m_blnShowDailyQuestion = false;//自動營業關帳提示訊息旗標
public async void ShowDailyQuestionMsg()//自動營業關帳提示訊息
{
if (!m_blnShowDailyQuestion)
{
return;
}
m_blnShowDailyQuestion = false;
GetClassDailyLastTime();
DateTime DTHasDaily = (m_StrHasDaily.Length > 0) ? Convert.ToDateTime(m_StrHasDaily) : DateTime.Now;
TimeSpan ts = DateTime.Now - DTHasDaily;
Double dblTotalDays = ts.TotalDays;
if (dblTotalDays > 2)
{
QuesMessageBox QuestionMsgBuf = new QuesMessageBox($"您已經超過{(int)(dblTotalDays)}日以上未執行[營業關帳]作業,是否要直接執行[營業關帳]呢?");
await this.ShowPopupAsync(QuestionMsgBuf);
if (QuesMessageBox.m_blnResult)
{
/*jash stop
ClosingHandover ClosingHandoverBuf = new ClosingHandover("營業關帳", false);
ClosingHandoverBuf.ShowDialog();
*/
}
}
}
public bool funcMainSet(int intMode = 0)//操作介面功能啟用與否設定模組
{
bool blnResult = true;
switch (intMode)
{
case 0:
//---
//新增訂單權限控管機制
if (m_funcMain.Count > 0)
{
for (int i = 0; i < m_funcMain.Count; i++)
{
if (m_funcMain[i].m_StrSID == "bill_add")
{
if (!m_funcMain[i].m_blnEenabe)
{
blnResult = m_funcMain[i].m_blnEenabe;
}
break;
}
}
}
//---新增訂單權限控管機制
break;
default://以上都不符合走這個
for (int i = 0; i < m_funcMain.Count; i++)
{
switch (m_funcMain[i].m_StrSID)
{
case "bill_cancel"://取消交易
//jash stop buttmain066.Visible = m_funcMain[i].m_blnEenabe;
break;
case "bill_discount"://自訂義折扣/折讓 啟動與否
m_blnBillDiscount = m_funcMain[i].m_blnEenabe;
break;
case "bill_discount_area"://優惠專區折扣/讓 啟動與否
m_blnBillDiscountArea = m_funcMain[i].m_blnEenabe;
break;
case "bill_reprint"://補印單據
//jash stop buttmain058.Visible = m_funcMain[i].m_blnEenabe;
break;
case "bill_search"://訂單查詢
//jash stop buttmain056.Visible = m_funcMain[i].m_blnEenabe;
break;
case "bill_voided"://訂單作廢
//jash stop buttmain057.Visible = m_funcMain[i].m_blnEenabe;
break;
case "class_change"://交班作業
//jash stop buttmain059.Visible = m_funcMain[i].m_blnEenabe;
break;
case "cloud_report"://雲端報表查詢
//jash stop m_blnSysMenu[2] = m_funcMain[i].m_blnEenabe;
break;
case "cust_display_setting"://客顯資料管理
//buttmain059.Visible = m_funcMain[i].m_blnEenabe;
break;
case "daily_close"://營業關帳
//jash stop buttmain060.Visible = m_funcMain[i].m_blnEenabe;
break;
case "data_sync"://資料同步更新
//jash stop m_blnSysMenu[3] = m_funcMain[i].m_blnEenabe;
break;
case "device_setting"://週邊設備管理
//jash stop m_blnSysMenu[1] = m_funcMain[i].m_blnEenabe;
break;
case "env_setting"://基本參數設定
//jash stop m_blnSysMenu[0] = m_funcMain[i].m_blnEenabe;
break;
case "expense_record"://收支紀錄
//jash stop buttmain061.Visible = m_funcMain[i].m_blnEenabe;
break;
case "meal_num_select"://牌號選擇
//jash stop buttmain065.Visible = m_funcMain[i].m_blnEenabe;
break;
case "open_cash_box"://開啟錢箱
//jash stop buttmain069.Visible = m_funcMain[i].m_blnEenabe;
break;
case "packages_select"://包材選擇
//jash stop buttmain048.Visible = m_funcMain[i].m_blnEenabe;
break;
case "report"://報表管理
//jash stop buttmain063.Visible = m_funcMain[i].m_blnEenabe;
break;
case "sale"://銷售管理
//buttmain063.Visible = m_funcMain[i].m_blnEenabe;
break;
case "system"://環境設定
//buttmain063.Visible = m_funcMain[i].m_blnEenabe;
break;
case "table_select"://桌號選擇
//jash stop buttmain064.Visible = m_funcMain[i].m_blnEenabe;
break;
}
}
break;
}
//jash stop buttmain067.Visible = m_blnBillDiscount | m_blnBillDiscountArea;
return blnResult; ;
}
public void ShopCartVarClear()//清空購物車相關變數
{
m_intOrderState = 0;
m_StrPosOrderNumber = "";
m_StrCustEinNumber = "";//紀錄客戶統一編號
m_StrCustCarrierNumber = "";//紀錄客戶發票載具
m_StrEasyCardPhysicalID = "";//紀錄交易悠遊卡內碼(發票載具)
m_StrLinePayCarrierNumber = "";//紀錄LinePay的paymentSID(發票載具)
m_ShopCart = null;
}
public async Task<int> PosOrderNumberCreatUIInitAsync()
{
int intResult = 0;
if (SqliteDataAccess.m_terminal_data[0].invoice_active_state == "Y")//判斷是否要開立電子發票
{
if ((POS_INVAPI.m_InvUseInfo == null) || ((POS_INVAPI.m_InvUseInfo != null) && (Convert.ToInt32(POS_INVAPI.m_InvUseInfo.Total_Count.ToString()) == 0)))//確認目前電子發票狀態
{
MessageBox MsgBuf = null;
if (POS_INVAPI.m_InvUseInfo != null)
{
MsgBuf = new MessageBox($"電子發票資料錯誤,所以無法建立訂單\n回傳代碼:{POS_INVAPI.m_InvUseInfo.Ret_Code}\n回傳資訊:{POS_INVAPI.m_InvUseInfo.Ret_Msg}");
}
else
{
MsgBuf = new MessageBox("電子發票資料錯誤,所以無法建立訂單");
}
await this.ShowPopupAsync(MsgBuf);
intResult = 1;
return intResult;
}
}
//---
//新增訂單權限控管機制
if (!funcMainSet(0))
{
MessageBox MsgBuf = new MessageBox("您無[新增訂單]的權限");
await this.ShowPopupAsync(MsgBuf);
intResult = 1;
return intResult;
}
//---新增訂單權限控管機制
if (m_intOrderTypeIdSelected < 0)
{
MessageBox MsgBuf = new MessageBox("請先選擇訂單類型,才能建立訂單");
await this.ShowPopupAsync(MsgBuf);
intResult = 1;
return intResult;
}
//---
//整合建立訂單編號字串功能
if (SystemNumberCreate() == 0)
{
PosOrderNumberUIShow();//顯示訂單號參數
return intResult;
}
else
{
//MessageBox.Show("超過測試次數,訂單號建立失敗", "訂單號建立失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox MsgBuf = new MessageBox("超過測試次數,訂單號建立失敗");
await this.ShowPopupAsync(MsgBuf);
intResult = 1;
return intResult;
}
//---整合建立訂單編號字串功能
}
public void NotOrderUIInit(bool blnLeftButtInit = true)//沒有訂單號時 畫面初始化
{
/*jash stop
txtmain001.Visible = false;//隱藏元件訂單備註顯示
txtmain002.Visible = false;//隱藏元件促銷資訊
OrderStatusLable.Text = "無訂單";
VisitorsValueLable.Text = m_StrGuestsNumber; //來客數
DiscountValueLable.Text = String.Format("{0} : {1}", "促銷/折扣", "");
QuantityValueLable.Text = String.Format("{0} : {1}", "訂單數量", "");
ReceivableValueLable.Text = String.Format("{0} : {1}", "應收金額", "");
ChangeValueLable.Text = "";//付款資訊
dgvmain001Clean();//購物車清空
if (blnLeftButtInit)
{
productButtonInitHide();//產品按鈕初始化
condimentButtonInitHide();//調味品按鈕初始化
categoryButtonInitShow();//產品類別按鈕初始化
}
laborderInformationInit();//訂單資訊初始化
orderButtonInitShow();//訂單按鈕初始化
quantityButtonEnableStateSet();//購物車數量調整按鈕初始化
buttmain064.Enabled = false;//桌號
buttmain065.Enabled = false;//牌號
buttmain066.Enabled = false;//取消交易
buttmain068.Enabled = false;//清除畫面
buttmain057.Enabled = false;//訂單作廢
buttmain058.Enabled = false;//訂單補印
buttmain067.Enabled = false; //折扣/折讓
buttmain070.Enabled = false; //小計
buttmain071.Enabled = false; //結算
*/
}
public int AfterPaymentUIInit()//結完帳UI初始化 & 加速進行下一訂單開啟的流程
{
int intResult = 0;
if (m_intOrderState != 0)
{
if (m_intOrderState == 1)//已結帳完成才能執行
{
NotOrderUIInit(false);//沒有訂單號時 畫面初始化
ShopCartVarClear();//清空購物車相關變數
intResult = 0;
}
else
{
intResult = 1;
}
}
return intResult;
}
//---
//外送平台串接資料
public static VTSTORE_params m_VTSTORE_params = new VTSTORE_params();//點點食
public static NIDIN_POS_params m_NIDIN_POS_params = new NIDIN_POS_params();//你訂
public static UBER_EATS_params m_UBER_EATS_params = new UBER_EATS_params();//吳柏毅
public static FOODPANDA_params m_FOODPANDA_params = new FOODPANDA_params();//熊貓
public static YORES_POS_params m_YORES_POS_params = new YORES_POS_params();//享什麼
public static void takeaways_params2Var()
{
SQLDataTableModel.takeaways_paramsLoad();
if (SQLDataTableModel.m_takeaways_params != null)
{
for (int i = 0; i < SQLDataTableModel.m_takeaways_params.Rows.Count; i++)
{
switch (SQLDataTableModel.m_takeaways_params.Rows[i]["SID"].ToString())
{
case "VTSTORE":
m_VTSTORE_params = JsonClassConvert.VTSTORE_params2Class(SQLDataTableModel.m_takeaways_params.Rows[i]["params"].ToString());
break;
case "NIDIN_POS":
m_NIDIN_POS_params = JsonClassConvert.NIDIN_POS_params2Class(SQLDataTableModel.m_takeaways_params.Rows[i]["params"].ToString());
break;
case "UBER_EATS":
m_UBER_EATS_params = JsonClassConvert.UBER_EATS_params2Class(SQLDataTableModel.m_takeaways_params.Rows[i]["params"].ToString());
break;
case "FOODPANDA":
m_FOODPANDA_params = JsonClassConvert.FOODPANDA_params2Class(SQLDataTableModel.m_takeaways_params.Rows[i]["params"].ToString());
break;
case "YORES_POS":
m_YORES_POS_params = JsonClassConvert.YORES_POS_params2Class(SQLDataTableModel.m_takeaways_params.Rows[i]["params"].ToString());
break;
}
}
}
}
//---外送平台串接資料
//---
//新增建立系統號碼字串函數
public static int NowClassDataGet()//取得目前班別
{
String SQL = "";
int intResult = 0;
if (SqliteDataAccess.m_class_data.Count == 0)
{
intResult = 1;//沒有班別資料
}
if (SqliteDataAccess.m_terminal_data[0].now_class_sid == "0")
{
SQL = String.Format("UPDATE terminal_data SET now_class_sid = '{0}'", SqliteDataAccess.m_class_data[0].SID);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
SqliteDataAccess.m_terminal_data = SqliteDataAccess.terminal_dataLoad();
}
for (int j = 0; j < SqliteDataAccess.m_class_data.Count; j++)
{
/*
DateTime dt1 = Convert.ToDateTime(SqliteDataAccess.m_class_data[j].time_start);
DateTime dt2 = Convert.ToDateTime(SqliteDataAccess.m_class_data[j].time_end);
DateTime dt3 = Convert.ToDateTime(DateTime.Now.ToString("HH:mm"));
if ((DateTime.Compare(dt2, dt3) >= 0) && (DateTime.Compare(dt3, dt1) >= 0))
{
m_intClassSid = SqliteDataAccess.m_class_data[j].SID;
m_StrClassName = SqliteDataAccess.m_class_data[j].class_name;
break;
}
*/
if (SqliteDataAccess.m_terminal_data[0].now_class_sid == SqliteDataAccess.m_class_data[j].SID.ToString())
{
m_intClassSid = SqliteDataAccess.m_class_data[j].SID;
m_StrClassName = SqliteDataAccess.m_class_data[j].class_name;
break;
}
}
return intResult;
}
public static int SystemNumberCreate(int intType = 0)
{
int intResult = 0;
String StrGuid = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
switch (intType)
{
case 0://ORDER_DATA
if (m_StrPosOrderNumber.Length == 0)
{
m_StrPosOrderNumber = PosOrderNumberCreate(StrGuid); //UI顯示班別資訊
if (m_StrPosOrderNumber.Length == 0)
{
intResult = 1;//建立失敗
}
else
{
intResult = 0;//建立成功
}
}
else
{
intResult = 0;//已存在不用建立
}
break;
case 1://DAILY_REPORT
PosReportNumberCreate(StrGuid, intType);
if (m_StrPosReportNumber.Length == 0)
{
intResult = 1;//建立失敗
}
else
{
intResult = 0;//建立成功
}
break;
case 2://CLASS_REPORT
PosReportNumberCreate(StrGuid, intType);
if (m_StrPosReportNumber.Length == 0)
{
intResult = 1;//建立失敗
}
else
{
intResult = 0;//建立成功
}
break;
case 3://EXPENSE_DATA
PosExpenseNumberCreate(StrGuid);
if (m_StrPosExpenseNumber.Length == 0)
{
intResult = 1;//建立失敗
}
else
{
intResult = 0;//建立成功
}
break;
}
return intResult;
}
public static String SerialCodeDataGet(String StrGUID, int intType)
{
String SQL = "";
String StrResultNumber = "";
String StrSerialName = "";
switch (intType)
{
case 0://PosOrderNumber
StrSerialName = "ORDER_DATA";
break;
case 1://DAILY_REPORT
StrSerialName = "DAILY_REPORT";
break;
case 2://CLASS_REPORT
StrSerialName = "CLASS_REPORT";
break;
case 3://EXPENSE_REPORT
StrSerialName = "EXPENSE_DATA";
break;
}
SqliteDataAccess.m_serial_code_data = SqliteDataAccess.serial_code_dataLoad();//載入最新資料,以便進行比對
if (SqliteDataAccess.m_serial_code_data.Count > 0)
{
for (int i = 0; i < SqliteDataAccess.m_serial_code_data.Count; i++)
{
if (SqliteDataAccess.m_serial_code_data[i].serial_name == StrSerialName)
{
//---
//取得規則資料
String Strcode_first_charBuf = SqliteDataAccess.m_serial_code_data[i].code_first_char;
String Strcode_split_charrBuf = SqliteDataAccess.m_serial_code_data[i].code_split_char;
int intcode_num_lenBuf = SqliteDataAccess.m_serial_code_data[i].code_num_len;
//---取得規則資料
//----
//組合出今天serial_code_data資料表 的 code_str欄位資料
Strcode_first_charBuf = Strcode_first_charBuf.Replace("[YEAR]", "yyyy");
Strcode_first_charBuf = Strcode_first_charBuf.Replace("[MONTH]", "MM");
Strcode_first_charBuf = Strcode_first_charBuf.Replace("[DAY]", "dd");
Strcode_first_charBuf = Strcode_first_charBuf.Replace("[HOUR]", "HH");
Strcode_first_charBuf = Strcode_first_charBuf.Replace("[MINUTE]", "mm");
String[] strs = Strcode_first_charBuf.Split("yyyy");
String StrHead = strs[0];
Strcode_first_charBuf = "yyyy" + strs[1];
String StrNowcode_str = StrHead + DateTime.Now.ToString(Strcode_first_charBuf);
//---組合出今天serial_code_data資料表 的 code_str欄位資料
//---
//比對code_str欄位資料
int intNowcode_num = 0;
String StrNowcode_num = "";
String Strcode_str = SqliteDataAccess.m_serial_code_data[i].code_str;
int intcode_num = SqliteDataAccess.m_serial_code_data[i].code_num;
if (StrNowcode_str == Strcode_str)
{
intNowcode_num = intcode_num + 1;
}
else
{
intNowcode_num = 1;
}
//---比對code_str欄位資料
StrNowcode_num = "" + intNowcode_num;
StrResultNumber = String.Format("{0}{1}{2}", StrNowcode_str, Strcode_split_charrBuf, StrNowcode_num.PadLeft(intcode_num_lenBuf, '0'));
//---
//更新serial_code_data資料表紀錄
SQL = String.Format("UPDATE serial_code_data SET code_str = '{0}', code_num = '{1}', updated_time = '{2}', serial_owner='{3}' WHERE serial_name = '{4}';", StrNowcode_str, intNowcode_num, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), StrGUID, StrSerialName);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
//---更新serial_code_data資料表紀錄
break;//跳離for
}//if (SqliteDataAccess.m_serial_code_data[i].serial_name == "DAILY_REPORT")
}//for (int i = 0; i < SqliteDataAccess.m_serial_code_data.Count; i++)
}//if (SqliteDataAccess.m_serial_code_data.Count > 0)
return StrResultNumber;
}
public static void SerialCodeDataInit(String StrGUID)
{
String SQL = "";
SqliteDataAccess.m_serial_code_data.Clear();
SqliteDataAccess.m_serial_code_data = SqliteDataAccess.serial_code_dataLoad();
if (SqliteDataAccess.m_serial_code_data.Count == 0)
{
SQL = String.Format("INSERT INTO serial_code_data (serial_type,serial_name,code_first_char,code_split_char,code_num_len,code_str,code_num,serial_owner,updated_time) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
"ORDER_DATA", "ORDER_DATA", "[YEAR][MONTH][DAY]", "-", "4", DateTime.Now.ToString("yyyMMdd"), 0, StrGUID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
SQL = String.Format("INSERT INTO serial_code_data (serial_type,serial_name,code_first_char,code_split_char,code_num_len,code_str,code_num,serial_owner,updated_time) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
"DAILY_REPORT", "DAILY_REPORT", "DR-[YEAR][MONTH]", "", "3", "DR-" + DateTime.Now.ToString("yyyMM"), 0, StrGUID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
SQL = String.Format("INSERT INTO serial_code_data (serial_type,serial_name,code_first_char,code_split_char,code_num_len,code_str,code_num,serial_owner,updated_time) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
"CLASS_REPORT", "CLASS_REPORT", "CR-[YEAR][MONTH]", "", "3", "CR-" + DateTime.Now.ToString("yyyMM"), 0, StrGUID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
SQL = String.Format("INSERT INTO serial_code_data (serial_type,serial_name,code_first_char,code_split_char,code_num_len,code_str,code_num,serial_owner,updated_time) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
"EXPENSE_DATA", "EXPENSE_DATA", "[YEAR][MONTH][DAY]", "", "4", DateTime.Now.ToString("yyyMMdd"), 0, StrGUID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
SqliteDataAccess.m_serial_code_data = SqliteDataAccess.serial_code_dataLoad();
}
}
public static void PosExpenseNumberCreate(String StrGUID)
{
String SQL = "";
m_StrPosExpenseNumber = "";
//---
//產生收支號的主流程
int intErrorTestCount = 0;
do
{
String StrPosExpenseNumberBuf = SerialCodeDataGet(StrGUID, 3);
SQL = String.Format("SELECT expense_no FROM expense_data WHERE expense_no='{0}' LIMIT 0,1;", StrPosExpenseNumberBuf);
DataTable expense_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
if ((expense_dataDataTable != null) && (expense_dataDataTable.Rows.Count > 0))
{
expense_dataDataTable.Clear();
}
else
{
m_StrPosExpenseNumber = StrPosExpenseNumberBuf;//紀錄產生的新訂單號
break;//跳離do-while
}
intErrorTestCount++;
} while (intErrorTestCount <= m_intExpenseNumberTestMaxCount);
//---產生收支號的主流程
}
public static void PosReportNumberCreate(String StrGUID, int type)
{
String SQL = "";
m_StrPosReportNumber = "";
//---
//產生報表號的主流程
int intErrorTestCount = 0;
do
{
String StrResult = "";//String StrPosReportNumberBuf = SerialCodeDataGet(StrGUID, type);
if (type == 1)//關帳
{
//jash stop StrResult = (SysParmUI.m_pos_serial_paramBuf.order_no_from == "S") ? HttpGetDailyNo() : SerialCodeDataGet(StrGUID, 1);
}
else//交班
{
//jash stop StrResult = (SysParmUI.m_pos_serial_paramBuf.order_no_from == "S") ? HttpGetClassNo() : SerialCodeDataGet(StrGUID, 2);
}
if (StrResult.Length == 0)
{
intErrorTestCount++;
if (intErrorTestCount <= m_intReportNumberTestMaxCount)
{
continue;
}
else
{
break;
}
}
SQL = String.Format("SELECT report_no FROM daily_report WHERE report_no='{0}' LIMIT 0,1;", StrResult);
DataTable daily_reportDataTable = SQLDataTableModel.GetDataTable(SQL);
if ((daily_reportDataTable != null) && (daily_reportDataTable.Rows.Count > 0))
{
daily_reportDataTable.Clear();
}
else
{
m_StrPosReportNumber = StrResult;//紀錄產生的新訂單號
break;//跳離do-while
}
intErrorTestCount++;
} while (intErrorTestCount <= m_intReportNumberTestMaxCount);
//---產生報表號的主流程
}
public static String PosOrderNumberCreate(String StrGUID)
{
String StrResult = "";
int intclass_sid = 0;
String Strclass_name = "";
String SQL = "";
//---
//產生訂單號的主流程
int intErrorTestCount = 0;
do
{
StrResult = (false) ? HttpGetOrderNo() : SerialCodeDataGet(StrGUID, 0); //jash stop StrResult = (SysParmUI.m_pos_serial_paramBuf.order_no_from == "S") ? HttpGetOrderNo() : SerialCodeDataGet(StrGUID, 0);
if (StrResult.Length == 0)
{
intErrorTestCount++;
if (intErrorTestCount <= m_intOrderNumberTestMaxCount)
{
continue;
}
else
{
break;
}
}
SQL = String.Format("SELECT order_no FROM order_data WHERE order_no='{0}' LIMIT 0,1;", StrResult);
DataTable order_dataDataTable = SQLDataTableModel.GetDataTable(SQL);
if ((order_dataDataTable != null) && (order_dataDataTable.Rows.Count > 0))
{
order_dataDataTable.Clear();
}
else
{
//停用直接賦予值 因為有可能取號是為了別的設備 m_StrPosOrderNumber = StrResult;//紀錄產生的新訂單號
SQL = String.Format("UPDATE terminal_data SET last_order_no = '{0}'", StrResult);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
//---
//新增一筆order_data資料
String Strorder_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
NowClassDataGet();//取得目前班別
intclass_sid = m_intClassSid;
Strclass_name = m_StrClassName;
//訂單狀態(order_state) 0:訂購中,1:已結帳 2: 暫存中
//點單模式(order_mode) L:本機點單,O:線上點單 S:自助點單
//取號來源(order_no_from) (C:Cloud ,L:Local,S:主定的主機)
//付款狀態(paid_flag) Y: 已付款
//實收現金金額(cash_fee) - 沒有在使用 ,有在使用的是 order_payment_data 的 received_fee [order_payment_data 的 amount 是紀錄該筆的支付金額]
//找零金額(change_fee) - 沒有在使用 ,有在使用的是 order_payment_data 的 change_fee
//paid_time
//paid_info
//class_sid
//class_name - 班別
//user_sid - 從user_data&登入比對取得
//employee_no - 從user_data&登入比對取得
//call_num - 取餐號
//business_day - 營業日 [terminnal_data.business_day]
//VisitorsValueLable.Text = Strclass_name; //UI顯示班別資訊
String business_day = Convert.ToDateTime(SqliteDataAccess.m_terminal_data[0].business_day).ToString("yyyy-MM-dd");
SQL = String.Format("INSERT INTO order_data (order_open_time,order_no, order_no_from, order_time,terminal_sid,class_sid,user_sid,created_time,updated_time,pos_no,order_state,order_mode,paid_flag,class_name,order_type,order_type_name,order_type_code,business_day,employee_no,upload_time,cancel_time,cancel_upload_time,paid_time) VALUES ('{1}','{0}', 'L', '{1}','{4}',{2},{3},'{1}','{1}','{5}',0,'L','N','{6}','{7}','{8}','{9}','{10}','{11}','1970-01-01','1970-01-01','1970-01-01','1970-01-01');", StrResult, Strorder_time, intclass_sid, m_StrUserSID, SqliteDataAccess.m_terminal_data[0].SID, SqliteDataAccess.m_terminal_data[0].pos_no, Strclass_name, m_intOrderTypeIdSelected, m_StrOrderTypeNameSelected, m_StrOrderTypeCodeSelected, business_day, m_StrEmployeeNo);
SQLDataTableModel.SQLiteInsertUpdateDelete(SQL);
//---新增一筆order_data資料
break;//跳離do-while
}
intErrorTestCount++;
} while (intErrorTestCount <= m_intOrderNumberTestMaxCount);
//---產生訂單號的主流程
return StrResult;
}
//---新增建立系統號碼字串函數
public static String m_StrHasDaily = "";
public static DateTime m_ClassLastTime = DateTime.Now;//最後一次執行交班時間
public static DateTime m_DailyLastTime = DateTime.Now;//最後一次執行關帳時間
public static DateTime m_ClassOrderFirstTime = DateTime.Now;
public static DateTime m_ClassOrderLastTime = DateTime.Now;
public static DateTime m_DailyOrderFirstTime = DateTime.Now;
public static DateTime m_DailyOrderLastTime = DateTime.Now;
public static void GetClassDailyLastTime()//抓取 最後一次執行交班時間 & 最後一次執行關帳時間
{
/*
SELECT
SUM(class_last_time) AS class_last_time,
SUM(daily_last_time) AS daily_last_time
FROM
(
SELECT
STRFTIME('%s',MAX(report_time)) AS class_last_time,
0 AS daily_last_time
FROM daily_report
WHERE report_type='C'
UNION
SELECT
0 AS class_last_time,
STRFTIME('%s',MAX(report_time)) AS daily_last_time
FROM daily_report
WHERE report_type='D'
);
*/
String SQL = "SELECT SUM(class_last_time) AS class_last_time,SUM(daily_last_time) AS daily_last_time FROM (SELECT STRFTIME('%s',MAX(report_time)) AS class_last_time,0 AS daily_last_time FROM daily_report WHERE report_type='C' UNION SELECT 0 AS class_last_time,STRFTIME('%s',MAX(report_time)) AS daily_last_time FROM daily_report WHERE report_type='D')";
DataTable dt = SQLDataTableModel.GetDataTable(SQL);
// 紀錄最後的交班時間及關帳時間
m_ClassLastTime = TimeConvert.UnixTimeStampToDateTime(Convert.ToDouble(dt.Rows[0][0].ToString()), false);
m_DailyLastTime = TimeConvert.UnixTimeStampToDateTime(Convert.ToDouble(dt.Rows[0][1].ToString()), false);
// 若交班的最後時間,小於關帳時間,就使用關帳時間做為期使時間
if (DateTime.Compare(m_ClassLastTime, m_DailyLastTime) < 0)
{
m_ClassLastTime = m_DailyLastTime;
}
SQL = "SELECT business_day FROM terminal_data LIMIT 0,1";
dt = SQLDataTableModel.GetDataTable(SQL);
m_StrHasDaily = Convert.ToDateTime(dt.Rows[0][0].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
/*
SQL = String.Format("SELECT MIN(order_time) AS order_first_time,MAX(order_time) AS order_last_time FROM order_data WHERE order_time >='{0}' AND order_time <='{1}' AND daily_close_flag != 'Y'", m_DailyLastTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
dt = SQLDataTableModel.GetDataTable(SQL);
if((dt!=null)&&(dt.Rows.Count > 0))
{
m_DailyOrderFirstTime = (dt.Rows[0][0].ToString().Length>0)? Convert.ToDateTime(dt.Rows[0][0].ToString()) : DateTime.Now;
m_DailyOrderLastTime = (dt.Rows[0][1].ToString().Length > 0)? Convert.ToDateTime(dt.Rows[0][1].ToString()) : DateTime.Now;
}
SQL = String.Format("SELECT MIN(order_time) AS order_first_time,MAX(order_time) AS order_last_time FROM order_data WHERE order_time >='{0}' AND order_time <='{1}' AND class_close_flag != 'Y'", m_ClassLastTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
dt = SQLDataTableModel.GetDataTable(SQL);
if ((dt != null) && (dt.Rows.Count > 0))
{
m_ClassOrderFirstTime = (dt.Rows[0][0].ToString().Length > 0) ? Convert.ToDateTime(dt.Rows[0][0].ToString()) : DateTime.Now;
m_ClassOrderLastTime = (dt.Rows[0][1].ToString().Length > 0) ? Convert.ToDateTime(dt.Rows[0][1].ToString()) : DateTime.Now;
}
*/
m_DailyOrderFirstTime = m_DailyLastTime;
m_DailyOrderLastTime = DateTime.Now;
m_ClassOrderFirstTime = m_ClassLastTime;
m_ClassOrderLastTime = DateTime.Now;
}
public bool HttpObjectInit(ref bool blnServerMode)//Http 服務相關元件初始化
{
bool blnResult = true;
/*jash stop
SysParmUI.SysParmUIMemberVarSet();//讀取 取號方式(Server/Local 方式) & KDS參數
if (SysParmUI.m_pos_serial_paramBuf.terminal_server_flag == "Y")//啟動服務
{
blnServerMode = true;
blnResult = HttpServerThread.Start(Convert.ToInt32(SysParmUI.m_pos_serial_paramBuf.terminal_server_port));
}
else
{
blnServerMode = false;
if (SysParmUI.m_pos_serial_paramBuf.order_no_from == "S")//主機取號
{
//單純主機IP&PORT連線測試
TcpClient tcpClient = new TcpClient();
try
{
tcpClient.Connect(SysParmUI.m_pos_serial_paramBuf.serial_server_name, SysParmUI.m_pos_serial_paramBuf.serial_server_port);
tcpClient.Close();
blnResult = true;
}
catch
{
blnResult = false;
}
tcpClient = null;
}
}
*/
return blnResult;
}
public static String HttpGetOrderNo()
{
String StrResult = "";
/*jash stop
String StrDomain = $"http://{SysParmUI.m_pos_serial_paramBuf.serial_server_name}:{SysParmUI.m_pos_serial_paramBuf.serial_server_port}/";
String StrBuf = HttpsFun.RESTfulAPI_get(StrDomain, "getorderno", "", "", "");
getorderno getordernoBuf = JsonClassConvert.getorderno2Class(StrBuf);
if (getordernoBuf != null)
{
StrResult = getordernoBuf.orderno;
}
*/
return StrResult;
}
public static String HttpGetDailyNo()
{
String StrResult = "";
/*jash stop
String StrDomain = $"http://{SysParmUI.m_pos_serial_paramBuf.serial_server_name}:{SysParmUI.m_pos_serial_paramBuf.serial_server_port}/";
String StrBuf = HttpsFun.RESTfulAPI_get(StrDomain, "getdailyno", "", "", "");
getdailyno getdailynoBuf = JsonClassConvert.getdailyno2Class(StrBuf);
if (getdailynoBuf != null)
{
StrResult = getdailynoBuf.dailyno;
}
*/
return StrResult;
}
public static String HttpGetClassNo()
{
String StrResult = "";
/*jash stop
String StrDomain = $"http://{SysParmUI.m_pos_serial_paramBuf.serial_server_name}:{SysParmUI.m_pos_serial_paramBuf.serial_server_port}/";
String StrBuf = HttpsFun.RESTfulAPI_get(StrDomain, "getclassno", "", "", "");
getclassno getclassnoBuf = JsonClassConvert.getclassno2Class(StrBuf);
if (getclassnoBuf != null)
{
StrResult = getclassnoBuf.classno;
}
*/
return StrResult;
}
public static bool HttpTestConnection()
{
bool blnResult = false;
/*jash stop
String StrDomain = $"http://{SysParmUI.m_pos_serial_paramBuf.serial_server_name}:{SysParmUI.m_pos_serial_paramBuf.serial_server_port}/";
String StrBuf = HttpsFun.RESTfulAPI_get(StrDomain, "testconnection", "", "", "");
testconnection testconnectionBuf = JsonClassConvert.testconnection2Class(StrBuf);
if ((testconnectionBuf != null) && (testconnectionBuf.servername.Length > 0))
{
blnResult = true;
}
*/
return blnResult;
}
public static void ShowSoftKeyboard()//顯示/呼叫 螢幕鍵盤/軟體鍵盤
{
try
{
//關閉螢幕鍵盤(尋找已開啟的軟體並將它關閉)
System.Diagnostics.Process[] MyProcess = System.Diagnostics.Process.GetProcessesByName("osk");
if (MyProcess.Length > 0)
{
MyProcess[0].Kill();
}
//Any CPU 寫法
//https://social.msdn.microsoft.com/Forums/vstudio/en-US/3cf45aac-fab9-45f0-b416-cc504daf71da/processstart-elevation-and-uac?forum=csharpgeneral
/*Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.WorkingDirectory = "C:\\";
process.StartInfo.FileName = "C:\\WINDOWS\\system32\\osk.exe";
//process.StartInfo.Verb = "runas";
process.Start();*/
//透過cmd的start執行軟體鍵盤 讓cmd不咬住 並且透過exit將cmd畫面關閉 [透過cmd克服C# x32程式無法呼叫 x64系統應用程式的問題]
Process.Start(@"cmd.exe", "/c start osk.exe exit");
}
catch (Exception ex)
{
String StrLog = String.Format("{0}:{1}", "ShowSoftKeyboard", ex.ToString());
LogFile.Write("ProcessError ; " + StrLog);
}
}
public static double m_dblScreenWidth = 0;
public static double m_dblScreenHeight = 0;
public static double m_dblScreenDensity = 0.0;
public void GetDisplayInfo()
{//抓螢幕解析度
LogFile.Write("GetDisplayInfo Start");
var displayInfo = DeviceDisplay.MainDisplayInfo;
m_dblScreenWidth = displayInfo.Width;
m_dblScreenHeight = displayInfo.Height;
m_dblScreenDensity = displayInfo.Density;
}
private ObservableCollection<ShopcartItem> m_ShopcartItems
= new ObservableCollection<ShopcartItem>();
private String[] m_StrShopcartIcons = new string[5] { "checkbox00.png", "checkbox01.png", "blank.png", "add.png", "up_arrow.png" };//存放購物車ICON圖片名
public MainPage()//建構子
{
InitializeComponent();
LogFile.Write("MainPage Start");
GetDisplayInfo();
ShowInfoInit();
ShopcartBtnGridInit();
MiddleRowButtonInit();
CreateCategoryBtn(8,2,4);
CreateProductBtn(16, 4, 4);//4, 1,4
CreateCondimentBtn(8,2,4);
CategoryBtnSetShow(true);
if (m_CategoryBtn[0].IsVisible)
{
m_CustBtnCategorySelected = m_CategoryBtn[0];
m_intCategorySelectedSID = m_CategoryBtn[0].m_intSID;
CategoryBtn_Clicked();
}
ShopcartListView.ItemsSource = m_ShopcartItems;//綁定購物車資料結構
/*
//---
//移除方格整列元素 & 動態調整版面大小
ShowInfoLine01.IsVisible = false;
InvoiceNoTextLable.IsVisible = false;
InvoiceNoValueLable.IsVisible = false;
InvoiceNoBtn.IsVisible = false;
InvoiceCountTextLable.IsVisible = false;
InvoiceCountValueLable.IsVisible = false;
CarrierBtn.IsVisible = false;
TaxIDTextLable.IsVisible = false;
TaxIDValueLable.IsVisible = false;
CarrierTextLable.IsVisible = false;
CarrierValueLable.IsVisible = false;
ShowInfoGrid.RowDefinitions.RemoveAt(2);
LeftContentGrid.RowDefinitions[0] = new RowDefinition(new GridLength(2.5, GridUnitType.Star));
LeftContentGrid.RowDefinitions[1] = new RowDefinition(new GridLength(6.5, GridUnitType.Star));
//---移除方格整列元素 & 動態調整版面大小
*/
}
private void ShowInfoInit()
{
//*
OrderStatusLable.Text = "";//訂購中
QuantityValueLable.Text = "";//商品數量
DiscountValueLable.Text = "";//優惠金額
ServiceValueLable.Text = "";//服務費
ReceivableValueLable.Text = "";//應收總額
ChangeValueLable.Text = "";//找零金額
OrderNoValueLable.Text = "";//訂單編號
PickupNoValueLable.Text = "";//取餐號
VisitorsValueLable.Text = "";//來客數
OrderTypeValueLable.Text = "";//訂單類型
TableNoValueLable.Text = "";//桌號
ShopNoValueLable.Text = "";//牌號
MemberNameValueLable.Text = "";//會員名稱
MemberTelValueLable.Text = "";//會員電話
InvoiceNoValueLable.Text = "";//發票號碼
InvoiceCountValueLable.Text = "";//發票剩餘張數
TaxIDValueLable.Text = "";//客戶統編
CarrierValueLable.Text = "";//發票載具
//*/
Color BackgroundColor = new Color(25, 74, 110);
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
CarrierBtn.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, "發票\n載具", dblFontSize);
InvoiceNoBtn.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, "客戶\n統編", dblFontSize);
}
private void ShopcartBtnGridInit()
{
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
ShopcartBtn00.m_intSID = 0;
ShopcartBtn01.m_intSID = 1;
ShopcartBtn02.m_intSID = 2;
ShopcartBtn03.m_intSID = 3;
ShopcartBtn04.m_intSID = 4;
ShopcartBtn05.m_intSID = 5;
ShopcartBtn06.m_intSID = 6;
ShopcartBtn07.m_intSID = 7;
ShopcartBtn08.m_intSID = 8;
//ShopcartBtn09.m_intSID = 9;
//ShopcartBtn10.m_intSID= 10;
Color BackgroundColor = new Color(25, 74, 110);
String []StrName= new String[11];
for(int i=0; i<11; i++)
{
StrName[i]= i.ToString();
}
ShopcartBtn00.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[0], dblFontSize);
ShopcartBtn01.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[1], dblFontSize);
ShopcartBtn02.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[2], dblFontSize);
ShopcartBtn03.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[3], dblFontSize);
ShopcartBtn04.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[4], dblFontSize);
ShopcartBtn05.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[5], dblFontSize);
ShopcartBtn06.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[6], dblFontSize);
ShopcartBtn07.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[7], dblFontSize);
ShopcartBtn08.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, StrName[8], dblFontSize);
//ShopcartBtn09.InitDisplay(Colors.White, BackgroundColor, StrName[9], dblFontSize);
//ShopcartBtn10.InitDisplay(Colors.White, BackgroundColor, StrName[10], dblFontSize);
// 綁定事件
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += ShopcartBtn_Clicked;
ShopcartBtn00.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn01.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn02.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn03.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn04.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn05.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn06.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn07.GestureRecognizers.Add(tapGestureRecognizer);
ShopcartBtn08.GestureRecognizers.Add(tapGestureRecognizer);
//ShopcartBtn09.GestureRecognizers.Add(tapGestureRecognizer);
//ShopcartBtn10.GestureRecognizers.Add(tapGestureRecognizer);
ModifiedBtn.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, "修改", dblFontSize);
PlusBtn.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, "┼", dblFontSize);
MinusBtn.InitDisplay(Colors.White, BackgroundColor, BackgroundColor, "─", dblFontSize);
}
private async void ShopcartBtn_Clicked(object sender, EventArgs e)
{
await this.ShowPopupAsync(new MessageBox($"{((CustBtn)(sender)).m_intSID}"));
switch(((CustBtn)(sender)).m_intSID)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4://結帳按鈕
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
}
}
//---
//畫面右側按鈕動態建立函數
CustBtn[] m_CategoryBtn;
private void CreateCategoryBtn(int intQuantity, int intRows, int intColumns)
{
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
var tapGestureRecognizer00 = new TapGestureRecognizer();
tapGestureRecognizer00.Tapped += CategoryUpDown_Clicked;
CategoryUpBtn.m_intSID = 0;
CategoryDownBtn.m_intSID = 1;
CategoryUpBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▲", dblFontSize);
CategoryDownBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▼", dblFontSize);
CategoryUpBtn.GestureRecognizers.Add(tapGestureRecognizer00);
CategoryDownBtn.GestureRecognizers.Add(tapGestureRecognizer00);
if (intRows*intColumns>= intQuantity)
{
Grid CategoryMainGrid = new Grid();//建立網格
CategoryMainGrid.Margin = new Thickness(2,1,2,1);
CategoryMainGrid.RowSpacing = 1;
CategoryMainGrid.ColumnSpacing = 1;
for (int i = 0;i<intRows;i++) //配置列數
{
CategoryMainGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < intColumns; i++)//配置行數
{
CategoryMainGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
m_CategoryBtn=new CustBtn[intQuantity];//建立按鈕陣列
for(int i=0;i<intQuantity;i++)
{
//建立按鈕
m_CategoryBtn[i] = new CustBtn();//建立每個按鈕實體
m_CategoryBtn[i].InitData(i);
dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
m_CategoryBtn[i].InitDisplay(new Color(65, 134, 168), new Color(36, 112, 160), new Color(253, 95, 0), $"產品類名稱超長測試{i + 1}", dblFontSize);//每個按鈕初始化
// 綁定事件
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += CategoryBtn_Clicked;
m_CategoryBtn[i].GestureRecognizers.Add(tapGestureRecognizer);
//放到Layout上
int intRow = i / intColumns;
int intColumn = i % intColumns;
CategoryMainGrid.Add(m_CategoryBtn[i], intColumn, intRow);
}
//放到XAML的Layout上
CategoryBtnGrid.Add(CategoryMainGrid, 0, 0);
}
}
private void CategoryBtnInitHide()
{
CategoryTextLable.Text = "";
for (int i = 0; i < m_CategoryBtn.Length; i++)
{
m_CategoryBtn[i].IsVisible = false;
}
}
//---
//DB取得產品分類
public int m_intCategoryNowPages = 1;
public int m_intCategoryTotalPages = 1;
private void CategoryBtnInformationGet()
{
m_intCategoryNowPages = 1;
m_intCategoryTotalPages = 1;
SqliteDataAccess.product_category2ListVar();
if (SqliteDataAccess.m_product_category != null)
{
m_intCategoryTotalPages = SqliteDataAccess.m_product_category.Count / m_CategoryBtn.Length;
if ((SqliteDataAccess.m_product_category.Count % m_CategoryBtn.Length) > 0)
{
m_intCategoryTotalPages++;
}
else
{
m_intCategoryTotalPages += 0;
}
if (m_intCategoryTotalPages == 0)
{
m_intCategoryNowPages = 0;
m_intCategoryTotalPages = 0;
}
}
else
{
m_intCategoryNowPages = 0;
m_intCategoryTotalPages = 0;
}
}
//---DB取得產品分類
void CategoryBtnSetShow(bool blnSQL = false)
{
CategoryBtnInitHide();
if (blnSQL == true)
{
CategoryBtnInformationGet();
}
int j = 0;
if ((SqliteDataAccess.m_product_category != null) && (m_intCategoryNowPages > 0))
{
for (int i = ((m_intCategoryNowPages - 1) * m_CategoryBtn.Length); i < SqliteDataAccess.m_product_category.Count; i++)
{
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
m_CategoryBtn[j].SetText(SqliteDataAccess.m_product_category[i].category_name);
m_CategoryBtn[j].m_intSID = SqliteDataAccess.m_product_category[i].SID;
m_CategoryBtn[j].m_intPrice = 0;
m_CategoryBtn[j].m_StrProductCode = SqliteDataAccess.m_product_category[i].category_code;
m_CategoryBtn[j].IsVisible = true;
j++;
if (j == m_CategoryBtn.Length)
{
break;
}
}
}
CategoryTextLable.Text = String.Format("{2}/{3}", "類別", "第", m_intCategoryNowPages, m_intCategoryTotalPages, "頁");
}
public CustBtn m_CustBtnCategorySelected = null;
public int m_intCategorySelectedSID = -1;
private void SetCategoryBtnBackgroundColor()
{
for (int i = 0; i < m_CategoryBtn.Length; i++)
{
if ((m_CustBtnCategorySelected == null) || (m_intCategorySelectedSID != m_CategoryBtn[i].m_intSID))
{
m_CategoryBtn[i].SetBackgroundColor();
}
else
{
m_CategoryBtn[i].SetBackgroundColor(true);
}
}
}
private async void CategoryBtn_Clicked()
{
SetCategoryBtnBackgroundColor();
if ((m_CustBtnCategorySelected != null) && (m_intCategorySelectedSID>0))
{
ProductBtnInitShow(true);
CondimentBtnInitHide();
}
//await this.ShowPopupAsync(new MessageBox($"{m_CustBtnCategorySelected.m_intSID}"));
}
private void CategoryBtn_Clicked(object sender, EventArgs e)
{
m_CustBtnCategorySelected = ((CustBtn)(sender));
m_intCategorySelectedSID = m_CustBtnCategorySelected.m_intSID;
CategoryBtn_Clicked();
}
private async void CategoryUpDown_Clicked(object sender, EventArgs e)
{
int intCategoryNowPages = m_intCategoryNowPages;
switch (((CustBtn)(sender)).m_intSID)
{
case 0://產品分類切頁事件 [-1]
m_intCategoryNowPages = (m_intCategoryNowPages - 1) > 0 ? (m_intCategoryNowPages - 1) : 1;
break;
case 1://產品分類切頁事件 [+1]
m_intCategoryNowPages = (m_intCategoryNowPages + 1) < m_intCategoryTotalPages ? (m_intCategoryNowPages + 1) : m_intCategoryTotalPages;
break;
}
if(intCategoryNowPages!= m_intCategoryNowPages)
{
CategoryBtnSetShow();
SetCategoryBtnBackgroundColor();
}
}
CustBtn[] m_ProductBtn;
private void CreateProductBtn(int intQuantity, int intRows, int intColumns)
{
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
var tapGestureRecognizer00 = new TapGestureRecognizer();
tapGestureRecognizer00.Tapped += ProductUpDown_Clicked;
ProductUpBtn.m_intSID = 0;
ProductDownBtn.m_intSID = 1;
ProductUpBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▲", dblFontSize);
ProductDownBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▼", dblFontSize);
ProductUpBtn.GestureRecognizers.Add(tapGestureRecognizer00);
ProductDownBtn.GestureRecognizers.Add(tapGestureRecognizer00);
if (intRows * intColumns >= intQuantity)
{
Grid ProductMainGrid = new Grid();
ProductMainGrid.Margin = new Thickness(2, 2, 1, 1);
ProductMainGrid.RowSpacing = 1;
ProductMainGrid.ColumnSpacing = 1;
for (int i = 0; i < intRows; i++)
{
ProductMainGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < intColumns; i++)
{
ProductMainGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
m_ProductBtn = new CustBtn[intQuantity];//建立按鈕陣列
for (int i = 0; i < intQuantity; i++)
{
//建立按鈕
m_ProductBtn[i] = new CustBtn();//建立每個按鈕實體
m_ProductBtn[i].InitData(i);
dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
m_ProductBtn[i].InitDisplay(Colors.White, new Color(106, 117, 79), new Color(106, 117, 79), $"產品名稱{i + 1}", dblFontSize);//每個按鈕初始化
// 綁定事件
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += Product_Clicked;
m_ProductBtn[i].GestureRecognizers.Add(tapGestureRecognizer);
//放到Layout上
int intRow = i / intColumns;
int intColumn = i % intColumns;
ProductMainGrid.Add(m_ProductBtn[i], intColumn, intRow);
}
//放到XAML的Layout上
ProductBtnGrid.Add(ProductMainGrid, 0, 0);
}
}
public CustBtn m_CustBtnProductSelected = null;
public int m_intProductSelectedSID = -1;
private async void Product_Clicked(object sender, EventArgs e)
{
if (AfterPaymentUIInit() != 0)
{
return;
}
//---
//整合建立訂單編號字串功能
if (await PosOrderNumberCreatUIInitAsync() != 0)
{
return;//跳出程序
}
//---整合建立訂單編號字串功能
//jash stop OrderStatusLable.Text = "訂購中";
m_CustBtnProductSelected = (CustBtn)sender;//productButtonClickShow(sender);
m_intProductSelectedSID = m_CustBtnProductSelected.m_intSID;
int intMainSID = -1;
//---
//購物車清單新增程序
if (m_CustBtnProductSelected.m_Strproduct_type == "T")//套餐
{
intMainSID = m_CustBtnProductSelected.m_intSID;
String StrCode = m_CustBtnProductSelected.m_StrProductCode;
String StrName = m_CustBtnProductSelected.GetText();
double dblPrice = (double)m_CustBtnProductSelected.m_intPrice;
await Navigation.PushModalAsync(new FoodMeal());
/*jash stop
FoodMeal foodMeal = new FoodMeal(intMainSID, StrCode, StrName, dblPrice);//套餐編輯UI
foodMeal.ShowDialog();
*/
intMainSID = -1;//預防刷新調味品區塊
/*jash stop
if (foodMeal.m_blnRun == true)
{
ShopCartFoodMealAdd();
}
*/
}
else if ((m_CustBtnProductSelected != null) && (m_CustBtnProductSelected.m_blnspec != true))//一般商品
{
intMainSID = m_CustBtnProductSelected.m_intSID;//正確記錄產選擇商品SID,利於後續顯示對應配料 at 20221102
ShopCartMainListAdd();
ShopcartListViewShow(0, (m_ShopCart.m_ShopMainList.Count - 1), -1, 14);//dgvmain001Show
}
else//產品規格群組
{
ProductSpecification ProductSpecificationBuf = new ProductSpecification(m_CustBtnProductSelected.GetText(), m_CustBtnProductSelected.m_product);
await this.ShowPopupAsync(ProductSpecificationBuf);
if((ProductSpecification.m_blnResult) && (ProductSpecification.m_BtnResult!=null))
{
m_CustBtnProductSelected = ProductSpecification.m_BtnResult;
intMainSID = ProductSpecification.m_BtnResult.m_intSID;
ShopCartMainListAdd();
ShopcartListViewShow(0, (m_ShopCart.m_ShopMainList.Count - 1), -1, 14);//dgvmain001Show
}
}
//---購物車清單新增程序
if (intMainSID != -1)
{
CondimentBtnInitShow(true, intMainSID);//顯示調味品清單程序
}
//ChangeOrderTypeCalculate();
}
private async void ProductUpDown_Clicked(object sender, EventArgs e)
{
int intProductNowPages = m_intProductNowPages;
switch (((CustBtn)(sender)).m_intSID)
{
case 0://產品切頁事件 [-1]
m_intProductNowPages = (m_intProductNowPages - 1) > 0 ? (m_intProductNowPages - 1) : 1;
break;
case 1://產品切頁事件 [+1]
m_intProductNowPages = (m_intProductNowPages + 1) < m_intProductTotalPages ? (m_intProductNowPages + 1) : m_intProductTotalPages;
break;
}
if (intProductNowPages != m_intProductNowPages)
{
ProductBtnInitShow();
}
}
public int m_intProductNowPages = 1;
public int m_intProductTotalPages = 1;
private void ProductBtnInformationGet()
{
m_intProductNowPages = 1;
m_intProductTotalPages = 1;
if (m_intCategorySelectedSID>0)
{
//SqliteDataAccess.product2ListVar(m_RoundButtonExpcategorySelected.m_intSID);
List<int> spec_sidbuf = new List<int>();
SQLDataTableModel.m_product_spec_Var.Clear();
string expression01;
expression01 = String.Format("category_sid={0} AND product_display='Y'", m_intCategorySelectedSID);
DataRow[] foundRows01 = SQLDataTableModel.m_productDataTable.Select(expression01);
if (foundRows01.Length > 0)
{
for (int i = 0; i < foundRows01.Length; i++)
{
int spec_sid = Int32.Parse(foundRows01[i]["spec_sid"].ToString());
if (spec_sid == 0)//單純產品
{
product_spec_Var product_Spec_VarBuf = new product_spec_Var();
product_Spec_VarBuf.product_price = Convert.ToDouble(foundRows01[i]["product_price"].ToString());
product_Spec_VarBuf.product_sid = Int32.Parse(foundRows01[i]["product_sid"].ToString());
product_Spec_VarBuf.product_code = foundRows01[i]["product_code"].ToString();
product_Spec_VarBuf.product_name = foundRows01[i]["product_name"].ToString();
product_Spec_VarBuf.blnspec = false;
product_Spec_VarBuf.m_Strproduct_type = foundRows01[i]["product_type"].ToString();
if (foundRows01[i]["tax_sid"].ToString().Length > 0)
product_Spec_VarBuf.m_inttax_sid = Int32.Parse(foundRows01[i]["tax_sid"].ToString()); //稅率編號 ; 產品若沒有稅率資料[m_tax_sid=0],就直接從company和tax_data取出預設值
if (foundRows01[i]["tax_rate"].ToString().Length > 0)
product_Spec_VarBuf.m_inttax_rate = Int32.Parse(foundRows01[i]["tax_rate"].ToString()); //稅率
product_Spec_VarBuf.m_Strtax_type = foundRows01[i]["tax_type"].ToString();//稅率類型
//product_Spec_VarBuf.m_inttax_fee; //稅率金額
SQLDataTableModel.m_product_spec_Var.Add(product_Spec_VarBuf);
}
else
{
bool blnfind = false;
for (int k = 0; k < spec_sidbuf.Count; k++)
{
int intbuf = spec_sidbuf[k];
if (intbuf == spec_sid)
{
blnfind = true;
break;
}
}
if (blnfind)
{
continue;
}
else
{
spec_sidbuf.Add(spec_sid);
string expression02;
expression02 = String.Format("category_sid={0} AND spec_sid={1}", m_intCategorySelectedSID, spec_sid);
DataRow[] foundRows02 = SQLDataTableModel.m_productDataTable.Select(expression02);
product_spec_Var product_Spec_VarBuf = new product_spec_Var();
product_Spec_VarBuf.product_sid = -1;
product_Spec_VarBuf.product_code = "";
product_Spec_VarBuf.product_price = 0;
product_Spec_VarBuf.blnspec = true;
for (int j = 0; j < foundRows02.Length; j++)
{
if (foundRows02[j]["spec_name"].ToString().Length > 0)
{
product_Spec_VarBuf.product_name = foundRows02[j]["spec_name"].ToString();
}
product_Var product_VarBuf = new product_Var();
product_VarBuf.product_price = Convert.ToDouble(foundRows02[j]["product_price"].ToString());
product_VarBuf.product_sid = Int32.Parse(foundRows02[j]["product_sid"].ToString());
product_VarBuf.product_code = foundRows02[j]["product_code"].ToString();
product_VarBuf.product_name = foundRows02[j]["product_name"].ToString();
product_VarBuf.alias_name = foundRows02[j]["alias_name"].ToString();
product_VarBuf.m_Strproduct_type = foundRows02[j]["product_type"].ToString();
if (foundRows02[j]["tax_sid"].ToString().Length > 0)
product_VarBuf.m_inttax_sid = Int32.Parse(foundRows02[j]["tax_sid"].ToString()); //稅率編號 ; 產品若沒有稅率資料[m_tax_sid=0],就直接從company和tax_data取出預設值
if (foundRows02[j]["tax_rate"].ToString().Length > 0)
product_VarBuf.m_inttax_rate = Int32.Parse(foundRows02[j]["tax_rate"].ToString()); //稅率
product_VarBuf.m_Strtax_type = foundRows02[j]["tax_type"].ToString();//稅率類型
//product_VarBuf.m_inttax_fee; //稅率金額
product_Spec_VarBuf.product.Add(product_VarBuf);
}
if (product_Spec_VarBuf.product_name.Length == 0)
{
product_Spec_VarBuf.product_name = product_Spec_VarBuf.product[0].product_name;
}
SQLDataTableModel.m_product_spec_Var.Add(product_Spec_VarBuf);
}
}
}
}
}
if (SQLDataTableModel.m_product_spec_Var != null)//if (SqliteDataAccess.m_product_data != null)
{
m_intProductTotalPages = SQLDataTableModel.m_product_spec_Var.Count / m_ProductBtn.Length;//intproductTotalPages = SqliteDataAccess.m_product_data.Count / 16;
if ((SQLDataTableModel.m_product_spec_Var.Count % m_ProductBtn.Length) > 0)//if ((SqliteDataAccess.m_product_data.Count % 16) > 0)
{
m_intProductTotalPages++;
}
else
{
m_intProductTotalPages += 0;
}
if (m_intProductTotalPages == 0)
{
m_intProductNowPages = 0;
m_intProductTotalPages = 0;
}
}
else
{
m_intProductNowPages = 0;
m_intProductTotalPages = 0;
}
}
void ProductBtnInitHide()
{
for (int i = 0; i < m_ProductBtn.Length; i++)
{
m_ProductBtn[i].IsVisible = false;
}
}
void ProductBtnInitShow(bool blnSQL = false)
{
ProductBtnInitHide();
if (blnSQL == true)
{
ProductBtnInformationGet();
}
int j = 0;
if ((SQLDataTableModel.m_product_spec_Var != null) && (m_intProductNowPages > 0))//if (SqliteDataAccess.m_product_data != null)
{
for (int i = ((m_intProductNowPages - 1) * m_ProductBtn.Length); i < SQLDataTableModel.m_product_spec_Var.Count; i++)//for (int i = ((intproductNowPages - 1) * 16); i < SqliteDataAccess.m_product_data.Count; i++)
{
m_ProductBtn[j].SetText(SQLDataTableModel.m_product_spec_Var[i].product_name);//m_Buttproduct[j].Text = SqliteDataAccess.m_product_data[i].product_name;
m_ProductBtn[j].m_intSID = SQLDataTableModel.m_product_spec_Var[i].product_sid;//m_Buttproduct[j].m_intSID = SqliteDataAccess.m_product_data[i].SID;
m_ProductBtn[j].m_intPrice = Convert.ToDecimal(SQLDataTableModel.m_product_spec_Var[i].product_price);//m_Buttproduct[j].m_intPrice = SqliteDataAccess.m_product_data[i].product_price;
m_ProductBtn[j].m_StrProductCode = SQLDataTableModel.m_product_spec_Var[i].product_code;//m_Buttproduct[j].m_StrProductCode = SqliteDataAccess.m_product_data[i].product_code;
m_ProductBtn[j].m_blnspec = SQLDataTableModel.m_product_spec_Var[i].blnspec;
m_ProductBtn[j].m_product = SQLDataTableModel.m_product_spec_Var[i].product;
m_ProductBtn[j].m_Strproduct_type = SQLDataTableModel.m_product_spec_Var[i].m_Strproduct_type;//類型
m_ProductBtn[j].m_inttax_sid = SQLDataTableModel.m_product_spec_Var[i].m_inttax_sid; //稅率編號
m_ProductBtn[j].m_inttax_rate = SQLDataTableModel.m_product_spec_Var[i].m_inttax_rate; //稅率
m_ProductBtn[j].m_Strtax_type = SQLDataTableModel.m_product_spec_Var[i].m_Strtax_type;//稅率類型
//m_Buttproduct[j].m_inttax_fee = 0; //稅率金額
m_ProductBtn[j].IsVisible = true;
j++;
if (j == m_ProductBtn.Length)
{
break;
}
}
}
ProductTextLable.Text = String.Format("{2}/{3}", "產品", "第", m_intProductNowPages, m_intProductTotalPages, "頁");
}
CustBtn[] m_CondimentBtn;
private void CreateCondimentBtn(int intQuantity, int intRows, int intColumns)
{
double dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
var tapGestureRecognizer00 = new TapGestureRecognizer();
tapGestureRecognizer00.Tapped += CondimentUpDown_Clicked;
CondimentUpBtn.m_intSID = 0;
CondimentDownBtn.m_intSID = 1;
CondimentUpBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▲", dblFontSize);
CondimentDownBtn.InitDisplay(Colors.White, new Color(25, 74, 110), new Color(25, 74, 110), "▼", dblFontSize);
CondimentUpBtn.GestureRecognizers.Add(tapGestureRecognizer00);
CondimentDownBtn.GestureRecognizers.Add(tapGestureRecognizer00);
if (intRows * intColumns >= intQuantity)
{
Grid CondimentMainGrid = new Grid();
CondimentMainGrid.Margin = new Thickness(2, 2, 1, 1);
CondimentMainGrid.RowSpacing = 0;
CondimentMainGrid.ColumnSpacing = 1;
for (int i = 0; i < intRows; i++)
{
CondimentMainGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < intColumns; i++)
{
CondimentMainGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
m_CondimentBtn = new CustBtn[intQuantity];//建立按鈕陣列
for (int i = 0; i < intQuantity; i++)
{
//建立按鈕
m_CondimentBtn[i] = new CustBtn();//建立每個按鈕實體
m_CondimentBtn[i].InitData(i);
dblFontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
m_CondimentBtn[i].InitDisplay(Colors.White, new Color(92, 171, 125), new Color(92, 171, 125), $"配料名稱{i + 1}", dblFontSize);//每個按鈕初始化
// 綁定事件
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += Condiment_Clicked;
m_CondimentBtn[i].GestureRecognizers.Add(tapGestureRecognizer);
//放到Layout上
int intRow = i / intColumns;
int intColumn = i % intColumns;
CondimentMainGrid.Add(m_CondimentBtn[i], intColumn, intRow);
}
//放到XAML的Layout上
CondimentBtnGrid.Add(CondimentMainGrid, 0, 0);
}
}
void CondimentBtnInitHide()
{
CondimentTextLable.Text = "1/1";
for (int i = 0; i < m_CondimentBtn.Length; i++)
{
m_CondimentBtn[i].SetText("");
m_CondimentBtn[i].m_intSID = 0;
m_CondimentBtn[i].m_intPrice = 0;
m_CondimentBtn[i].m_StrProductCode = "";
m_CondimentBtn[i].IsVisible = false;
}
}
public int m_intCondimentNowPages = 1;
public int m_intCondimentTotalPages = 1;
void CondimentBtnInformationGet(int intMainSID = -1)
{
m_intCondimentNowPages = 1;
m_intCondimentTotalPages = 1;
int intproduct_sid = -1;
SQLDataTableModel.m_condiment_Var.Clear();
if (m_CustBtnProductSelected != null)
{
intproduct_sid = m_CustBtnProductSelected.m_intSID;//SqliteDataAccess.condiment2ListVar(m_RoundButtonExpproductSelected.m_intSID);
}
else
{
intproduct_sid = intMainSID;//SqliteDataAccess.condiment2ListVar(intMainSID);
}
if (intproduct_sid != -1)
{
if (SQLDataTableModel.m_condimentDataTable != null)
{
string expression01;
expression01 = String.Format("product_sid={0}", intproduct_sid);
DataRow[] foundRows01 = SQLDataTableModel.m_condimentDataTable.Select(expression01);
if (foundRows01.Length > 0)
{
for (int i = 0; i < foundRows01.Length; i++)
{
condiment_Var condiment_VarBuf = new condiment_Var();
condiment_VarBuf.condiment_sid = Int32.Parse(foundRows01[i]["condiment_sid"].ToString());
condiment_VarBuf.condiment_code = foundRows01[i]["condiment_code"].ToString();
condiment_VarBuf.condiment_name = foundRows01[i]["condiment_name"].ToString();
condiment_VarBuf.condiment_price = Convert.ToDouble(foundRows01[i]["condiment_price"].ToString());
condiment_VarBuf.group_sid = Int32.Parse(foundRows01[i]["group_sid"].ToString());
condiment_VarBuf.min_count = Int32.Parse(foundRows01[i]["min_count"].ToString());
condiment_VarBuf.max_count = Int32.Parse(foundRows01[i]["max_count"].ToString());
condiment_VarBuf.m_Strcondiment_type = "C";//類型
condiment_VarBuf.m_inttax_sid = 0; //稅率編號 ; 產品若沒有稅率資料[m_tax_sid=0],就直接從company和tax_data取出預設值
condiment_VarBuf.m_inttax_rate = 0; //稅率
condiment_VarBuf.m_Strtax_type = "";//稅率類型
//m_inttax_fee; //稅率金額
string expression02;
expression02 = String.Format("group_sid={0}", condiment_VarBuf.group_sid);
DataRow[] foundRows02 = SQLDataTableModel.m_condimentDataTable.Select(expression02);
List<int> ListBuf = new List<int>();
if (foundRows02.Length > 0)
{
ListBuf.Clear();
for (int j = 0; j < foundRows02.Length; j++)
{
int intBuf = Int32.Parse(foundRows02[j]["condiment_sid"].ToString());
bool blnRepeat = false;
for (int k = 0; k < ListBuf.Count; k++)
{
if (ListBuf[k] == intBuf)
{
blnRepeat = true;
break;
}
}
if (!blnRepeat)
{
condiment_VarBuf.same_group_sid.Add(intBuf);
ListBuf.Add(intBuf);
}
else
{
continue;
}
}//for (int j = 0; j < foundRows02.Length; j++)
}//if (foundRows02.Length > 0)
SQLDataTableModel.m_condiment_Var.Add(condiment_VarBuf);
}//for (int i = 0; i < foundRows01.Length; i++)
}//if (foundRows01.Length > 0)
}//if(SQLDataTableModel.m_condimentDataTable != null)
}//if(intproduct_sid != -1)
if (SQLDataTableModel.m_condiment_Var != null)//if (SqliteDataAccess.m_condiment_data != null)
{
m_intCondimentTotalPages = SQLDataTableModel.m_condiment_Var.Count / m_CondimentBtn.Length;//intcondimentTotalPages = SqliteDataAccess.m_condiment_data.Count / 15;
if ((SQLDataTableModel.m_condiment_Var.Count % m_CondimentBtn.Length) > 0)//if ((SqliteDataAccess.m_condiment_data.Count % 15) > 0)
{
m_intCondimentTotalPages++;
}
else
{
m_intCondimentTotalPages += 0;
}
if (m_intCondimentTotalPages == 0)
{
m_intCondimentNowPages = 0;
m_intCondimentTotalPages = 0;
}
}
else
{
m_intCondimentNowPages = 0;
m_intCondimentTotalPages = 0;
}
}
void CondimentBtnInitShow(bool blnSQL = false, int intMainSID = -1)
{
//---
//實作相同類型配料按鈕顏色一致
Color[] ColorBuf = new Color[4];
ColorBuf[0] = new Color(92, 171, 125);//G
ColorBuf[1] = new Color(28, 74, 110);//B
ColorBuf[2] = Colors.Firebrick;//R
ColorBuf[3] = new Color(253, 95, 0);//O
int intLastsame_group_sid = -1;
int intColorsIndex = -1;
//---實作相同類型配料按鈕顏色一致
CondimentBtnInitHide();
if (blnSQL == true)
{
CondimentBtnInformationGet(intMainSID);
}
int j = 0;
if ((SQLDataTableModel.m_condiment_Var != null) && (m_intCondimentNowPages > 0))//if (SqliteDataAccess.m_condiment_data != null)
{
for (int i = ((m_intCondimentNowPages - 1) * m_CondimentBtn.Length); i < SQLDataTableModel.m_condiment_Var.Count; i++)//for (int i = ((intcondimentNowPages - 1) * 15); i < SqliteDataAccess.m_condiment_data.Count; i++)
{
m_CondimentBtn[j].SetText(SQLDataTableModel.m_condiment_Var[i].condiment_name);//SqliteDataAccess.m_condiment_data[i].condiment_name;
m_CondimentBtn[j].m_intSID = SQLDataTableModel.m_condiment_Var[i].condiment_sid;//SqliteDataAccess.m_condiment_data[i].SID;
m_CondimentBtn[j].m_intPrice = (int)SQLDataTableModel.m_condiment_Var[i].condiment_price;//SqliteDataAccess.m_condiment_data[i].condiment_price;
m_CondimentBtn[j].m_StrProductCode = SQLDataTableModel.m_condiment_Var[i].condiment_code;//SqliteDataAccess.m_condiment_data[i].condiment_code;
m_CondimentBtn[j].m_same_group_sid = SQLDataTableModel.m_condiment_Var[i].same_group_sid;
m_CondimentBtn[j].m_min_count = SQLDataTableModel.m_condiment_Var[i].min_count;
m_CondimentBtn[j].m_max_count = SQLDataTableModel.m_condiment_Var[i].max_count;
m_CondimentBtn[j].IsVisible = true;
//---
//實作相同類型配料按鈕顏色一致
if (intLastsame_group_sid != SQLDataTableModel.m_condiment_Var[i].group_sid)
{
intLastsame_group_sid = SQLDataTableModel.m_condiment_Var[i].group_sid;
intColorsIndex++;
}
m_CondimentBtn[j].SetBackgroundColor(ColorBuf[intColorsIndex]);
//---實作相同類型配料按鈕顏色一致
m_CondimentBtn[j].m_Strproduct_type = "C";//類型
m_CondimentBtn[j].m_inttax_sid = 0; //稅率編號 ; 產品若沒有稅率資料[m_tax_sid=0],就直接從company和tax_data取出預設值
m_CondimentBtn[j].m_inttax_rate = 0; //稅率
m_CondimentBtn[j].m_Strtax_type = "";//稅率類型
j++;
if (j == m_CondimentBtn.Length)
{
break;
}
}
}
CondimentTextLable.Text = String.Format("{2}/{3}", "配料", "第", m_intCondimentNowPages, m_intCondimentTotalPages, "頁");
}
public CustBtn m_CustBtnCondimentSelected = null;
private async void Condiment_Clicked(object sender, EventArgs e)
{
if (m_intOrderState != 0)//調味品按鈕訂單狀態偵測防呆
{
return;
}
m_CustBtnCondimentSelected = (CustBtn)sender;
ShopCartSubListAdd();
}
private void CondimentUpDown_Clicked(object sender, EventArgs e)
{
int intCondimentNowPages = m_intCondimentNowPages;
switch (((CustBtn)(sender)).m_intSID)
{
case 0://配料切頁事件 [-1]
m_intCondimentNowPages = (m_intCondimentNowPages - 1) > 0 ? (m_intCondimentNowPages - 1) : 1;
break;
case 1://配料切頁事件 [+1]
m_intCondimentNowPages = (m_intCondimentNowPages + 1) < m_intCondimentTotalPages ? (m_intCondimentNowPages + 1) : m_intCondimentTotalPages;
break;
}
if (intCondimentNowPages != m_intCondimentNowPages)
{
CondimentBtnInitShow();
}
}
//---畫面右側按鈕動態建立函數
private int m_intDelItemType = -1;//0[產品],1[折扣讓],2[小計],4[調味品單一],5[套餐],6[套餐折扣讓]
private ShopcartItem m_ShopcartItemSelected = null;
private int m_intShopcartSelectedIndex = -1;
private void ShopcartListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
int intLastSelectedIndex = -1;
if (e.SelectedItem == null)
{
m_ShopcartItemSelected = null;
m_intShopcartSelectedIndex = -1;
return;
}
if (m_intOrderState != 0)//購物車清單項目訂單狀態偵測防呆
{
return;
}
intLastSelectedIndex = m_intShopcartSelectedIndex;
m_ShopcartItemSelected = (ShopcartItem)e.SelectedItem;
m_intShopcartSelectedIndex = e.SelectedItemIndex;
if (intLastSelectedIndex == m_intShopcartSelectedIndex)
{
return;
}
//---
//改變選擇列顏色
ShopcartItem ShopcartItemSelectedBuf = new ShopcartItem();
ShopcartItemSelectedBuf.id = m_ShopcartItemSelected.id;
ShopcartItemSelectedBuf.Image00 = m_ShopcartItemSelected.Image00;
ShopcartItemSelectedBuf.Image01 = m_ShopcartItemSelected.Image01;
ShopcartItemSelectedBuf.Name = m_ShopcartItemSelected.Name;
ShopcartItemSelectedBuf.Amount = m_ShopcartItemSelected.Amount;
ShopcartItemSelectedBuf.Price = m_ShopcartItemSelected.Price;
ShopcartItemSelectedBuf.Sum = m_ShopcartItemSelected.Sum;
ShopcartItemSelectedBuf.image_id = m_ShopcartItemSelected.image_id;
ShopcartItemSelectedBuf.Font_Color = Colors.White;
ShopcartItemSelectedBuf.Font_Size = m_ShopcartItemSelected.Font_Size;
ShopcartItemSelectedBuf.State = m_ShopcartItemSelected.State;
ShopcartItemSelectedBuf.BColor=Colors.Blue;
m_ShopcartItems.Insert(m_intShopcartSelectedIndex, ShopcartItemSelectedBuf);
m_ShopcartItems.RemoveAt((m_intShopcartSelectedIndex + 1));
if (intLastSelectedIndex>=0)
{
ShopcartItemSelectedBuf = new ShopcartItem();
ShopcartItemSelectedBuf.id = m_ShopcartItems[intLastSelectedIndex].id;
ShopcartItemSelectedBuf.Image00 = m_ShopcartItems[intLastSelectedIndex].Image00;
ShopcartItemSelectedBuf.Image01 = m_ShopcartItems[intLastSelectedIndex].Image01;
ShopcartItemSelectedBuf.Name = m_ShopcartItems[intLastSelectedIndex].Name;
ShopcartItemSelectedBuf.Amount = m_ShopcartItems[intLastSelectedIndex].Amount;
ShopcartItemSelectedBuf.Price = m_ShopcartItems[intLastSelectedIndex].Price;
ShopcartItemSelectedBuf.Sum = m_ShopcartItems[intLastSelectedIndex].Sum;
ShopcartItemSelectedBuf.image_id = m_ShopcartItems[intLastSelectedIndex].image_id;
ShopcartItemSelectedBuf.Font_Color = Colors.Black;
ShopcartItemSelectedBuf.Font_Size = m_ShopcartItems[intLastSelectedIndex].Font_Size;
ShopcartItemSelectedBuf.State = m_ShopcartItems[intLastSelectedIndex].State;
ShopcartItemSelectedBuf.BColor = Colors.White;
//m_ShopcartItems.Insert(intLastSelectedIndex, ShopcartItemSelectedBuf);
//m_ShopcartItems.RemoveAt((intLastSelectedIndex + 1));
m_ShopcartItems[intLastSelectedIndex] = ShopcartItemSelectedBuf;
m_ShopcartItems.Move(intLastSelectedIndex, intLastSelectedIndex);
}
//---改變選擇列顏色
//判斷項目內容-產品/調味品/折扣讓/小計
//state0
//0[產品]
//1[折扣讓]
//2[小計]
//3[調味品合併]
//4[調味品單一]
int intState0 = -1;
String StrBuf = m_ShopcartItemSelected.id;
string[] strs = StrBuf.Split(',');
int intIndex = Int32.Parse(strs[0]);
int intBuf = Int32.Parse(strs[1]);
String StrTs = (strs.Length > 2) ? strs[2] : "";//判斷該列是否為套餐相關資料
if (intIndex < 0)//訂單結帳列,直接跳離防呆機制
{
return;
}
if (intBuf >= 0)
{
//3[調味品合併]
//4[調味品單一]
if (Int32.Parse(m_ShopcartItemSelected.Amount) > 1)//使用數量判斷
{
intState0 = 3;
}
else
{
intState0 = 4;
}
}
else
{
//0[產品]
//1[折扣讓]
//2[小計]
intState0 = Math.Abs(intBuf) - 1;
}
m_intDelItemType = intState0; //0[產品],1[折扣讓],2[小計],4[調味品單一],5[套餐],6[套餐折扣讓]
if (StrTs == "T")
{
m_intDelItemType = 5;
}
else if (StrTs == "TD")
{
m_intDelItemType = 6;
}
int item_no = m_ShopCart.m_ShopMainList[intIndex].m_intitem_no;
String SQL = String.Format("SELECT discount_type,subtotal_flag FROM order_content_data WHERE order_no='{0}' AND item_no='{1}' LIMIT 0,1;", m_StrPosOrderNumber, item_no);
DataTable order_content_dataTable = SQLDataTableModel.GetDataTable(SQL);
//判斷有折扣/折讓
//state1 0/1
int intState1 = 0;//無 折扣/折讓
//判斷有無小計
//state2 0/1
int intState2 = 0;//無 小計
if (order_content_dataTable.Rows.Count > 0)
{
if (order_content_dataTable.Rows[0]["discount_type"].ToString() != "N")
{
intState1 = 1;
}
if (order_content_dataTable.Rows[0]["subtotal_flag"].ToString() != "N")
{
intState2 = 1;
}
}
QuantityBtnEnableStateSet(intState0, intState1, intState2, StrTs);
if ((intState0==0) && (StrTs.Length == 0))
{
ShopCartListChangeCondimentBtnInitShow();//購物車點選切換調味品選項
}
else
{
CondimentBtnInitHide();//調味品按鈕初始化
}
}
//---
//系統菜單事件
private async void LogoutBtn_Clicked(object sender, EventArgs e)//登出
{
LogFile.Write("MainPage End");
await Shell.Current.GoToAsync("login");
}
private async void DevicesBtn_Clicked(object sender, EventArgs e)//周邊管理
{
await Navigation.PushModalAsync(new DevicesListPage());
}
private void SettingsBtn_Clicked(object sender, EventArgs e)//系統設定
{
}
private async void SynchronizeBtn_Clicked(object sender, EventArgs e)//資料更新
{
await this.ShowPopupAsync(new QuesMessageBox("確定要執行資料更新?"));
if (QuesMessageBox.m_blnResult)
{
if (HttpsFun.WebRequestTest(ref LoadingPage.m_intNetworkLevel))//判斷是否有網路
{
await this.ShowPopupAsync(new SyncLocalDatabase());//同步本地端資料庫
LogFile.Write("MainPage End");
await Shell.Current.GoToAsync("login");//切換到登入頁面
}
else
{
await this.ShowPopupAsync(new MessageBox("網路偵測異常,無法執行資料同步?"));
}
}
}
private void ShopcartListViewImage00_Clicked(object sender, TappedEventArgs e)
{
if(m_ShopcartItemSelected != null)
{
String StrBuf = m_ShopcartItemSelected.id;
string[] strs = StrBuf.Split(',');
int intMain = Int32.Parse(strs[0]);
int intSub = Int32.Parse(strs[1]);
if(intSub < 0)
{
if(m_ShopcartItemSelected.image_id=="1")
{
m_ShopcartItemSelected.image_id = "2";//not check
m_ShopcartItemSelected.Image00 = m_StrShopcartIcons[1];//"checkbox01.png"
}
else
{
m_ShopcartItemSelected.image_id = "1";//checked
m_ShopcartItemSelected.Image00 = m_StrShopcartIcons[0];//"checkbox00.png"
}
((Image)(sender)).Source = ImageSource.FromFile(m_ShopcartItemSelected.Image00);//換圖
}
}
}
private void ShopcartListViewImage01_Clicked(object sender, TappedEventArgs e)
{
if (m_ShopcartItemSelected != null)
{
String StrBuf = m_ShopcartItemSelected.id;
string[] strs = StrBuf.Split(',');
int intIndex = Int32.Parse(strs[0]);
int intBuf = Int32.Parse(strs[1]);
}
}
//---系統菜單事件
}
}
備註:
Add/Modified 將購物車顯示元件改回ListView 在ListView的Grid元件綁定BColor參數 在ListView的Grid元件綁定VisualStateGroupList 在ShopcartItem類別新增BColor成員 在ShopcartListView_ItemSelected事件函數實作 改變選擇列顏色 功能 ~ 因為VisualStateGroupList對於Selected 事件無反應
運行圖:

One thought on “C# Maui ListView 實作Select Item 改變顏色 [VisualState + Event Function]”
『把Bug(錯誤)/Defect(缺陷) 變(VS) Feature(特色)/Function(功能)』 實際實作
~承認/接受/利用 錯誤/缺陷