public static StockOut From(StockIn stockIn, Department department,StockDefinitionStatus definitionStatus, int confirmFlag = 0,string description ="") { IDictionary<Product,long> productList = new Dictionary<Product, long>(); foreach (var detail in stockIn.StockInDetails) { productList.Add(detail.Product,detail.Quantity); } return Create( department, productList, stockIn.CreateId, stockIn.CreateDate, definitionStatus, description, 0); }
public static StockIn Create(Department department,IDictionary<Product,long> productList, string createId,DateTime createDate,string description,int stockInType = 1,int confirmFlag = 1) { CoralPOS.Models.StockIn stockIn = new CoralPOS.Models.StockIn { CreateDate = createDate, ConfirmFlg = confirmFlag, CreateId = createId, UpdateId = createId, UpdateDate = createDate, Description = description, ExclusiveKey = 0, DelFlg = 0, StockInDate = createDate, StockInDetails = new List<StockInDetail>(), StockInType = 3, }; foreach (var tempValid in productList) { CoralPOS.Models.StockInDetail detail = new StockInDetail { StockIn = stockIn, CreateDate = createDate, UpdateDate = createDate, CreateId = createId, UpdateId = createId, DelFlg = 0, ExclusiveKey = 0, Quantity = tempValid.Value, Product = tempValid.Key, ProductMaster = tempValid.Key.ProductMaster, StockInType = stockInType, }; stockIn.StockInDetails.Add(detail); } return stockIn; }
protected override void OnActivate() { var list = Flow.Session.Get(FlowConstants.PRODUCT_NAMES_LIST) as IList; ProductMasterList = list; StockInDetailList = new ArrayList(); SelectedStockInDetails = new ArrayList(); StockIn = Flow.Session.Get(FlowConstants.SAVE_STOCK_IN) as CoralPOS.Models.StockIn; if (StockIn == null) { //CoralPOS.Models.StockIn stockIn = DataErrorInfoFactory.Create<CoralPOS.Models.StockIn>(); var stockIn = new CoralPOS.Models.StockIn(); stockIn.StockInType = 0; stockIn.ConfirmFlg = 0; stockIn.Description = Description; stockIn.CreateDate = DateTime.Now; stockIn.UpdateDate = DateTime.Now; stockIn.StockInDate = DateTime.Now; stockIn.CreateId = "admin"; stockIn.UpdateId = "admin"; stockIn.DelFlg = 0; stockIn.ExclusiveKey = 0; stockIn.StockInDetails = ObjectConverter.ConvertTo<StockInDetail>(StockInDetailList); StockIn = stockIn; } else { StockInDetailList = ObjectConverter.ConvertFrom(StockIn.StockInDetails); } }
private object ChooseStockIn(StockIn selectedStockIn) { StockIn stockIn = StockInLogic.Fetch(SelectedStockIn); StockInLogic.FetchMainStock(stockIn); return stockIn; }
public void Initialize() { FromDate = DateTime.Now; ToDate = DateTime.Now; CategoryList = CategoryLogic.FindAll(new ObjectCriteria<Category>()) as IList; IList searchedStockOut = Flow.Session.Get(FlowConstants.STOCK_IN_SEARCH_RESULT) as IList; CoralPOS.Models.StockIn selectedStockOut = Flow.Session.Get(FlowConstants.SAVE_STOCK_IN) as CoralPOS.Models.StockIn; if (searchedStockOut == null) { SelectedStockIn = new CoralPOS.Models.StockIn(); } else { if (selectedStockOut != null) SelectedStockIn = selectedStockOut; else { SelectedStockIn = new CoralPOS.Models.StockIn(); } } }
protected bool Equals(StockIn entity) { if (entity == null) return false; if (!base.Equals(entity)) return false; return true; }
public void Delete(StockIn data) { StockInDao.Delete(data); }
public StockIn Add(StockIn data) { StockInDao.Add(data); return data; }
public void Update(StockIn data) { StockInDao.Update(data); }
public void FetchMainStock(StockIn stockIn) { StockInDao.Execute(delegate(ISession session) { foreach (StockInDetail inDetail in stockIn.StockInDetails) { MainStock stock = (from stk in session.Query<MainStock>() where stk.Product.ProductId.Equals(inDetail.Product.ProductId) select stk).FirstOrDefault(); inDetail.Stock = stock; } return null; }); }
public StockIn Fetch(StockIn stockIn) { return StockInDao.Fetch(stockIn); }
public StockIn Add(StockIn data) { IDictionary<string,MainPrice> prices = new Dictionary<string, MainPrice>(); var maxIdResult = StockInDao.SelectSpecificType(null, Projections.Max("StockInId")); long nextStockInId = maxIdResult != null ? Int64.Parse(maxIdResult.ToString()) + 1 : 1; // add or update stock var maxStockIdResult = MainStockDao.SelectSpecificType(null, Projections.Max("StockId")); long nextStockId = maxStockIdResult != null ? Int64.Parse(maxStockIdResult.ToString()) + 1 : 1; data.StockInId = nextStockInId.ToString(); StockInDao.Add(data); foreach (StockInDetail inDetail in data.StockInDetails) { inDetail.StockInDetailPK.StockInId = nextStockInId.ToString(); Product current = ProductDao.FindById(inDetail.Product.ProductId); if (current != null) { inDetail.Product = current; } else { ProductDao.Add(inDetail.Product); } StockInDetailDao.Add(inDetail); ObjectCriteria<MainStock> findStock = new ObjectCriteria<MainStock>(); string productId = inDetail.Product.ProductId; findStock.Add(stk => stk.Product.ProductId==productId); MainStock currentStock = MainStockDao.FindFirst(findStock) as MainStock; if(currentStock == null) // create new stock { MainStock newStock = new MainStock { StockId = nextStockId++, CreateDate = DateTime.Now, UpdateDate = DateTime.Now, CreateId = "admin", UpdateId = "admin", DelFlg = 0, ExclusiveKey = 1, Product = inDetail.Product, ProductMaster = inDetail.ProductMaster, Quantity = inDetail.Quantity, GoodQuantity = inDetail.Quantity }; MainStockDao.Add(newStock); } else // update current stock { currentStock.Quantity += inDetail.Quantity; currentStock.GoodQuantity += inDetail.Quantity; currentStock.ExclusiveKey += 1; MainStockDao.Update(currentStock); } // add price for update later prices[inDetail.MainPrice.MainPricePK.ProductMasterId] = inDetail.MainPrice; } // update price if have foreach (KeyValuePair<string, MainPrice> mainPrice in prices) { ObjectCriteria<MainPrice> findPrice = new ObjectCriteria<MainPrice>(); string productMasterId = mainPrice.Key; findPrice.Add( price => price.MainPricePK.ProductMasterId == productMasterId); MainPrice currentPrice = MainPriceDao.FindFirst(findPrice) as MainPrice; if (currentPrice == null) { MainPriceDao.Add(mainPrice.Value); } else { currentPrice.Price = mainPrice.Value.Price; currentPrice.WholeSalePrice = mainPrice.Value.WholeSalePrice; MainPriceDao.Update(currentPrice); } } // color and size // the updating informs that specialized object has been used in stock in so it can not be deleted. IList<ExProductColor> colors = data.StockInDetails.Select(x => x.Product.ProductColor).Distinct().ToList(); foreach (ExProductColor exProductColor in colors) { if(exProductColor.ExFld1 == 1) continue; exProductColor.ExFld1 = 1; ExProductColorDao.Update(exProductColor); } IList<ExProductSize> sizes = data.StockInDetails.Select(x => x.Product.ProductSize).Distinct().ToList(); foreach (ExProductSize exProductSize in sizes) { if(exProductSize.ExFld1 == 1) continue; exProductSize.ExFld1 = 1; ExProductSizeDao.Update(exProductSize); } return data; }