Avalonia Image 滑鼠點擊事件(PointerPressed) 範例
Avalonia Image 滑鼠點擊事件(PointerPressed) 範例
資料來源: copilot
XAML
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="using:VPOS_Avalonia.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="VPOS_Avalonia.Views.MainWindow" x:DataType="vm:MainWindowViewModel" Icon="/Assets/sys.ico" Title="VPOS_Avalonia" Background="#ff194a6e"> <Design.DataContext> <!-- This only sets the DataContext for the previewer in an IDE, to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> <vm:MainWindowViewModel/> </Design.DataContext> <Grid x:Name="FullGrid" Margin="3"> <Grid.RowDefinitions> <RowDefinition /> <!--Workspace --> <RowDefinition Height="40" /> <!--status column --> </Grid.RowDefinitions> <Grid x:Name="WorkspaceGrid" Margin="0,2,0,2" Grid.Row="0" Grid.Column="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="60"/> <!-- Menu --> <ColumnDefinition /> <!-- Content --> </Grid.ColumnDefinitions> <Grid x:Name="MenuGrid" Margin="1,0,1,0" Grid.Row="0" Grid.Column="0"> <Border x:Name="MenuBorder" BorderBrush="#194a6e" BorderThickness="1" CornerRadius="5"> <StackPanel Spacing="5"> <Border BorderThickness="2" BorderBrush="White"> <Image x:Name="SettingsBtn" Source="/Assets/settings.png" PointerPressed="SettingsBtn_Clicked"/> </Border> <Border BorderThickness="2" BorderBrush="White"> <Image x:Name="DevicesBtn" Source="/Assets/device.png" PointerPressed="DevicesBtn_Clicked"/> </Border> <Border BorderThickness="2" BorderBrush="White"> <Image x:Name="SynchronizeBtn" Source="/Assets/synchronize.png" PointerPressed="SynchronizeBtn_Clicked"/> </Border> <Border BorderThickness="2" BorderBrush="White"> <Image x:Name="LogoutBtn" Source="/Assets/logout.png" PointerPressed="LogoutBtn_Clicked"/> </Border> </StackPanel> </Border> <!--MenuBorder--> </Grid> <!--MenuGrid--> <Grid x:Name="ContentGrid" Grid.Row="0" Grid.Column="1" Margin="1,0,0,0" ColumnDefinitions="5.4*,6.6*"> <Border x:Name="LeftContentBorder" Grid.Row="0" Grid.Column="0" BorderThickness="1" BorderBrush="White" CornerRadius="5"> <Grid x:Name="LeftContentGrid" RowDefinitions="3.3*,5.7*,2*"> <Border x:Name="LeftContentBorder00" Grid.Row="0" Grid.Column="0" BorderThickness="1" BorderBrush="White" CornerRadius="5"> <Grid x:Name="ShowInfoGrid" RowDefinitions="1.3*,1.2*,0.8*"> <Grid x:Name="ShowInfoGrid00" Margin="2,0" Background="#1c4a6e" Grid.Row="0" Grid.Column="0" RowDefinitions="0.4*,0.3*,0.3*" ColumnDefinitions="*,*,*,*,*,*" IsEnabled="True"> <TextBlock x:Name="OrderStatusLable" Grid.Row="0" Grid.ColumnSpan="6" Text="訂購中" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="26" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="QuantityTextLable" Grid.Row="1" Grid.Column="0" Text="商品數量:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="QuantityValueLable" Grid.Row="1" Grid.Column="1" Text="10000" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="22" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="DiscountTextLable" Grid.Row="1" Grid.Column="2" Text="優惠金額:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="DiscountValueLable" Grid.Row="1" Grid.Column="3" Text="10000" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="22" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ServiceTextLable" Grid.Row="1" Grid.Column="4" Text="服務費:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ServiceValueLable" Grid.Row="1" Grid.Column="5" Text="10000" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="22" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ReceivableTextLable" Grid.Row="2" Grid.Column="0" Text="應收總額:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ReceivableValueLable" Grid.Row="2" Grid.Column="1" Text="30000" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="22" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ChangeValueLable" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="4" Text="10000" TextWrapping="WrapWithOverflow" Foreground="Red" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Left"/> </Grid> <Grid x:Name="ShowInfoGrid01" Margin="2,0" Grid.Row="1" Grid.Column="0" RowDefinitions="2,*,*,*" ColumnDefinitions="1.09*,1.99*,1.09*,1.5*,0.9*,0.6*"> <Separator x:Name="ShowInfoLine00" Grid.Row="0" Grid.ColumnSpan="6" Background="White" Height="2"/> <TextBlock x:Name="OrderNoTextLable" Grid.Row="1" Grid.Column="0" Text="訂單編號:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="OrderNoValueLable" Grid.Row="1" Grid.Column="1" Text="20230927-0001" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="PickupNoTextLable" Grid.Row="1" Grid.Column="2" Text="取餐號:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="PickupNoValueLable" Grid.Row="1" Grid.Column="3" Text="00000001" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="VisitorsTextLable" Grid.Row="1" Grid.Column="4" Text="來客數:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="VisitorsValueLable" Grid.Row="1" Grid.Column="5" Text="0001" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="OrderTypeTextLable" Grid.Row="2" Grid.Column="0" Text="訂單類型:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="OrderTypeValueLable" Grid.Row="2" Grid.Column="1" Text="Uber Eats" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="TableNoTextLable" Grid.Row="2" Grid.Column="2" Text="桌號:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="TableNoValueLable" Grid.Row="2" Grid.Column="3" Text="豪華廳A0001" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ShopNoTextLable" Grid.Row="2" Grid.Column="4" Text="牌號:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="ShopNoValueLable" Grid.Row="2" Grid.Column="5" Text="100" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="MemberNameTextLable" Grid.Row="3" Grid.Column="0" Text="會員名稱:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="MemberNameValueLable" Grid.Row="3" Grid.Column="1" Text="合用系統有限公司" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock x:Name="MemberTelTextLable" Grid.Row="3" Grid.Column="2" Text="會員電話:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="MemberTelValueLable" Grid.Row="3" Grid.Column="3" Text="04-22216292" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Grid> <Grid x:Name="ShowInfoGrid02" Margin="2,0" Grid.Row="2" Grid.Column="0" RowDefinitions="2,*,*" ColumnDefinitions="1*,1.3*,0.6*,1.31*,1.19*,0.6*"> <Separator x:Name="ShowInfoLine01" Grid.Row="0" Grid.ColumnSpan="6" Background="White" Height="2"/> <TextBlock x:Name="InvoiceNoTextLable" Grid.Row="1" Grid.Column="0" Text="發票號碼:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="InvoiceNoValueLable" Grid.Row="1" Grid.Column="1" Text="AB14433816" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <Border BorderBrush="White" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#2470a0" CornerRadius="5" Margin="2,2,2,2" Grid.Row="1" Grid.Column="2" Grid.RowSpan="2" > <TextBlock x:Name="TaxIDBtn" Text="客戶
統編" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="16"/> </Border> <TextBlock x:Name="InvoiceCountTextLable" Grid.Row="1" Grid.Column="3" Text="發票剩餘張數:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="InvoiceCountValueLable" Grid.Row="1" Grid.Column="4" Text="100" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"/> <Border BorderBrush="White" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#2470a0" CornerRadius="5" Margin="2,2,2,2" Grid.Row="1" Grid.Column="5" Grid.RowSpan="2" > <TextBlock x:Name="CarrierBtn" Text="發票
載具" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="16" /> </Border> <TextBlock x:Name="TaxIDTextLable" Grid.Row="2" Grid.Column="0" Text="客戶統編:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" Padding="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="TaxIDValueLable" Grid.Row="2" Grid.Column="1" Text="42897648" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="CarrierTextLable" Grid.Row="2" Grid.Column="3" Text="發票載具:" TextWrapping="WrapWithOverflow" Foreground="#ff7f50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="CarrierValueLable" Grid.Row="2" Grid.Column="4" Text="/RZDFEP2" TextWrapping="WrapWithOverflow" Foreground="White" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Left"/> </Grid> </Grid> </Border> </Grid> </Border> </Grid> </Grid> </Grid> </Window>
CS
using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Media; using Avalonia.Threading; using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.IO; using System.Net.Mail; using System.Reflection; using System.Threading; using System.Timers; using VPOS; using VPOS_Avalonia.ViewModels; using static System.Runtime.InteropServices.JavaScript.JSType; using String = System.String; namespace VPOS_Avalonia.Views { public partial class MainWindow : Window { public MainWindow() { ExternalPopup.mainWindow = this; LogFile.Write("MainPage Start"); this.WindowState = WindowState.FullScreen; //隱藏工具列 this.ExtendClientAreaToDecorationsHint = true; this.ExtendClientAreaTitleBarHeightHint = -1; this.SystemDecorations = SystemDecorations.None; //---隱藏工具列 InitializeComponent(); } private bool m_blnMemberInvoiceCarrierShow = false; public bool m_blnFirstRun = false;//第一次執行旗標 public System.Timers.Timer MainTimmer { get; set; } private int m_intTimerCount = 0;//Timer狀態計數器 public void InitTimmer() { ClosingHandover.m_blnShow = false; m_blnFirstRun = false;//第一次執行旗標 MainTimmer = new System.Timers.Timer(1000); //Application.Current.Dispatcher.CreateTimer(); //MainTimmer.Interval = new TimeSpan(0, 0, 0, 0, 100);//天/時/分/秒/毫秒 MainTimmer.Elapsed += MainTimmer_Tick;//MainTimmer.Tick += MainTimmer_Tick; MainTimmer.AutoReset = true; //MainTimmer.IsRepeating = true;//the timer will keep recurring, you can set false MainTimmer.Start(); } public void DeleteTimmer() { m_blnMainReady = false; if (MainTimmer != null) { MainTimmer.Stop(); } MainTimmer = null; } public static bool m_blnMainReady = false; private async void MainTimmer_Tick(object sender, EventArgs e)//Timer事件函數 { } //timmer.Stop(); //--- //ViewModels public MainWindowViewModel m_MainWindowViewModel = null; //---ViewModels //--- //顯示器解析度 ~ Loading 頁面抓取 public static double m_dblScreenWidth = 0; public static double m_dblScreenHeight = 0; public static double m_dblScreenDensity = 0.0; //---顯示器解析度 public static String m_StrVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; public static String m_StrDeviceCode = FileLib.GetDeviceCode(); 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:詢問 public static bool m_blnInvoiceState = false;//啟用發票參數旗標 && 有發票參數 public static VTSTORE_params m_VTSTORE_params = null;//new VTSTORE_params();//點點食 public static NIDIN_POS_params m_NIDIN_POS_params = null;//new NIDIN_POS_params();//你訂 public static UBER_EATS_params m_UBER_EATS_params = null;//new UBER_EATS_params();//吳柏毅 public static FOODPANDA_params m_FOODPANDA_params = null;//new FOODPANDA_params();//熊貓 public static YORES_POS_params m_YORES_POS_params = null;//new YORES_POS_params();//享什麼 //--- //收支號相關變數 public static String m_StrPosExpenseNumber = "";//紀錄報表號的成員變數 private const int m_intExpenseNumberTestMaxCount = 50;//建立報表號最大嘗試次數 //---收支號相關變數 //--- //報表號相關變數 public static String m_StrPosReportNumber = "";//紀錄報表號的成員變數 private const int m_intReportNumberTestMaxCount = 50;//建立報表號最大嘗試次數 //---報表號相關變數 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)//關帳 { StrResult = (SysParm.m_pos_serial_paramBuf.order_no_from == "S") ? HttpGetDailyNo() : SerialCodeDataGet(StrGUID, 1); } else//交班 { StrResult = (SysParm.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 = (SysParm.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 = VP_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(VP_Convert.ToDouble(dt.Rows[0][0].ToString()), false); m_DailyLastTime = TimeConvert.UnixTimeStampToDateTime(VP_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 = SqliteDataAccess.m_terminal_data[0].business_day;//VP_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)? VP_Convert.ToDateTime(dt.Rows[0][0].ToString()) : DateTime.Now; m_DailyOrderLastTime = (dt.Rows[0][1].ToString().Length > 0)? VP_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) ? VP_Convert.ToDateTime(dt.Rows[0][0].ToString()) : DateTime.Now; m_ClassOrderLastTime = (dt.Rows[0][1].ToString().Length > 0) ? VP_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 static bool HttpObjectInit(ref bool blnServerMode)//Http 服務相關元件初始化 { bool blnResult = true; SysParm.SysParmUIMemberVarSet();//讀取 取號方式(Server/Local 方式) & KDS參數 if (SysParm.m_pos_serial_paramBuf.terminal_server_flag == "Y")//啟動服務 { blnServerMode = true; blnResult = HttpServerThread.Start(SysParm.m_pos_serial_paramBuf.terminal_server_port); } else { blnServerMode = false; if (SysParm.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; */ blnResult = MainWindow.HttpTestConnection(); } } return blnResult; } public static String HttpGetOrderNo() { String StrResult = ""; String StrDomain = $"http://{SysParm.m_pos_serial_paramBuf.serial_server_name}:{SysParm.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 = ""; String StrDomain = $"http://{SysParm.m_pos_serial_paramBuf.serial_server_name}:{SysParm.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 = ""; String StrDomain = $"http://{SysParm.m_pos_serial_paramBuf.serial_server_name}:{SysParm.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; String StrDomain = $"http://{SysParm.m_pos_serial_paramBuf.serial_server_name}:{SysParm.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 CloseVTCD() { //--- //關閉先前開啟的客顯 foreach (var process in Process.GetProcessesByName("VTCD")) { try { process.Kill(); } catch { } } //---關閉先前開啟的客顯 } public static void CallVTCD()//呼叫客顯UI的執行檔 { CloseVTCD(); SQLDataTableModel.cust_display_paramLoad();//客顯資料載入 if ((SQLDataTableModel.m_cust_display_param != null) && (SQLDataTableModel.m_cust_display_param.Rows.Count > 0) && (SQLDataTableModel.m_cust_display_param.Rows[0]["display_show"].ToString() == "Y")) { ProcessStartInfo start = new ProcessStartInfo(); String StrPath = (App.m_blnParentDir) ? Directory.GetParent(FileLib.path.Substring(0, FileLib.path.Length - 1)).FullName + "\\" : FileLib.path; start.FileName = StrPath + "VTCD.exe"; start.UseShellExecute = false; start.RedirectStandardOutput = false; start.UseShellExecute = true; start.WindowStyle = ProcessWindowStyle.Normal; Process p01 = Process.Start(start); } } //--- //新增建立系統號碼字串函數 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 = VP_Convert.ToDateTime(SqliteDataAccess.m_class_data[j].time_start); DateTime dt2 = VP_Convert.ToDateTime(SqliteDataAccess.m_class_data[j].time_end); DateTime dt3 = VP_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(ref String StrResult, int intType = 0) { int intResult = 0; String StrGuid = Guid.NewGuid().ToString().Replace("-", "").ToUpper(); StrResult = ""; switch (intType) { case 0://ORDER_DATA /* if (m_StrPosOrderNumber.Length == 0) { m_StrPosOrderNumber = PosOrderNumberCreate(StrGuid); //UI顯示班別資訊 if (m_StrPosOrderNumber.Length == 0) { intResult = 1;//建立失敗 } else { StrResult = m_StrPosOrderNumber; intResult = 0;//建立成功 } } else { intResult = 0;//已存在不用建立 } */ StrResult = PosOrderNumberCreate(StrGuid); //UI顯示班別資訊 if (StrResult.Length == 0) { intResult = 1;//建立失敗 } else { intResult = 0;//建立成功 } break; case 1://DAILY_REPORT PosReportNumberCreate(StrGuid, intType); if (m_StrPosReportNumber.Length == 0) { intResult = 1;//建立失敗 } else { StrResult = m_StrPosReportNumber; intResult = 0;//建立成功 } break; case 2://CLASS_REPORT PosReportNumberCreate(StrGuid, intType); if (m_StrPosReportNumber.Length == 0) { intResult = 1;//建立失敗 } else { StrResult = m_StrPosReportNumber; intResult = 0;//建立成功 } break; case 3://EXPENSE_DATA PosExpenseNumberCreate(StrGuid); if (m_StrPosExpenseNumber.Length == 0) { intResult = 1;//建立失敗 } else { StrResult = m_StrPosExpenseNumber; 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 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_StrCallNumber = "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;//建立訂單號最大嘗試次數 //---訂單號相關變數 public static bool m_blnShowDailyQuestion = false;//自動營業關帳提示訊息旗標 public int CalculateDaily()//計算營業關帳天數 { if (!m_blnShowDailyQuestion) { return 0; } m_blnShowDailyQuestion = false; GetClassDailyLastTime(); DateTime DTHasDaily = (m_StrHasDaily.Length > 0) ? VP_Convert.ToDateTime(m_StrHasDaily) : DateTime.Now; TimeSpan ts = DateTime.Now - DTHasDaily; Double dblTotalDays = ts.TotalDays; return (int)dblTotalDays; } private bool IsNewDailyOrder()//是否有未關帳訂單 { bool blnResult = false; String SQL = "SELECT COUNT(order_no) FROM order_data WHERE paid_flag='Y' AND daily_close_flag<>'Y'"; DataTable DataTableBuf = SQLDataTableModel.GetDataTable(SQL); if ((DataTableBuf != null) && (VP_Convert.ToInt32(DataTableBuf.Rows[0][0].ToString()) > 0)) { blnResult = true; } else { if (SqliteDataAccess.m_terminal_data[0].business_day != DateTime.Now.ToString("yyyy-MM-dd")) { SQL = String.Format("UPDATE terminal_data SET business_day = '{0}'", DateTime.Now.ToString("yyyy-MM-dd")); SQLDataTableModel.SQLiteInsertUpdateDelete(SQL); SqliteDataAccess.m_terminal_data = SqliteDataAccess.terminal_dataLoad(); } } return blnResult; } public static bool funcMainSet(String StrSID)//操作介面功能啟用與否設定模組 { bool blnResult = true; for (int i = 0; i < m_funcMain.Count; i++) { if (m_funcMain[i].m_StrSID == StrSID) { blnResult = m_funcMain[i].m_blnEenabe; break; } } return blnResult; ; } public void StatusBarSet()//狀態列顯示值更新 { } //--- //背景執行序 private Thread m_AutoSyncThread = null;//背景同步(上傳)資料到 cloud 執行序 private Thread m_PrintThread = null;//背景列印執行序 public void syncthreadStop(int type = 1)//停止背景同步(上傳)資料 { if (type == 0) { SyncThread.m_blnRunLoop = false;//讓背景同步執行序自行停止 return; } if ((m_AutoSyncThread != null) && (m_AutoSyncThread.IsAlive)) { do { SyncThread.m_blnRunLoop = false;//讓背景同步執行序自行停止 } while (m_AutoSyncThread.IsAlive); m_AutoSyncThread = null; } } public void syncthreadCreate()//建立背景同步(上傳)執行序 [定時確認網路狀態] { syncthreadStop(); m_AutoSyncThread = new Thread(SyncThread.ThreadMain); m_AutoSyncThread.Priority = ThreadPriority.Lowest;//設定執行緒 優先順序 m_AutoSyncThread.IsBackground = true; m_AutoSyncThread.Start(); } public void printthreadStop(int type = 1)//停止背景同步(上傳)資料 { if (type == 0) { PrintThread.m_blnRunLoop = false;//讓背景同步執行序自行停止 return; } if ((m_PrintThread != null) && (m_PrintThread.IsAlive)) { do { PrintThread.m_blnRunLoop = false;//讓背景同步執行序自行停止 } while (m_PrintThread.IsAlive); m_PrintThread = null; } } public void printthreadCreate()//建立背景列印執行序 { printthreadStop(); PrintThread.VarInit();//列印執行序變數初始化 m_PrintThread = new Thread(PrintThread.main); m_PrintThread.Priority = ThreadPriority.BelowNormal;//設定執行緒 優先順序 m_PrintThread.IsBackground = true; m_PrintThread.Start(); } //---背景執行序 public void SettingsBtn_Clicked(object sender, PointerPressedEventArgs e) { } public void DevicesBtn_Clicked(object sender, PointerPressedEventArgs e) { } public void SynchronizeBtn_Clicked(object sender, PointerPressedEventArgs e) { } public void LogoutBtn_Clicked(object sender, PointerPressedEventArgs e) { syncthreadStop(0); printthreadStop(0); DeleteTimmer(); ExternalPopup.mainWindow = null; LogFile.Write("MainPage Leave(LogoutBtn_Clicked)"); Return2LoginUI(); } private async void Btn01_Click(object sender, RoutedEventArgs e) { Login LoginUI = new Login(); if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { Login.m_blnCloseApp = true; LoginUI.Closed += (sender, args) => { if (Login.m_blnCloseApp) { desktop.Shutdown();//應用程式關閉。[WPF] } }; desktop.MainWindow = LoginUI; } await ExternalPopup.MessageBox(0, "Test"); await ExternalPopup.WaitMessageBox(0, TestWaitMessageBoxFun, "Test"); await ExternalPopup.QuesMessageBox(0, "test?"); if (QuesMessageBox.m_blnResult) { LoginUI.Show(); this.Close(); } } public void Return2LoginUI() { if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { Login LoginUI = new Login(); Login.m_blnCloseApp = true; LoginUI.Closed += (sender, args) => { if (Login.m_blnCloseApp) { desktop.Shutdown();//應用程式關閉。[WPF] } }; desktop.MainWindow = LoginUI; LoginUI.Show(); this.Close(); } } public static void TestWaitMessageBoxFun() { Thread.Sleep(5000); } } }