Beispiel #1
0
        public ActionResult AddScheduler(int orderId, int orderServiceId, int serviceNatureId, string serviceWorkDate, string serviceWorkTime, string serviceWorkPlace, string tugId,
            string isCaptainConfirm, string informCaptainTime, string captainConfirmTime,  string ropeUsed, int ropeNum, string remark)
        {
            this.Internationalization();

            try
            {
                TugDataEntities db = new TugDataEntities();
                {
                    //插入多个调度到数据库
                    {
                        List<string> lstTugIds = tugId.Split(',').ToList();
                        if (lstTugIds != null && lstTugIds.Count > 0)
                        {
                            List<Scheduler> lstSchedulers = new List<Scheduler>();
                            foreach (string item in lstTugIds)
                            {
                                TugDataModel.Scheduler aScheduler = new Scheduler();

                                //aScheduler.OrderID = orderId;
                                //aScheduler.ServiceNatureID = serviceNatureId;
                                aScheduler.OrderServiceID = orderServiceId;

                                aScheduler.TugID = Util.toint(item);

                                aScheduler.RopeUsed = ropeUsed;
                                aScheduler.RopeNum = ropeNum;
                                aScheduler.Remark = remark;

                                aScheduler.IsCaptainConfirm = isCaptainConfirm;

                                aScheduler.InformCaptainTime = informCaptainTime;
                                aScheduler.CaptainConfirmTime = captainConfirmTime;
                                aScheduler.JobStateID = 32;

                                aScheduler.OwnerID = -1;
                                aScheduler.UserID = Session.GetDataFromSession<int>("userid");

                                aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                aScheduler.UserDefinedCol1 = "";
                                aScheduler.UserDefinedCol2 = "";
                                aScheduler.UserDefinedCol3 = "";
                                aScheduler.UserDefinedCol4 = "";

                                //if (Request.Form["UserDefinedCol5"].Trim() != "")
                                //    aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                                //if (Request.Form["UserDefinedCol6"].Trim() != "")
                                //    aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                                //if (Request.Form["UserDefinedCol7"].Trim() != "")
                                //    aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                                //if (Request.Form["UserDefinedCol8"].Trim() != "")
                                //    aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                                aScheduler.UserDefinedCol9 = "";
                                aScheduler.UserDefinedCol10 = "";

                                lstSchedulers.Add(aScheduler);
                            }

                            db.Scheduler.AddRange(lstSchedulers);
                            db.SaveChanges();
                        }
                    }

                    {
                        //更新订单状态
                        //OrderInfor tmpOrder = db.OrderInfor.Where(u => u.IDX == orderId).FirstOrDefault();
                        //if (tmpOrder != null)
                        //{
                        //    tmpOrder.WorkStateID = 3; //已排船
                        //    db.Entry(tmpOrder).State = System.Data.Entity.EntityState.Modified;
                        //    db.SaveChanges();
                        //}
                    }

                    //更新服务状态
                    {
                        OrderService os = db.OrderService.Where(u => u.IDX == orderServiceId).FirstOrDefault();
                        if (os == null)
                        {
                            os = new OrderService();
                            os.CreateDate = os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            os.OrderID = orderId;
                            os.OwnerID = -1;
                            os.ServiceNatureID = serviceNatureId;
                            os.ServiceWorkDate = serviceWorkDate;
                            os.ServiceWorkTime = serviceWorkTime;
                            os.ServiceWorkPlace = serviceWorkPlace;
                            os.JobStateID = 115;
                            os.UserID = Session.GetDataFromSession<int>("userid");
                            os = db.OrderService.Add(os);
                            db.SaveChanges();
                        }
                        else
                        {
                            os.ServiceWorkDate = serviceWorkDate;
                            os.ServiceWorkTime = serviceWorkTime;
                            os.ServiceWorkPlace = serviceWorkPlace;
                            os.JobStateID = 115;
                            os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();

                        }
                    }

                    var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                    //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                    return Json(ret);
                }
            }
            catch (Exception)
            {
                var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                return Json(ret);
            }
        }
