Exemplo n.º 1
0
        //Button sửa
        private void btnSuaTK_Click(object sender, EventArgs e)
        {
            if (drvTK == null)
            {
                MessageBox.Show("Chọn tài khoản muốn cập nhật");
                return;
            }

            TaiKhoan_DTO taikhoan = new TaiKhoan_DTO();

            taikhoan.Matkhau = txtMatKhau.Text;
            taikhoan.Tentk   = txtTenTaiKhoan.Text;
            if (TaiKhoan_BUS.SuaTaiKhoan(taikhoan))
            {
                drvTK = null;
                txtTenTaiKhoan.Text = "";
                txtMatKhau.Text     = "";
                LoadTaiKhoan();
                MessageBox.Show("Sửa thành công");
            }
            else
            {
                MessageBox.Show("Sửa thất bại");
            }
            return;
        }
Exemplo n.º 2
0
        private void BtnLUU_Click(object sender, EventArgs e)
        {
            if (flag == 1)
            {
                TaiKhoan_DTO Tk = new TaiKhoan_DTO();


                if (rdNhanVien.Checked == true)
                {
                    Tk.TaiKhoan = cboTaiKhoan.Text;
                }
                else if (rdSinhVien.Checked == true)
                {
                    Tk.TaiKhoan = comboBox1.Text;
                }
                Tk.TenHienThi = cboTenHT.Text;
                Tk.MauKhau    = txtMatKhau.Text;

                Tk.QuyenHan = cboQuyenHan.Text;


                if (TaiKhoan_BUS.TimTk_TheoTen(comboBox1.Text.Trim()) != null)
                {
                    XtraMessageBox.Show("Tài khoản đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //else if (TaiKhoan_BUS.TimTk_TheoTen(cboTaiKhoan.Text.Trim()) != null)
                //{
                //    XtraMessageBox.Show("Tài khoản đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}

                else if (TaiKhoan_BUS.ThemTaiKhoan(Tk))
                {
                    frmTaiKhoan_Load(sender, e);
                    XtraMessageBox.Show("Bạn đã thêm thành công tài khoản ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (flag == 2)
            {
                TaiKhoan_DTO Tk = new TaiKhoan_DTO();
                Tk.ID         = int.Parse(nmID.Text);
                Tk.TaiKhoan   = txtTaiKhoan.Text;
                Tk.TenHienThi = txtTenHT.Text;
                Tk.MauKhau    = txtMatKhau.Text;
                Tk.QuyenHan   = cboQuyenHan.Text;


                if (txtTaiKhoan.Text.Trim() == "")
                {
                    XtraMessageBox.Show("Bạn chưa chọn dòng cần sửa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (TaiKhoan_BUS.TimTk_TheoTen(txtTaiKhoan.Text.Trim()) != null)
                {
                    XtraMessageBox.Show("Tên tài khoản trùng rồi !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (TaiKhoan_BUS.TimTk_TheoTenHT(txtTenHT.Text.Trim()) != null)
                {
                    XtraMessageBox.Show("Tên hiển thị đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                else if (TaiKhoan_BUS.SuaTaiKhoan(Tk))
                {
                    frmTaiKhoan_Load(sender, e);
                    XtraMessageBox.Show("Bạn đã sửa thành công tài khoản ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }