protected void rptDepartments_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Del": string[] args = e.CommandArgument.ToString().Split(','); int deptId = Convert.ToInt32(args[0]); string deptName = args[1]; DeptParams param = new DeptParams() { DeptId = deptId }; bool result = empAuth.DeleteDepartmentData(param); //新增後端操作記錄 empAuth.InsertBackEndLogData(new BackEndLogData() { EmpAccount = c.GetEmpAccount(), Description = string.Format(".刪除部門/Delete department .代碼/id[{0}] 名稱/name[{1}] 結果/result[{2}]", deptId, deptName, result), IP = c.GetClientIP() }); // log to file c.LoggerOfUI.InfoFormat("{0} deletes {1}, result: {2}", c.GetEmpAccount(), "dept-" + deptId.ToString() + "-" + deptName, result); if (result) { DisplayDepartments(); } else { if (param.IsThereAccountsOfDept) { Master.ShowErrorMsg(Resources.Lang.ErrMsg_ThereIsAccountOfDept); } else { Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeleteDeptFailed); } } break; } }
protected void btnSave_Click(object sender, EventArgs e) { if (!IsValid) { return; } try { txtDeptName.Text = txtDeptName.Text.Trim(); DeptParams param = new DeptParams() { DeptName = txtDeptName.Text, SortNo = Convert.ToInt32(txtSortNo.Text), PostAccount = c.GetEmpAccount() }; bool result = false; if (c.qsAct == ConfigFormAction.add) { result = empAuth.InsertDepartmentData(param); if (!result) { if (param.HasDeptNameBeenUsed) { Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeptNameHasBeenUsed); } else { Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed); } } } else if (c.qsAct == ConfigFormAction.edit) { param.DeptId = c.qsId; result = empAuth.UpdateDepartmentData(param); if (!result) { if (param.HasDeptNameBeenUsed) { Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeptNameHasBeenUsed); } else { 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 department[{1}] DeptId[{2}] 結果/result[{3}]", Title, txtDeptName.Text, param.DeptId, result), IP = c.GetClientIP() }); } catch (Exception ex) { c.LoggerOfUI.Error("", ex); Master.ShowErrorMsg(ex.Message); } }