public bool SaveHrRightApply(string phid, string billno, string billname, string remark, string applicantObj, string orgObj, string roleObj, string otype, string removeApplicant) { JObject applicantJObj = JObject.Parse(applicantObj); JObject orgJObj = JObject.Parse(orgObj); JObject roleJObj = JObject.Parse(roleObj); try { DbHelper.BeginTran(); if (otype == "add") { if (string.IsNullOrEmpty(phid)) { phid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightapply").ToString(); } dac.InsertHrRightApplyDt(phid, billno, billname, remark); } else if (otype == "edit") { dac.UpdateHrRightApplyDt(billno, billname, remark); } JArray applicantJArr = JArray.Parse(applicantJObj["store"].ToString()); if (otype == "edit") { dac.DeleteApplicantDt(billno); } foreach (var applicant in applicantJArr) { long applicantphid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightapplicant"); string hrid = applicant["hrid"].ToString(); string userid = applicant["userid"].ToString(); if (otype == "edit" && removeApplicant.IndexOf(userid + ",") > -1) { removeApplicant = removeApplicant.Replace(userid + ",", ""); } string hrname = applicant["hrname"].ToString(); string dept = applicant["dept"].ToString(); string station = applicant["station"].ToString(); string applicantremark = applicant["remark"].ToString(); dac.InsertApplicantDt(applicantphid, billno, hrid, userid, hrname, dept, station, applicantremark); if (orgJObj[userid] != null) { JArray orgJArr = JArray.Parse(orgJObj[userid].ToString()); if (otype == "edit") { dac.DeleteOrgDt(billno, userid); } foreach (var org in orgJArr) { long orgphid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightorg"); string orgid = org["orgid"].ToString(); string orgname = org["orgname"].ToString(); int isselect = org["select"].ToString() == "True" ? 1 : 0; int fillpsnorg = 0; int applicantorg = 0; if (org["fillpsnorg"].ToString() == "登录组织/信息组织") { fillpsnorg = 1; } else if (org["fillpsnorg"].ToString() == "信息组织") { fillpsnorg = 2; } if (org["applicantorg"].ToString() == "登录组织/信息组织") { applicantorg = 1; } else if (org["applicantorg"].ToString() == "信息组织") { applicantorg = 2; } dac.InsertOrgDt(orgphid, billno, userid, orgid, orgname, isselect, fillpsnorg, applicantorg); if (roleJObj[userid + "|" + orgid] != null) { if (otype == "edit") { dac.DeleteRoleDt(billno, userid, orgid); } JArray roleJArr = JArray.Parse(roleJObj[userid + "|" + orgid].ToString()); foreach (var role in roleJArr) { long rolephid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightrole"); string roleid = role["roleid"].ToString(); string rolename = role["rolename"].ToString(); if (role["select"].ToString() == "True") { dac.InsertRoleDt(rolephid, billno, userid, orgid, roleid, rolename); } } } } } } if (otype == "edit" && !string.IsNullOrEmpty(removeApplicant)) { string[] useridArr = removeApplicant.Split(','); for (int i = 0; i < useridArr.Length - 1; i++) { dac.DeleteRemovedOrgRoleDt(billno, useridArr[i]); } } if (otype == "add") { ResBillNoOrIdEntity entity = SUP.Common.Rule.CommonUtil.GetBillNoIntensive("HrRightApply"); SUP.Common.Rule.CommonUtil.CommitBillNo("HrRightApply", entity);//提交单据用户编码,此操作将单据用户编码永久占用 } DbHelper.CommitTran(); } catch { DbHelper.RollbackTran(); return(false); } return(true); }