Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtUsername.Text.Length > 0)
     {
         if (txtPassword.Text.Length > 0)
         {
             TaiKhoan temp = new TaiKhoan();
             temp = new TKController().Login(txtUsername.Text, txtPassword.Text);
             if (temp == null)
             {
                 MessageBox.Show("Đăng nhập thất bại");
                 return;
             }
             else
             {
                 ConstantCommon.ID            = temp.ID;
                 ConstantCommon.QUYEN         = temp.Quyen;
                 ConstantCommon.TEN_DANG_NHAP = txtUsername.Text;
                 ConstantCommon.MAT_KHAU      = txtPassword.Text;
                 this.Hide();
                 frmMain frm = new frmMain();
                 frm.ShowDialog();
                 Close();
             }
         }
     }
 }
Ejemplo n.º 2
0
        public frmTaiKhoan()
        {
            InitializeComponent();
            var nv = new TKController();

            ShowView(nv.Detail());
            IsAdmin(ConstantCommon.QUYEN);
        }
Ejemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtFind.Text.Length > 0)
     {
         TKController drc = new TKController();
         var          li  = drc.FindByName(txtFind.Text);
         if (li.Count <= 0)
         {
             MessageBox.Show("không tìm thấy");
             return;
         }
         ShowView(li);
     }
 }
Ejemplo n.º 4
0
        private void btnDelCLB_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Bạn có muốn xóa bản ghi này?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                long id     = Convert.ToInt64(txbID.Text);
                var  entity = new TKController();
                if (entity.delete(id))
                {
                    ShowView(entity.Detail());
                }
                else
                {
                    MessageBox.Show("Không xóa được!");
                }
            }
        }
Ejemplo n.º 5
0
        private void btnSaveCLB_Click(object sender, EventArgs e)
        {
            if (Add_bool == true && Edit_bool == false)
            {
                var entity = new TaiKhoan();

                entity.TenTK   = txbUserName.Text;
                entity.Quyen   = string.IsNullOrEmpty(cboQuyen.Text) ? "User" : cboQuyen.Text;
                entity.MatKhau = txbMatKhau.Text;
                var  clb = new TKController();
                long t   = clb.Add(entity);
                if (t > 0)
                {
                    ShowView(clb.Detail());
                    MessageBox.Show("Tạo tài khoản mới thành công");
                }
                else
                {
                    MessageBox.Show("Thêm bản ghi không thành công");
                }
            }
            if (Add_bool == false && Edit_bool == true)
            {
                var entity = new TaiKhoan();
                entity.ID    = Convert.ToInt64(txbID.Text);
                entity.Quyen = string.IsNullOrEmpty(cboQuyen.Text) ? "User" : cboQuyen.Text;
                var clb = new TKController();
                if (clb.ChangeRole(entity))
                {
                    ShowView(clb.Detail());
                }
                else
                {
                    MessageBox.Show("Sửa bản ghi không thành công");
                }
            }
            btn_edit(false);
            pnlCreatPass.Visible = false;
        }
Ejemplo n.º 6
0
        private void button2_Click(object sender, EventArgs e)
        {
            TKController drc = new TKController();

            ShowView(drc.Detail());
        }