コード例 #1
0
        public void kiemTra(string tenDN, string MK)
        {
            SqlConnection  dbConn = new SqlConnection(@"Data Source=HUUTHUAN\SQLEXPRESS;Initial Catalog=QLHSSV_TTLL;Integrated Security=True");
            string         cmd    = "SELECT hoTen FROM DANGNHAP WHERE tenDangNhap = '" + tenDN + "' AND matKhau = '" + MK + "'";
            SqlDataAdapter sql    = new SqlDataAdapter(cmd, dbConn);
            DataTable      ds     = new DataTable();

            sql.Fill(ds);
            if (ds.Rows.Count == 1)
            {
                /* I have made a new page called home page. If the user is successfully authenticated then the form will be moved to the next form */
                this.Hide();
                if (ds.Rows[0][0].ToString() != "admin")
                {
                    TrangChu f = new TrangChu(ds.Rows[0][0].ToString());
                    f.Show();
                }
            }
            else
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu.Xin vui lòng kiểm tra lại!");
            }
            txtMK.Text    = "";
            txtTenDN.Text = "";
        }
コード例 #2
0
ファイル: DangNhap.cs プロジェクト: doanlaptrinh/QLPKFinal
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtUser.Text != "" && txtPass.Text != "")
     {
         DTO_DangNhap tv = new DTO_DangNhap(txtUser.Text, txtPass.Text, "");
         if (busTV.ktThanhVien(tv))
         {
             this.Hide();
             TrangChu fm = new TrangChu();
             fm.Show();
         }
         else
         {
             MessageBox.Show("Đăng nhập ko thành công");
         }
     }
 }