Пример #1
0
        //更新申请,含明细
        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);
        }
Пример #2
0
 partial void DeleteReqEvectionSchedule(ReqEvectionSchedule instance);
Пример #3
0
 partial void InsertReqEvectionSchedule(ReqEvectionSchedule instance);
Пример #4
0
 partial void UpdateReqEvectionSchedule(ReqEvectionSchedule instance);
Пример #5
0
		private void detach_ReqEvectionSchedules(ReqEvectionSchedule entity)
		{
			this.SendPropertyChanging();
			entity.ReqEvectionMain = null;
		}