public async static Task<SYS_tblUserDRO> GetUserItem(string url) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { var response_data = await HttpGet(url); if (response_data.ToLower().StartsWith("error")) { result.ResponseItem.IsError = true; string[] tmp = response_data.Split('|'); result.ResponseItem.ErrorCode = tmp[1]; result.ResponseItem.ErrorMessage = tmp[2]; } else { var response_collection = JsonConvert.DeserializeObject<SYS_tblUserDRO>(response_data + ""); if (response_collection != null) { result.UserItem = response_collection.UserItem; } } } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async void GetAllUsers() { try { gridUser.DataBindings.Clear(); SYS_tblUserDRO users = new SYS_tblUserDRO(); users = await SYS_tblUserBUS.GetAllUsers(CommonEngine.userInfo.UserID, CommonEngine.userInfo.LanguageID, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionEN = BaseConstant.COMMAND_LOAD_ALL_DATA_EN, ActionVN = BaseConstant.COMMAND_LOAD_ALL_DATA_VI, FunctionID = "10", DescriptionVN = string.Format("Tài khoản '{0}' vừa tải thành công dữ liệu người dùng.", CommonEngine.userInfo.UserID), DescriptionEN = string.Format("Account '{0}' downloaded successfully data of users.", CommonEngine.userInfo.UserID) }); if (!CommonEngine.CheckValidResponseItem(users.ResponseItem)) return; gridUser.DataSource = users.UserList; barBottom.Visible = (users != null && users.UserList.Count > 0) ? true : false; CommonEngine.LoadUserPermission("10", btnDelete, btnPrint, btnImport, btnExport); } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); } }
public async static Task<SYS_tblUserDRO> GetUserItem(string username, string language_id, string userid) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format("{0}/GetUserByID?Username={1}&LanguageID={2}&UsernameOther={3}", GetBaseUrl(), username, language_id, userid); result = await SYS_tblUserDAO.GetUserItem(url); } catch(Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblUserDRO> CheckLogin(string username, string password, string language_id) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format("{0}/CheckLogin?Username={1}&Password={2}&LanguageID={3}", GetBaseUrl(), username, password, language_id); result = await SYS_tblUserDAO.CheckLogin(url); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblUserDRO> InsertUpdateUser(SYS_tblUserDTO item, SYS_tblActionLogDTO actionLog) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format(@"{0}/InsertUpdateUser", GetBaseUrl()); var postData = new SYS_tblUserDCO { Username = item.Username, Password = item.Password, GroupID = item.GroupID, GroupName = item.GroupName, EffectiveDate = item.EffectiveDate, ToDate = item.ToDate, DateChangePass = item.DateChangePass, Locked = item.Locked, LockDate = item.LockDate, UnlockDate = item.UnlockDate, PassNeverExpired = item.PassNeverExpired, ChangePassNextTime = item.ChangePassNextTime, EmpID = item.EmpID, FullName = item.FullName, Email = item.EmpID, Note = item.Note, CanNotChangePassword = item.CanNotChangePassword, Activity = item.Activity, UserID = item.UserID, LanguageID = item.LanguageID }; var json_data = "{\"user\":" + JsonConvert.SerializeObject(postData, new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }) + "}"; result = await SYS_tblUserDAO.InsertUpdateUser(url, json_data); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblUserDRO> GetAllUsers(string username, string language_id, SYS_tblActionLogDTO actionLog) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format("{0}/GetAllUsers?Username={1}&LanguageID={2}", GetBaseUrl(), username, language_id); result = await SYS_tblUserDAO.GetAllUsers(url); if (string.IsNullOrEmpty(result.ResponseItem.Message)) if (actionLog != null) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
private async Task<bool> SaveUser(bool isEdit) { CommonEngine.ShowWaitForm(this); SYS_tblUserDRO result = new SYS_tblUserDRO(); try { result = await SYS_tblUserBUS.InsertUpdateUser(new SYS_tblUserDTO { Username = txtUsername.Text, Password = EncryptEngine.Encrypt(txtPassword.Text.Trim()), GroupID = gluGroupUser.EditValue + "", EmpID = chkIsEmployee.Checked ? gluEmployee.EditValue + "" : "", FullName = txtFullName.Text, EffectiveDate = dteEffectiveDate.DateTime, ToDate = dteToDate.EditValue == null ? (DateTime?)null : dteToDate.DateTime, Locked = chkLocked.Checked, LockDate = (chkLocked.Checked && dteLockDate.EditValue != null) ? dteLockDate.DateTime : (DateTime?)null, UnlockDate = (chkLocked.Checked && dteUnlockDate.EditValue != null) ? dteUnlockDate.DateTime : (DateTime?)null, CanNotChangePassword = chkCanNotChangePassword.Checked, ChangePassNextTime = chkChangePassNextTime.Checked, PassNeverExpired = chkPasswordNeverExpired.Checked, Email = txtEmail.Text, Note = mmoNote.Text, Activity = (isEdit) ? BaseConstant.UPDATE_COMMAND : BaseConstant.INSERT_COMMAND, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language }, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = txtUsername.Text, LanguageID = ConfigEngine.Language, ActionEN = BaseConstant.COMMAND_UPDATE_EN, ActionVN = BaseConstant.COMMAND_UPDATE_VI, FunctionID = "10", DescriptionVN = string.Format("Tài khoản '{0}' vừa cập nhật thành công người dùng có tên tài khoản '{1}'.", CommonEngine.userInfo.UserID, txtUsername.Text.Trim()), DescriptionEN = string.Format("Account '{0}' has updated user successfully with username is '{1}'.", CommonEngine.userInfo.UserID, txtUsername.Text.Trim()) }); if (CommonEngine.CheckValidResponseItem(result.ResponseItem)) { if (!string.IsNullOrEmpty(result.ResponseItem.Message)) { CommonEngine.CloseWaitForm(); CommonEngine.ShowMessage(result.ResponseItem.Message, 0); txtUsername.Focus(); return false; } else parent_form.GetAllUsers(); } else { CommonEngine.CloseWaitForm(); return false; } } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); return false; } finally { CommonEngine.CloseWaitForm(); } return true; }
private async void btnSave_Click(object sender, EventArgs e) { if (CheckValidate()) { CommonEngine.ShowWaitForm(this); SYS_tblUserDRO result = new SYS_tblUserDRO(); try { result = await SYS_tblUserBUS.ChangeUserPassword(txtUsername.Text, ConfigEngine.Language, EncryptEngine.Encrypt(txtNewPassword.Text), new DTO.Systems.SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = txtUsername.Text, LanguageID = ConfigEngine.Language, ActionVN = "Đổi Mật Khẩu", ActionEN = "Change Password", FunctionID = "", FunctionNameVN = "Đổi Mật Khẩu", FunctionNameEN = "Change Password", DescriptionVN = string.Format("Tài khoản '{0}' vừa đổi mật khẩu thành công vào lúc {1}.", txtUsername.Text, DateTime.Now), DescriptionEN = string.Format("Account '{0}' has change password successfully at {1}.", txtUsername.Text, DateTime.Now) }); CommonEngine.CloseWaitForm(); if (string.IsNullOrEmpty(result.ResponseItem.Message)) { CommonEngine.userInfo.Password = EncryptEngine.Encrypt(txtNewPassword.Text); txtOldPassword.EditValue = txtNewPassword.EditValue = txtConfirmPassword.EditValue = null; depError.ClearErrors(); CommonEngine.ShowMessage(ConfigEngine.Language.Equals("vi") ? "Đổi mật khẩu người dùng thành công." : "Change user password successfully.", MessageType.Success); this.ParentForm.Close(); } else { CommonEngine.ShowMessage(result.ResponseItem.Message, 0); txtOldPassword.Focus(); } } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); txtOldPassword.Focus(); } } }
public async static Task<SYS_tblUserDRO> ChangeUserPassword(string username, string language_id, string password, SYS_tblActionLogDTO actionLog) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format(@"{0}/ChangeUserPassword?Username={1}&LanguageID={2}&Password={3}", GetBaseUrl(), username, language_id, password); result = await SYS_tblUserDAO.ChangeUserPassword(url); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblUserDRO> DeleteUser(string user_code_list, string username, string language_id, SYS_tblActionLogDTO actionLog) { SYS_tblUserDRO result = new SYS_tblUserDRO(); try { string url = string.Format(@"{0}/DeleteUser?Username={1}&LanguageID={2}&UserCodeList={3}", GetBaseUrl(), username, language_id, user_code_list); result = await SYS_tblUserDAO.DeleteUser(url); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
private async Task DeleteUser() { user_code_list = ""; foreach (int index in grvUser.GetSelectedRows()) user_code_list = string.Join("$", user_code_list, grvUser.GetRowCellDisplayText(index, gcolUsername)); if (user_code_list.Length > 0) user_code_list = user_code_list.Substring(1); SYS_tblUserDRO result = new SYS_tblUserDRO(); result.ResponseItem.Message = "ready"; if (!string.IsNullOrEmpty(user_code_list)) { try { if (user_code_list.Contains("$")) { if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000012", ConfigEngine.Language).Replace("$Count$", user_code_list.Split('$').Length.ToString()))) { CommonEngine.ShowWaitForm(this.ParentForm); result = await SYS_tblUserBUS.DeleteUser(user_code_list, CommonEngine.userInfo.Username, ConfigEngine.Language, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionVN = BaseConstant.COMMAND_DELETE_VI, ActionEN = BaseConstant.COMMAND_DELETE_EN, FunctionID = "10", DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công người dùng có các tên tài khoản '{1}'.", CommonEngine.userInfo.UserID, user_code_list.Replace("$", ", ")), DescriptionEN = string.Format("Account '{0}' has deleted user successfully with username are '{1}'.", CommonEngine.userInfo.UserID, user_code_list.Replace("$", ", ")) }); } } else { if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000005", ConfigEngine.Language))) { CommonEngine.ShowWaitForm(this.ParentForm); result = await SYS_tblUserBUS.DeleteUser(user_code_list, CommonEngine.userInfo.Username, ConfigEngine.Language, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionVN = BaseConstant.COMMAND_DELETE_VI, ActionEN = BaseConstant.COMMAND_DELETE_EN, FunctionID = "10", DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công người dùng có tên tài khoản '{1}'.", CommonEngine.userInfo.UserID, user_code_list), DescriptionEN = string.Format("Account '{0}' has deleted user successfully with username is '{1}'.", CommonEngine.userInfo.UserID, user_code_list) }); } } if (!CommonEngine.CheckValidResponseItem(result.ResponseItem)) return; if (!result.ResponseItem.Message.Equals("ready")) if (string.IsNullOrEmpty(result.ResponseItem.Message)) GetAllUsers(); else CommonEngine.ShowMessage(result.ResponseItem.Message, 0); } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); } finally { CommonEngine.CloseWaitForm(); } } else CommonEngine.ShowMessage("000027", IMC.Helper.MessageType.Warning, true); }