Beispiel #2
0
        public ActionResult AddEditScheduler()
        {
            this.Internationalization();

            #region Add

            if (Request.Form["oper"].Equals("add"))
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();
                    {
                        TugDataModel.Scheduler aScheduler = new Scheduler();
                        aScheduler.ArrivalBaseTime = Request.Form["ArrivalBaseTime"].Trim();
                        aScheduler.ArrivalShipSideTime = Request.Form["ArrivalShipSideTime"].Trim();
                        aScheduler.CaptainConfirmTime = Request.Form["CaptainConfirmTime"].Trim();
                        aScheduler.DepartBaseTime = Request.Form["DepartBaseTime"].Trim();
                        aScheduler.InformCaptainTime = Request.Form["InformCaptainTime"].Trim();
                        aScheduler.WorkCommencedTime = Request.Form["WorkCommencedTime"].Trim();
                        aScheduler.WorkCompletedTime = Request.Form["WorkCompletedTime"].Trim();

                        aScheduler.JobStateID = Util.toint(Request.Form["JobStateID"].Trim()); ;

                        //aScheduler.OrderID = Util.toint(Request.Form["OrderID"].Trim());
                        aScheduler.OwnerID = -1;
                        aScheduler.UserID = Session.GetDataFromSession<int>("userid");
                        aScheduler.Remark = Request.Form["Remark"].Trim(); ;

                        //aScheduler.RopeUsed = Request.Form["RopeUsed"].Trim();
                        //if (aScheduler.RopeUsed.Equals("是"))
                        //    aScheduler.RopeNum = Util.toint(Request.Form["RopeNum"].Trim());
                        //else
                        //    aScheduler.RopeNum = 0;

                        //aScheduler.ServiceNatureID = Util.toint(Request.Form["ServiceNatureLabel"].Trim().Split('~')[0]);
                        aScheduler.TugID = Util.toint(Request.Form["TugID"].Trim());
                        aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        aScheduler.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                        aScheduler.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                        aScheduler.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                        aScheduler.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

                        if (Request.Form["UserDefinedCol5"].Trim() != "")
                            aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                        if (Request.Form["UserDefinedCol6"].Trim() != "")
                            aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                        if (Request.Form["UserDefinedCol7"].Trim() != "")
                            aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                        if (Request.Form["UserDefinedCol8"].Trim() != "")
                            aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                        aScheduler.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim();
                        aScheduler.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim();

                        aScheduler = db.Scheduler.Add(aScheduler);
                        db.SaveChanges();

                        {
                            //更新订单状态
                            //OrderInfor tmpOrder = db.OrderInfor.Where(u => u.IDX == aScheduler.OrderID).FirstOrDefault();
                            //if(tmpOrder != null)
                            //{
                            //    tmpOrder.WorkStateID = 3; //已排船
                            //    db.Entry(tmpOrder).State = System.Data.Entity.EntityState.Modified;
                            //    db.SaveChanges();
                            //}
                        }

                        {
                            //OrderService os = db.OrderService.Where(u => u.OrderID == aScheduler.OrderID && u.ServiceNatureID == aScheduler.ServiceNatureID).FirstOrDefault();
                            //if (os == null)
                            //{
                            //    os = new OrderService();
                            //    os.CreateDate = os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    os.OrderID = aScheduler.OrderID;
                            //    os.OwnerID = -1;
                            //    os.ServiceNatureID = aScheduler.ServiceNatureID;
                            //    os.ServiceWorkDate = Request.Form["ServiceWorkDate"].Trim();
                            //    os.ServiceWorkPlace = Request.Form["ServiceWorkPlace"].Trim();
                            //    os.UserID = Session.GetDataFromSession<int>("userid");
                            //    os = db.OrderService.Add(os);
                            //    db.SaveChanges();
                            //}
                            //else
                            //{
                            //    os.ServiceWorkDate = Request.Form["ServiceWorkDate"].Trim();
                            //    os.ServiceWorkPlace = Request.Form["ServiceWorkPlace"].Trim();
                            //    os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                            //    db.SaveChanges();
                            //}
                        }

                        var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret);
                    }
                }
                catch (Exception)
                {
                    var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                    //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                    return Json(ret);
                }
            }

            #endregion Add

            #region Edit

            if (Request.Form["oper"].Equals("edit"))
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();

                    int idx = Util.toint(Request.Form["IDX"].Trim());
                    Scheduler aScheduler = db.Scheduler.Where(u => u.IDX == idx).FirstOrDefault();

                    if (aScheduler == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    else
                    {
                        //aScheduler.ArrivalBaseTime = Request.Form["ArrivalBaseTime"].Trim();
                        //aScheduler.ArrivalShipSideTime = Request.Form["ArrivalShipSideTime"].Trim();
                        //aScheduler.CaptainConfirmTime = Request.Form["CaptainConfirmTime"].Trim();
                        //aScheduler.DepartBaseTime = Request.Form["DepartBaseTime"].Trim();
                        //aScheduler.InformCaptainTime = Request.Form["InformCaptainTime"].Trim();
                        //aScheduler.WorkCommencedTime = Request.Form["WorkCommencedTime"].Trim();
                        //aScheduler.WorkCompletedTime = Request.Form["WorkCompletedTime"].Trim();

                        //aScheduler.JobStateID = Util.toint(Request.Form["JobStateID"].Trim()); ;

                        //aScheduler.OrderID = Util.toint(Request.Form["OrderID"].Trim());
                        aScheduler.OwnerID = -1;
                        aScheduler.UserID = Session.GetDataFromSession<int>("userid");
                        aScheduler.Remark = Request.Form["Remark"].Trim();
                        aScheduler.IsCaptainConfirm = Request.Form["IsCaptainConfirm"].Trim();

                        //aScheduler.RopeUsed = Request.Form["RopeUsed"].Trim();
                        //if (aScheduler.RopeUsed.Equals("是"))
                        //    aScheduler.RopeNum = Util.toint(Request.Form["RopeNum"].Trim());
                        //else
                        //    aScheduler.RopeNum = 0;

                        //aScheduler.ServiceNatureID = Util.toint(Request.Form["ServiceNatureLabel"].Trim().Split('~')[0]);

                        //aScheduler.TugID = Util.toint(Request.Form["TugID"].Trim());
                        aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        //aScheduler.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                        //aScheduler.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                        //aScheduler.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                        //aScheduler.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

                        //if (Request.Form["UserDefinedCol5"].Trim() != "")
                        //    aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                        //if (Request.Form["UserDefinedCol6"].Trim() != "")
                        //    aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                        //if (Request.Form["UserDefinedCol7"].Trim() != "")
                        //    aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                        //if (Request.Form["UserDefinedCol8"].Trim() != "")
                        //    aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                        //aScheduler.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim();
                        //aScheduler.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim();

                        db.Entry(aScheduler).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        {
                            //OrderService os = db.OrderService.Where(u => u.OrderID == aScheduler.OrderID && u.ServiceNatureID == aScheduler.ServiceNatureID).FirstOrDefault();
                            //if (os == null)
                            //{
                            //    os = new OrderService();
                            //    os.CreateDate = os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    os.OrderID = aScheduler.OrderID;
                            //    os.OwnerID = -1;
                            //    os.ServiceNatureID = aScheduler.ServiceNatureID;
                            //    os.ServiceWorkDate = Request.Form["ServiceWorkDate"].Trim();
                            //    os.ServiceWorkPlace = Request.Form["ServiceWorkPlace"].Trim();
                            //    os.UserID = Session.GetDataFromSession<int>("userid");
                            //    os = db.OrderService.Add(os);
                            //    db.SaveChanges();
                            //}
                            //else
                            //{
                            //    os.ServiceWorkDate = Request.Form["ServiceWorkDate"].Trim();
                            //    os.ServiceWorkPlace = Request.Form["ServiceWorkPlace"].Trim();
                            //    os.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                            //    db.SaveChanges();
                            //}
                        }

                        return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                    }
                }
                catch (Exception exp)
                {
                    return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
                }
            }

            #endregion Edit

            return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
        }
