Ejemplo n.º 1
0
        //更新申请,含明细
        public ActionResult Update(string json)
        {
            var rdto = new ResultMessages();
            rdto.Message = "";
            JavaScriptSerializer jss = new JavaScriptSerializer();
            ReqVehicleMains obj = jss.Deserialize<ReqVehicleMains>(json);
            obj.ReqDate = DateTime.Now;
            try
            {
                ReqVehicleMains oriObj = ctx.ReqVehicleMains.Single(r => r.FormNo ==obj.FormNo);
                oriObj.ReqDate = obj.ReqDate;
                oriObj.Vehicle = obj.Vehicle;
                oriObj.Riders = obj.Riders;
                oriObj.RiderCnt = obj.RiderCnt;
                oriObj.PreStartTime = obj.PreStartTime;
                oriObj.PreEndTime = obj.PreEndTime;
                oriObj.Cause = obj.Cause;
                oriObj.StatusId = obj.StatusId;
                foreach(var v in obj.ReqVehicleSubs)
                {
                    ReqVehicleSubs reqSub = null;
                    if(v.Id>0)
                    {
                        reqSub = oriObj.ReqVehicleSubs.Single(r => r.Id == v.Id);
                    }
                    else
                    {
                        reqSub = new ReqVehicleSubs();
                        reqSub.FormNo = oriObj.FormNo;
                        oriObj.ReqVehicleSubs.Add(reqSub);
                    }
                    reqSub.FromSite = v.FromSite;
                    reqSub.ToSite = v.ToSite;
                    reqSub.PreDistance = v.PreDistance;
                    reqSub.PreTimespan = v.PreTimespan;
                    reqSub.Cause = v.Cause;
                    reqSub.OrderNo = v.OrderNo;
                }
                //更新时删除之前的签核数据
                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);
        }
Ejemplo n.º 2
0
 partial void DeleteReqVehicleSubs(ReqVehicleSubs instance);
Ejemplo n.º 3
0
 partial void InsertReqVehicleSubs(ReqVehicleSubs instance);
Ejemplo n.º 4
0
 partial void UpdateReqVehicleSubs(ReqVehicleSubs instance);
Ejemplo n.º 5
0
		private void detach_ReqVehicleSubs(ReqVehicleSubs entity)
		{
			this.SendPropertyChanging();
			entity.ReqVehicleMains = null;
		}