当前位置: 首页>>代码示例>>C#>>正文


C# TugDataEntities.Entry方法代码示例

本文整理汇总了C#中TugDataModel.TugDataEntities.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# TugDataEntities.Entry方法的具体用法?C# TugDataEntities.Entry怎么用?C# TugDataEntities.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TugDataModel.TugDataEntities的用法示例。


在下文中一共展示了TugDataEntities.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AmountSumAdd_Update

        //这个Tuple类型数组的amountlist中依次存储 int SchedulerID, int TugID, float Amount, float Hours
        //一个账单调用一次
        public void AmountSumAdd_Update(int CustomerID, int CustomerShipID, int BillingID, DateTime BillingDate, Tuple<int, int, float, float>[] amountlist)
        {
            try
            {
                TugDataEntities db = new TugDataEntities();
                //先删除
                System.Linq.Expressions.Expression<Func<AmountSum, bool>> exp = u => u.BillingID == BillingID;
                var entitys = db.AmountSum.Where(exp);
                entitys.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                db.AmountSum.RemoveRange(entitys);
                db.SaveChanges();
                //新增
                foreach(var obj in amountlist)
                {
                    TugDataModel.AmountSum newobj = new AmountSum();
                    newobj.CustomerID = CustomerID;
                    newobj.CustomerShipID = CustomerShipID;
                    newobj.BillingID = BillingID;
                    newobj.BillingDateTime = BillingDate;
                    newobj.SchedulerID = obj.Item1;//SchedulerID;
                    newobj.TugID = obj.Item2;;
                    newobj.Amount = obj.Item3; ;
                    newobj.Hours = obj.Item4; ;
                    newobj.OwnerID = -1;
                    newobj.CreateDate = newobj.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ;//.ToString("yyyy-MM-dd");
                    newobj.UserID = Session.GetDataFromSession<int>("userid");
                    newobj.UserDefinedCol1 = "";
                    newobj.UserDefinedCol2 = "";
                    newobj.UserDefinedCol3 = "";
                    newobj.UserDefinedCol4 = "";
                    //if (Request.Form["UserDefinedCol5"].Trim() != "")
                    //    newobj.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

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

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

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

                    newobj.UserDefinedCol9 = "";
                    newobj.UserDefinedCol10 = "";

                    newobj = db.AmountSum.Add(newobj);
                }

                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 ex)
            {

                throw ex;
            }
        }
开发者ID:,项目名称:,代码行数:62,代码来源:

示例2: AddEditRowUser


//.........这里部分代码省略.........
                        userRole.AddUserID = Session.GetDataFromSession<int>("userid");
                        userRole.UserDefinedCol1 = Request.Form["UserDefinedCol1"];
                        userRole.UserDefinedCol2 = Request.Form["UserDefinedCol2"];
                        userRole.UserDefinedCol3 = Request.Form["UserDefinedCol3"];
                        userRole.UserDefinedCol4 = Request.Form["UserDefinedCol4"];

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

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

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

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

                        userRole.UserDefinedCol9 = Request.Form["UserDefinedCol9"];
                        userRole.UserDefinedCol10 = Request.Form["UserDefinedCol10"];

                        userRole = db.UsersRole.Add(userRole);
                        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"]);
                    UsersRole userRole = db.UsersRole.Where(u => u.IDX == idx).FirstOrDefault();

                    if (userRole == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    else
                    {
                        userRole.UserID = Util.toint(Request.Form["UserID"]);
                        userRole.RoleID = Util.toint(Request.Form["RoleID"]);
                        userRole.IsAdmin = Request.Form["IsAdmin"];
                        userRole.System = "Role";
                        userRole.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ;

                        userRole.OwnerID = -1;
                        userRole.AddUserID = Session.GetDataFromSession<int>("userid");
                        userRole.UserDefinedCol1 = Request.Form["UserDefinedCol1"];
                        userRole.UserDefinedCol2 = Request.Form["UserDefinedCol2"];
                        userRole.UserDefinedCol3 = Request.Form["UserDefinedCol3"];
                        userRole.UserDefinedCol4 = Request.Form["UserDefinedCol4"];

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

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

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

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

                        userRole.UserDefinedCol9 = Request.Form["UserDefinedCol9"];
                        userRole.UserDefinedCol10 = Request.Form["UserDefinedCol10"];

                        db.Entry(userRole).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 });
        }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: AddEditService2

        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() != "")
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: AddEditScheduler


