Ejemplo n.º 1
0
 private void BtnEnter_Click(object sender, EventArgs e)
 {
     if (txtMK.Text == "" || txtTenDN.Text == "")
     {
         MessageBox.Show("Vui lòng nhập lại tài khoản!");
         return;
     }
     foreach (NguoiDung nd in ListND)
     {
         long a;
         if (!long.TryParse(txtTenDN.Text, out a))
         {
             MessageBox.Show("Vui lòng nhập lại tài khoản!");
             return;
         }
         if (a == nd.MaND && txtMK.Text == nd.MatKhau)
         {
             NhatKyDAO dao = new NhatKyDAO();
             dao.Insert(a);
             FrmChinh frm = new FrmChinh();
             frm.Show();
             this.Hide();
             return;
         }
     }
     MessageBox.Show("Vui lòng nhập lại tài khoản!");
 }
        public void Validation()
        {
            if (txtTenDN.Text == "")
            {
                lblThongBao.Text = "Bạn phải nhập tên đăng nhập";
                return;
            }
            else if (txtMatKhau.Text == "")
            {
                lblThongBao.Text = "Bạn phải nhập mật khẩu";
                return;
            }
            else if (txtMatKhau.Text != "" && txtTenDN.Text != "")
            {
                //string MK = GetMd5(txtMatKhau.Text);
                var kiemTra = (from i in data.DangNhaps
                               where i.Username == txtTenDN.Text.Trim() && i.Password == txtMatKhau.Text.Trim()
                               select i).SingleOrDefault();

                if (kiemTra == null)
                {
                    lblThongBao.Text = "Tên đăng nhập hoặc mật khẩu không đúng";
                    return;
                }
            }

            this.Hide();
            FrmChinh frmChinh = new FrmChinh();

            frmChinh._dn = new DangNhap
            {
                Username = txtTenDN.Text,
                Password = txtMatKhau.Text
            };
            frmChinh._frmLG = this;
            frmChinh.Show();
            //frmChangePass newForm = new frmChangePass(txtTenDN.Text);
            //newForm.ShowDialog();
        }