//新增申请 public ActionResult Add(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqInvite obj = jss.Deserialize<ReqInvite>(json); string maxFormNo = ctx.ReqInvites.Max(r => r.FormNo); string formNo = "Form_Invi_000001"; if (!string.IsNullOrEmpty(maxFormNo)) { formNo = "Form_Invi_" + (int.Parse(maxFormNo.Substring(10)) + 1000001).ToString().Substring(1); } obj.FormNo = formNo; EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; EmpDepPosition edp = ebi.EmpDepPos.Where(r => r.PosId <= 7).OrderByDescending(r => r.PosId).First(); obj.DeptId = edp.DeptId; obj.EmpId = ebi.Id; obj.ReqDate = DateTime.Now; try { ctx.ReqInvites.InsertOnSubmit(obj); ctx.SubmitChanges(); rdto.Message = "新增成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "新增失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); fs.SetSignFlow(formNo,ebi); rdto.Message = "保存且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//新增申请,含明细 public ActionResult Add(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqEvectionMain o= jss.Deserialize<ReqEvectionMain>(json); string maxFormNo = ctx.ReqEvectionMains.Max(r => r.FormNo); string formNo = "Form_Evec_000001"; if (!string.IsNullOrEmpty(maxFormNo)) { formNo = "Form_Evec_" + (int.Parse(maxFormNo.Substring(10)) + 1000001).ToString().Substring(1); } o.FormNo = formNo; EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; o.EmpId =ebi.Id; o.ReqDate = DateTime.Now; try { ctx.ReqEvectionMains.InsertOnSubmit(o); ctx.SubmitChanges(); rdto.Message = "新增成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "新增失败"; rdto.Result = false; } if (o.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); fs.SetSignFlow(formNo,ebi); rdto.Message = "保存且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请,含明细 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqVacationMain obj = jss.Deserialize<ReqVacationMain>(json); obj.ReqDate = DateTime.Now; try { ReqVacationMain oriObj = ctx.ReqVacationMains.Single(r => r.FormNo == obj.FormNo); oriObj.ReqDate = obj.ReqDate; oriObj.VacationType = obj.VacationType; oriObj.DaysCnt = obj.DaysCnt; oriObj.ReplacedDay = obj.ReplacedDay; oriObj.Cause = obj.Cause; oriObj.StatusId = obj.StatusId; foreach (var v in obj.ReqVacationSubs) { ReqVacationSub reqSub = null; if (v.Id > 0) { reqSub = oriObj.ReqVacationSubs.Single(r => r.Id == v.Id); } else { reqSub = new ReqVacationSub(); reqSub.FormNo = oriObj.FormNo; oriObj.ReqVacationSubs.Add(reqSub); } reqSub.PreStartTime = v.PreStartTime; reqSub.PreEndTime = v.PreEndTime; reqSub.Remarks = v.Remarks; } //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo, ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请,含明细 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqPerchaseMain obj = jss.Deserialize<ReqPerchaseMain>(json); obj.ReqDate = DateTime.Now; try { ReqPerchaseMain oriObj = ctx.ReqPerchaseMains.Single(r => r.FormNo == obj.FormNo); oriObj.ReqDate = obj.ReqDate; oriObj.Cost = obj.Cost; oriObj.Cause = obj.Cause; oriObj.StatusId = obj.StatusId; foreach (var v in obj.ReqPerchaseSubs) { ReqPerchaseSub reqSub = null; if (v.Id > 0) { reqSub = oriObj.ReqPerchaseSubs.Single(r => r.Id == v.Id); } else { reqSub = new ReqPerchaseSub(); reqSub.FormNo = oriObj.FormNo; oriObj.ReqPerchaseSubs.Add(reqSub); } reqSub.GoodsName = v.GoodsName; reqSub.Model = v.Model; reqSub.Specification = v.Specification; reqSub.PerPrice = v.PerPrice; reqSub.Unit = v.Unit; reqSub.Number = v.Number; } //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo, ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqInvite obj = jss.Deserialize<ReqInvite>(json); obj.ReqDate = DateTime.Now; try { ReqInvite oriObj = ctx.ReqInvites.Single(r => r.FormNo == obj.FormNo); oriObj.ReqDate = obj.ReqDate; oriObj.Position = obj.Position; oriObj.ReqNum = obj.ReqNum; oriObj.Salary = obj.Salary; oriObj.OnDutyDate = obj.OnDutyDate; oriObj.Reason = obj.Reason; oriObj.PositionDesc = obj.PositionDesc; oriObj.Sex = obj.Sex; oriObj.Age = obj.Age; oriObj.Education = obj.Education; oriObj.Major = obj.Major; oriObj.English = obj.English; oriObj.ProfTitle = obj.ProfTitle; oriObj.Qualify = obj.Qualify; oriObj.Experience = obj.Experience; oriObj.EssenKnowledge = obj.EssenKnowledge; oriObj.Skill = obj.Skill; oriObj.Trait = obj.Trait; oriObj.Remarks = obj.Remarks; oriObj.StatusId = obj.StatusId; //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo, ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请,含明细 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqEvectionMain obj = jss.Deserialize<ReqEvectionMain>(json); obj.ReqDate = DateTime.Now; try { ReqEvectionMain oriObj = ctx.ReqEvectionMains.Single(r => r.FormNo == obj.FormNo); oriObj.ReqDate = obj.ReqDate; oriObj.TriperIds = obj.TriperIds; oriObj.PreCost = obj.PreCost; oriObj.Cause = obj.Cause; oriObj.StatusId = obj.StatusId; foreach (var v in obj.ReqEvectionSchedules)//行程段 { ReqEvectionSchedule reqSub = null; if (v.Id > 0) { reqSub = oriObj.ReqEvectionSchedules.Single(r => r.Id == v.Id); } else { reqSub = new ReqEvectionSchedule(); reqSub.FormNo = oriObj.FormNo; oriObj.ReqEvectionSchedules.Add(reqSub); } reqSub.PreStartTime = v.PreStartTime; reqSub.PreEndTime = v.PreEndTime; reqSub.TrafficTool = v.TrafficTool; reqSub.LeavePoint = v.LeavePoint; reqSub.ArrivePoint = v.ArrivePoint; reqSub.Cause = v.Cause; reqSub.OrderNo = v.OrderNo; } foreach (var v in obj.ReqEvectionVoyages)//机票段 { ReqEvectionVoyage reqSub = null; if (v.Id > 0) { reqSub = oriObj.ReqEvectionVoyages.Single(r => r.Id == v.Id); } else { reqSub = new ReqEvectionVoyage(); oriObj.ReqEvectionVoyages.Add(reqSub); } reqSub.PreLeaveTimeSpan = v.PreLeaveTimeSpan; reqSub.PreArriveTimeSpan = v.PreArriveTimeSpan; reqSub.LeavePoint = v.LeavePoint; reqSub.ArrivePoint = v.ArrivePoint; reqSub.PrePickTimeSpan = v.PrePickTimeSpan; } foreach (var v in obj.ReqEvectionFlighters)//乘机人 { ReqEvectionFlighter reqSub = null; if (v.Id > 0) { reqSub = oriObj.ReqEvectionFlighters.Single(r => r.Id == v.Id); } else { reqSub = new ReqEvectionFlighter(); oriObj.ReqEvectionFlighters.Add(reqSub); } reqSub.FlighterName = v.FlighterName; reqSub.FlighterId = v.FlighterId; reqSub.FlighterCell = v.FlighterCell; } //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges();//此处为整个事务的提交 rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo,ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqOvertime obj = jss.Deserialize<ReqOvertime>(json); obj.ReqDate = DateTime.Now; try { ReqOvertime oriObj = ctx.ReqOvertimes.Single(r => r.FormNo == obj.FormNo); oriObj.ReqDate = obj.ReqDate; oriObj.PreStartTime = obj.PreStartTime; oriObj.PreEndTime = obj.PreEndTime; oriObj.Cause = obj.Cause; oriObj.StatusId = obj.StatusId; //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo, ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }
//更新申请 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); ReqReception obj = jss.Deserialize<ReqReception>(json); obj.ReqDate = DateTime.Now; try { ReqReception oriObj = ctx.ReqReceptions.Single(r => r.FormNo == obj.FormNo); oriObj.Customer = obj.Customer; oriObj.CustomerCnt = obj.CustomerCnt; oriObj.CustomerAddr = obj.CustomerAddr; oriObj.CorpAccompanies = obj.CorpAccompanies; oriObj.CustomerAccompanies = obj.CustomerAccompanies; oriObj.PeopleCnt = obj.PeopleCnt; oriObj.MealStd = obj.MealStd; oriObj.MealCnt = obj.MealCnt; oriObj.RestaurantStd = obj.RestaurantStd; oriObj.RestaurantCnt = obj.RestaurantCnt; oriObj.VehicleSchedule = obj.VehicleSchedule; oriObj.PreCost = obj.PreCost; oriObj.Cause = obj.Cause; oriObj.StatusId = obj.StatusId; //更新时删除之前的签核数据 var list = from r in ctx.SignFlows where r.FormNo == obj.FormNo select r; ctx.SignFlows.DeleteAllOnSubmit(list); ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } if (obj.StatusId == 1)//写签核流程 { try { FlowSet fs = new FlowSet(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; fs.SetSignFlow(obj.FormNo, ebi); rdto.Message = "更新且提交成功"; } catch (Exception ex) { rdto.Message = "表单已保存,但提交签核失败"; rdto.Result = false; } } return Json(rdto); }