Exemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (_id == -1)
         {
             new MessageBoxBA().Show("Bạn vui lòng chọn dữ liệu trên lưới!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
             return;
         }
         var result = new MessageBoxBA().Show("Bạn có muốn xóa user này không?", "Thông báo", MessageBoxButtonsBA.YesNo, MessageBoxIconBA.Question);
         if (result == MessageBoxResult.Yes)
         {
             Company_User objUser = new Company_User();
             objUser.Id = _id;
             objUser.Delete();
             new MessageBoxBA().Show("Xóa thông tin user thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
             ResetForm();
             RefreshGridControl();
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("btnDelete_Click", ex);
     }
 }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckValid())
                {
                    return;
                }

                Company_User objUser = new Company_User();
                objUser.Id           = _id;
                objUser.UserName     = txtUserName.Text;
                objUser.Password     = new BACryptor.Encryption(KeyEngypt).Encrypt(txtPassword.Text);
                objUser.FK_CompanyID = cboCompany.EditValue.To <int>();
                objUser.IsActive     = chkIsActive.Checked;

                if (_id == -1)//Thêm mới
                {
                    objUser.Insert();
                    new MessageBoxBA().Show("Thêm mới dữ liệu thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                }
                else
                {
                    objUser.Update();
                    new MessageBoxBA().Show("Cập nhật dữ liệu thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                }
                btnRefresh.PerformClick();
            }
            catch (Exception ex)
            {
                new MessageBoxBA().Show("Cập nhật dữ liệu thất bại!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                LogError.WriteLogError("btnSave_Click: ", ex);
            }
        }
Exemplo n.º 3
0
 private void gridControl_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         Company_User row = (Company_User)gridView.GetFocusedRow();
         if (row != null)
         {
             _id = row.Id;
             txtUserName.Enabled  = false;
             txtUserName.Text     = row.UserName;
             txtPassword.Text     = new BACryptor.Encryption(KeyEngypt).Decrypt(row.Password);
             cboCompany.EditValue = row.FK_CompanyID;
             chkIsActive.Checked  = row.IsActive;
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("gridControl_DoubleClick: ", ex);
     }
 }
Exemplo n.º 4
0
        private void btnResetPass_Click(object sender, EventArgs e)
        {
            try
            {
                if (_id == -1)
                {
                    new MessageBoxBA().Show("Bạn vui lòng chọn dữ liệu trên lưới!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                    return;
                }

                Company_User objUser = (Company_User)gridView.GetFocusedRow();
                objUser.Password = new BACryptor.Encryption(KeyEngypt).Encrypt(DefaultPassWord);
                objUser.Update();
                new MessageBoxBA().Show("Reset mật khẩu thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
            }
            catch (Exception ex)
            {
                new MessageBoxBA().Show("Reset mật khẩu thất bại!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                LogError.WriteLogError("btnResetPass_Click: ", ex);
            }
        }