private void OnDisplayUserList() { Result result = LogonBus.GetUserList(); if (result.IsOK) { DataTable dt = result.QueryResult as DataTable; MethodInvoker method = delegate { cboUserName.DataSource = dt; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("LogonBus.GetUserList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.GetUserList")); } }
private void OnDisplayUserLogonList() { Result result = LogonBus.GetUserListWithoutAdmin(); if (result.IsOK) { MethodInvoker method = delegate { dgLogon.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("LogonBus.GetUserListWithoutAdmin"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.GetUserListWithoutAdmin")); } }
private void OnChangePassword() { Result result = LogonBus.ChangePassword(_newPassword); if (result.IsOK) { Global.Password = _newPassword; } else { MsgBox.Show(this.Text, result.GetErrorAsString("LogonBus.ChangePassword"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.ChangePassword")); } }
private void OnSaveInfo() { try { RijndaelCrypto crypt = new RijndaelCrypto(); _logon.Status = (byte)Status.Actived; _logon.Password = crypt.Encrypt(txtPassword.Text); if (_isNew) { _logon.CreatedDate = DateTime.Now; _logon.CreatedBy = Guid.Parse(Global.UserGUID); } else { _logon.UpdatedDate = DateTime.Now; _logon.UpdatedBy = Guid.Parse(Global.UserGUID); } MethodInvoker method = delegate { _logon.DocStaffGUID = Guid.Parse(cboDocStaff.SelectedValue.ToString()); DataTable dtPermission = dgPermission.DataSource as DataTable; Result result = LogonBus.InsertUserLogon2(_logon, dtPermission); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("LogonBus.InsertUserLogon2"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.InsertUserLogon2")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private void OnDeleteUserLogon() { List <string> deletedLogonList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgLogon.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedLogonList.Add(row["LogonGUID"].ToString()); deletedRows.Add(row); } } if (deletedLogonList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những người sử dụng mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = LogonBus.DeleteUserLogon(deletedLogonList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("LogonBus.DeleteUserLogon"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.DeleteUserLogon")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những người sử dụng cần xóa.", IconType.Information); } }
private bool CheckInfo() { if (cboDocStaff.SelectedValue == null || cboDocStaff.Text == string.Empty) { MsgBox.Show(this.Text, "Vui lòng chọn bác sĩ.", IconType.Information); cboDocStaff.Focus(); return(false); } if (!Utility.IsValidPassword(txtPassword.Text)) { MsgBox.Show(this.Text, "Mật khẩu không hợp lệ (4-12 kí tự). Vui lòng nhập lại.", IconType.Information); txtPassword.Focus(); return(false); } string logonGUID = _isNew ? string.Empty : _logon.LogonGUID.ToString(); Result result = LogonBus.CheckUserLogonExist(logonGUID, cboDocStaff.SelectedValue.ToString()); if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) { if (result.Error.Code == ErrorCode.EXIST) { MsgBox.Show(this.Text, "Bác sĩ này đã được cấp tài khoản đăng nhập rồi. Vui lòng chọn bác sĩ khác.", IconType.Information); cboDocStaff.Focus(); return(false); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("LogonBus.CheckUserLogonExist"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("LogonBus.CheckUserLogonExist")); return(false); } return(true); }