private void btnSVLuu_Click(object sender, EventArgs e) { if (btnSVLuu.Tag.ToString() == "Them") { myTK = new Models.Taikhoan(txtMaDocGia.Text, txttendangnhap.Text, txtmatkhau.Text, cbbquyen.Text); var i = myTK.InsertTaikhoan(); if (i == 0) { MessageBox.Show("Thêm mới thất bại !"); } else { MessageBox.Show("Thêm mới thành công !"); hienthidanhsach(); } } if (btnSVLuu.Tag.ToString() == "Sua") { myTK = new Models.Taikhoan(txtMaDocGia.Text, txttendangnhap.Text, txtmatkhau.Text, cbbquyen.Text); var i = myTK.UpdateTaikhoan(); if (i == 0) { MessageBox.Show("Sửa thất bại !"); } else { MessageBox.Show("Sửa thành công !"); hienthidanhsach(); } } }
private void btndangnhap_Click(object sender, EventArgs e) { string LoginName = ""; try { LoginName = txtuser.Text; } catch { } string Password = ""; try { Password = txtmk.Text; } catch { } if (txtuser.Text != "Nhập Tài Khoản" & txtuser.Text != "") { if (txtmk.Text != "Nhập Mật Khẩu" & txtmk.Text != "") { Models.Taikhoan Tk = new Models.Taikhoan(txtho.Text, txtuser.Text, txtmk.Text, txtposition.Text); var NV = Tk.InsertTaikhoan(); if (NV == 0) { MessageBox.Show("Tạo Tài Khoản Thấp Bại"); } else { MessageBox.Show("Tạo Tài Khoản Thành Công"); } } else { msgError2("Bạn Chưa Nhập Mật Khẩu"); } txtuser.Focus(); } else { msgError1("Bạn Chưa Nhập Tài Khoản"); } txtuser.Focus(); }