Beispiel #1
0
 private void txtUserCD_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         string temp = txtUserCD.Text;
         if (temp.Contains(";"))
         {
             temp = temp.Split(';')[0].Trim();
         }
         if (temp.Length > 6)
         {
             txtUserCD.Text = temp.Substring(temp.Length - 6);
         }
         else
         {
             txtUserCD.Text = temp;
         }
         try
         {
             m_mes_user mUser = new m_mes_user();
             lbUserName.Text       = mUser.GetUser(txtUserCD.Text).user_name;
             lbUserName.BackColor  = Color.Lime;
             pnlInspection.Visible = true;
             txtBarcode.Focus();
         }
         catch (Exception ex)
         {
             txtUserCD.Focus();
             lbUserName.Text      = "User Name";
             lbUserName.BackColor = Color.FromKnownColor(KnownColor.ActiveCaption);
             CustomMessageBox.Error("Wrong User Code!" + Environment.NewLine + "(" + ex.Message + ")");
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Click button OK for login
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(txtUsername.Text))
         {
             loginpass = loginpass.CheckLogIn(txtUsername.Text, txtpass.Text);
             if (loginpass.is_online)
             {
                 if (CustomMessageBox.Question("This user is online." + Environment.NewLine + "Are you want re-login?") == DialogResult.No)
                 {
                     return;
                 }
             }
             UserData.isOnline       = loginpass.LogIO(txtUsername.Text, true);
             mesuser                 = mesuser.GetUser(loginpass.user_cd);
             UserData.onTime         = 0;
             timerOnTimeSet.Enabled  = true;
             UserData.dept           = mesuser.dept_cd;
             UserData.usercode       = mesuser.user_cd;
             UserData.username       = mesuser.user_name;
             UserData.position       = mesuser.user_position_cd;
             UserData.logintime      = loginpass.last_login_time;
             UserData.role_permision = userrole.GetListRole(loginpass.user_cd);
             //Show main form
             MainForm main = new MainForm();
             this.Hide();
             txtpass.Clear();
             main.ShowDialog();
             loginpass.LogIO(txtUsername.Text, false);
             this.Show();
             this.Focus();
         }
         else
         {
             CustomMessageBox.Notice("Please fill user code!");
             txtUsername.Focus();
         }
     }
     catch (Exception ex)
     {
         CustomMessageBox.Error(ex.Message);
         txtpass.Clear();
     }
 }
Beispiel #3
0
 private void txtUserCode_Validated(object sender, EventArgs e)
 {
     try
     {
         m_mes_user muser = new m_mes_user();
         muser                = muser.GetUser(txtUserCode.Text);
         lbUserName.Text      = muser.user_name;
         lbUserName.BackColor = Color.Lime;
         errorProvider.SetError(txtUserCode, null);
     }
     catch (Exception ex)
     {
         txtUserCode.Focus();
         lbUserName.Text      = "User Name";
         lbUserName.BackColor = Color.FromKnownColor(KnownColor.ActiveCaption);
         errorProvider.SetError(txtUserCode, "Wrong User Code" + Environment.NewLine + ex.Message);
     }
 }