Exemplo n.º 1
0
        static private void BuildMessageBox(string title)
        {
            newMessageBox                 = new CCMsgBox();
            newMessageBox.Text            = title;
            newMessageBox.Size            = new System.Drawing.Size(400, 200);
            newMessageBox.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            newMessageBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            newMessageBox.Paint          += new PaintEventHandler(newMessageBox_Paint);
            newMessageBox.BackColor       = System.Drawing.Color.White;

            TableLayoutPanel tlp = new TableLayoutPanel();

            tlp.RowCount    = 3;
            tlp.ColumnCount = 0;
            tlp.Dock        = System.Windows.Forms.DockStyle.Fill;
            tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22));
            tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50));
            tlp.BackColor = System.Drawing.Color.Transparent;
            tlp.Padding   = new Padding(2, 5, 2, 2);

            frmTitle           = new Label();
            frmTitle.Dock      = System.Windows.Forms.DockStyle.Fill;
            frmTitle.BackColor = System.Drawing.Color.Transparent;
            frmTitle.ForeColor = System.Drawing.Color.White;
            frmTitle.Font      = new Font("Tahoma", 9, FontStyle.Bold);

            frmMessage           = new Label();
            frmMessage.Dock      = System.Windows.Forms.DockStyle.Fill;
            frmMessage.Location  = new Point(150, 150);
            frmMessage.BackColor = System.Drawing.Color.White;
            frmMessage.Font      = new Font("Tahoma", 9, FontStyle.Regular);
            frmMessage.Text      = "hiii";

            largeIcon = new IntPtr[250];
            smallIcon = new IntPtr[250];
            pIcon     = new PictureBox();
            ExtractIconEx("shell32.dll", 0, largeIcon, smallIcon, 250);

            flpButtons = new FlowLayoutPanel();
            flpButtons.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
            flpButtons.Padding       = new Padding(0, 5, 5, 0);
            flpButtons.Dock          = System.Windows.Forms.DockStyle.Fill;
            flpButtons.BackColor     = System.Drawing.Color.FromArgb(240, 240, 240);

            TableLayoutPanel tlpMessagePanel = new TableLayoutPanel();

            tlpMessagePanel.BackColor   = System.Drawing.Color.White;
            tlpMessagePanel.Dock        = System.Windows.Forms.DockStyle.Fill;
            tlpMessagePanel.ColumnCount = 2;
            tlpMessagePanel.RowCount    = 0;
            tlpMessagePanel.Padding     = new Padding(4, 20, 4, 4);
            tlpMessagePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50));
            tlpMessagePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            tlpMessagePanel.Controls.Add(pIcon);
            tlpMessagePanel.Controls.Add(frmMessage);

            tlp.Controls.Add(frmTitle);
            tlp.Controls.Add(tlpMessagePanel);
            tlp.Controls.Add(flpButtons);
            newMessageBox.Controls.Add(tlp);
        }
Exemplo n.º 2
0
        static void Main()
        {
            #region Exception Process
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) =>
            {
                HandleException(e.ExceptionObject as Exception);
            };
            // 处理UI线程异常
            Application.ThreadException += (object sender, ThreadExceptionEventArgs e) =>
            {
                HandleException(e.Exception);
            };
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadExit += new EventHandler(Application_ThreadExit);

            #endregion  Exception Process

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();
            Application.DoEvents();
            //Application.Run(new Waiting());
            Waiting.Show("正在加载程序,请稍候...", 20);

            bool existRunningInstance = ExistRunInstance();
            if (existRunningInstance)
            {
                CCMsgBox.Show("对不起,你已经运行了该程序!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }

            Waiting.Show("正在测试数据库连接,请稍候...", 40);
            if (!TestDbConnect())
            {
                CCMsgBox.Show("对不起!数据库连接失败,请联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }

            Waiting.Show("正在检测INI配置文件,请稍候...", 50);
            string iniFilePath = Path.Combine(Application.StartupPath, "ODConfig.ini");
            if (File.Exists(iniFilePath))
            {
                IniManager.Open(iniFilePath);
            }
            else
            {
                CreateIniFile(iniFilePath);
                CCMsgBox.Show("对不起!INI配置文件,请联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
            }

            Waiting.Show("正在检测客户端信息,请稍候...", 60);
            SalesPointBusiness salesPointManage = new SalesPointBusiness();
            string             localMacAddress  = NetHelper.GetLocalMACAddress();
            if (!salesPointManage.ExistsMacAddress(localMacAddress))
            {
                CCMsgBox.Show("对不起!客户端信息不对,请先注册客户端信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }
            else
            {
            }

            Waiting.Show("正在检测营业点信息,请稍候...", 60);
            IniEntry iniEntry       = new IniEntry(iniFilePath);
            string   salesPointName = iniEntry.Sections["ClientInfo"]["SalesPointName"].ToString();
            if (!salesPointManage.Exists(salesPointName))
            {
                CCMsgBox.Show("对不起!营业点信息不对,请先注册营业点信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);

                return;
            }
            else
            {
                CurrentSystemInfo.SalesPoint = salesPointManage.GetInstanceObj(new SalesPoint {
                    Name = salesPointName
                });
            }

            Waiting.Show("正在检测餐牌信息,请稍候...", 80);
            RestaurantTypeBusiness typeManage = new RestaurantTypeBusiness();

            if (!typeManage.Exists(iniEntry.Sections["ClientInfo"]["DishType"]))
            {
                CCMsgBox.Show("对不起!餐牌信息不对,请先配制餐牌信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }
            else
            {
                CurrentSystemInfo.RestaurantType = typeManage.GetInstanceObj(new RestaurantType {
                    Name = iniEntry.Sections["ClientInfo"]["DishType"]
                });
            }

            Waiting.Show("正在读取餐段信息,请稍候...", 90);

            //string mealTypeId = new MealTimeManage().GetMealTimeId();

            MealTimesBusiness workShiftManager = new MealTimesBusiness();

            if (workShiftManager.GetInstanceList().Count < 1)
            {
                MessageBox.Show("对不起,没有找着餐段信息,请先配制餐牌信息!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
            }

            //Waiting.Show("正在同步系统时间,请稍候....", 80);
            // 同步时间
            //GetDbDateTime dbcomm = new GetDbDateTime();
            //dbcomm.SynchoronizeServerTime();

            ////InitForm();

            Waiting.Show("准备登录界面,请稍候....", 90);
            frmLogin login = new frmLogin();

            Waiting.Show("程序加载完成", 100);
            Waiting.Hide();



            //new FormMain().ShowDialog();
            while (login.ShowDialog() == DialogResult.OK)
            {
                //    dbcomm.SynchoronizeServerTime();                        // 再次同步时间

                login.Close();
            }
        }