Пример #1
0
        private async void btnDangNhap_Click(object sender, EventArgs e)
        {
            btnDangNhap.Enabled = false;
            string Account  = txtAccount.Text;
            string Password = txtPassword.Text;

            if (Account != "" && Password != "")
            {
                pbCheck.Show();
                lbCheck.Show();
                await Task.Delay(2000);

                if (DNV.Login(txtAccount.Text, txtPassword.Text))
                {
                    MainForm form = new MainForm(DNV.getRole(txtAccount.Text), DNV.getName(txtAccount.Text), txtAccount.Text);
                    form.Show();
                    this.Hide();
                    if (Ckb_SaveMyPass.Checked)
                    {
                        Properties.Settings.Default.UserName = txtAccount.Text;
                        Properties.Settings.Default.Password = txtPassword.Text;
                        Properties.Settings.Default.Save();
                    }
                }
                else
                {
                    btnDangNhap.Enabled = true;
                    pbCheck.Hide();
                    lbCheck.Hide();
                    txtSoLanDN.Show();
                    check          += 1;
                    txtSoLanDN.Text = "Lần thử thứ " + check + "/5";
                    MessageBox.Show("Sai tài khoản hoặc mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (check == 5)
                    {
                        second = second * numberCheck;
                        btnDangNhap.Enabled = false;
                        timer1.Interval     = 1000;
                        timer1.Start();
                    }
                }
            }
            else
            {
                btnDangNhap.Enabled = true;
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            Data_NV DNV  = new Data_NV();
            var     name = DNV.getName(Id);

            this.name = name;
            if (MdiChildren.Count() == 0)
            {
                txtXinChao.Caption = "Xin chào: ".ToUpper() + name;
                txtChucVu.Caption  = "Chức vụ: ".ToUpper() + ChucVu;
                WelcomeBack.Text   = "Chào mừng quay trở lại: " + name;
            }
            this.Opacity   = 1.00d;
            this.BackColor = Color.White;
            this.accordionControl1.Appearance.AccordionControl.BackColor = Color.Empty;
            if (MdiChildren.Count() == 0)
            {
                pb1.Show();
                WelcomeBack.Show();
            }
            accordionControl1.Show();
        }
 public void check()
 {
     if (Properties.Settings.Default.UserName != "")
     {
         string Account  = Properties.Settings.Default.UserName;
         string Password = Properties.Settings.Default.Password;
         if (DNV.Login(Account, Password))
         {
             MainForm form = new MainForm(DNV.getRole(Account), DNV.getName(Account), Account);
             form.Show();
         }
         else
         {
             MessageBox.Show("Có lỗi xảy ra, vui lòng đăng nhập lại");
             DangNhap dn = new DangNhap();
             dn.Show();
         }
     }
     else
     {
         DangNhap dn = new DangNhap();
         dn.Show();
     }
 }