//.........这里部分代码省略.........
                {
                    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 });
        }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例5: AddEdit


//.........这里部分代码省略.........
                        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());
                    OrderInfor aOrder = db.OrderInfor.Where(u => u.IDX == idx).FirstOrDefault();

                    if (aOrder == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    else
                    {
                        aOrder.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.WorkDate = Request.Form["WorkDate"].Trim();
                        //aOrder.WorkTime = Request.Form["WorkTime"].Trim();
                        //aOrder.EstimatedCompletionTime = Request.Form["EstimatedCompletionTime"].Trim();

                        aOrder.ShipID = Util.toint(Request.Form["ShipID"].Trim());
                        aOrder.ShipName = Request.Form["ShipName"].Trim();
                        //if (Request.Form["BigTugNum"].Trim() != "")
                        //    aOrder.BigTugNum = Util.toint(Request.Form["BigTugNum"].Trim());
                        //if (Request.Form["MiddleTugNum"].Trim() != "")
                        //    aOrder.MiddleTugNum = Util.toint(Request.Form["MiddleTugNum"].Trim());
                        //if (Request.Form["SmallTugNum"].Trim() != "")
                        //    aOrder.SmallTugNum = Util.toint(Request.Form["SmallTugNum"].Trim());
                        //aOrder.WorkPlace = Request.Form["WorkPlace"].Trim();

                        //Dictionary<string, string> dic = TugBusinessLogic.Utils.ResolveServices(Request.Form["ServiceNatureNames"].Trim());
                        //aOrder.ServiceNatureIDS = dic["ids"];
                        //aOrder.ServiceNatureNames = dic["labels"];

                        //aOrder.WorkStateID = Util.toint(Request.Form["WorkStateID"].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();

                        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 });
        }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例6: DeleteOrder_Service

        //删除拆分后的订单,一个订单一个服务
        public ActionResult DeleteOrder_Service()
        {
            this.Internationalization();
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    var f = Request.Form;

                    int orderid = Util.toint(Request.Form["data[OrderID]"]);
                    int orderserviceid = Util.toint(Request.Form["data[OrderServiceID]"]);

                    TugDataEntities db = new TugDataEntities();
                    //System.Linq.Expressions.Expression<Func<V_OrderService_Scheduler, bool>> exps = u => u.UserDefinedCol1 == ordermark;
                    //List<V_OrderService_Scheduler> schedulerInfor = db.V_OrderService_Scheduler.Where(exps).Select(u => u).ToList<V_OrderService_Scheduler>();
                    //if (schedulerInfor.Count != 0)
                    //{
                    //    return Json(new { code = Resources.Common.SUCCESS_CODE, message = "該訂單已排船,無法刪除!"});
                    //}
                    System.Linq.Expressions.Expression<Func<V_OrderService, bool>> exps = u => u.OrderID == orderid & (u.ServiceJobStateLabel == "已完工" || u.ServiceJobStateValue == "2");
                    List<V_OrderService> objs = db.V_OrderService.Where(exps).Select(u => u).ToList<V_OrderService>();
                    if (objs.Count != 0)
                    {
                        return Json(new { code = Resources.Common.SUCCESS_CODE, message = "該訂單的服务项已完工,無法刪除,如需刪除請先聯繫財務進行駁回操作!!" });//已完工
                    }
                    //获取服务项
                    System.Linq.Expressions.Expression<Func<OrderService, bool>> exp = u => u.OrderID == orderid;
                    List<OrderService> entityos = db.OrderService.Where(exp).ToList();

                    //先刪除該訂單下的排船信息
                    for (int i = 0; i < entityos.Count(); i++)
                    {
                        int ordsrvid = Util.toint(entityos[i].IDX);
                        System.Linq.Expressions.Expression<Func<Scheduler, bool>> exp0 = u => u.OrderServiceID == ordsrvid;
                        var entitysch = db.Scheduler.Where(exp0);
                        entitysch.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                        db.Scheduler.RemoveRange(entitysch);
                        db.SaveChanges();
                    }

                    //先删除订单下的所有服务项

                    entityos.ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                    db.OrderService.RemoveRange(entityos);
                    db.SaveChanges();

                    //删除订单
                    System.Linq.Expressions.Expression<Func<OrderInfor, bool>> exp2 = u => u.IDX == orderid;
                    var entityord = db.OrderInfor.Where(exp2);
                    entityord.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                    db.OrderInfor.RemoveRange(entityord);
                    db.SaveChanges();

                    trans.Complete();
                    return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });

                }
                catch (Exception)
                {
                    trans.Dispose();
                    return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
                }
            }
        }
