Exemplo n.º 1
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.º 2
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);
            }
        }