Beispiel #3
0
        public ActionResult AddEditService2()
        {
            this.Internationalization();

            #region Edit
            using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope())
            {
                if (Request.Form["oper"].Equals("edit"))
                {
                    try
                    {
                        TugDataEntities db = new TugDataEntities();

                        int idx = Util.toint(Request.Form["OrderServiceID"].Trim());
                        int orderid = Util.toint(Request.Form["OrderID"].Trim());
                        var customerName = Request.Form["CustomerName"].Trim();
                        var shipName = Request.Form["ShipName"].Trim();
                        int customerid;// =  Util.toint(Request.Form["CustomerID"].Trim());
                        int shipid;//=  Util.toint(Request.Form["ShipID"].Trim());
                        //判断客户名称是否存在
                        System.Linq.Expressions.Expression<Func<Customer, bool>> expctm = u => u.Name1 == customerName;
                        Customer objctm = db.Customer.Where(expctm).FirstOrDefault();
                        if (objctm == null)
                        {
                            //throw new Exception("客戶名稱不存在!");
                            return Json(new { code = Resources.Common.ERROR_CODE, message = "客戶名稱不存在!" });
                        }
                        else
                            customerid = objctm.IDX;
                        //判断客户船名称是否存在//
                        System.Linq.Expressions.Expression<Func<CustomerShip, bool>> expcts = u => u.Name1 == shipName;
                        CustomerShip objcts = db.CustomerShip.Where(expcts).FirstOrDefault();
                        if (objcts == null)
                        {
                            //throw new Exception("客戶船名稱不存在!");
                            return Json(new { code = Resources.Common.ERROR_CODE, message = "客戶船名稱不存在!" });
                        }
                        else
                            shipid = objcts.IDX;
                        OrderService aOrderService = db.OrderService.Where(u => u.IDX == idx).FirstOrDefault();

                        if (aOrderService == null)
                        {
                            return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                        }
                        else
                        {
                            aOrderService.ServiceWorkDate = Request.Form["ServiceWorkDate"];
                            aOrderService.ServiceWorkTime = Request.Form["ServiceWorkTime"];
                            aOrderService.ServiceNatureID = TugBusinessLogic.Module.Util.toint(Request.Form["ServiceNatureID"]);
                            aOrderService.ServiceWorkPlace = Request.Form["ServiceWorkPlace"];

                            aOrderService.BigTugNum = Util.toint(Request.Form["BigTugNum"].Trim());
                            aOrderService.MiddleTugNum = Util.toint(Request.Form["MiddleTugNum"].Trim());
                            aOrderService.SmallTugNum = Util.toint(Request.Form["SmallTugNum"].Trim());

                            aOrderService.UserDefinedCol9 = Request.Form["TugIDs"];
                            aOrderService.UserDefinedCol10 = Request.Form["TugNames"];

                            aOrderService.OwnerID = -1;
                            aOrderService.UserID = Session.GetDataFromSession<int>("userid");

                            aOrderService.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                            db.Entry(aOrderService).State = System.Data.Entity.EntityState.Modified;
                            if (0 < db.SaveChanges()) //修改成功
                            {
                                //更新订单
                                OrderInfor aOrder = db.OrderInfor.Where(u => u.IDX == orderid).FirstOrDefault();
                                if (aOrder != null)
                                {
                                    aOrder.CustomerID = customerid;// Util.toint(Request.Form["CustomerID"].Trim());
                                    aOrder.CustomerName = Request.Form["CustomerName"].Trim();
                                    aOrder.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                    ////aOrder.IsGuest = Request.Form["IsGuest"].Trim();
                                    aOrder.LinkMan = Request.Form["LinkMan"].Trim();
                                    aOrder.LinkPhone = Request.Form["LinkPhone"].Trim();
                                    aOrder.LinkEmail = Request.Form["LinkEmail"].Trim();

                                    //aOrder.OrdDate = Request.Form["OrdDate"].Trim();
                                    aOrder.ShipID = shipid;//Util.toint(Request.Form["ShipID"].Trim());
                                    aOrder.ShipName = Request.Form["ShipName"].Trim();
                                    //aOrder.Remark = Request.Form["Remark"].Trim();

                                    //aOrder.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                                    //aOrder.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                                    //aOrder.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                                    //aOrder.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

                                    //if (Request.Form["UserDefinedCol5"].Trim() != "")
                                    //    aOrder.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                                    //if (Request.Form["UserDefinedCol6"].Trim() != "")
                                    //    aOrder.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                                    //if (Request.Form["UserDefinedCol7"].Trim() != "")
                                    //    aOrder.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                                    //if (Request.Form["UserDefinedCol8"].Trim() != "")
                                    //    aOrder.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                                    //aOrder.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim();
                                    //aOrder.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim();

                                    db.Entry(aOrder).State = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();
                                }
                                //1.先删除原有的调度
                                var oldSchedulers = db.Scheduler.Where(u => u.OrderServiceID == idx).ToList();
                                if (oldSchedulers != null)
                                {
                                    db.Scheduler.RemoveRange(oldSchedulers);
                                    if (0 < db.SaveChanges())
                                    {
                                        OrderService os = db.OrderService.FirstOrDefault(u => u.IDX == idx);
                                        os.JobStateID = 114;
                                        db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                                        db.SaveChanges();
                                    }
                                }

                                //2.插入新更改的调度
                                #region 插入多个调度到数据库
                                {
                                    if (aOrderService.UserDefinedCol9.Trim() != "")
                                    {
                                        List<string> lstTugIds = aOrderService.UserDefinedCol9.Split(',').ToList();
                                        if (lstTugIds != null && lstTugIds.Count > 0)
                                        {
                                            List<Scheduler> lstSchedulers = new List<Scheduler>();
                                            foreach (string item in lstTugIds)
                                            {
                                                TugDataModel.Scheduler aScheduler = new Scheduler();

                                                aScheduler.OrderServiceID = idx;

                                                aScheduler.TugID = Util.toint(item);

                                                aScheduler.RopeUsed = "";
                                                aScheduler.RopeNum = 0;
                                                aScheduler.Remark = "";

                                                aScheduler.IsCaptainConfirm = "";

                                                aScheduler.InformCaptainTime = "";
                                                aScheduler.CaptainConfirmTime = "";
                                                aScheduler.JobStateID = 32;

                                                aScheduler.OwnerID = -1;
                                                aScheduler.UserID = Session.GetDataFromSession<int>("userid");

                                                aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                                aScheduler.UserDefinedCol1 = "";
                                                aScheduler.UserDefinedCol2 = "";
                                                aScheduler.UserDefinedCol3 = "";
                                                aScheduler.UserDefinedCol4 = "";

                                                aScheduler.UserDefinedCol9 = "";
                                                aScheduler.UserDefinedCol10 = "";

                                                lstSchedulers.Add(aScheduler);
                                            }

                                            db.Scheduler.AddRange(lstSchedulers);
                                            if (0 < db.SaveChanges())
                                            {
                                                OrderService os = db.OrderService.FirstOrDefault(u => u.IDX == idx);
                                                os.JobStateID = 115;
                                                db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                                                db.SaveChanges();
                                            }
                                        }
                                    }
                                }
                                #endregion
                            }
                            trans.Complete();
                            return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                        }
                    }
                    catch (Exception ex)
                    {
                        trans.Dispose();
                        throw ex;
                        //return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
                    }
                }
            }
            #endregion Edit

            return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
        }
