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


C# TugDataEntities.SaveChanges方法代码示例

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


在下文中一共展示了TugDataEntities.SaveChanges方法的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: AddCustomData

 public ActionResult AddCustomData(string CustomName, string CustomValue)
 {
     this.Internationalization();
     TugDataEntities db = new TugDataEntities();
     try
     {
     System.Linq.Expressions.Expression<Func<CustomField, bool>> exp = u => u.CustomName == CustomName && u.CustomLabel == CustomValue;
     CustomField tmpCustom = db.CustomField.Where(exp).FirstOrDefault();
     if (tmpCustom != null)
     {
         throw new Exception(CustomValue + "已存在!");
     }
     CustomField custom = new CustomField();
     custom.CustomName = CustomName;
     custom.CustomValue = "";
     custom.CustomLabel = CustomValue;
     custom.Description = "";
     custom.UserID = Session.GetDataFromSession<int>("userid");
     custom.CreateDate = custom.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     custom = db.CustomField.Add(custom);
         db.SaveChanges();
      return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: AddCredit

        public ActionResult AddCredit(int billingId, string billingCode, string creditContent, double creditAmount, string creditdate, string remark)
        {
            TugDataModel.Credit credit;
            this.Internationalization();
            try
            {
                TugDataEntities db = new TugDataEntities();
                {
                    credit = new Credit();

                    credit.BillingID = billingId;
                    credit.CreditCode = "C" +  billingCode.Substring(1, billingCode.Length - 1 );
                    credit.CreditContent = creditContent;
                    credit.CreditAmount = creditAmount;
                    credit.UserDefinedCol10 = creditdate;
                    credit.Remark = remark;
                    credit.CreateDate = credit.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    credit.OwnerID = -1;
                    credit.UserID = credit.UserID = Session.GetDataFromSession<int>("userid");

                    //credit.UserDefinedCol1 = "";
                    //credit.UserDefinedCol2 = "";
                    //credit.UserDefinedCol3 = "";
                    //credit.UserDefinedCol4 = "";
                    //credit.UserDefinedCol5 = 0;
                    //credit.UserDefinedCol6 = 0;
                    //credit.UserDefinedCol7 = 0;
                    //credit.UserDefinedCol8 = 0;

                    //credit.UserDefinedCol9 = "";
                    //credit.UserDefinedCol10 = "";

                    credit = db.Credit.Add(credit);
                    db.SaveChanges();

                    //更新账单中的回扣金额
                    {
                        TugBusinessLogic.Module.FinanceLogic.UpdateTotalRebateOfBilling(billingId);
                    }

                }

                var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE, billing_id = credit.IDX };
                return Json(ret, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                return Json(ret, JsonRequestBehavior.AllowGet);
            }
        }
开发者ID:,项目名称:,代码行数:51,代码来源:

示例4: Delete

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

            try
            {
                var f = Request.Form;

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

                TugDataEntities db = new TugDataEntities();
                CustomField custom = db.CustomField.FirstOrDefault(u => u.IDX == idx);
                if (custom != null)
                {
                    db.CustomField.Remove(custom);
                    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)
            {
                return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
            }
        }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例5: AddEditCustomerBillScheme

        public ActionResult AddEditCustomerBillScheme(int custId)
        {
            //this.Internationalization();

            #region Add

            if (Request.Form["oper"].Equals("add"))
            {
                try
                {
                    //重名了
                    if (true == CheckBillingTemplateName(custId, Request.Form["BillingTemplateName"].Trim(), -1))
                    {
                        return Json(new { code = Resources.Common.FAIL_CODE, message = Resources.Common.FAIL_MESSAGE });
                    }
                    else
                    {
                        TugDataEntities db = new TugDataEntities();
                        {
                            TugDataModel.BillingTemplate cstmer = new BillingTemplate();

                            cstmer.BillingTemplateCode = Request.Form["BillingTemplateCode"].Trim();
                            cstmer.BillingTemplateName = Request.Form["BillingTemplateName"].Trim();
                            cstmer.BillingTemplateTypeID = Util.toint(Request.Form["BillingTemplateTypeID"].Trim());

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

                            cstmer.CustomerID = custId; // Convert.ToInt32(customerId);
                            cstmer.TemplateCreditContent = Request.Form["TemplateCreditContent"].Trim();
                            cstmer.TimeTypeID = Util.toint(Request.Form["TimeTypeID"].Trim());

                            cstmer.Discount = Convert.ToDouble(Request.Form["Discount"].Trim());

                            cstmer.Remark = Request.Form["Remark"].Trim();
                            cstmer.OwnerID = -1;
                            cstmer.UserID = Session.GetDataFromSession<int>("userid");
                            cstmer.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                            cstmer.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                            cstmer.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                            cstmer.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

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

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

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

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

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

                            cstmer = db.BillingTemplate.Add(cstmer);
                            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["BillingTemplateIDX"]);
                    BillingTemplate cstmer = db.BillingTemplate.Where(u => u.IDX == idx).FirstOrDefault();

                    if (cstmer == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    //重名了
                    if (true == CheckBillingTemplateName(Util.toint(Request.Form["CustomerID"].Trim()), Request.Form["BillingTemplateName"].Trim(), idx))
                    {
                        return Json(new { code = Resources.Common.FAIL_CODE, message = Resources.Common.FAIL_MESSAGE });
                    }
                    else
                    {
                        cstmer.BillingTemplateCode = Request.Form["BillingTemplateCode"].Trim();
                        cstmer.BillingTemplateName = Request.Form["BillingTemplateName"].Trim();
                        cstmer.BillingTemplateTypeID = Util.toint(Request.Form["BillingTemplateTypeID"].Trim());
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例6: 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,代码来源:

示例7: RepealSubmit

        public ActionResult RepealSubmit(Billing data)
        {
            int id = data.IDX;
            int BillingType = 0;
            int idx = Util.toint(Request.Form["data[IDX]"].Trim());
            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 curUserId = Session.GetDataFromSession<int>("userid");
            if (Phase > 1 || 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();

                string billtype = billInfor.InvoiceType.ToString();
                if (billtype == "特殊账单") BillingType = 1;

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

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = idx;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = 0;
                addApprove.Task = "创建";
                addApprove.Accept = 3;
                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:,项目名称:,代码行数:47,代码来源:

示例8: AddEdit

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

            #region Add

            if (Request.Form["oper"].Equals("add"))
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();
                    {
                        TugDataModel.OrderInfor aOrder = new OrderInfor();

                        aOrder.Code = TugBusinessLogic.Utils.AutoGenerateOrderSequenceNo();

                        aOrder.CreateDate = aOrder.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        aOrder.CustomerID = Util.toint(Request.Form["CustomerID"]);
                        aOrder.CustomerName = Request.Form["CustomerName"].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.IsGuest = "否"; // Request.Form["IsGuest"].Trim();
                        aOrder.LinkMan = Request.Form["LinkMan"].Trim();
                        aOrder.LinkPhone = Request.Form["LinkPhone"].Trim();
                        aOrder.LinkEmail = Request.Form["LinkEmail"].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.OwnerID = -1;
                        aOrder.Remark = Request.Form["Remark"].Trim();
                        aOrder.ShipID = Util.toint(Request.Form["ShipID"].Trim());
                        aOrder.ShipName = Request.Form["ShipName"].Trim();
                        aOrder.UserID = Session.GetDataFromSession<int>("userid");
                        //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.WorkStateID = 2; //CustomField表里面的OrderInfor.WorkStateID的IDX

                        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();

                        aOrder = db.OrderInfor.Add(aOrder);
                        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());
                    OrderInfor aOrder = db.OrderInfor.Where(u => u.IDX == idx).FirstOrDefault();

                    if (aOrder == null)
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例9: AddEditScheduler

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

示例10: 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,代码来源:

示例11: 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,代码来源:

示例12: AddCustomer

        public ActionResult AddCustomer(string Code,string Name1,string Name2,string SimpleName,string ContactPerson,
            string Telephone, string Fax, string Email, string Address, string MailCode, string Remark)
        {
            this.Internationalization();
            try
            {
                TugDataEntities db = new TugDataEntities();
                System.Linq.Expressions.Expression<Func<Customer, bool>> exp = u => u.Name1 == Name1;
                Customer obj = db.Customer.Where(exp).FirstOrDefault();
                if (obj != null)
                {
                    throw new Exception("客户名称已存在!");
                }
                {
                    TugDataModel.Customer cstmer = new Customer();

                    cstmer.Code = Code;
                    cstmer.Name1 = Name1;
                    cstmer.Name2 = Name2;
                    cstmer.SimpleName = SimpleName;
                    cstmer.ContactPerson = ContactPerson;
                    cstmer.Telephone = Telephone;
                    cstmer.Fax = Fax;
                    cstmer.Email = Email;
                    cstmer.Address = Address;
                    cstmer.MailCode = MailCode;
                    cstmer.Remark = Remark;
                    cstmer.OwnerID = -1;
                    cstmer.CreateDate = cstmer.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ;//.ToString("yyyy-MM-dd");
                    cstmer.UserID = Session.GetDataFromSession<int>("userid");
                    cstmer.UserDefinedCol1 = "";
                    cstmer.UserDefinedCol2 = "";
                    cstmer.UserDefinedCol3 = "";
                    cstmer.UserDefinedCol4 = "";
                    //if (Request.Form["UserDefinedCol5"].Trim() != "")
                    //    cstmer.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

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

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

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

                    cstmer.UserDefinedCol9 = "";
                    cstmer.UserDefinedCol10 = "";

                    cstmer = db.Customer.Add(cstmer);
                    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,代码来源:

示例13: AddCustomerBillSchemeItem

        public ActionResult AddCustomerBillSchemeItem(int billingTemplateId, int itemId, string unitPrice, string currency, int typeId)
        {
            this.Internationalization();

            try
            {
                TugDataEntities db = new TugDataEntities();
                {
                    TugDataModel.BillingItemTemplate aScheduler = new BillingItemTemplate();
                    aScheduler.BillingTemplateID = billingTemplateId;
                    aScheduler.ItemID = itemId;
                    aScheduler.UnitPrice = Convert.ToDouble(unitPrice);
                    aScheduler.Currency = currency;
                    aScheduler.TypeID = typeId;

                    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"] != "")
                    //    aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]);

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

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

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

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

                    aScheduler = db.BillingItemTemplate.Add(aScheduler);
                    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)
            {
                var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                return Json(ret);
            }
            return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
        }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例14: Delete_LinkMan

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

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

                    TugDataEntities db = new TugDataEntities();

                    //删除聯繫人
                    LinkMan cstmer = db.LinkMan.FirstOrDefault(u => u.IDX == idx);
                    db.LinkMan.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:,项目名称:,代码行数:28,代码来源:

示例15: DeleteCustomerBillSchemeItem

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

            try
            {
                var f = Request.Form;

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

                TugDataEntities db = new TugDataEntities();
                //Billing obj = db.Billing.FirstOrDefault(u => u.BillingTemplateID == billingTemplateID);
                //if (obj != null)
                //    throw new Exception("此計費方案项目已在賬單中使用過,不能被刪除!");
                //else
                {
                    BillingItemTemplate aScheduler = db.BillingItemTemplate.FirstOrDefault(u => u.IDX == idx);
                    if (aScheduler != null)
                    {
                        db.BillingItemTemplate.Remove(aScheduler);
                        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)
            {
                throw ex;
                //return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
            }
        }
开发者ID:,项目名称:,代码行数:36,代码来源:


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