示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctnModel"></param>
        /// <param name="userAccount"></param>
        /// <param name="ctnid"></param>
        /// <returns></returns>
        public bool AddHmCarton(CMS_ProductCTN_Model ctnModel, string userAccount, out long ctnid)
        {
            using (var db = new PermaisuriCMSEntities())
            {
                var hmnum = db.CMS_HMNUM.FirstOrDefault(h => h.ProductID == ctnModel.ProductID);
                if (hmnum == null)
                {
                    ctnid = 0;
                    return(false);
                }

                var newModel = new CMS_ProductCTN
                {
                    CTNComment = ctnModel.CTNComment,
                    CTNCube    = ctnModel.CTNCube,
                    CTNHeight  = ctnModel.CTNHeight,
                    CTNLength  = ctnModel.CTNLength,
                    CTNTitle   = ctnModel.CTNTitle,
                    CTNWidth   = ctnModel.CTNWidth,
                    HMNUM      = ctnModel.HMNUM,
                    ProductID  = ctnModel.ProductID,
                    UpdateBy   = userAccount,
                    UpdateOn   = DateTime.Now,
                    CreateOn   = DateTime.Now,
                    CTNWeight  = ctnModel.CTNWeight
                };

                db.CMS_ProductCTN.Add(newModel);

                hmnum.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync ?? (r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                {
                    StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                })).ForEach(k =>
                {
                    k.StatusID   = 0;
                    k.StatusDesc = "NeedSend";
                    k.UpdateBy   = userAccount;
                    k.UpdateOn   = DateTime.Now;
                });

                BllExtention.DbRecorder(new LogOfUserOperatingDetails
                {
                    ModelName    = ModelName,
                    ActionName   = MethodBase.GetCurrentMethod().Name,
                    ActionType   = LogActionTypeEnum.Inert.GetHashCode(),
                    ProductID    = hmnum.ProductID,
                    HMNUM        = hmnum.HMNUM,
                    Descriptions = "Add new carton  [ <b>" + newModel.CTNTitle + " </b>] for " + hmnum.HMNUM,
                    CreateBy     = userAccount,
                    CreateOn     = DateTime.Now
                });


                var retVal = db.SaveChanges();
                ctnid = newModel.CTNID;
                return(retVal > 0);
            }
        }
示例#2
0
        public bool EditHmCartons(IEnumerable <CMS_ProductCTN_Model> ctnList, string userAccount)
        {
            if (ctnList == null)
            {
                throw new ArgumentNullException("ctnList");
            }

            using (var db = new PermaisuriCMSEntities())
            {
                var retVal = 0;
                foreach (var model in ctnList)
                {
                    var ctn = db.CMS_ProductCTN.FirstOrDefault(c => c.CTNID == model.CTNID);
                    if (ctn != null)
                    {
                        ctn.CTNCube    = model.CTNCube;
                        ctn.CTNLength  = model.CTNLength;
                        ctn.CTNWidth   = model.CTNWidth;
                        ctn.CTNHeight  = model.CTNHeight;
                        ctn.CTNComment = model.CTNComment;
                        ctn.UpdateBy   = userAccount;
                        ctn.CTNWeight  = model.CTNWeight;//新增重量信息 2014年3月6日


                        ctn.CMS_HMNUM.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync ?? (r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                        {
                            StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                        })).ForEach(k =>
                        {
                            k.StatusID   = 0;
                            k.StatusDesc = "NeedSend";
                            k.UpdateBy   = userAccount;
                            k.UpdateOn   = DateTime.Now;
                        });

                        var entry = db.Entry(ctn);
                        BllExtention.DbRecorder(entry, new LogOfUserOperatingDetails
                        {
                            ModelName  = ModelName,
                            ActionName = MethodBase.GetCurrentMethod().Name,
                            ActionType = LogActionTypeEnum.Update.GetHashCode(),
                            ProductID  = ctn.ProductID,
                            HMNUM      = ctn.HMNUM,
                            CreateBy   = userAccount,
                            CreateOn   = DateTime.Now
                        });


                        ctn.UpdateOn = DateTime.Now;
                    }


                    retVal = db.SaveChanges();//如果上面的几个Value都没有改变,则返回的值还是0 2013年11月15日17:20:03
                }
                return(retVal > 0);
            }
        }
