Exemplo n.º 1
0
 private void btndangnhap_Click(object sender, EventArgs e)
 {
     if (textBoxuser.Text != "Username" && textBoxuser.TextLength > 2)
     {
         if (textBoxpass.Text != "Password")
         {
             Models.Taikhoan user       = new Models.Taikhoan();
             var             validLogin = user.Login(textBoxuser.Text, textBoxpass.Text);
             if (validLogin == true)
             {
                 this.Hide();
                 Manage mainMenu = new Manage();
                 mainMenu.Show();
                 mainMenu.FormClosed += LogOut;
             }
             else
             {
                 msgError("Incorrect username or password entered. \n" + "        " + "   Please try again.");
                 textBoxpass.Text = "Password";
                 textBoxpass.UseSystemPasswordChar = false;
                 textBoxpass.Clear();
                 textBoxuser.Clear();
                 textBoxuser.Focus();
             }
         }
         else
         {
             msgError("Please enter password.");
         }
     }
     else
     {
         msgError("Please enter username.");
     }
 }
Exemplo n.º 2
0
        private void btnSVXoa_Click(object sender, EventArgs e)
        {
            string _txtMaDocGia = "";

            try
            {
                _txtMaDocGia = txtMaDocGia.Text;
                MessageBox.Show(_txtMaDocGia);
            }
            catch { }
            DialogResult dr = MessageBox.Show(" Bạn có chắc chắn xóa ?", "Xác nhận ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                myTK = new Models.Taikhoan(txtMaDocGia.Text, txttendangnhap.Text, txtmatkhau.Text, cbbquyen.Text);
                var i = myTK.DeleteTaikhoan();
                if (i > 0)
                {
                    MessageBox.Show("Xóa Thành Công !");
                }
                else
                {
                    MessageBox.Show("Xóa Không thành công");
                }
            }
            hienthidanhsach();
        }
Exemplo n.º 3
0
 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();
         }
     }
 }
Exemplo n.º 4
0
        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();
        }