开发者ID:,项目名称:,代码行数:65,代码来源:

示例7: Add_EditOrder

        public ActionResult Add_EditOrder(string oper,string ordermark,int customerId, string customerName, string ordDate,
            int shipId, string shipName, string linkMan, string linkPhone, string linkEmail, string remark,List<string[]> dataListFromTable)
        {
            //customerName中&符
            customerName = customerName.Replace("~*~", "&");
            TugDataModel.OrderInfor aOrder=null;
            this.Internationalization();

            using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope())
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();
                    {
                        //判断客户名称是否存在
                        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("客戶名稱不存在!");
                        }
                        //判断客户船名称是否存在
                        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("客戶船名稱不存在!");
                        }
                        //获取服务项
                        System.Linq.Expressions.Expression<Func<OrderService, bool>> exp = u => u.UserDefinedCol1 == ordermark;
                        List<OrderService> entityos = db.OrderService.Where(exp).ToList();

                        //先刪除該訂單下的排船信息
                        for (int i = 0; i < entityos.Count(); i++)
                        {
                            int ordsrvid = Util.toint(entityos[i].IDX);
                            System.Linq.Expressions.Expression<Func<Scheduler, bool>> exp0 = u => u.OrderServiceID == ordsrvid;
                            var entitysch = db.Scheduler.Where(exp0);
                            entitysch.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                            db.Scheduler.RemoveRange(entitysch);
                            db.SaveChanges();
                        }

                        //先删除订单下的所有服务项

                        entityos.ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                        db.OrderService.RemoveRange(entityos);
                        db.SaveChanges();

                        //删除订单
                        System.Linq.Expressions.Expression<Func<OrderInfor, bool>> exp2 = u => u.UserDefinedCol1 == ordermark;
                        var entityord = db.OrderInfor.Where(exp2);
                        entityord.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                        db.OrderInfor.RemoveRange(entityord);
                        db.SaveChanges();

                        //保存
                        //获取服务项
                        List<CustomField> listServ;
                        listServ = TugBusinessLogic.Utils.GetServices();
                        string mcode = TugBusinessLogic.Utils.AutoGenerateOrderSequenceNo();
                        for (int i = 0; i < dataListFromTable.Count - 1; i++)//最后一行空行
                        {
                            //保存订单
                            aOrder = new OrderInfor();
                            aOrder.Code = mcode;//TugBusinessLogic.Utils.AutoGenerateOrderSequenceNo();
                            aOrder.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            aOrder.HasInvoice = "否"; //没有账单
                            aOrder.HasInFlow = "否"; //没有在流程中
                            aOrder.IsGuest = "否";
                            //if (oper == "add")
                            //{
                            //    aOrder = new OrderInfor();
                            //    aOrder.Code = TugBusinessLogic.Utils.AutoGenerateOrderSequenceNo();
                            //    aOrder.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //    aOrder.HasInvoice = "否"; //没有账单
                            //    aOrder.HasInFlow = "否"; //没有在流程中
                            //    aOrder.IsGuest = "否";

                            //}
                            //else if (oper == "edit")
                            //{
                            //    aOrder = db.OrderInfor.Where(u => u.IDX == orderId).FirstOrDefault();

                            //}
                            aOrder.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            //aOrder.CustomerID = customerId;
                            aOrder.CustomerID = CustomerLogic.AutoAddCustomer("", customerName, "", "", linkMan, linkPhone, "", linkEmail, "", "", "", Session.GetDataFromSession<int>("userid"));
                            aOrder.CustomerName = customerName;
                            aOrder.OrdDate = ordDate;

                            aOrder.LinkMan = linkMan;
                            aOrder.LinkPhone = linkPhone;
                            aOrder.LinkEmail = linkEmail;

                            aOrder.OwnerID = -1;
                            aOrder.Remark = remark;
                            //aOrder.ShipID = shipId;
                            aOrder.ShipID = CustomerLogic.AutoAddCustomerShip((int)aOrder.CustomerID, shipName, "", "", "", "", "", "", "", "", Session.GetDataFromSession<int>("userid"));
                            aOrder.ShipName = shipName;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例8: ApproveReject

        public ActionResult ApproveReject(List<int> rejectdata, string RejectReason)
        {
            int curUserId;
            int BillingType = 0;
            TugDataEntities db = new TugDataEntities();
            curUserId = Session.GetDataFromSession<int>("userid");
            foreach (int id in rejectdata)
            {
                //更改Billing状态
                System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == id;
                Billing billInfor = db.Billing.Where(exp).FirstOrDefault();
                string billtype = billInfor.InvoiceType.ToString();
                if (billtype == "特殊账单") BillingType = 1;

                billInfor.Phase = 0;
                billInfor.Status = "被駁回";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, id, "否");

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = id;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = billInfor.Phase;
                addApprove.Task = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                addApprove.Accept = 0;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
            }
            return Json(new { message = "操作完成!" });
        }