Beispiel #4
0
        public ActionResult AddScheduler2(int orderServiceId, string tugIds, string tugNames)
        {
            this.Internationalization();

            try
            {
                TugDataEntities db = new TugDataEntities();
                {
                    //1.先删除原有的调度
                    var oldSchedulers = db.Scheduler.Where(u => u.OrderServiceID == orderServiceId).ToList();
                    if (oldSchedulers != null)
                    {
                        db.Scheduler.RemoveRange(oldSchedulers);
                        if (0 < db.SaveChanges())
                        {
                            OrderService os = db.OrderService.FirstOrDefault(u => u.IDX == orderServiceId);
                            os.JobStateID = 114;
                            os.UserDefinedCol9 = tugIds;
                            os.UserDefinedCol10 = tugNames;
                            db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }

                    //2.插入新更改的调度
                    #region 插入多个调度到数据库
                    {
                        if (tugIds.Trim() != "")
                        {
                            List<string> lstTugIds = tugIds.Split(',').ToList();
                            if (lstTugIds != null && lstTugIds.Count > 0)
                            {
                                List<Scheduler> lstSchedulers = new List<Scheduler>();
                                foreach (string item in lstTugIds)
                                {
                                    TugDataModel.Scheduler aScheduler = new Scheduler();

                                    aScheduler.OrderServiceID = orderServiceId;

                                    aScheduler.TugID = Util.toint(item);

                                    aScheduler.RopeUsed = "";
                                    aScheduler.RopeNum = 0;
                                    aScheduler.Remark = "";

                                    aScheduler.IsCaptainConfirm = "";

                                    aScheduler.InformCaptainTime = "";
                                    aScheduler.CaptainConfirmTime = "";
                                    aScheduler.JobStateID = 32;

                                    aScheduler.OwnerID = -1;
                                    aScheduler.UserID = Session.GetDataFromSession<int>("userid");

                                    aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                    aScheduler.UserDefinedCol1 = "";
                                    aScheduler.UserDefinedCol2 = "";
                                    aScheduler.UserDefinedCol3 = "";
                                    aScheduler.UserDefinedCol4 = "";

                                    aScheduler.UserDefinedCol9 = "";
                                    aScheduler.UserDefinedCol10 = "";

                                    lstSchedulers.Add(aScheduler);
                                }

                                db.Scheduler.AddRange(lstSchedulers);
                                if (0 < db.SaveChanges())
                                {
                                    OrderService os = db.OrderService.FirstOrDefault(u => u.IDX == orderServiceId);
                                    os.JobStateID = 115;
                                    os.UserDefinedCol9 = tugIds;
                                    os.UserDefinedCol10 = tugNames;
                                    db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();
                                }
                            }
                        }
                    }
                    #endregion

                    var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                    //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                    return Json(ret);
                }
            }
            catch (Exception)
            {
                var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                return Json(ret);
            }
        }