示例#1
0
        private void Test(MemberOrganization oOrgan, MemberChannel oChannel, ProductOnTemplate oTemplate,
            ProductInformation oProduct, List<Object> oItemList = null)
        {
            Debug.WriteLine(oOrgan.Code);
            Debug.WriteLine(oChannel.Code);
            Debug.WriteLine(oTemplate.Code);
            Debug.WriteLine(oProduct.Code + oProduct.Name.Matter);
            foreach (Dictionary<string, object> item in oItemList)
            {
                Debug.WriteLine(item["Status"].ToString());

                ProductInfoItem oInfoItem = (ProductInfoItem)item["SkuItem"];
                Debug.WriteLine(oInfoItem.Code + oInfoItem.FullName.Matter);

                GeneralMeasureUnit oUnit = (GeneralMeasureUnit)item["Unit"];
                Debug.WriteLine(oUnit.Code);

                GeneralMeasureUnit oCurrency1 = (GeneralMeasureUnit)item["Currency1"];
                if (oCurrency1 != null)
                    Debug.WriteLine(oCurrency1.Code);
            }
        }
示例#2
0
        public void ProductWarehouse()
        {
            using (var oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection))
            {
                MemberOrganization oOrgan = oLiveEntities.MemberOrganizations.Where(o => o.Code == "Zhuchao").Single();
                MemberUser oUser = oLiveEntities.MemberUsers.Where(u => u.LoginName == "admin").Single();

                ProductInformation oProduct = new ProductInformation
                {
                    Organization = oOrgan,
                    Code = "6001002",
                    Name = new GeneralResource
                    {
                        Matter = "产品名称"
                    },
                    SkuItems = new List<ProductInfoItem>
                    {
                        new ProductInfoItem
                        {
                            Organization = oOrgan,
                            Code = "6001002001",
                            Barcode = "6001002001"
                        },
                        new ProductInfoItem
                        {
                            Organization = oOrgan,
                            Code = "6001002002",
                            Barcode = "6001002002"
                        }
                    }
                };

                oLiveEntities.ProductInformations.Add(oProduct);
                oLiveEntities.SaveChanges();
            }
        }
示例#3
0
 /// <summary>
 /// 测试ProductOnUnitPrice
 /// </summary>
 /// <returns>新建的ProductOnUnitPrice对象</returns>
 public ProductOnUnitPrice ProductOnUnitPriceTest()
 {
     MemberOrganization oOrg = new MemberOrganization
     {
         Code = GetRandCode()
     };
     oLiveEntities.MemberOrganizations.Add(oOrg);
     oLiveEntities.SaveChanges();
     GeneralResource oName = new GeneralResource { };
     oLiveEntities.GeneralResources.Add(oName);
     oLiveEntities.SaveChanges();
     ProductInformation oProduct = new ProductInformation
     {
         Organization = oOrg,
         Code = GetRandCode(),
         Name = oName
     };
     oLiveEntities.ProductInformations.Add(oProduct);
     oLiveEntities.SaveChanges();
     ProductInfoItem oProductInfoItem = new ProductInfoItem
     {
         Organization = oOrg,
         Product = oProduct,
         Code = GetRandCode()
     };
     oLiveEntities.ProductInfoItems.Add(oProductInfoItem);
     oLiveEntities.SaveChanges();
     ProductOnItem oPOI = new ProductOnItem
     {
         OnSale = ProductOnSaleTest(),
         SkuItem = oProductInfoItem
     };
     oLiveEntities.ProductOnItems.Add(oPOI);
     oLiveEntities.SaveChanges();
     GeneralMeasureUnit oGMU = new GeneralMeasureUnit
     {
         Code = GetRandCode()
     };
     oLiveEntities.GeneralMeasureUnits.Add(oGMU);
     oLiveEntities.SaveChanges();
     ProductOnUnitPrice oPUP = new ProductOnUnitPrice
     {
         OnSkuItem = oPOI,
         ShowUnit = oGMU
     };
     oLiveEntities.ProductOnUnitPrices.Add(oPUP);
     oLiveEntities.SaveChanges();
     return oPUP;
 }