示例#3
0
        /// <summary>
        /// 编辑HM#基本信息,用于HMNUM Configuration页面
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userAccount"></param>
        /// <returns></returns>
        public bool EditHmBasicInfo(CMS_HMNUM_Model model, string userAccount)
        {
            using (var db = new PermaisuriCMSEntities())
            {
                var hmnum = db.CMS_HMNUM.FirstOrDefault(h => h.ProductID == model.ProductID);
                if (hmnum == null)
                {
                    return(db.SaveChanges() > 0);
                }
                hmnum.StockKey      = model.StockKey;
                hmnum.Comments      = model.Comments;
                hmnum.StatusID      = model.StatusID;
                hmnum.ShipViaTypeID = model.ShipViaTypeID;
                hmnum.NetWeight     = model.NetWeight;
                hmnum.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync ?? (r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                {
                    StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                })).ForEach(k =>
                {
                    k.StatusID   = 0;
                    k.StatusDesc = "NeedSend";
                    k.UpdateBy   = userAccount;
                    k.UpdateOn   = DateTime.Now;
                });

                var entry = db.Entry(hmnum);
                BllExtention.DbRecorder(entry, new LogOfUserOperatingDetails
                {
                    ModelName  = ModelName,
                    ActionName = MethodBase.GetCurrentMethod().Name,
                    ActionType = LogActionTypeEnum.Update.GetHashCode(),
                    ProductID  = hmnum.ProductID,
                    HMNUM      = hmnum.HMNUM,
                    CreateBy   = userAccount,
                    CreateOn   = DateTime.Now
                });

                hmnum.ModifyBy = userAccount;
                hmnum.ModifyOn = DateTime.Now;


                return(db.SaveChanges() > 0);
            }
        }
        /// <summary>
        /// 2014年3月14日
        /// </summary>
        /// <param name="ProductID"></param>
        /// <param name="ChildrenProductID"></param>
        /// <param name="SellSets"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool UpdateSellSets(long ProductID, long ChildrenProductID, int SellSets, User_Profile_Model user)
        {
            using (PermaisuriCMSEntities db = new PermaisuriCMSEntities())
            {
                var relation = db.CMS_HMGroup_Relation.FirstOrDefault(h => h.ProductID == ProductID && h.ChildrenProductID == ChildrenProductID);
                if (relation == null)
                {
                    return(false);
                }

                StringBuilder sb = new StringBuilder();
                sb.Append(" <b> [sub-HMNUM=" + relation.CMS_HMNUM_Children.HMNUM + ", SellSets:] </b> : old value =  <span style='color:red'>  " + relation.SellSets + " </span> , new Value = <span style='color:red'>  " + SellSets + "  </span>");
                sb.Append("<br>");

                relation.SellSets = SellSets;

                relation.CMS_HMNUM.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync == null ? r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                {
                    StatusID = 1 //这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                } : r.CMS_SKU.CMS_Ecom_Sync).ForEach(k =>
                {
                    k.StatusID   = 0;
                    k.StatusDesc = "NeedSend";
                    k.UpdateBy   = user.User_Account;
                    k.UpdateOn   = DateTime.Now;
                });


                BllExtention.DbRecorder(new LogOfUserOperatingDetails
                {
                    ModelName    = Model_Name,
                    ActionName   = MethodBase.GetCurrentMethod().Name,
                    ActionType   = LogActionTypeEnum.Inert.GetHashCode(),
                    ProductID    = relation.ProductID,
                    HMNUM        = relation.CMS_HMNUM.HMNUM,
                    Descriptions = sb.ToString(),
                    CreateBy     = user.User_Account,
                    CreateOn     = DateTime.Now
                });

                return(db.SaveChanges() > -1);
            }
        }
        /// <summary>
        /// 编辑HM#基本信息,用于HMNUM Configuration页面
        /// </summary>
        /// <param name="model"></param>
        /// <param name="User_Account"></param>
        /// <returns></returns>
        public bool EditHMBasicInfo(CMS_HMNUM_Model model, string User_Account)
        {
            using (PermaisuriCMSEntities db = new PermaisuriCMSEntities())
            {
                var HMNUM = db.CMS_HMNUM.FirstOrDefault(h => h.ProductID == model.ProductID);
                HMNUM.StockKey = model.StockKey;
                HMNUM.Comments = model.Comments;


                HMNUM.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync == null ? r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                {
                    StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                } : r.CMS_SKU.CMS_Ecom_Sync).ForEach(k =>
                {
                    k.StatusID   = 0;
                    k.StatusDesc = "NeedSend";
                    k.UpdateBy   = User_Account;
                    k.UpdateOn   = DateTime.Now;
                });


                var entry = db.Entry(HMNUM);
                BllExtention.DbRecorder(entry, new LogOfUserOperatingDetails
                {
                    ModelName  = Model_Name,
                    ActionName = MethodBase.GetCurrentMethod().Name,
                    ActionType = LogActionTypeEnum.Update.GetHashCode(),
                    ProductID  = HMNUM.ProductID,
                    HMNUM      = HMNUM.HMNUM,
                    CreateBy   = User_Account,
                    CreateOn   = DateTime.Now
                });

                HMNUM.ModifyBy = User_Account;
                HMNUM.ModifyOn = DateTime.Now;



                return(db.SaveChanges() > 0);
            }
        }
