예제 #1
0
        private int check()
        {
            if (acc.PassWord != txb_cur_pass.Text)
            {
                MessageBox.Show("Mật khẩu hiện tại không đúng");
                return(0);
            }
            else
            {
                if (txb_new_pass.Text != txb_confirm_pass.Text)
                {
                    return(2);
                }
                else
                {
                    bool result = new AccoutDAO().Change_Pass(acc.UserName, txb_new_pass.Text);

                    if (result)
                    {
                        MessageBox.Show("Thay đổi mật khẩu thành công");
                        return(1);
                    }
                    else
                    {
                        MessageBox.Show("Có lỗi xảy ra");
                        return(0);
                    }
                }
            }
        }
예제 #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (btnXoa.Text == "Xóa")
            {
                DialogResult rs = MessageBox.Show("Bạn có chắc chắn muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo);
                if (rs == DialogResult.Yes)
                {
                    string Emp_ID = grv_PhanQuyen.GetFocusedRowCellValue("UserName").ToString();

                    bool result = new AccoutDAO().Delete_Account(Emp_ID);
                    if (result)
                    {
                        MessageBox.Show("Xóa tài khoản thành công");
                        Disable_Control();
                        Load_dgr_PhanQuyen();
                    }
                    else
                    {
                        MessageBox.Show("Có lỗi xảy ra");
                    }
                }
            }

            if (btnXoa.Text == "Hủy")
            {
                btnThem.Text = "Thêm";
                btnSua.Text  = "Sửa";
                btnXoa.Text  = "Xóa";

                Disable_Control();
                Load_dgr_PhanQuyen();
            }
        }
예제 #3
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            var res = new AccoutDAO().Login(metroTextBox1.Text, metroTextBox2.Text);

            if (res != null)
            {
                MessageBox.Show("Đăng nhập thành công", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MainForm mf = new MainForm(res, this);
                this.Hide();
                mf.Show();
            }
            else
            {
                MessageBox.Show("Đăng nhập thất bại, sai thông tin hoặc tài khoản bị khóa !!");
            }
        }
예제 #4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (btnThem.Text == "Thêm")
            {
                btnThem.Text   = "Lưu";
                btnThem.Image  = Resources.download_32x32;
                btnXoa.Text    = "Hủy";
                btnXoa.Image   = Resources.cancel_32x32;
                btnSua.Enabled = false;

                Clear_Control();
                Enable_Control();

                return;
            }

            if (btnThem.Text == "Lưu")
            {
                if (Validate())
                {
                    Account item = new Account();

                    item.UserName     = txb_Username.Text;
                    item.PassWord     = txb_pass.Text;
                    item.PermissionID = Convert.ToInt32(cbo_Quyen.SelectedValue);
                    item.EmployeeID   = Convert.ToInt32(cbo_NhanVien.SelectedValue);
                    item.Status       = (bool)cbo_TrangThai.SelectedValue;
                    item.CreateDate   = DateTime.Now;

                    bool result = new AccoutDAO().Insert_Account(item);

                    if (result)
                    {
                        MessageBox.Show("Thêm tài khoản thành công");
                        Disable_Control();
                        Load_dgr_PhanQuyen();
                    }
                    else
                    {
                        MessageBox.Show("Thêm tài khoản xảy ra lỗi");
                    }
                }
                return;
            }
        }