protected void btnSave_Click(object sender, EventArgs e) { if (!IsValid) { return; } try { txtEmpAccount.Text = txtEmpAccount.Text.Trim(); txtPsw.Text = txtPsw.Text.Trim(); string passwordValue = hidEmpPasswordOri.Text; bool passwordHashed = Convert.ToBoolean(hidPasswordHashed.Text); if (txtPsw.Text != "") { passwordValue = HashUtility.GetPasswordHash(txtPsw.Text); passwordHashed = true; } txtEmpName.Text = txtEmpName.Text.Trim(); txtEmail.Text = txtEmail.Text.Trim(); txtRemarks.Text = txtRemarks.Text.Trim(); txtOwnerAccount.Text = txtOwnerAccount.Text.Trim(); AccountParams param = new AccountParams() { EmpAccount = txtEmpAccount.Text, EmpPassword = passwordValue, EmpName = txtEmpName.Text, Email = txtEmail.Text, Remarks = txtRemarks.Text, DeptId = Convert.ToInt32(ddlDept.SelectedValue), RoleId = Convert.ToInt32(ddlRoles.SelectedValue), IsAccessDenied = chkIsAccessDenied.Checked, StartDate = Convert.ToDateTime(txtStartDate.Text), EndDate = Convert.ToDateTime(txtEndDate.Text), OwnerAccount = txtOwnerAccount.Text, PasswordHashed = passwordHashed, DefaultRandomPassword = hidDefaultRandomPassword.Text, PostAccount = c.GetEmpAccount() }; bool result = false; if (c.qsAct == ConfigFormAction.add) { result = empAuth.InsertEmployeeData(param); if (!result) { if (param.HasAccountBeenUsed) { Master.ShowErrorMsg(Resources.Lang.ErrMsg_AccountHasBeenUsed); } else { Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed); } } } else if (c.qsAct == ConfigFormAction.edit) { param.EmpId = c.qsEmpId; result = empAuth.UpdateEmployeeData(param); if (!result) { Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed); } } if (result) { ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true); } //新增後端操作記錄 empAuth.InsertBackEndLogData(new BackEndLogData() { EmpAccount = c.GetEmpAccount(), Description = string.Format(".{0} .儲存帳號/Save account[{1}] EmpId[{2}] 結果/result[{3}]", Title, txtEmpAccount.Text, param.EmpId, result), IP = c.GetClientIP() }); } catch (Exception ex) { c.LoggerOfUI.Error("", ex); Master.ShowErrorMsg(ex.Message); } }