示例#6
0
        /// <summary>
        /// 更新HMNUMCosting的信息,用于HMNUM Configuration页面的的Costing的编辑更新
        /// 需要注意的是每一次的跟新都将在库表新增一条价格信息,影响将来报表的生成。
        /// 虽然和HMNUMController页面的方法一样,但是还是分开维护,因为2个展示有可能不同,遇到需求变动会变得痛苦!
        /// </summary>
        /// <param name="model"></param>
        /// <param name="costing">输入输出参数,输入时候代表客户端需要更新的价格传递给服务器,输出代表价格跟新后在数据库的实际存储方式。比如,客户端输入10个小数点的数字后....</param>
        /// <param name="userAccount"></param>
        /// <returns></returns>
        public bool EditHmnumCosting(CMS_HMNUM_Model model, ref CMS_HM_Costing_Model costing, string userAccount)
        {
            //逻辑:先讲当前最新的价格插入到Costing表(注意是新增不是编辑),然后更新当前HMNUM的Costing信息,取最新的那条。
            //EF本身自带有Transaction功能。
            using (var db = new PermaisuriCMSEntities())
            {
                var newCosting = new CMS_HM_Costing
                {
                    CreateBy        = userAccount,
                    CreateOn        = DateTime.Now,
                    EffectiveDate   = DateTime.Now,
                    HMNUM           = costing.HMNUM, // out: use unsigned parameter costing....2013年11月14日11:25:25
                    FirstCost       = Convert.ToDecimal(costing.FirstCost),
                    LandedCost      = Convert.ToDecimal(costing.LandedCost),
                    EstimateFreight = Convert.ToDecimal(costing.EstimateFreight),

                    OceanFreight      = Convert.ToDecimal(costing.OceanFreight),
                    USAHandlingCharge = Convert.ToDecimal(costing.USAHandlingCharge),
                    Drayage           = Convert.ToDecimal(costing.Drayage),
                };

                //db.CMS_HM_Costing.Add(newCosting);
                //long newCostID = newCosting.HMCostID;

                var hmnum = db.CMS_HMNUM.FirstOrDefault(h => h.ProductID == model.ProductID);

                //HMNUM.HMCostID = newCostID;
                if (hmnum != null)
                {
                    hmnum.CMS_HM_Costing = newCosting;

                    hmnum.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync ?? (r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync {
                        StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                    })).ForEach(k =>
                    {
                        k.StatusID   = 0;
                        k.StatusDesc = "NeedSend";
                        k.UpdateBy   = userAccount;
                        k.UpdateOn   = DateTime.Now;
                    });


                    var sb = new StringBuilder();
                    sb.Append(" <b> [FirstCost] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.FirstCost + " </span> , new Value = <span style='color:red'>  " + newCosting.FirstCost + "  </span>");
                    sb.Append("<br>");

                    sb.Append(" <b> [LandedCost] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.LandedCost + " </span> , new Value = <span style='color:red'>  " + newCosting.LandedCost + "  </span>");
                    sb.Append("<br>");

                    sb.Append(" <b> [EstimateFreight] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.EstimateFreight + " </span> , new Value = <span style='color:red'>  " + newCosting.EstimateFreight + "  </span>");

                    sb.Append(" <b> [OceanFreight] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.OceanFreight + " </span> , new Value = <span style='color:red'>  " + newCosting.OceanFreight + "  </span>");

                    sb.Append(" <b> [USAHandlingCharge] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.USAHandlingCharge + " </span> , new Value = <span style='color:red'>  " + newCosting.USAHandlingCharge + "  </span>");

                    sb.Append(" <b> [Drayage] </b> : old value =  <span style='color:red'>  " + hmnum.CMS_HM_Costing.Drayage + " </span> , new Value = <span style='color:red'>  " + newCosting.Drayage + "  </span>");
                    sb.Append("<br>");

                    BllExtention.DbRecorder(new LogOfUserOperatingDetails
                    {
                        ModelName    = ModelName,
                        ActionName   = MethodBase.GetCurrentMethod().Name,
                        ActionType   = LogActionTypeEnum.Inert.GetHashCode(),
                        ProductID    = hmnum.ProductID,
                        HMNUM        = hmnum.HMNUM,
                        Descriptions = sb.ToString(),
                        CreateBy     = userAccount,
                        CreateOn     = DateTime.Now
                    });

                    db.SaveChanges();

                    newCosting.HisProductID = hmnum.ProductID;
                }
                var retVal = db.SaveChanges();
                costing.FirstCost       = newCosting.FirstCost.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));
                costing.LandedCost      = newCosting.LandedCost.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));
                costing.EstimateFreight = newCosting.EstimateFreight.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));

                costing.OceanFreight      = newCosting.OceanFreight.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));
                costing.USAHandlingCharge = newCosting.USAHandlingCharge.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));
                costing.Drayage           = newCosting.Drayage.ConvertToNotNull().ToString("C", new CultureInfo("en-US"));

                return(retVal > 0);
            }
        }