/// <summary> /// 保存按钮点击事件执行方法 /// </summary> protected void PageSave() { //ajax返回信息 string resultmsg = ""; //实例化工作汇报实体 MWorkReport modelMWorkReport = new MWorkReport(); //实例化业务层 BIndividual bllBIndividual = new BIndividual(); if (!string.IsNullOrEmpty(hidId.Value)) { //修改状态根据id获取汇报实体 modelMWorkReport = bllBIndividual.GetWorkReport(Utils.GetInt(hidId.Value)); } else { //汇报时间 modelMWorkReport.IssueTime = DateTime.Now; } #region 显性属性(页面直接和用户交互) //标题 string title = this.txtTitle.Text; //汇报人 string userName = this.txtUserName.Text; //部门id string departID = Utils.GetFormValue(this.SelectSection1.SelectIDClient); //部门名称 string departName = Utils.GetFormValue(this.SelectSection1.SelectNameClient); //汇报时间 string dateTime = this.txtDateTime.Text; //汇报内容 string content = this.txtContent.Text; //附件上传 string strUploadUrl = Utils.GetFormValue(this.UploadControl1.ClientHideID); #region 审批人列表 //审批人 string strapprover = Utils.GetFormValue(this.SelectSection2.SellsNameClient); string[] approver = { "" }; if (strapprover != null && strapprover.Contains(',')) { approver = strapprover.Split(','); } else { approver[0] = strapprover; } //审核人id string strapproverId = Utils.GetFormValue(this.SelectSection2.SellsIDClient); string[] approverId = { "" }; if (strapproverId != null && strapproverId.Contains(',')) { approverId = strapproverId.Split(','); } else { approverId[0] = strapproverId; } List <MWorkReportCheck> list = new List <MWorkReportCheck>(); if (approver.Length > 0) { for (int i = 0; i < approver.Length; i++) { MWorkReportCheck modelMWorkReportCheck = new MWorkReportCheck(); if (approverId[i] != null) { //审批人id modelMWorkReportCheck.ApproverId = approverId[i]; } //审批人姓名 modelMWorkReportCheck.Approver = approver[i]; list.Add(modelMWorkReportCheck); } } #endregion #region 实体赋值 modelMWorkReport.Title = title; modelMWorkReport.OperatorName = userName; modelMWorkReport.OperatorId = ""; modelMWorkReport.DepartmentId = Utils.GetInt(departID); modelMWorkReport.Department = departName; modelMWorkReport.IssueTime = Utils.GetDateTime(dateTime); modelMWorkReport.Content = content; modelMWorkReport.Status = Status.审批中; #region 附件 if (!string.IsNullOrEmpty(strUploadUrl)) { //验证数据 string[] strUploadList = strUploadUrl.Split('|'); if (strUploadList.Length == 2) { strUploadUrl = strUploadList[0] + "|" + strUploadList[1]; } } else { if (!string.IsNullOrEmpty(Utils.GetFormValue("hideOtherFile"))) { strUploadUrl = Utils.GetFormValue("hideOtherFile"); } } modelMWorkReport.UploadUrl = strUploadUrl; #endregion modelMWorkReport.list = list; #endregion #endregion #region 隐性属性(id之类) //系统公司id string companyid = SiteUserInfo.CompanyId; modelMWorkReport.CompanyId = companyid; //汇报人编号 modelMWorkReport.OperatorId = SiteUserInfo.UserId; #endregion //操作之后返回结果 bool result = false; if (!string.IsNullOrEmpty(hidId.Value)) { result = bllBIndividual.UpdWorkReport(modelMWorkReport); if (result) { resultmsg = UtilsCommons.AjaxReturnJson("true", "修改成功"); } else { resultmsg = UtilsCommons.AjaxReturnJson("false", "修改失败,检查选用的数据是否正确"); } } else { result = bllBIndividual.AddWorkReport(modelMWorkReport); if (result) { resultmsg = UtilsCommons.AjaxReturnJson("true", "添加成功"); } else { resultmsg = UtilsCommons.AjaxReturnJson("false", "添加失败,检查选用的数据是否正确"); } } Response.Clear(); Response.Write(resultmsg); Response.End(); }