示例#4
0
        /// <summary>
        /// 导入商品定义,包括PU和SKU
        /// </summary>
        /// <param name="sExcelFile">Excel文件名</param>
        /// <param name="sSheetName">Sheet名</param>
        public void ImportProduct(string sExcelFile, string sSheetName)
        {
            try
            {
                ExcelData oExcel = new ExcelData(sExcelFile, sSheetName);
                DataColumn colOrgan = oExcel.ExcelTable.Columns["组织"];
                DataColumn colProdCode = oExcel.ExcelTable.Columns["PU代码"];
                DataColumn colSkuCode = oExcel.ExcelTable.Columns["SKU代码"];
                DataColumn colBarcode = oExcel.ExcelTable.Columns["条码"];
                DataColumn colExCode1 = oExcel.ExcelTable.Columns["自定义编码"];
                DataColumn colProdNameCN = oExcel.ExcelTable.Columns["PU中文名称"];
                DataColumn colSkuNameCN = oExcel.ExcelTable.Columns["SKU中文名称"];
                DataColumn colStdCat = oExcel.ExcelTable.Columns["标准分类"];
                DataColumn colPrvCat = oExcel.ExcelTable.Columns["私有分类"];
                DataColumn colBlock = oExcel.ExcelTable.Columns["拆单分组标志"];
                DataColumn colMode = oExcel.ExcelTable.Columns["产品模式"];
                DataColumn colUnitType = oExcel.ExcelTable.Columns["单位类型"];
                DataColumn colUnitCode = oExcel.ExcelTable.Columns["单位代码"];
                DataColumn colPercision = oExcel.ExcelTable.Columns["计量精度"];
                DataColumn colSpecification = oExcel.ExcelTable.Columns["规格"];
                DataColumn colProdPicture = oExcel.ExcelTable.Columns["主图路径"];
                DataColumn colBriefCN = oExcel.ExcelTable.Columns["简单描述"];
                DataColumn colIntroCN = oExcel.ExcelTable.Columns["详细描述"];
                DataColumn colMinQuantity = oExcel.ExcelTable.Columns["起订量"];
                DataColumn colCycle = oExcel.ExcelTable.Columns["生产周期"];
                DataColumn colGuarantee = oExcel.ExcelTable.Columns["保质期"];
                DataColumn colMarketPriceRMB = oExcel.ExcelTable.Columns["市场价¥"];
                DataColumn colSuggestPriceRMB = oExcel.ExcelTable.Columns["建议价¥"];
                DataColumn colLowestPriceRMB = oExcel.ExcelTable.Columns["最低价¥"];
                DataColumn colKeywords = oExcel.ExcelTable.Columns["关键词"];
                DataColumn colGrossWeight = oExcel.ExcelTable.Columns["毛重"];
                DataColumn colNetWeight = oExcel.ExcelTable.Columns["净重"];
                DataColumn colGrossVolume = oExcel.ExcelTable.Columns["毛体积"];
                DataColumn colNetVolume = oExcel.ExcelTable.Columns["净体积"];
                DataColumn colNetPiece = oExcel.ExcelTable.Columns["计件"];
                DataColumn colRemark = oExcel.ExcelTable.Columns["备注"];

                ProductInformation oProduct = null;
                MemberOrganization oOrgan = null;
                foreach (DataRow row in oExcel.ExcelTable.Rows)
                {
                    string sOrgan = row[colOrgan].ToString();
                    if (!String.IsNullOrEmpty(sOrgan))
                        oOrgan = (from o in dbEntity.MemberOrganizations
                                  where o.Code == sOrgan && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION
                                  select o).FirstOrDefault();
                    string sProdCode = row[colProdCode].ToString();
                    string sSkuCode = row[colSkuCode].ToString();
                    if (String.IsNullOrEmpty(sSkuCode)) continue;
                    string sBarcode = row[colBarcode].ToString();
                    string sExCode1 = row[colExCode1].ToString();
                    GeneralResource oProdName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colProdNameCN].ToString());
                    GeneralResource oSkuName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colSkuNameCN].ToString());
                    GeneralResource oFullName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colProdNameCN].ToString() + row[colSkuNameCN].ToString());
                    GeneralResource oShortName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colSkuNameCN].ToString());
                    string sStdCat = row[colStdCat].ToString();
                    string sPrvCat = row[colPrvCat].ToString();
                    byte nBlock;
                    Byte.TryParse(row[colBlock].ToString(), out nBlock);
                    byte nMode;
                    Byte.TryParse(row[colMode].ToString(), out nMode);
                    byte nUnitType;
                    Byte.TryParse(row[colUnitType].ToString(), out nUnitType);
                    string sUnitCode = row[colUnitCode].ToString();
                    byte nPercision;
                    Byte.TryParse(row[colPercision].ToString(), out nPercision);
                    GeneralResource oSpecification = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colSpecification].ToString());
                    string sProdPicture = row[colProdPicture].ToString();
                    GeneralResource oBrief = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colBriefCN].ToString());
                    GeneralLargeObject oIntro = new GeneralLargeObject(2052, row[colIntroCN].ToString());
                    decimal nMinQuantity;
                    Decimal.TryParse(row[colMinQuantity].ToString(), out nMinQuantity);
                    int nCycle;
                    Int32.TryParse(row[colCycle].ToString(), out nCycle);
                    int nGuarantee;
                    Int32.TryParse(row[colGuarantee].ToString(), out nGuarantee);
                    decimal nMarketPriceRMB;
                    Decimal.TryParse(row[colMarketPriceRMB].ToString(), out nMarketPriceRMB);
                    decimal nSuggestPriceRMB;
                    Decimal.TryParse(row[colSuggestPriceRMB].ToString(), out nSuggestPriceRMB);
                    decimal nLowestPriceRMB;
                    Decimal.TryParse(row[colLowestPriceRMB].ToString(), out nLowestPriceRMB);
                    string sKeywords = row[colKeywords].ToString();
                    decimal nGrossWeight;
                    Decimal.TryParse(row[colGrossWeight].ToString(), out nGrossWeight);
                    decimal nNetWeight;
                    Decimal.TryParse(row[colNetWeight].ToString(), out nNetWeight);
                    decimal nGrossVolume;
                    Decimal.TryParse(row[colGrossVolume].ToString(), out nGrossVolume);
                    decimal nNetVolume;
                    Decimal.TryParse(row[colNetVolume].ToString(), out nNetVolume);
                    int nNetPiece;
                    Int32.TryParse(row[colNetPiece].ToString(), out nNetPiece);
                    string sRemark = row[colRemark].ToString();

                    if (!String.IsNullOrEmpty(sProdCode))
                    {
                        // 导入产品主表
                        oProduct = (from p in dbEntity.ProductInformations
                                    where p.OrgID == oOrgan.Gid && p.Code == sProdCode
                                    select p).FirstOrDefault();
                        if (oProduct == null)
                        {
                            oProduct = new ProductInformation { Organization = oOrgan, Code = sProdCode };
                            dbEntity.ProductInformations.Add(oProduct);
                        }
                        if (oProduct.Name == null)
                            oProduct.Name = oProdName;
                        else
                            oProduct.Name.SetResource(ModelEnum.ResourceType.STRING, oProdName);
                        oProduct.StandardCategory = dbEntity.GeneralStandardCategorys.Where(c => c.Code == sStdCat && c.Ctype == (byte)ModelEnum.StandardCategoryType.PRODUCT).FirstOrDefault();
                        oProduct.Block = nBlock;
                        oProduct.Mode = nMode;
                        oProduct.Picture = sProdPicture;
                        if (oProduct.Brief == null)
                            oProduct.Brief = oBrief;
                        else
                            oProduct.Brief.SetResource(ModelEnum.ResourceType.STRING, oBrief);
                        if (oProduct.Matter == null)
                            oProduct.Matter = oIntro;
                        else
                            oProduct.Matter.SetLargeObject(oIntro);
                        oProduct.MinQuantity = nMinQuantity;
                        oProduct.ProductionCycle = nCycle;
                        oProduct.GuaranteeDays = nGuarantee;
                        oProduct.Keywords = sKeywords;
                        oProduct.Remark = sRemark;
                        dbEntity.SaveChanges();
                    }
                    // 导入产品SKU表
                    var oProdItem = (from i in dbEntity.ProductInfoItems
                                     where i.OrgID == oOrgan.Gid && i.Code == sSkuCode
                                     select i).FirstOrDefault();
                    if (oProdItem == null)
                    {
                        oProdItem = new ProductInfoItem { Organization = oOrgan, Code = sSkuCode };
                        dbEntity.ProductInfoItems.Add(oProdItem);
                    }
                    oProdItem.Product = oProduct;
                    oProdItem.Barcode = (String.IsNullOrEmpty(sBarcode)) ? sSkuCode : sBarcode;
                    oProdItem.CodeEx1 = sExCode1;
                    if (oProdItem.FullName == null)
                        oProdItem.FullName = oFullName;
                    else
                        oProdItem.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                    if (oProdItem.ShortName == null)
                        oProdItem.ShortName = oShortName;
                    else
                        oProdItem.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                    oProdItem.StandardUnit = dbEntity.GeneralMeasureUnits.Where(u => u.Code == sUnitCode && u.Utype == nUnitType).FirstOrDefault();
                    if (oProdItem.Specification == null)
                        oProdItem.Specification = oSpecification;
                    else
                        oProdItem.Specification.SetResource(ModelEnum.ResourceType.STRING, oSpecification);
                    var oCurrency = (from u in dbEntity.GeneralMeasureUnits
                                     where u.Utype == (byte)ModelEnum.MeasureUnit.CURRENCY && u.Code == "¥"
                                     select u).FirstOrDefault();
                    if (oProdItem.MarketPrice == null)
                        oProdItem.MarketPrice = new GeneralResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nMarketPriceRMB);
                    else
                        oProdItem.MarketPrice.SetResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nMarketPriceRMB);
                    if (oProdItem.SuggestPrice == null)
                        oProdItem.SuggestPrice = new GeneralResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nSuggestPriceRMB);
                    else
                        oProdItem.SuggestPrice.SetResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nSuggestPriceRMB);
                    if (oProdItem.LowestPrice == null)
                        oProdItem.LowestPrice = new GeneralResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nLowestPriceRMB);
                    else
                        oProdItem.LowestPrice.SetResource(ModelEnum.ResourceType.MONEY, oCurrency.Gid, nLowestPriceRMB);
                    oProdItem.GrossWeight = nGrossWeight;
                    oProdItem.NetWeight = nNetWeight;
                    oProdItem.GrossVolume = nGrossVolume;
                    oProdItem.NetVolume = nNetVolume;
                    oProdItem.NetPiece = nNetPiece;
                    oProdItem.Remark = sRemark;
                    dbEntity.SaveChanges();
                    if (Utility.ConfigHelper.GlobalConst.IsDebug)
                        Debug.WriteLine("{0} {1} {2} {3} {4}", this.ToString(), sProdCode, oProdName.Matter, oSkuName.Matter, sRemark);
                }
                oEventBLL.WriteEvent(String.Format("导入ProductInformation成功: {0} {1}", sExcelFile, sSheetName),
                    ModelEnum.ActionLevel.GENERIC, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
            catch (Exception ex)
            {
                oEventBLL.WriteEvent(String.Format("导入ProductInformation错误: {0} {1} {2}", sExcelFile, sSheetName, ex.Message),
                    ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
        }
示例#5
0
        /// <summary>
        /// ProductOnItem
        /// </summary>
        public ProductOnItem ProductOnItemTest()
        {
            GeneralResource oResource = new GeneralResource { };
            oLiveEntities.GeneralResources.Add(oResource);

            MemberOrganization oOrg = new MemberOrganization
            {
                Code = GetRandCode()
            };
            oLiveEntities.MemberOrganizations.Add(oOrg);

            ProductInformation oProd = new ProductInformation
            {
                Code = GetRandCode(),
                Organization = oOrg,
                Name = oResource
            };
            oLiveEntities.ProductInformations.Add(oProd);

            MemberChannel mChl = new MemberChannel
            {
                Code = GetRandCode()
            };
            oLiveEntities.MemberChannels.Add(mChl);

            MemberOrgChannel oOChl = new MemberOrgChannel
            {
                Organization = oOrg,
                Channel = mChl
            };
            oLiveEntities.MemberOrgChannels.Add(oOChl);

            ProductOnSale onSale = new ProductOnSale
            {
                Code = GetRandCode(),
                Product = oProd,
                Channel = mChl,
                Name = oResource
            };
            oLiveEntities.ProductOnSales.Add(onSale);

            ProductInfoItem oSku = new ProductInfoItem
            {
                Code = GetRandCode(),
                Organization = oOrg,
                Product = oProd
            };
            oLiveEntities.ProductInfoItems.Add(oSku);

            ProductOnItem oOnSku = new ProductOnItem
            {
                OnSale = onSale,
                SkuItem = oSku
            };
            oLiveEntities.ProductOnItems.Add(oOnSku);
            oLiveEntities.SaveChanges();
            return oOnSku;
        }
示例#6
0
 /// <summary>
 /// 测试ProductOnSale
 /// </summary>
 /// <returns>新建的ProductOnSale对象</returns>
 public ProductOnSale ProductOnSaleTest()
 {
     MemberOrganization oOrg = new MemberOrganization
     {
         Code = GetRandCode()
     };
     oLiveEntities.MemberOrganizations.Add(oOrg);
     GeneralResource oName = new GeneralResource { };
     oLiveEntities.GeneralResources.Add(oName);
     ProductInformation oProduct = new ProductInformation
     {
         Organization = oOrg,
         Code = GetRandCode(),
         Name = oName
     };
     oLiveEntities.ProductInformations.Add(oProduct);
     MemberChannel oChannel = new MemberChannel
     {
         Code = GetRandCode()
     };
     oLiveEntities.MemberChannels.Add(oChannel);
     GeneralResource oName2 = new GeneralResource { };
     oLiveEntities.GeneralResources.Add(oName2);
     ProductOnSale oProductOnSale = new ProductOnSale
     {
         Product = oProduct,
         Channel = oChannel,
         Name = oName2,
         Code = GetRandCode()
     };
     oLiveEntities.ProductOnSales.Add(oProductOnSale);
     oLiveEntities.SaveChanges();
     return oProductOnSale;
 }
示例#7
0
        /// <summary>
        /// 产品基本信息-PU 首页
        /// </summary>
        /// <returns>产品基本信息页面</returns>        
        public ActionResult Index()
        {
            // 权限验证
            if (!base.CheckPrivilege())
                return RedirectToAction("ErrorPage", "Home", new { LiveAzure.Resource.Common.NoPermission });
            ViewBag.organizationList = GetSupportOrganizations();//组织下拉框 默认选中当前用户组织
            ProductInformation oViewProductInfomation = new ProductInformation();
            //if (organizationGuid == null || organizationGuid== Guid.Empty)//首次进来默认全局组织为当前用户组织
            organizationGuid = CurrentSession.OrganizationGID;//首次进来默认全局组织为当前用户组织
            oViewProductInfomation.OrgID = organizationGuid;
            SearchKey = null;
            Category = Guid.Empty;
            return View(oViewProductInfomation);
            //if (Guid.Empty == organizationGuid)
            //{
            //    ViewBag.organizationList = GetSupportOrganizations();//orgnization downlist
            //    organizationGuid = CurrentSession.OrganizationGID;
            //}
            //else
            //{
            //    List<MemberOrganization> oUserOrganization = new List<MemberOrganization>();
            //    Guid UserID = (Guid)CurrentSession.UserID;
            //    if (CurrentSession.IsAdmin)//是管理员 则有所有组织权限
            //    {
            //        oUserOrganization = dbEntity.MemberOrganizations
            //                            .Where(o => o.Deleted == false && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION)
            //                            .OrderByDescending(o => o.Sorting)
            //                            .ToList();
            //    }
            //    else//非管理员
            //    {
            //        try
            //        {
            //            byte IsValde = dbEntity.MemberPrivileges.Where(p => p.UserID == CurrentSession.UserID && p.Ptype == (byte)ModelEnum.UserPrivType.ORGANIZATION).FirstOrDefault().Pstatus;
            //            if (IsValde == 1)//如果是启用状态,则将权限表中查得的组织添加到列表
            //            {
            //                oUserOrganization = (from pi in dbEntity.MemberPrivItems.AsEnumerable()
            //                                     join p in dbEntity.MemberPrivileges.AsEnumerable() on pi.PrivID equals p.Gid
            //                                     join org in dbEntity.MemberOrganizations.AsEnumerable() on pi.RefID equals org.Gid
            //                                     where pi.Deleted == false && p.UserID == UserID && p.Ptype == (byte)ModelEnum.UserPrivType.ORGANIZATION
            //                                     orderby org.Sorting descending
            //                                     select org).ToList();
            //            }
            //            //将自己所属组织加到列表
            //            MemberOrganization currentOrg = dbEntity.MemberOrganizations.Where(o => o.Deleted == false && o.Gid == CurrentSession.OrganizationGID).FirstOrDefault();
            //            oUserOrganization.Add(currentOrg);
            //        }
            //        catch (Exception e)//
            //        {
            //            oEventBLL.WriteEvent(e.ToString());
            //        }
            //    }
            //    List<SelectListItem> ogranizationList = new List<SelectListItem>();
            //    foreach (MemberOrganization item in oUserOrganization)
            //    {
            //        if (item.Gid == organizationGuid)//默认选中自己所属组织
            //            ogranizationList.Add(new SelectListItem { Text = item.FullName.GetResource(CurrentSession.Culture), Value = item.Gid.ToString(), Selected = true });
            //        else
            //            ogranizationList.Add(new SelectListItem { Text = item.FullName.GetResource(CurrentSession.Culture), Value = item.Gid.ToString(), Selected = false });
            //    }
            //    ViewBag.organizationList = ogranizationList;
            //}

            ////获取用户的默认组织
            //MemberUser currentUser = dbEntity.MemberUsers.Where(p => p.Gid == (Guid)CurrentSession.UserID).FirstOrDefault();
            //organizationGuid = currentUser.OrgID;
            ////获取当前用户所属的所有组织
            //if (currentUser.LoginName == "admin")
            //{
            //    List<MemberOrganization> productOrganization = dbEntity.MemberOrganizations.Where(p => p.Deleted == false).ToList();
            //    List<SelectListItem> modelList = new List<SelectListItem>();
            //    foreach (MemberOrganization item in productOrganization)
            //    {
            //        modelList.Add(new SelectListItem { Text = item.FullName.GetResource(CurrentSession.Culture), Value = item.Gid.ToString() });
            //    }
            //    ViewBag.organizationList = modelList;
            //}
            //else
            //{
            //    List<MemberUser> oUser = dbEntity.MemberUsers.Where(p => p.Gid == (Guid)CurrentSession.UserID).ToList();
            //    List<SelectListItem> modelList = new List<SelectListItem>();
            //    foreach (MemberUser item in oUser)
            //    {
            //        MemberOrganization productOrganization = dbEntity.MemberOrganizations.Where(p => p.Deleted == false && p.Gid == item.OrgID).Single();
            //        modelList.Add(new SelectListItem { Text = productOrganization.FullName.GetResource(CurrentSession.Culture), Value = productOrganization.Gid.ToString() });
            //    }
            //    ViewBag.organizationList = modelList;
            //}
        }
示例#8
0
        public void ProductOnAdjustTest()
        {
            ProductOnSale oSale = ProductOnSaleTest();
            ProductOnItem oSku = ProductOnItemTest();

            MemberOrganization org = new MemberOrganization
            {
                Code = GetRandCode()
            };
            oLiveEntities.MemberOrganizations.Add(org);

            GeneralResource res = new GeneralResource
            {
            };
            oLiveEntities.GeneralResources.Add(res);

            ProductInformation prod = new ProductInformation
            {
                Name = res,
                Organization = org,
                Code = GetRandCode()
            };
            oLiveEntities.ProductInformations.Add(prod);

            ProductInfoItem infoItem = new ProductInfoItem
            {
                Organization = org,
                Product = prod,
                Code = GetRandCode()
            };
            oLiveEntities.ProductInfoItems.Add(infoItem);
            oLiveEntities.SaveChanges();

            ProductOnAdjust oAdjust = new ProductOnAdjust
            {
                OnSaleID = oSale.Gid,
                OnSkuID = oSku.Gid
            };
            oLiveEntities.ProductOnAdjusts.Add(oAdjust);
            oLiveEntities.SaveChanges();
        }
示例#9
0
        /// <summary>
        /// 保存详情
        /// </summary>
        /// <param name="oProductInfo">产品页面对象</param>
        /// <returns></returns>
        public bool saveProductInfoDetail(ProductInformation model)
        {
            try
            {
                ProductInformation oProductInformation = dbEntity.ProductInformations.Include("Brief").Include("Matter").Where(p => p.Deleted == false && p.Gid == model.Gid).Single();
                oProductInformation.Brief.SetResource(ModelEnum.ResourceType.STRING, model.Brief);
            ///////////////////////////////////待更改/////////////////////////////////////////////////////
                if (oProductInformation.Matter == null)
                {
                    GeneralLargeObject oClob = new GeneralLargeObject();
                    oClob.CLOB = model.Matter.CLOB;
                    dbEntity.GeneralLargeObjects.Add(oClob);
                    dbEntity.SaveChanges();
                    oProductInformation.aMatter = oClob.Gid;
                }
                else
                {
                    oProductInformation.Matter.CLOB = model.Matter.CLOB;
                }
            ////////////////////////////////////////////////////////////////////////////////////////////////
                dbEntity.SaveChanges();

            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
示例#10
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="formCollection"></param>
        public string SaveProductInfo(ProductInformation oProductInfo, FormCollection formCollection)
        {
            //判断是添加产品还是编辑产品
            bool bNewOrEdit = true;

            ProductInformation oNewProductInfo;

            if (oProductInfo.Gid.Equals(Guid.Empty))
            {
                List<ProductInformation> listPU = dbEntity.ProductInformations.Where(p => p.OrgID == organizationGuid && p.Code == oProductInfo.Code).ToList();
                if (listPU.Count > 0)
                {
                    oNewProductInfo = listPU.ElementAt(0);
                    if (oNewProductInfo.Deleted == false)
                    {
                        return "failure";
                    }
                    else
                    {
                        oNewProductInfo.Deleted = false;
                        oNewProductInfo.Name = oProductInfo.Name;
                        oNewProductInfo.Code = oProductInfo.Code;
                    }
                }
                else
                {
                    oNewProductInfo = new ProductInformation { Name = NewResource(ModelEnum.ResourceType.STRING, organizationGuid) };
                    oNewProductInfo.Name = oProductInfo.Name;
                    oNewProductInfo.Code = formCollection["Code"];
                }
            }
            else
            {
                oNewProductInfo = dbEntity.ProductInformations.Where(p => p.Gid == selectedProductGuid).Single();
                oNewProductInfo.Name.SetResource(ModelEnum.ResourceType.STRING, oProductInfo.Name);
                bNewOrEdit = false;
            }

            oNewProductInfo.OrgID = organizationGuid;
            oNewProductInfo.StdCatID = Guid.Parse(formCollection["StandardCategory.Name.Matter"]);
            oNewProductInfo.Block = Byte.Parse(formCollection["Block"]);
            oNewProductInfo.Mode = Byte.Parse(formCollection["Mode"]);
            oNewProductInfo.MinQuantity = Decimal.Parse(formCollection["MinQuantity"]);
            oNewProductInfo.ProductionCycle = Int32.Parse(formCollection["ProductionCycle"]);
            oNewProductInfo.GuaranteeDays = Int32.Parse(formCollection["GuaranteeDays"]);
            oNewProductInfo.Keywords = formCollection["Keywords"];
            //oNewProductInfo.SaleType = 0;
            oNewProductInfo.Remark = formCollection["Remark"];
            oNewProductInfo.Picture = oProductInfo.Picture;

            if (bNewOrEdit == true)
            {
                dbEntity.ProductInformations.Add(oNewProductInfo);

                dbEntity.SaveChanges();

                //重新给全局变量赋值
                selectedProductGuid = oNewProductInfo.Gid;
            }
            else
            {
                dbEntity.SaveChanges();
            }

            return "success";
        }
示例#11
0
        /// <summary>
        /// 详细信息页
        /// </summary>
        /// <param name="puGID">产品GUID</param>
        /// <returns></returns>
        public ActionResult ProductDetailInfo()
        {
            ProductInformation oProduct = dbEntity.ProductInformations.Where(p => p.Gid == selectedProductGuid && p.Deleted == false).FirstOrDefault();
            if (oProduct != null)
            {
                ViewBag.ProductCode = oProduct.Code;
                ViewBag.ProductName = oProduct.Name.GetResource(CurrentSession.Culture);
            }
            ProductInformation oProductInformation = new ProductInformation { Brief = NewResource(ModelEnum.ResourceType.STRING, organizationGuid) };
            try
            {
                oProductInformation = dbEntity.ProductInformations.Include("Brief").Include("Matter").Where(p => p.Deleted == false && p.Gid == selectedProductGuid).FirstOrDefault();
                oProductInformation.Brief = RefreshResource(ModelEnum.ResourceType.STRING, oProductInformation.Name, organizationGuid);
            }
            catch (Exception)
            {

            }
            return View(oProductInformation);
        }
示例#12
0
        /// <summary>
        /// 跳转到基础信息编辑页面
        /// </summary>
        /// <returns></returns>
        public ActionResult ProductBaseInfo()
        {
            ProductInformation oProductInfo;
            bool bAddOrEdit = true;
            //判断是否为添加新的PU
            if (selectedProductGuid.Equals(Guid.Empty))
            {
                oProductInfo = new ProductInformation { Name = NewResource(ModelEnum.ResourceType.STRING, organizationGuid) };
                bAddOrEdit = true;
            }
            else
            {
                oProductInfo = dbEntity.ProductInformations.Where(p => p.Gid == selectedProductGuid).Single();
                oProductInfo.Name = RefreshResource(ModelEnum.ResourceType.STRING, oProductInfo.Name, organizationGuid);
                bAddOrEdit = false;
            }

            //标准类别下拉框,取自数据库表
            List<SelectListItem> oStdList = new List<SelectListItem>();

            //标准类型3为商品全局标准分类
            List<GeneralStandardCategory> listStd = dbEntity.GeneralStandardCategorys.Where(p => p.Ctype == 3 && p.Deleted == false).ToList();

            int nListCount = listStd.Count;

            for (int i = 0; i < nListCount; i++)
            {
                oStdList.Add(new SelectListItem { Text = listStd.ElementAt(i).Name.GetResource(CurrentSession.Culture), Value = listStd.ElementAt(i).Gid.ToString() });
            }

            //分组下拉框,枚举类型
            List<SelectListItem> oBlockList = new List<SelectListItem>();
            oBlockList = GetSelectList(oProductInfo.BlockList);

            //模式下拉框,枚举类型
            List<SelectListItem> oModeList = new List<SelectListItem>();

            oModeList = GetSelectList(oProductInfo.ProductModeList);

            ////销售类型下拉框,枚举类型
            //List<SelectListItem> oSaleTypeList = new List<SelectListItem>();
            //oSaleTypeList.Add(new SelectListItem { Text = "直营", Value = "0" });

            string strSaltKey = CurrentSession.SaltKey;

            ViewBag.saltKey = strSaltKey;
            ViewBag.oStdList = oStdList;
            ViewBag.oModeList = oModeList;
            ViewBag.oBlockList = oBlockList;
            ViewBag.bAddOrEdit = bAddOrEdit;
            //ViewBag.oSaleTypeList = oSaleTypeList;

            return View(oProductInfo);
        }
示例#13
0
        public string ProductTemplateOnSale(MemberOrganization oOrgan, MemberChannel oChannel, ProductOnTemplate oTemplate,
            ProductInformation oProduct, List<Object> oItemList = null)
        {
            //判断是否存在SKU列表,如果不存在SKU列表,则只添加产品上架相关的信息;
            //否则既添加产品上架信息,还要添加SKU上架表的信息。
            ProductOnSale oProductOnsale;
            Guid currentOnsaleGid;
            Guid productGid = oProduct.Gid;
            Guid onSaleChID = oChannel.Gid;
            Guid onSaleOrgID = oOrgan.Gid;
            //ProductInformation oProduct = dbEntity.ProductInformations.Include("SkuItems").Where(p => p.Gid == productGid && p.Deleted == false).FirstOrDefault();
            String productOnsaleCode = oProduct.Code;

            ProductOnSale productOnsale = dbEntity.ProductOnSales.Where(p => p.ProdID == productGid && p.ChlID == onSaleChID && p.Code == productOnsaleCode).FirstOrDefault();
            //为新上架商品
            if (productOnsale == null)
            {
                oProductOnsale = new ProductOnSale();
                #region 模板上架ProductOnsale表信息添加

                oProductOnsale.ProdID = productGid;
                oProductOnsale.OrgID = onSaleChID;
                oProductOnsale.ChlID = onSaleChID;
                oProductOnsale.Code = productOnsaleCode;
                oProductOnsale.Ostatus = 1;
                oProductOnsale.aName = (Guid)oProduct.aName;
                oProductOnsale.Mode = oProduct.Mode;
                //=====市场价以及销售价======

                //=========================
                //oProductOnsale.CanSplit = oProduct.Block;
                oProductOnsale.aBrief = oProduct.aBrief;
                oProductOnsale.aMatter = oProduct.aMatter;

                dbEntity.ProductOnSales.Add(oProductOnsale);
                dbEntity.SaveChanges();
                //当前上架商品的OnsaleID
                currentOnsaleGid = oProductOnsale.Gid;

                #endregion

                #region 模板上架ProductOnItems表信息添加
                Guid marketPriceGid;
                Guid salePriceGid;
                //保存SKU的信息,如果存在SKU
                if (oItemList != null)
                {
                    foreach (Dictionary<string, object> item in oItemList)
                    {
                        //保存进入ProductOnItem表
                        ProductInfoItem oInfoItem = (ProductInfoItem)item["SkuItem"];
                        ProductOnItem oNewProductItem = new ProductOnItem();
                        oNewProductItem.OnSaleID = currentOnsaleGid;
                        oNewProductItem.SkuID = oInfoItem.Gid;
                        oNewProductItem.aFullName = oInfoItem.aFullName;
                        oNewProductItem.aShortName = oInfoItem.aShortName;
                        dbEntity.ProductOnItems.Add(oNewProductItem);
                        dbEntity.SaveChanges();
                        //获取当前保存的OnSKUID
                        Guid currentOnSKUGid = oNewProductItem.Gid;
                        GeneralMeasureUnit oUnit = (GeneralMeasureUnit)item["Unit"];
                        Guid currentUnitGid = oUnit.Gid;

                        GeneralMeasureUnit oCurrency1 = (GeneralMeasureUnit)item["Currency1"];
                        //第一个价格不存在则认为添加失败
                        if (oCurrency1 != null)
                        {
                            GeneralResource oMarketCash = new GeneralResource();
                            oMarketCash.Rtype = (byte)ModelEnum.ResourceType.MONEY;
                            oMarketCash.Currency = oCurrency1.Gid;
                            oMarketCash.Cash = (decimal)item["MarketPrice1"];
                            GeneralResource oSaleCash = new GeneralResource();
                            oSaleCash.Rtype = (byte)ModelEnum.ResourceType.MONEY;
                            oSaleCash.Currency = oCurrency1.Gid;
                            oSaleCash.Cash = (decimal)item["SalePrice1"];
                            dbEntity.GeneralResources.Add(oMarketCash);
                            dbEntity.GeneralResources.Add(oSaleCash);
                            dbEntity.SaveChanges();
                            marketPriceGid = oMarketCash.Gid;
                            salePriceGid = oSaleCash.Gid;
                            GeneralMeasureUnit oCurrency2 = (GeneralMeasureUnit)item["Currency2"];
                            if (oCurrency2 != null)
                            {
                                GeneralResItem oMarketResItem1 = new GeneralResItem();
                                oMarketResItem1.ResID = marketPriceGid;
                                oMarketResItem1.Currency = oCurrency2.Gid;
                                oMarketResItem1.Cash = (decimal)item["MarketPrice2"];
                                GeneralResItem oSaleResItem1 = new GeneralResItem();
                                oSaleResItem1.ResID = salePriceGid;
                                oSaleResItem1.Currency = oCurrency2.Gid;
                                oSaleResItem1.Cash = (decimal)item["SalePrice2"];
                                dbEntity.GeneralResItems.Add(oMarketResItem1);
                                dbEntity.GeneralResItems.Add(oSaleResItem1);
                                dbEntity.SaveChanges();
                            }
                            GeneralMeasureUnit oCurrency3 = (GeneralMeasureUnit)item["Currency3"];
                            if (oCurrency3 != null)
                            {
                                GeneralResItem oMarketResItem2 = new GeneralResItem();
                                oMarketResItem2.ResID = marketPriceGid;
                                oMarketResItem2.Currency = oCurrency3.Gid;
                                oMarketResItem2.Cash = (decimal)item["MarketPrice3"];
                                GeneralResItem oSaleResItem2 = new GeneralResItem();
                                oSaleResItem2.ResID = salePriceGid;
                                oSaleResItem2.Currency = oCurrency3.Gid;
                                oSaleResItem2.Cash = (decimal)item["SalePrice3"];
                                dbEntity.GeneralResItems.Add(oMarketResItem2);
                                dbEntity.GeneralResItems.Add(oSaleResItem2);
                                dbEntity.SaveChanges();
                            }
                            GeneralMeasureUnit oCurrency4 = (GeneralMeasureUnit)item["Currency4"];
                            if (oCurrency3 != null)
                            {
                                GeneralResItem oMarketResItem3 = new GeneralResItem();
                                oMarketResItem3.ResID = marketPriceGid;
                                oMarketResItem3.Currency = oCurrency3.Gid;
                                oMarketResItem3.Cash = (decimal)item["MarketPrice4"];
                                GeneralResItem oSaleResItem3 = new GeneralResItem();
                                oSaleResItem3.ResID = salePriceGid;
                                oSaleResItem3.Currency = oCurrency3.Gid;
                                oSaleResItem3.Cash = (decimal)item["SalePrice4"];
                                dbEntity.GeneralResItems.Add(oMarketResItem3);
                                dbEntity.GeneralResItems.Add(oSaleResItem3);
                                dbEntity.SaveChanges();
                            }
                            //添加到UnitPrice表里
                            ProductOnUnitPrice oProductOnUnitPrice = new ProductOnUnitPrice();
                            oProductOnUnitPrice.OnSkuID = currentOnSKUGid;
                            oProductOnUnitPrice.aShowUnit = currentUnitGid;
                            oProductOnUnitPrice.aMarketPrice = marketPriceGid;
                            oProductOnUnitPrice.aSalePrice = salePriceGid;
                            oProductOnUnitPrice.UnitRatio = (decimal)item["Ratio"];
                            oProductOnUnitPrice.Percision = (byte)item["Percision"];
                            dbEntity.ProductOnUnitPrices.Add(oProductOnUnitPrice);
                            dbEntity.SaveChanges();
                        }

                    }
                }
                else
                {
                    for (int i = 0; i < oProduct.SkuItems.Count; i++)
                    {
                        ProductOnItem oNewProductItem = new ProductOnItem();
                        oNewProductItem.OnSaleID = currentOnsaleGid;
                        oNewProductItem.SkuID = oProduct.SkuItems.ElementAt(i).Gid;
                        oNewProductItem.aFullName = oProduct.SkuItems.ElementAt(i).aFullName;
                        oNewProductItem.aShortName = oProduct.SkuItems.ElementAt(i).aShortName;
                        dbEntity.ProductOnItems.Add(oNewProductItem);
                        dbEntity.SaveChanges();
                        //加入价套信息
                        Guid stdUnitGid = oProduct.SkuItems.ElementAt(i).StdUnit;
                        ProductOnUnitPrice oNewUnitPrice = new ProductOnUnitPrice();
                        oNewUnitPrice.OnSkuID = oNewProductItem.Gid;
                        oNewUnitPrice.aShowUnit = stdUnitGid;
                        GeneralResource oMarketCash = new GeneralResource();
                        oMarketCash.Rtype = (byte)ModelEnum.ResourceType.MONEY;
                        oMarketCash.Currency = oProduct.SkuItems.ElementAt(i).MarketPrice.Currency;
                        oMarketCash.Cash = oProduct.SkuItems.ElementAt(i).MarketPrice.Cash;
                        GeneralResource oSaleCash = new GeneralResource();
                        oSaleCash.Rtype = (byte)ModelEnum.ResourceType.MONEY;
                        oSaleCash.Currency = oProduct.SkuItems.ElementAt(i).SuggestPrice.Currency;
                        oSaleCash.Cash = oProduct.SkuItems.ElementAt(i).SuggestPrice.Cash;
                        dbEntity.GeneralResources.Add(oMarketCash);
                        dbEntity.GeneralResources.Add(oSaleCash);
                        dbEntity.SaveChanges();
                        marketPriceGid = oMarketCash.Gid;
                        salePriceGid = oSaleCash.Gid;
                        oNewUnitPrice.aMarketPrice = marketPriceGid;
                        oNewUnitPrice.aSalePrice = salePriceGid;
                        Guid oldMarketGid = oProduct.SkuItems.ElementAt(i).MarketPrice.Gid;
                        List<GeneralResItem> listMarketPrice = dbEntity.GeneralResItems.Where(p => p.ResID == oldMarketGid && p.Deleted == false).ToList();
                        for (int j = 0; j < listMarketPrice.Count; j++)
                        {
                            GeneralResItem newMarketPrice = new GeneralResItem();
                            newMarketPrice.ResID = marketPriceGid;
                            newMarketPrice.Currency = listMarketPrice.ElementAt(j).Currency;
                            newMarketPrice.Cash = listMarketPrice.ElementAt(j).Cash;
                            dbEntity.GeneralResItems.Add(newMarketPrice);
                            dbEntity.SaveChanges();
                        }
                        Guid oldSaleGid = oProduct.SkuItems.ElementAt(i).SuggestPrice.Gid;
                        List<GeneralResItem> listSalePrice = dbEntity.GeneralResItems.Where(p => p.ResID == oldSaleGid && p.Deleted == false).ToList();
                        for (int j = 0; j < listSalePrice.Count; j++)
                        {
                            GeneralResItem newSalePrice = new GeneralResItem();
                            newSalePrice.ResID = salePriceGid;
                            newSalePrice.Currency = listSalePrice.ElementAt(j).Currency;
                            newSalePrice.Cash = listSalePrice.ElementAt(j).Cash;
                            dbEntity.GeneralResItems.Add(newSalePrice);
                            dbEntity.SaveChanges();
                        }
                        dbEntity.ProductOnUnitPrices.Add(oNewUnitPrice);
                        dbEntity.SaveChanges();
                    }
                }

                #endregion

                #region 根据数据库中取出的模板对上架商品进行赋值

                Guid onSaleTemplateGid = oTemplate.Gid;
                ProductOnTemplate oCurrentTemplate = dbEntity.ProductOnTemplates.Where(p => p.Gid == onSaleTemplateGid && p.Deleted == false).FirstOrDefault();
                if (oCurrentTemplate != null)
                {
                    string strShipPolicy = oCurrentTemplate.ShipPolicy;
                    string strPayPolicy = oCurrentTemplate.PayPolicy;
                    string strRelation = oCurrentTemplate.Relation;
                    string strLevelDiscount = oCurrentTemplate.LevelDiscount;

                    //将承运商信息和地区信息存入数据库
                    Guid onSaleShippingGid = new Guid();
                    string[] shippingInfo = strShipPolicy.Split(';');
                    for (int i = 0; i < shippingInfo.Count(); i++)
                    {
                        string[] currentShipAndAreaInfo = shippingInfo[i].Split(':');
                        //承运商代码
                        string currentShipCode = currentShipAndAreaInfo[0].Split('|')[0];
                        //承运商权重
                        string currentShipWeight = currentShipAndAreaInfo[0].Split('|')[1];
                        //承运商计费方案
                        string currentShipSolution = currentShipAndAreaInfo[0].Split('|')[2];
                        //承运商地区信息
                        string[] currentShipAreaList = currentShipAndAreaInfo[1].Split(',');

                        //保存承运商信息
                        //如果承运商信息不为空,保存信息;否则不做操作。
                        if (currentShipAndAreaInfo[0] != "")
                        {
                            ProductOnShipping oNewProductOnShipping = new ProductOnShipping();
                            oNewProductOnShipping.OnSaleID = currentOnsaleGid;
                            byte bOrgType = (byte)ModelEnum.OrganizationType.SHIPPER;
                            //判断承运商信息是否在数据库中已删除
                            ShippingInformation oCurrentShippingInfomation = dbEntity.ShippingInformations.Where(p => p.Code == currentShipCode && p.aParent == onSaleOrgID && p.Otype == bOrgType && p.Deleted == false).FirstOrDefault();
                            if (oCurrentShippingInfomation != null)
                            {
                                Guid currentShippingID = oCurrentShippingInfomation.Gid;
                                oNewProductOnShipping.ShipID = currentShippingID;
                                oNewProductOnShipping.ShipWeight = Int32.Parse(currentShipWeight);
                                oNewProductOnShipping.Solution = byte.Parse(currentShipSolution);
                                dbEntity.ProductOnShippings.Add(oNewProductOnShipping);
                                dbEntity.SaveChanges();
                                onSaleShippingGid = oNewProductOnShipping.Gid;
                                //将对应的承运商的区域存入ProductOnShipArea表
                                //如果承运商地区信息不为空,保存信息;否则不做操作。
                                if (currentShipAreaList[0] != "")
                                {
                                    for (int j = 0; j < currentShipAreaList.Count(); j++)
                                    {
                                        Guid currentRegionGid = Guid.Parse(currentShipAreaList[j]);
                                        //判断数据库中地区是否存在
                                        GeneralRegion oRegion = dbEntity.GeneralRegions.Where(p => p.Gid == currentRegionGid && p.Deleted == false).FirstOrDefault();
                                        if (oRegion != null)
                                        {
                                            ProductOnShipArea oNewShipArea = new ProductOnShipArea();
                                            oNewShipArea.RegionID = currentRegionGid;
                                            oNewShipArea.OnShip = onSaleShippingGid;
                                            dbEntity.ProductOnShipAreas.Add(oNewShipArea);
                                            dbEntity.SaveChanges();
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    //将相关的支付方式存入数据库
                    string[] paymentList = strPayPolicy.Split(';');
                    //如果有支付方式,则将支付方式写入数据库;否则不保存。
                    if (paymentList[0] != "")
                    {
                        for (int i = 0; i < paymentList.Count(); i++)
                        {
                            string strPaymentCode = paymentList[i];
                            //判断支付方式在数据库中是否存在
                            FinancePayType oPaytype = dbEntity.FinancePayTypes.Where(p => p.OrgID == onSaleOrgID && p.Code == strPaymentCode && p.Deleted == false).FirstOrDefault();
                            if (oPaytype != null)
                            {
                                Guid currentPaymentGid = oPaytype.Gid;
                                ProductOnPayment oProductOnPayment = new ProductOnPayment();
                                oProductOnPayment.OnSaleID = currentOnsaleGid;
                                oProductOnPayment.PayID = currentPaymentGid;
                                dbEntity.ProductOnPayments.Add(oProductOnPayment);
                                dbEntity.SaveChanges();
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    //将相关的商品信息存入数据库
                    string[] relationList = strRelation.Split(';');
                    //判断是否存在关联商品信息
                    if (relationList[0] != "")
                    {
                        for (int i = 0; i < relationList.Count(); i++)
                        {
                            Guid relationProductGid = Guid.Parse(relationList[i].Split('|')[0]);
                            byte relationType = byte.Parse(relationList[i].Split('|')[1]);
                            ProductOnSale oRelationProductOnSale = dbEntity.ProductOnSales.Where(p => p.Gid == relationProductGid && p.Deleted == false).FirstOrDefault();
                            if (oRelationProductOnSale != null)
                            {
                                ProductOnRelation oProductOnRelation = new ProductOnRelation();
                                oProductOnRelation.OnSaleID = currentOnsaleGid;
                                oProductOnRelation.aOnRelation = relationProductGid;
                                oProductOnRelation.Rtype = relationType;
                                dbEntity.ProductOnRelations.Add(oProductOnRelation);
                                dbEntity.SaveChanges();
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    //将相关的会员打折信息存入数据库
                    string[] levelDiscountList = strLevelDiscount.Split(';');
                    //判断是否存在会员打折信息
                    if (levelDiscountList[0] != "")
                    {
                        for (int i = 0; i < levelDiscountList.Count(); i++)
                        {
                            string strMemberCode = levelDiscountList[i].Split(':')[0];
                            decimal decDiscount = Decimal.Parse(levelDiscountList[i].Split(':')[1]);
                            MemberLevel oMemberLevel = dbEntity.MemberLevels.Where(p => p.Code == strMemberCode && p.Deleted == false).FirstOrDefault();
                            if (oMemberLevel != null)
                            {
                                Guid memberLevelGid = oMemberLevel.Gid;
                                ProductOnLevelDiscount oProductOnLevelDiscount = new ProductOnLevelDiscount();
                                oProductOnLevelDiscount.OnSaleID = currentOnsaleGid;
                                oProductOnLevelDiscount.aUserLevel = memberLevelGid;
                                oProductOnLevelDiscount.Discount = decDiscount;
                                dbEntity.ProductOnLevelDiscounts.Add(oProductOnLevelDiscount);
                                dbEntity.SaveChanges();
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                }

                #endregion

            }
            else
            {
                //存在上架的商品,同时还是可用状态,则提示用户不能重复上架
                if (productOnsale.Deleted == false)
                {
                    return "fail";
                }
                else
                {
                    //==================ToDo===================

                    //#region 恢复原来的上架信息

                    ////上架商品表信息恢复
                    //productOnsale.Deleted = false;
                    //currentOnsaleGid = productOnsale.Gid;

                    ////上架SKU信息恢复
                    //List<ProductOnItem> listProductOnItem = dbEntity.ProductOnItems.Where(p => p.OnSaleID == currentOnsaleGid).ToList();
                    //foreach (ProductOnItem productOnItem in listProductOnItem)
                    //{
                    //    productOnItem.Deleted = false;
                    //}

                    ////上架承运商信息恢复
                    //List<ProductOnShipping> listProductOnShipping = dbEntity.ProductOnShippings.Where(p => p.OnSaleID == currentOnsaleGid).ToList();
                    //foreach (ProductOnShipping productOnShipping in listProductOnShipping)
                    //{
                    //    productOnShipping.Deleted = false;
                    //    Guid deleteShipGid = productOnShipping.Gid;
                    //    //上架承运商地区信息恢复
                    //    List<ProductOnShipArea> listProductOnShipArea = dbEntity.ProductOnShipAreas.Where(p => p.OnShip == deleteShipGid).ToList();
                    //    foreach (ProductOnShipArea productShipArea in listProductOnShipArea)
                    //    {
                    //        productShipArea.Deleted = false;
                    //    }
                    //}

                    ////上架支付方式信息恢复
                    //List<ProductOnPayment> listProductOnPayment = dbEntity.ProductOnPayments.Where(p => p.OnSaleID == currentOnsaleGid).ToList();
                    //foreach (ProductOnPayment productOnPayment in listProductOnPayment)
                    //{
                    //    productOnPayment.Deleted = false;
                    //}

                    ////上架关联商品信息恢复
                    //List<ProductOnRelation> listProductOnRelation = dbEntity.ProductOnRelations.Where(p => p.OnSaleID == currentOnsaleGid).ToList();
                    //foreach (ProductOnRelation productOnRelation in listProductOnRelation)
                    //{
                    //    productOnRelation.Deleted = false;
                    //}

                    ////上架会员打折信息恢复
                    //List<ProductOnLevelDiscount> listProductOnLevelDiscount = dbEntity.ProductOnLevelDiscounts.Where(p => p.OnSaleID == currentOnsaleGid).ToList();
                    //foreach (ProductOnLevelDiscount productOnLevelDiscount in listProductOnLevelDiscount)
                    //{
                    //    productOnLevelDiscount.Deleted = false;
                    //}

                    //#endregion
                }
            }

            return "success";
        }