Example #1
0
 public bool LoadExcel(string FileName, string SheetName)
 {
     Cart.Clear();
     try
     {
         Cart.Clear();
         XSSFWorkbook hssfwb;
         using (FileStream file = new FileStream
                                      ($@"C:\Users\patro\Desktop\doc\{FileName}.xlsx", FileMode.Open, FileAccess.Read))
         {
             hssfwb = new XSSFWorkbook(file);
         }
         ISheet sheet = hssfwb.GetSheet(SheetName);
         for (int row = 1; row <= sheet.LastRowNum; row++)
         {
             if (sheet.GetRow(row) != null)
             {
                 int               id       = (int)sheet.GetRow(row).GetCell(0).NumericCellValue;
                 string            name     = sheet.GetRow(row).GetCell(1).StringCellValue;
                 decimal           Price    = (decimal)sheet.GetRow(row).GetCell(2).NumericCellValue;
                 ProductCategoryId category = Enum.Parse <ProductCategoryId>(sheet.GetRow(row).GetCell(3).StringCellValue);
                 Cart.Add(new Product(id, name, Price, category));
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
        private List <JoinVpToProd> GetVendorProducts(VendorId vendorId, ProductCategoryId catId)
        {
            List <JoinVpToProd> result = new List <JoinVpToProd>();

            using (Ambient.DbSession.Activate())
            {
                Dictionary <int, Product> productDict;
                List <VendorProduct>      venprodList;
                if (catId.Value == VendorProductHelper.AllCategoriesId)
                {
                    VendorProductHelper.LoadForAllCategories(vendorId, out productDict, out venprodList);
                }
                else
                {
                    VendorProductHelper.LoadForCategory(vendorId, catId, out productDict, out venprodList);
                }
                foreach (VendorProduct venprod in venprodList)
                {
                    Product      product = productDict[venprod.ProductId.Value];
                    JoinVpToProd join    = new JoinVpToProd(venprod, product);
                    join.SetExternalData(new ZeroFreightProvider());
                    result.Add(join);
                }
            }
            return(result);
        }
Example #3
0
 public bool LoadText(string FileName)
 {
     Cart.Clear();
     try
     {
         foreach (var line in File.ReadAllLines($@"C:\Users\patro\Desktop\doc\{FileName}.txt"))
         {
             if (!string.IsNullOrWhiteSpace(line))
             {
                 var               item     = line.Split(":");
                 int               id       = int.Parse(item[0]);
                 string            name     = item[1];
                 decimal           Price    = decimal.Parse(item[2]);
                 ProductCategoryId category = Enum.Parse <ProductCategoryId>(item[3]);
                 Cart.Add(new Product(id, name, Price, category));
             }
         }
         PrintList();
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
Example #4
0
 public Product(int id, string name, decimal price, ProductCategoryId productCategoryId)
 {
     Id       = id;
     Name     = name;
     Price    = price;
     Category = productCategoryId;
 }
        public static void LoadForCategory(VendorId vendorId, ProductCategoryId productCategoryId,
                                           out Dictionary <int, Product> productDict, out List <VendorProduct> venprodList)
        {
            List <Product> products = OrderingRepositories.Product.Get(vendorId, productCategoryId);

            productDict = MakeProductDictionary(products);
            venprodList = OrderingRepositories.VendorProduct.Get(vendorId, productCategoryId);
        }
 public List <VendorProduct> Get(VendorId vendorId, ProductCategoryId productCategoryId)
 {
     return(Search("dbo.GetVendorProductsByVendorCategory",
                   delegate(SqlCommand cmd)
     {
         SqlHelper.AddParamInputId(cmd, "@VendorId", vendorId.Value);
         SqlHelper.AddParamInputId(cmd, "@ProductCategoryId", productCategoryId.Value);
     }));
 }
 public List <Product> Get(ProductBrandId brandId, ProductCategoryId productCategoryId)
 {
     return(Search("dbo.GetProductsByBrandCategory",
                   delegate(SqlCommand cmd)
     {
         SqlHelper.AddParamInputId(cmd, "@BrandId", brandId.Value);
         SqlHelper.AddParamInputId(cmd, "@ProductCategoryId", productCategoryId.Value);
     }));
 }
Example #8
0
 public void AddCategory(PurOrderId orderId, ProductCategoryId categoryId, bool includeInactive)
 {
     ExecuteNonQuery("dbo.PurLineAddCategory",
                     delegate(SqlCommand cmd)
     {
         SqlHelper.AddParamInputId(cmd, "@OrderId", orderId.Value);
         SqlHelper.AddParamInputId(cmd, "@CategoryId", categoryId.Value);
         SqlHelper.AddParamInt(cmd, "@IncludeInactive", includeInactive ? 1 : 0);
     });
 }
Example #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (Name == null ? 0 : Name.GetHashCode());
         hash = hash * 23 + (ProductCategoryId == default(int) ? 0 : ProductCategoryId.GetHashCode());
         hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode());
         return(hash);
     }
 }
Example #10
0
        public int RemoveCategory(PurOrderId orderId, ProductCategoryId categoryId)
        {
            SqlParameter outputParam = null;

            ExecuteNonQuery("dbo.PurLineRemoveCategory",
                            delegate(SqlCommand cmd)
            {
                SqlHelper.AddParamInputId(cmd, "@OrderId", orderId.Value);
                SqlHelper.AddParamInputId(cmd, "@CategoryId", categoryId.Value);
                outputParam = SqlHelper.AddParamOutputInt(cmd, "@LinesRemaining");
            });
            return((int)outputParam.Value);
        }
Example #11
0
 public bool CreateNewProduct(string name, decimal price, ProductCategoryId categoryid)
 {
     using (var context = new OrderManagmentDbContext())
     {
         var newProduct = new Product();
         newProduct.Name     = name;
         newProduct.Price    = price;
         newProduct.Category = categoryid;
         context.Add(newProduct);
         context.SaveChanges();
         return(true);
     }
 }
Example #12
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("ProductCategory(");
        bool __first = true;

        if (__isset.productCategoryId)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ProductCategoryId: ");
            ProductCategoryId.ToString(sb);
        }
        if (Title != null && __isset.title)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Title: ");
            Title.ToString(sb);
        }
        if (__isset.productCount)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ProductCount: ");
            ProductCount.ToString(sb);
        }
        if (__isset.newFlag)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("NewFlag: ");
            NewFlag.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
Example #13
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            if (__isset.productCategoryId)
            {
                hashcode = (hashcode * 397) + ProductCategoryId.GetHashCode();
            }
            if (__isset.title)
            {
                hashcode = (hashcode * 397) + Title.GetHashCode();
            }
            if (__isset.productCount)
            {
                hashcode = (hashcode * 397) + ProductCount.GetHashCode();
            }
            if (__isset.newFlag)
            {
                hashcode = (hashcode * 397) + NewFlag.GetHashCode();
            }
        }
        return(hashcode);
    }
Example #14
0
 public ProductCategory(ProductCategoryId id, ProductCategoryOrder order)
 {
     Id    = id;
     Order = order;
 }