示例#1
0
        protected bool Equals(Product entity)
        {
            if (entity == null) return false;
            if (!base.Equals(entity)) return false;

            return true;
        }
示例#2
0
 private bool CheckProductInStockInDetailList(Product product)
 {
     foreach (StockInDetail inDetail in _stockInDetailList)
     {
         if (inDetail.Product.ProductId.Equals(product.ProductId)) return true;
     }
     return false;
 }
 private bool ProductInStockOutList(ArrayList detail, Product product)
 {
     foreach (StockOutDetail outDetail in detail)
     {
         if (outDetail.Product.ProductId.Equals(product.ProductId))
             return true;
     }
     return false;
 }
示例#4
0
 public void Delete(Product data)
 {
     ProductDao.Delete(data);
 }
示例#5
0
 public Product Add(Product data)
 {
     ProductDao.Add(data);
     return data;
 }
示例#6
0
 public void Update(Product data)
 {
     ProductDao.Update(data);
 }
示例#7
0
        public static IList<Product> CreateProduct(ProductMaster productMaster, IList colorList, IList sizeList)
        {
            IList<Product> products = new List<Product>();
            // product id is formed by productmasterid-colorid-sizeid and month of input
            string productIdPart1 = string.Format("{0:000000}", Int64.Parse(productMaster.ProductMasterId));
            string month = "";
            int i = DateTime.Now.Month%12;
            switch (i)
            {
                case 10:
                    month = "A";
                    break;
                case 11:
                    month = "B";
                    break;
                case 12:
                    month = "C";
                    break;
                default:
                    month = (i) + "";
                    break;
            }
            //string productIdPart4 = month;
            string year = (DateTime.Now.Year - 2012) + "";
            string productIdPart4 = year + month;

            foreach (ExProductColor color in colorList)
            {
                string productIdPart2 = string.Format("{0:00}", color.ColorId);
                foreach (ExProductSize size in sizeList)
                {
                    string productIdPart3 = string.Format("{0:00}", size.SizeId);
                    string productId = productIdPart1 + productIdPart2 + productIdPart3 + productIdPart4;
                    Product newProduct = new Product
                                             {
                                                 ProductId = productId,
                                                 Barcode = productId,
                                                 ProductMaster = productMaster,
                                                 CreateDate = DateTime.Now,
                                                 UpdateDate = DateTime.Now,
                                                 CreateId = "admin",
                                                 UpdateId = "admin",
                                                 ProductColor = color,
                                                 ProductSize = size
                                             };
                    products.Add(newProduct);
                }
            }
            return products;
        }
        public IEnumerable ProcessBarcode(string barCode)
        {
            MainPrice price;
            var product = ProductDao.FindById(barCode);
            // if can not get product by id so we try barcode
            if (product == null)
            {
                product = (Product)ProductDao.Execute(delegate(ISession session)
                                       {
                                           return (from prd in session.Query<Product>()
                                                       where prd.Barcode.Equals(barCode)
                                                       select prd).ToList().FirstOrDefault();
                                       });
            }
            if (product != null) // if we found the product by id or barcode
            {
                product.ProductMaster = ProductMasterDao.FindById(product.ProductMaster.ProductMasterId);
                // process sale actions
                price =
                    MainPriceDao.FindById(new MainPricePK
                                              {
                                                  DepartmentId = 0,
                                                  ProductMasterId = product.ProductMaster.ProductMasterId
                                              });

            }
            else // if can not find product by id & barcode
            {
                // check whether it is a valid barcode
                string productMasterId = string.Format("{0:0000000000000}", Int64.Parse(barCode.Substring(0, 7)));
                long colorId = Int64.Parse(barCode.Substring(7, 2));
                long sizeId = Int64.Parse(barCode.Substring(9, 2));
                var productMaster = ProductMasterDao.FindById(productMasterId);

                var color = ProductColorDao.FindById(colorId);
                var size = ProductSizeDao.FindById(sizeId);
                if (productMaster == null || color == null || size == null) throw new Exception("Invalid Barcode");

                Product exProduct = new Product
                                        {
                                            ProductId = string.Format("{0:0000000}",Int64.Parse(productMaster.ProductMasterId))
                                                         + string.Format("{0:00}",color.ColorId)
                                                         + string.Format("{0:00}", size.SizeId)
                                                         +"F",
                                            ProductColor = color,
                                            ProductSize = size,
                                            ProductMaster = productMaster,
                                            Barcode = barCode,
                                            AdhocCase = 1
                                        };
                product = exProduct;
                price =
                    MainPriceDao.FindById(new MainPricePK
                    {
                        DepartmentId = 0,
                        ProductMasterId = productMaster.ProductMasterId
                    });
            }
            yield return product;
            yield return price;
        }