Exemple #1
0
 private void Btndangnhap_Click(object sender, EventArgs e)
 {
     // xử lý nếu người dùng không điền vô textbox taikkhoan
     if (txtuser.Text == "")
     {
         MessageBox.Show("Tài khoản không được rỗng.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (dangNhapBUS.CheckLogin(txtuser.Text, txtmatkhau.Text, ref RoldeId))
         {
             NhatKyHeThongBUS nhatKyHeThongBUS = new NhatKyHeThongBUS();
             try
             {
                 nhatKyHeThongBUS.ThemNhatKyHeThong("Hệ Thống", "Đăng Nhập", " ");
             }
             catch
             {
             }
             if (checksave.Checked)
             {
                 Quan_Ly_Ban_Hang.Properties.Settings.Default.UserName = txtuser.Text;
                 Quan_Ly_Ban_Hang.Properties.Settings.Default.Password = txtmatkhau.Text;
                 Quan_Ly_Ban_Hang.Properties.Settings.Default.Save();
             }
             GlobalVar.tendn = txtuser.Text;
             var list = dangNhapBUS.GetListRolform(RoldeId);
             // Đưa vô distionary
             foreach (var RoleForm in list)
             {
                 GlobalVar.distRoleForm.Add(RoleForm.FormId, RoleForm);
             }
             this.Hide();
             TrangChu trangChu = new TrangChu(RoldeId, txtuser.Text);
             if (trangChu.ShowDialog() != DialogResult.OK)
             {
                 Application.Exit();
             }
             else
             {
                 trangChu.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("Đăng nhập thất bại.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }