public PartialViewResult CreateMaterial(Guid ID)
 {
     ViewData["LinkMainCID"] = ID;
     IBrand IB = new BrandBase();
     List<Brand> BL = IB.GetBrandList(string.Empty, ID);
     return PartialView("CreateMaterial", BL);
 }
Пример #2
0
 public Drink(BrandBase brand, SkuBase sku)
 {
     this._brand = brand;
     this._sku   = sku;
 }
Пример #3
0
 public FruitTea(BrandBase brand, SizeBase size) : base(brand, size)
 {
     Name = "Fruit Tea";
     Cost = 6.0;
 }
 public PartialViewResult CreateMaterialByExcel(Guid ID)
 {
     Guid LinkMainCID = ID;
     ViewData["LinkMainCID"] = LinkMainCID;
     List<MatExcel> ML = IM.GetMatExcelList(LinkMainCID);
     IBrand IB = new BrandBase();
     List<Brand> BL = IB.GetBrandList(string.Empty, LinkMainCID);
     ViewData["BL"] = BL;
     return PartialView("CreateMaterialByExcel", ML);
 }
 public PartialViewResult UpdateMaterialBase(Guid ID)
 {
     Material M = IM.GetMaterialItemDB(ID);
     IBrand IB = new BrandBase();
     List<Brand> BL = IB.GetBrandList(string.Empty, M.LinkMainCID);
     ViewData["BL"] = BL;
     return PartialView("UpdateMaterialBase", M);
 }
        public ActionResult DownBrandTempExcel(FormCollection FC)
        {
            //获取Brand
            IBrand IB = new BrandBase();
            Guid BID = new Guid(FC["D_BrandID"]);
            Brand B = IB.GetBrandItem(BID);

            string Path = string.Empty;

            //设定表头
            DataTable dt = new DataTable("TempInvoice");
            //设定dataTable表头
            DataColumn myDataColumn = new DataColumn();
            string[] TableHeads = {
                        "产品编号",
                        "产品名称",
                        "规格型号",
                        "制造商编号",
                        "品牌",
                        "品牌分类",
                        "单位",
                        "未税采购价",
                        "未税厂商面价",
                        "货期(天)",
                        "产品简述",
              };

            foreach (string TableHead in TableHeads)
            {
                //TableHead
                myDataColumn = new DataColumn();
                myDataColumn.DataType = Type.GetType("System.String");
                myDataColumn.ColumnName = TableHead;
                myDataColumn.ReadOnly = true;
                myDataColumn.Unique = false;  //获取或设置一个值,该值指示列的每一行中的值是否必须是唯一的。
                dt.Columns.Add(myDataColumn);
            }

            try
            {
                DataRow newRow;
                for (int i = 0; i <= 20; i++ )
                {
                    newRow = dt.NewRow();

                    newRow["产品编号"] = string.Empty;
                    newRow["产品名称"] = string.Empty;
                    newRow["规格型号"] = string.Empty;
                    newRow["制造商编号"] = string.Empty;
                    newRow["品牌"] = B.BrandName;
                    newRow["品牌分类"] = B.BrandType;
                    newRow["单位"] = string.Empty;
                    newRow["未税采购价"] = string.Empty;
                    newRow["未税厂商面价"] = string.Empty;
                    newRow["货期(天)"] = string.Empty;
                    newRow["产品简述"] = string.Empty;
                    dt.Rows.Add(newRow);
                }
                Path = MyExcel.CreateNewExcel(dt, string.Empty);
            }
            catch
            {
                Path = MyExcel.CreateNewExcel(dt, string.Empty);
            }

            string FileNameStr = string.Empty;
            if(!string.IsNullOrEmpty(B.BrandType))
            {
                FileNameStr = B.BrandName + "-" + B.BrandType;
            }
            else
            {
                FileNameStr = B.BrandName;
            }
            return File(Path, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", FileNameStr+"-数据模板");
        }
Пример #7
0
        public MaterialPageBySearchList FindMaterialPageBySearchListByQDT(int PageIndex, int PageSize, string Keyword, string MatBrand, Guid CatID, string IsStatUs)
        {
            var query = (from M in db.Material
                         where true
                         select M).AsQueryable();

            //品牌判断
            if (!string.IsNullOrEmpty(MatBrand))
            {
                query = query.Where(m => m.MatBrand.Contains(MatBrand)).AsQueryable();
            }

            ICategory ICat = new CategoryBase();
            CatTree CT = ICat.GetCatTreeByQDT();

            //分类判断
            if (CatID != Guid.Empty)
            {
                if (CT.SecondCatTree.Where(c => c.CatID == CatID).Count() > 0)
                {
                    query = query.Where(c => c.LinkQDTCatID == CatID).AsQueryable();
                }
            }

            //发布 新品 置顶判断
            if (IsStatUs == MatISNo.IsPublic.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotPublic.ToString())
            {
                query = query.Where(x => x.IsPublic == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsTop.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsTop == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotTop.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsTop == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNew.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsNew == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();

            }
            else if (IsStatUs == MatISNo.IsNotNew.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsNew == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsPromotion.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 1 && x.IsGroupMat <= 0).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotPromotion.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 0 && x.IsGroupMat <= 0).AsQueryable();
            }

            if (!string.IsNullOrEmpty(Keyword))
            {
                Keyword = Regex.Replace(Keyword, @"( )\1+", "$1", RegexOptions.None);
                string[] KeywordStr = Keyword.Split(' ');

                foreach (var K in KeywordStr)
                {
                    if (!string.IsNullOrEmpty(K))
                    {
                        query = query.Where(
                           m => m.MatSn.Contains(K) ||
                           m.MatBrand.Contains(K) ||
                           m.MatManufacturerSn.Contains(K) ||
                           m.MatSpecifications.Contains(K) ||
                           m.MatName.Contains(K) ||
                           m.KeywordIndex.Contains(K)
                           ).AsQueryable();
                    }
                }
            }

            //获取以过滤的品牌项
            var queryBrand = query.Where(x => x.MatBrandID != Guid.Empty).GroupBy(x => x.MatBrandID).Select(x => x.Key).AsQueryable();
            List<P_Brand> PBL = new List<P_Brand>();
            P_Brand PB = new P_Brand();
            Brand B = new Brand();

            foreach (var x in queryBrand)
            {
                B = db.Brand.Find(x);
                if (B != null)
                {
                    PB = new P_Brand();
                    PB.BID = B.BID;
                    PB.BrandName = B.BrandName;
                    PB.BrandEnName = B.BrandNameEn;
                    PB.BrandLogo = B.BrandLogo;
                    PBL.Add(PB);
                }else{
                    PB = new P_Brand();
                    PB.BID = Guid.Empty;
                    PB.BrandName = string.Empty;
                    PB.BrandEnName = string.Empty;
                    PB.BrandLogo = string.Empty;
                    PBL.Add(PB);
                }
            }

            List<P_Brand> PBLNew = new List<P_Brand>();
            var QueryBrandNew = from x in PBL
                                where true
                                &&
                                x.BID != Guid.Empty
                                &&
                                x.BrandLogo != string.Empty
                                &&
                                x.BrandName != string.Empty
                                group x by x.BrandName into g
                                select new {
                                    BID = g.FirstOrDefault().BID,
                                    BrandLogo = g.FirstOrDefault().BrandLogo,
                                    BrandName = g.FirstOrDefault().BrandName,
                                    BrandEnName = g.FirstOrDefault().BrandEnName,
                                };
            P_Brand NewB = new P_Brand();
               foreach(var x in QueryBrandNew)
               {
               NewB = new P_Brand();
               NewB.BID = x.BID;
               NewB.BrandLogo = x.BrandLogo;
               NewB.BrandEnName = x.BrandEnName;
               NewB.BrandName = x.BrandName;
               PBLNew.Add(NewB);
               }

            //获取以过滤分类项
            var queryCat = from x in query
                           where true
                           &&
                           x.CategoryID != Guid.Empty
                           &&
                           x.LinkQDTCatID != Guid.Empty
                           group x by x.LinkQDTCatID into g
                           select new
                           {
                               CID = g.Key,
                               Count = g.Count()
                           };

            List<P_Cat> PCL = new List<P_Cat>();
            P_Cat PC = new P_Cat();
            Category Cat = new Category();

            foreach (var x in queryCat)
            {
                PC = new P_Cat();
                if (CT.SecondCatTree.Where(c => c.CatID == x.CID).Count() > 0)
                {
                    PC.CatID = x.CID;
                    PC.CatCount = x.Count;
                    PC.CatName = CT.SecondCatTree.Where(c => c.CatID == x.CID).FirstOrDefault().CategoryName;
                    PCL.Add(PC);
                }
            }

            List<Material> ML = query.OrderByDescending(s => s.LastUpdateTime).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
            List<Material> SubGroupML = new List<Material>();

            IBrand IB = new BrandBase();
            string MaxPrice = string.Empty;
            string MinPrice = string.Empty;
            foreach (var x in ML)
            {
                x.MoreDetail = string.Empty;
                if (x.IsGroupMat > 0)
                {
                    SubGroupML = this.GetMaterialByGroupMatID(Guid.Empty, x.MatID);
                    x.LinkGroupMatCount = SubGroupML.Count();
                    try
                    {
                        MaxPrice = SubGroupML.Where(c => c.PriceInfo.SalesPrice > 0).Max(c => c.PriceInfo.SalesPrice).ToString("N");
                        MinPrice = SubGroupML.Where(c => c.PriceInfo.SalesPrice > 0).Min(c => c.PriceInfo.SalesPrice).ToString("N");
                        if (MaxPrice != MinPrice)
                        {
                            x.LinkGroupPrice = MinPrice + " ~ " + MaxPrice;
                        }
                        else
                        {
                            x.LinkGroupPrice = MinPrice;
                        }
                    }
                    catch
                    {
                        x.LinkGroupPrice = string.Empty;
                    }
                }
            }

            ML = IB.GetMatSalesPriceInfoList(ML, Guid.Empty);

            MaterialPageBySearchList MP = new MaterialPageBySearchList();
            MP.PageIndex = PageIndex;
            MP.PageSize = PageSize;
            MP.TotalRecord = query.Count();
            MP.Rows = ML;
            MP.Brand = PBLNew;
            MP.Cat = PCL;
            return MP;
        }
Пример #8
0
 public Coffee(BrandBase brand, SizeBase size) : base(brand, size)
 {
     Name = "Coffee";
     Cost = 5.0;
 }
Пример #9
0
        public List<Material> FindMaterialByPage(int PageIndex, int PageSize, out int TotalRecord, string Keyword, string MatBrand, string CatName, string IsImg, string IsStore, Guid MatBrandID, string IsStatUs, Guid LinkMainCID)
        {
            var query = (from M in db.Material
                         where true
                         &&
                         M.LinkMainCID.Equals(LinkMainCID)
                         select M).AsQueryable();

            //品牌判断
            if (!string.IsNullOrEmpty(MatBrand))
            {
                query = query.Where(m => m.MatBrand.Contains(MatBrand)).AsQueryable();
            }

            //品牌ID判断
            if (MatBrandID != Guid.Empty)
            {
                query = query.Where(m => m.MatBrandID.Equals(MatBrandID)).AsQueryable();
            }

            //分类判断
            if (!string.IsNullOrEmpty(CatName))
            {
                if(CatName == "IsNotConfigCatID")
                {
                    query = query.Where(m => m.CategoryID == Guid.Empty).AsQueryable();
                }
                else
                {
                    CatName = CatName + ',';
                    query = query.Where(m => m.CategoryName.Contains(CatName)).AsQueryable();
                }

            }

            //图片判断
            if (IsImg == "IsImg")
            {
                query = query.Where(m => m.MatImgPath != string.Empty && m.MatImgPath != null).AsQueryable();
            }

            if (IsImg == "IsNotImg")
            {
                query = query.Where(m => m.MatImgPath == string.Empty || m.MatImgPath == null).AsQueryable();
            }

            //安全库存判断
            if (IsStore == "IsStore")
            {
                query = query.Where(m => m.SafetyStock > 0).AsQueryable();
            }

            //发布 新品 置顶判断
            if(IsStatUs == MatISNo.IsPublic.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotPublic.ToString())
            {
                query = query.Where(x => x.IsPublic == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsTop.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsTop == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotTop.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsTop == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNew.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsNew == 1 && x.GroupToMatID == Guid.Empty).AsQueryable();

            }
            else if (IsStatUs == MatISNo.IsNotNew.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsNew == 0 && x.GroupToMatID == Guid.Empty).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsPromotion.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 1 && x.IsGroupMat <= 0).AsQueryable();
            }
            else if (IsStatUs == MatISNo.IsNotPromotion.ToString())
            {
                query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 0 && x.IsGroupMat <= 0 ).AsQueryable();
            }

            if (!string.IsNullOrEmpty(Keyword))
            {
                Keyword = Regex.Replace(Keyword, @"( )\1+", "$1", RegexOptions.None);
                string[] KeywordStr = Keyword.Split(' ');

                foreach (var K in KeywordStr)
                {
                    if (!string.IsNullOrEmpty(K))
                    {
                        query = query.Where(
                           m => m.MatSn.Contains(K) ||
                           m.MatBrand.Contains(K) ||
                           m.MatManufacturerSn.Contains(K) ||
                           m.MatSpecifications.Contains(K) ||
                           m.MatName.Contains(K) ||
                           m.KeywordIndex.Contains(K)
                           ).AsQueryable();
                    }
                }
            }

            TotalRecord = query.Count();
            List<Material> ML = query.OrderByDescending(s => s.LastUpdateTime).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();

            foreach(var x in ML)
            {
                try
                {
                    x.SingleOrderNumber = Convert.ToInt32(x.WeeklySales * (x.LeadTime / 7) + x.SafetyStock);
                }
                catch
                {
                    x.SingleOrderNumber = 0;
                }
            }

            string SupName = string.Empty;
            foreach(var x in ML.GroupBy(x=>x.LinkSupID).Select(x=>x.Key))
            {
                if(x == Guid.Empty)
                {
                    SupName = string.Empty;
                }
                else
                {
                    SupName = db.Supplier.Find(x).SupName;
                }

                foreach(var xx in ML.Where(c=>c.LinkSupID == x))
                {
                    xx.SupplierName = SupName;
                }
            }

            IBrand IB = new BrandBase();
            ML = IB.GetMatSalesPriceInfoList(ML, Guid.Empty);
            return ML;
        }
Пример #10
0
        public List<Material> FindMaterialForCustomerByPage(int PageIndex, int PageSize, out int TotalRecord, string Keyword, string MatBrand, string CatName, Guid MatBrandID, string IsStatUs, Guid CustomerID, Guid LinkMainCID)
        {
            var query = (from M in db.Material
                         where true
                         &&
                         M.LinkMainCID.Equals(LinkMainCID)
                         &&
                         M.IsGroupMat <= 0
                         select M).AsQueryable();

            if (IsStatUs == MatISNo.IsPublic.ToString())
            {
                query = query.Where(x => x.IsPublic == 1).AsQueryable();
            }

            //品牌判断
            if (!string.IsNullOrEmpty(MatBrand))
            {
                query = query.Where(m => m.MatBrand.Contains(MatBrand)).AsQueryable();
            }

            //品牌ID判断
            if (MatBrandID != Guid.Empty)
            {
                query = query.Where(m => m.MatBrandID.Equals(MatBrandID)).AsQueryable();
            }

            //分类判断
            if (!string.IsNullOrEmpty(CatName))
            {
                if (CatName == "IsNotConfigCatID")
                {
                    query = query.Where(m => m.CategoryID == Guid.Empty).AsQueryable();
                }
                else
                {
                    CatName = CatName + ',';
                    query = query.Where(m => m.CategoryName.Contains(CatName)).AsQueryable();
                }
            }

            if (!string.IsNullOrEmpty(Keyword))
            {
                Keyword = Regex.Replace(Keyword, @"( )\1+", "$1", RegexOptions.None);
                string[] KeywordStr = Keyword.Split(' ');

                foreach (var K in KeywordStr)
                {
                    if (!string.IsNullOrEmpty(K))
                    {
                        query = query.Where(
                           m => m.MatSn.Contains(K) ||
                           m.MatBrand.Contains(K) ||
                           m.MatManufacturerSn.Contains(K) ||
                           m.MatSpecifications.Contains(K) ||
                           m.MatName.Contains(K) ||
                           m.KeywordIndex.Contains(K)
                           ).AsQueryable();
                    }
                }
            }

            TotalRecord = query.Count();
            List<Material> ML = query.OrderByDescending(s => s.LastUpdateTime).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
            foreach (var x in ML)
            {
                x.MoreDetail = string.Empty;
            }

            IBrand IB = new BrandBase();
            ML = IB.GetMatSalesPriceInfoList(ML, CustomerID);
            return ML;
        }
Пример #11
0
        public Material GetMaterialItem(Guid MatID, Guid CID)
        {
            Material M = db.Material.Find(MatID);
            IBrand IB = new BrandBase();
            M.PriceInfo = IB.GetMatSalesPriceInfo(M, CID);

            try
            {
                M.SupplierName = db.Supplier.Find(M.LinkSupID).SupName;
            }
            catch
            {
                M.SupplierName = string.Empty;
            }

            MainCompany MC = db.MainCompany.Find(M.LinkMainCID);
            if(MC != null)
            {
                M.LinkMainCIDComName = MC.MainCompanyName;
                M.linkMainCIDWebSite = MC.WebSiteName;
            }

            return M;
        }
Пример #12
0
        public List<Material> GetMaterialByGroupMatID(Guid CID, Guid MatID)
        {
            List<Material> ML = new List<Material>();
            ML = db.Material.Where(x => x.GroupToMatID == MatID).OrderBy(x => x.MatName).ThenBy(x => x.MatSpecifications).ThenBy(x => x.MatManufacturerSn).ToList();

            IBrand IB = new BrandBase();
            ML = IB.GetMatSalesPriceInfoList(ML, CID);
            foreach (var x in ML)
            {
                x.MoreDetail = string.Empty;
            }
            return ML;
        }
Пример #13
0
 protected DrinkBase(BrandBase brand, SizeBase size)
 {
     _brand = brand;
     _size  = size;
 }
Пример #14
0
 public Naicha(BrandBase brand, SkuBase sku) : base(brand, sku)
 {
     Name  = "奶茶";
     Price = 8;
 }
Пример #15
0
 public Kafei(BrandBase brand, SkuBase sku) : base(brand, sku)
 {
     Name  = "咖啡";
     Price = 12;
 }