开发者ID:,项目名称:,代码行数:38,代码来源:

示例9: ApprovePass

        public ActionResult ApprovePass(List<int> passdata)
        {
            //var ids = Request.Form["data"];
            int curUserId = 0;
            TugDataEntities db = new TugDataEntities();
            curUserId = Session.GetDataFromSession<int>("userid");
            foreach (int id in passdata)
            {
                System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == id;
                Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = id;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = billInfor.Phase;
                addApprove.Task = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                addApprove.Accept = 1;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();

                //判断是不是流程最后一步
                System.Linq.Expressions.Expression<Func<Flow, bool>> expFlow = u => u.BillingID == id && u.MarkID == billInfor.TimesNo;
                List<Flow> flowData = db.Flow.Where(expFlow).Select(u => u).ToList<Flow>();
                if (billInfor.Phase + 1 == flowData.Count)  //流程最后一步
                {
                    string billingCode = TugBusinessLogic.Utils.AutoGenerateBillCode();
                    //更改Billing状态
                    billInfor.Phase = -1;
                    billInfor.Status = "完成";
                    if (Util.checkdbnull(billInfor.BillingCode)=="") billInfor.BillingCode = billingCode;  //生成账单编号
                    billInfor.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    //若账单有回扣单生成回扣单编号
                     System.Linq.Expressions.Expression<Func<Credit, bool>> expCredit = u => u.BillingID == id;
                     List<Credit> tmpCredit = db.Credit.Where(expCredit).Select(u => u).ToList<Credit>();
                     //Credit tmpCredit = db.Credit.Where(expCredit).FirstOrDefault();
                     if (tmpCredit.Count  != 0)
                     {
                         foreach (var item in tmpCredit)
                         {
                             if (Util.checkdbnull(item.CreditCode) == "")
                             {
                                 item.CreditCode = "C" + billInfor.BillingCode.Substring(1, billingCode.Length - 1);
                                 db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                                 db.SaveChanges();
                             }

                         }
                     }
                }
                else
                {
                    //更改Billing状态
                    billInfor.Phase = billInfor.Phase + 1;
                    billInfor.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    billInfor.Status = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                    db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return Json(new { message = "审核完成!" });
        }
开发者ID:,项目名称:,代码行数:69,代码来源:

示例10: UpdateUserInfor

 public ActionResult UpdateUserInfor(string UserName)
 {
     TugDataEntities db = new TugDataEntities();
     System.Linq.Expressions.Expression<Func<UserInfor, bool>> exp = u => u.UserName == UserName;
     try
     {
         UserInfor user = db.UserInfor.Where(exp).FirstOrDefault();
         if (user != null)  //更新用户信息
         {
             user.Name1 = Request.Form["Name1"].ToString();
             user.Name2 = Request.Form["Name2"].ToString();
             user.Email = Request.Form["Email"].ToString();
             user.Tel = Request.Form["Tel"].ToString();
             user.Sex = Request.Form["Sex"].ToString();
             db.Entry(user).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return Json(new { message = "个人信息已更新!" });
         }
         else   //失败
         {
             return Json(new { message = "未找到当前用户信息!" });
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return Json(new { message = ex.Message });
         //throw;
     }
 }
开发者ID:,项目名称:,代码行数:30,代码来源:

示例11: SetHomePage

 public ActionResult SetHomePage(string controller, string action)
 {
     //string v = ControllerContext.RouteData.Values["action"].ToString();
     int curUserId = 0;
     TugDataEntities db = new TugDataEntities();
     curUserId = Session.GetDataFromSession<int>("userid");
     UserInfor objs = db.UserInfor.Where(u => u.IDX == curUserId).FirstOrDefault();
     //objs.UserDefinedCol1 = Session.GetDataFromSession<string>("HomePage");
     objs.UserDefinedCol2 = "/" + controller + "/" + action;
     db.Entry(objs).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return Json(new { message = "恁已設置當前頁為首頁!" });
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例12: SavePwd

 public ActionResult SavePwd()
 {
     string pwd = Request.Form["Pwd"].ToString();
     string newpwd = Request.Form["newPwd"].ToString();
     TugDataEntities db = new TugDataEntities();
     UserInfor newUser = new UserInfor();
     System.Linq.Expressions.Expression<Func<UserInfor, bool>> exp = u => u.UserName == User.Identity.Name && u.Pwd == pwd;
     UserInfor user = db.UserInfor.Where(exp).FirstOrDefault();
     if (user != null)    //原密码验证通过
     {
         user.Pwd = newpwd;
         db.Entry(user).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return Json(new { message = "新密码已生效,请重新登录!" });
     }
     else   //原密码错误
     {
         //Response.StatusCode = (int)HttpStatusCode.BadRequest;
         Response.StatusCode = 404;
         return Json(new { message = "原密码不正确,请重新输入!" });
     }
 }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例13: Delete

        public ActionResult Delete()
        {
            this.Internationalization();
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    var f = Request.Form;

                    int idx = Util.toint(Request.Form["data[IDX]"]);

                    TugDataEntities db = new TugDataEntities();
                    //先判断此客户是否已被使用过
                    OrderInfor obj = db.OrderInfor.FirstOrDefault(u => u.CustomerID == idx);
                    if (obj != null) throw new Exception("此客戶已在訂單中使用過,不能被刪除!");
                    //先删除客户船
                    System.Linq.Expressions.Expression<Func<CustomerShip, bool>> exp0 = u => u.CustomerID == idx;
                    var entitys = db.CustomerShip.Where(exp0);
                    entitys.ToList().ForEach(entity => db.Entry(entity).State = System.Data.Entity.EntityState.Deleted); //不加这句也可以
                    db.CustomerShip.RemoveRange(entitys);
                    db.SaveChanges();
                    //删除客户
                    Customer cstmer = db.Customer.FirstOrDefault(u => u.IDX == idx);
                    db.Customer.Remove(cstmer);
                    db.SaveChanges();
                    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 });
                }
            }
        }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例14: DeleteCustomerBillScheme

        public ActionResult DeleteCustomerBillScheme()
        {
            this.Internationalization();

            try
            {
                var f = Request.Form;

                int idx = Util.toint(Request.Form["data[BillingTemplateIDX]"]);

                TugDataEntities db = new TugDataEntities();
                //先判断此计费方案有没有被使用过
                Billing obj = db.Billing.FirstOrDefault(u => u.BillingTemplateID == idx);
                if (obj != null)
                {
                    //throw new Exception("此計費方案已在賬單中使用過,不能被刪除!");

                    BillingTemplate cstmer = db.BillingTemplate.FirstOrDefault(u => u.IDX == idx);

                    cstmer.UserDefinedCol6 = -1;
                    db.Entry(cstmer).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                }
                else
                {
                    BillingTemplate cstmer = db.BillingTemplate.FirstOrDefault(u => u.IDX == idx);
                    if (cstmer != null)
                    {
                        List<BillingItemTemplate> items = db.BillingItemTemplate.Where(u => u.BillingTemplateID == cstmer.IDX).ToList();
                        if (items != null)
                            db.BillingItemTemplate.RemoveRange(items);

                        db.BillingTemplate.Remove(cstmer);
                        db.SaveChanges();
                        return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                    }
                    else
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                }
            }
            catch (Exception ex)
            {
                //return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
                throw ex;
            }
        }
