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 void Delete(ProductMaster data) { ProductMasterDao.Delete(data); }
public ProductMaster Add(ProductMaster data) { ProductMasterDao.Add(data); return data; }
public void Update(ProductMaster data) { ProductMasterDao.Update(data); }
public bool Save(ProductMaster master, IList colors, IList sizes) { var maxIdResult = ProductMasterDao.SelectSpecificType(null, Projections.Max("ProductMasterId")); long maxProductMasterId = maxIdResult != null ? Int64.Parse(maxIdResult.ToString()) + 1 : 1; string productMasterId = string.Format("{0:0000000000000}", maxProductMasterId); master.ProductMasterId = productMasterId; ProductMasterDao.Add(master); if (master.Category.ExFld1 != 1) { master.Category.ExFld1 = 1; // category has been used for creating a productmaster CategoryDao.Update(master.Category); } if (master.ProductType.ExFld1 != 1) { master.ProductType.ExFld1 = 1; // product type has been used for creating a product master ProductTypeDao.Update(master.ProductType); } // create product // product id is formed by productmasterid-colorid-sizeid and year-month of input /*string productIdPart1 = string.Format("{0:000000}", maxProductMasterId); 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; } // year will count from the day set up system. The first year is 0 string year = (DateTime.Now.Year - 2012) + ""; string productIdPart4 = year + month; foreach (ExProductColor color in colors) { string productIdPart2 = string.Format("{0:00}", color.ColorId); foreach (ExProductSize size in sizes) { string productIdPart3 = string.Format("{0:00}", size.SizeId); string productId = productIdPart1 + productIdPart2 + productIdPart3 + productIdPart4; Product existProduct = ProductDao.FindById(productId); if(existProduct == null) { Product newProduct = new Product { ProductId = productId, Barcode = productId, ProductMaster = master, CreateDate = DateTime.Now, UpdateDate = DateTime.Now, CreateId = "admin", UpdateId = "admin", ProductColor = color, ProductSize = size }; //ProductDao.Add(newProduct); } } }*/ return true; }
protected override void OnInitialize() { base.OnInitialize(); var list = Flow.Session.Get(FlowConstants.PRODUCT_NAMES_LIST); DefinitionStatus = new StockDefinitionStatus(); ProductMasterList = list as IList; var deptsList = Flow.Session.Get(FlowConstants.DEFINITION_STATUS_LIST); DefinitionStatusList = deptsList as IList; ProductMaster = new CoralPOS.Models.ProductMaster(); var details = new ArrayList(); StockOutDetails = details; CreateDate = DateTime.Now; CoralPOS.Models.StockOut stockOut = Flow.Session.Get(FlowConstants.SAVE_STOCK_OUT) as CoralPOS.Models.StockOut; if (stockOut != null) { StockOutDetails = ObjectConverter.ConvertFrom(stockOut.StockOutDetails); DefinitionStatus = stockOut.DefinitionStatus; } else { /*StockDefinitionStatus definitionStatus = DataErrorInfoFactory.Create<StockDefinitionStatus>(); definitionStatus.DefectStatusId = (int)StockOutType.Normal; definitionStatus.DefectStatusName = "NORMAL";*/ Department department = new Department{ DepartmentId = 0,DepartmentName = "KHO CHINH"}; stockOut = DataErrorInfoFactory.Create<CoralPOS.Models.StockOut>(); stockOut.ConfirmFlg = 0; stockOut.CreateDate = DateTime.Now; stockOut.UpdateDate = DateTime.Now; stockOut.StockOutDate = DateTime.Now; stockOut.CreateId = "admin"; stockOut.UpdateId = "admin"; stockOut.DelFlg = 0; stockOut.ExclusiveKey = 0; stockOut.Department = department; /*stockOut.DefinitionStatus = definitionStatus;*/ } StockOut = stockOut; }
public void OnActivated() { var list = Flow.Session.Get(FlowConstants.PRODUCT_NAMES_LIST); ProductMasterList = list as IList; var deptsList = Flow.Session.Get(FlowConstants.DEPARTMENTS); Departments = deptsList as IList; ProductMaster = new CoralPOS.Models.ProductMaster(); var details = new ArrayList(); DepartmentStockOutDetails = details; CreateDate = DateTime.Now; CoralPOS.Models.DepartmentStockOut stockOut = Flow.Session.Get(FlowConstants.SAVE_DEPT_STOCK_OUT) as CoralPOS.Models.DepartmentStockOut; if (stockOut != null) { DepartmentStockOutDetails = ObjectConverter.ConvertFrom(stockOut.DepartmentStockOutDetails); Department = new Department { DepartmentId = stockOut.DepartmentStockOutPK.DepartmentId, DepartmentName = "CK" }; } else { StockDefinitionStatus definitionStatus = DataErrorInfoFactory.Create<StockDefinitionStatus>(); definitionStatus.DefectStatusId = (int)StockOutType.Normal; definitionStatus.DefectStatusName = "NORMAL"; stockOut = DataErrorInfoFactory.Create<CoralPOS.Models.DepartmentStockOut>(); stockOut.ConfirmFlg = 0; stockOut.CreateDate = DateTime.Now; stockOut.UpdateDate = DateTime.Now; stockOut.StockOutDate = DateTime.Now; stockOut.CreateId = "admin"; stockOut.UpdateId = "admin"; stockOut.DelFlg = 0; stockOut.ExclusiveKey = 0; stockOut.StockDefinitionStatus = definitionStatus; } DepartmentStockOut = stockOut; }
protected bool Equals(ProductMaster entity) { if (entity == null) return false; if (!base.Equals(entity)) return false; return true; }
private void CreateNewProductMaster() { //ProductMaster = DataErrorInfoFactory.Create<CoralPOS.Models.ProductMaster>(); ProductMaster = new CoralPOS.Models.ProductMaster(); }