Ejemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CurrentUser = new User();
            bool ownmutex;

            // Tạo và lấy quyền sở hữu một Mutex có tên là Icon;
            using (var mutex = new Mutex(true, "Shipping FujiXerox", out ownmutex))
            {
                // Nếu ứng dụng sở hữu Mutex, nó có thể tiếp tục thực thi;
                // nếu không, ứng dụng sẽ thoát.
                if (ownmutex)
                {
                    if(CheckConnection())
                    {
                        Application.Run(new FormMainV2());
                    }
                    else
                    {
                        Application.Run(new FormError());
                    }
                    //giai phong Mutex;
                    mutex.ReleaseMutex();
                }
                else
                    Application.ExitThread();
            }
        }
Ejemplo n.º 2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtOperatorID.Text))
     {
         Ultils.TextControlNotNull(txtOperatorID, "Operator ID");
     }
     else if (string.IsNullOrEmpty(txtLineID.Text))
     {
         Ultils.TextControlNotNull(txtLineID, "Line ID");
     }
     else if (string.IsNullOrEmpty(txtOperationID.Text))
     {
         Ultils.TextControlNotNull(txtOperationID, "Operation ID");
     }
     else
     {
         var user = new User()
         {
             OperatorCode = _operator.OperatorID,
             OperatorName = _operator.OperatorName,
             LineID = int.Parse(txtLineID.EditValue.ToString()),
             OperationID = int.Parse(txtOperationID.EditValue.ToString()),
             ProcessID = txtProcess.Text,
         };
         SaveRegistry();
         Program.CurrentUser = user;
         Hide();
         if (Program.CurrentUser != null)
         {
             var qa = new FormOQCNullModel();
             qa.ShowDialog();
         }
         
     }
 }