开发者ID:,项目名称:,代码行数:49,代码来源:

示例15: RepealPass

        public ActionResult RepealPass()
        {
            //int idx = Util.toint(Request.Form["data[IDX]"].Trim());
            var f = Request.Form;
            int BillingType = 0;
            int idx = Convert.ToInt32(Request.Form["data[IDX]"]);
            TugDataEntities db = new TugDataEntities();
            System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == idx;
            Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

            int Phase = Convert.ToInt32(billInfor.Phase);
            int timeNo = Convert.ToInt32(billInfor.TimesNo);
            int tmpUserID =  Convert.ToInt32(Request.Form["data[UserID]"]);
            int curUserId = Session.GetDataFromSession<int>("userid");
            string billtype = billInfor.InvoiceType.ToString();
            if (billtype == "特殊账单") BillingType = 1;

            System.Linq.Expressions.Expression<Func<Flow, bool>> expF = u => u.BillingID == idx && u.MarkID == timeNo && u.FlowUserID == curUserId;
            Flow flowData = db.Flow.Where(expF).FirstOrDefault();
            if (tmpUserID == curUserId)

            {
                return Json(new { message = "该记录是您的提交任务,您无法撤销通过!" });
            }
            else if (Phase > flowData.Phase + 1)  //流程已进入下一审核环节,不能撤销
            {
                var ret = new { code = Resources.Common.ERROR_CODE, message = "已进入下一审核环节,不能撤销!" };
                return Json(ret);
            }
            else
            {
                //更新Billing表状态
                billInfor.Phase = 0;
                billInfor.Status = "已撤销通过";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, idx, "否");

                //写入Approve表
                System.Linq.Expressions.Expression<Func<Approve, bool>> expA = u => u.BillingID == idx && u.FlowMark == timeNo && u.PersonID == curUserId;
                Approve approveInfor = db.Approve.Where(expA).FirstOrDefault(); //获取当前用户的审核信息

                Approve addApprove = new Approve();
                addApprove.BillingID = idx;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = approveInfor.Phase;
                addApprove.Task = approveInfor.Task;
                addApprove.Accept = 4;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
                return Json(new { message = "撤销成功!" });
            }
        }
开发者ID:,项目名称:,代码行数:59,代码来源:


注:本文中的TugDataModel.TugDataEntities.Entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。