private bool IsInList(DepartmentStockInDetailCollection collection, DepartmentStockInDetail detail) { foreach (DepartmentStockInDetail inDetail in collection) { if(detail.Product.ProductId.Equals(inDetail.Product.ProductId)) { return true; } } return false; }
public void Update(DepartmentStockInDetail data) { DepartmentStockInDetailDAO.Update(data); }
private void btnAddProduct_Click(object sender, EventArgs e) { if (DepartmentStockInDetailList == null) { DepartmentStockInDetailList = new ArrayList(); } BindDataToList(); for (int i = 0; i < numericUpDown.Value; i++) { var stockInDetail = new DepartmentStockInDetail{Product = new Product{ProductMaster = new ProductMaster()}}; DepartmentStockInDetailList.Add(stockInDetail); } PopulateDataGrid(); }
private void DepartmentStockInFromMainEditForm_Shown(object sender, EventArgs e) { if(StockOut == null ) { return; } deptSIDetailList.Clear(); foreach (StockOutDetail outDetail in StockOut.StockOutDetails) { DepartmentStockInDetail deptDetail = new DepartmentStockInDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.DepartmentStockInDetailPK = new DepartmentStockInDetailPK(); deptDetail.Product = outDetail.Product; deptDetail.ProductMaster = outDetail.Product.ProductMaster; deptDetail.Quantity = outDetail.Quantity; deptDetail.StockOutDetailId = outDetail.StockOutDetailId; deptSIDetailList.Add(deptDetail); } DepartmentStockInEventArgs eventArgs = new DepartmentStockInEventArgs(); eventArgs.DepartmentStockInDetailList = ObjectConverter.ConvertToNonGenericList(deptSIDetailList); EventUtility.fireEvent(FindRemainsQuantity,this,eventArgs); deptSIDetailList.Clear(); foreach (DepartmentStockInDetail departmentStockInDetail in eventArgs.DepartmentStockInDetailList) { deptSIDetailList.Add(departmentStockInDetail); } foreach (Department department in cbbDept.Items) { if(department.DepartmentId == StockOut.DepartmentId) { cbbDept.SelectedItem = department; break; } } }
private void ProcessStockInDetail(DepartmentStockInDetail detail, DataAccessLayer dal) { // insert type name string typeName = detail.Product.ProductMaster.ProductType.TypeName; object id = dal.GetSingleValue("Select type_id from product_type where type_name = '" + typeName + "'"); if (id == null || id.ToString() == string.Empty) { id = dal.GetSingleValue("Select max(type_id) from product_type "); if (id == null || id.ToString() == string.Empty) { id = 1; } else { id = Convert.ToInt32(id.ToString()) + 1; } dal.ExecuteQuery("insert into product_type(type_id, type_name) values (" + id.ToString() + ", N'" + typeName.Replace("'", "''") + "')"); } // insert color name string colorName = detail.Product.ProductMaster.ProductColor.ColorName; id = dal.GetSingleValue("Select color_id from product_color where color_name = '" + colorName.Replace("'", "''") + "'"); if (id == null || id.ToString() == string.Empty) { id = dal.GetSingleValue("Select max(color_id) from product_color "); if (id == null || id.ToString() == string.Empty) { id = 1; } else { id = Convert.ToInt32(id.ToString()) + 1; } dal.ExecuteQuery("insert into product_color(Color_id, Color_name) values (" + id.ToString() + ", N'" + colorName.Replace("'", "''") + "')"); } // insert size name string sizeName = detail.Product.ProductMaster.ProductSize.SizeName; id = dal.GetSingleValue("Select size_id from product_size where size_name = '" + sizeName.Replace("'", "''") + "'"); if (id == null || id.ToString() == string.Empty) { id = dal.GetSingleValue("Select max(size_id) from product_size "); if (id == null || id.ToString() == string.Empty) { id = 1; } else { id = Convert.ToInt32(id.ToString()) + 1; } dal.ExecuteQuery("insert into product_size(size_id, size_name) values (" + id.ToString() + ", N'" + sizeName.Replace("'", "''") + "')"); } // insert product master string productMasterId = detail.Product.ProductMaster.ProductMasterId; id = dal.GetSingleValue("Select product_master_id from product_master where product_master_id = '" + productMasterId + "'"); if (id == null || id.ToString() == string.Empty) { id = dal.GetSingleValue("Select max(product_master_id) from product_master "); if (id == null || id.ToString() == string.Empty) { id = 1; } else { id = Convert.ToInt32(id.ToString()) + 1; } dal.ExecuteQuery("insert into product_master(product_master_id, product_name, size_id, color_id, type_id, create_date,description) values ('" + productMasterId + "', '" + detail.Product.ProductMaster.ProductName.Replace("'", "''") + "', " + detail.Product.ProductMaster.ProductSize.SizeId + ", " + detail.Product.ProductMaster.ProductColor.ColorId + ", " + detail.Product.ProductMaster.ProductType.TypeId + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + detail.Product.ProductMaster.Description + "')"); } // product string productId = detail.Product.ProductId; id = dal.GetSingleValue("Select product_id from product where product_id = '" + productId + "'"); if (id == null || id.ToString() == string.Empty) { dal.ExecuteQuery("insert into product(product_id, product_master_id, quantity, price, create_date) values ('" + productId + "', '" + productMasterId + "', " + detail.Quantity + ", " + detail.Price + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"); } // dept-price id = dal.GetSingleValue("Select product_master_id from department_price where product_master_id = '" + productMasterId + "'"); // chi cap nhat gia le, khong cap nhat gia ban si if (id == null || id.ToString() == string.Empty) { dal.ExecuteQuery("insert into department_price(department_id, product_master_id, price, whole_sale_price) values (" + "0, '" + productMasterId + "', " + detail.Price + ", " + 0 + ")"); } else { dal.ExecuteQuery("update department_price set price = " + detail.Price + " where product_master_id = '" + productMasterId + "'"); } }
private object[] AddProductToDataGrid(DepartmentStockInDetail stockInDetail, int rowIndex) { var obj = new object[MAX_COLUMNS]; obj[PRODUCT_PRICE_POS] = stockInDetail.Product.Price; obj[PRODUCT_QUANTITY_POS] = stockInDetail.Product.Quantity; obj[PRODUCT_SELL_PRICE_POS] = stockInDetail.OnStorePrice; if (DepartmentStockList != null && DepartmentStockList.Count > 0 && !string.IsNullOrEmpty(stockInDetail.Product.ProductId)) { foreach (DepartmentStock stock in DepartmentStockList) { if (stock.Product.ProductId == stockInDetail.Product.ProductId) { obj[STOCK_QUANTITY_POS] = stockInDetail.Quantity - stock.Quantity; break; } } } if (DepartmentRemainStockList != null && DepartmentRemainStockList.Count > 0 && !string.IsNullOrEmpty(stockInDetail.Product.ProductMaster.ProductMasterId)) { foreach (DepartmentStockSearchResult stock in DepartmentRemainStockList) { if (stock.DepartmentStock.Product.ProductMaster.ProductMasterId.Equals(stockInDetail.Product.ProductMaster.ProductMasterId)) { obj[STOCK_REMAIN_QUANTITY_POS] = stock.SumQuantity; break; } } } if (stockInDetail.Product.ProductMaster != null) { obj[PRODUCT_ID_POS] = stockInDetail.Product.ProductMaster.ProductMasterId; obj[PRODUCT_NAME_POS] = stockInDetail.Product.ProductMaster.ProductName; if (stockInDetail.Product.ProductMaster.ProductType != null) { obj[PRODUCT_TYPE_POS] = stockInDetail.Product.ProductMaster.ProductType.TypeName; } if (stockInDetail.Product.ProductMaster.ProductSize != null) { obj[PRODUCT_SIZE_POS] = stockInDetail.Product.ProductMaster.ProductSize.SizeName; } if (stockInDetail.Product.ProductMaster.ProductColor != null) { obj[PRODUCT_COLOR_POS] = stockInDetail.Product.ProductMaster.ProductColor.ColorName; } if (stockInDetail.Product.ProductMaster.Country != null) { obj[PRODUCT_COUNTRY_POS] = stockInDetail.Product.ProductMaster.Country.CountryName; } if (stockInDetail.Product.ProductMaster.Manufacturer != null) { obj[PRODUCT_SUPPLIER_POS] = stockInDetail.Product.ProductMaster.Manufacturer.ManufacturerName; } } obj[MAX_COLUMNS - 1] = stockInDetail.DelFlg; return obj; }
void _departmentStockInView_FindByBarcodeEvent(object sender, DepartmentStockInEventArgs e) { /*var subCriteria = new SubObjectCriteria("StockOut"); subCriteria.AddEqCriteria("DefectStatus.DefectStatusId", (long)4); // tạm xuất là 8*/ var objectCriteria = new ObjectCriteria(); objectCriteria.AddEqCriteria("Product.ProductId", e.ProductId); objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); objectCriteria.AddEqCriteria("DefectStatus.DefectStatusId", (long)4); // tạm xuất là 4 IList list = DepartmentStockOutDetailLogic.FindAll(objectCriteria); if (list!=null && list.Count > 0) { var detail = new DepartmentStockInDetail { Product = ((DepartmentStockOutDetail)list[0]).Product }; foreach (DepartmentStockOutDetail soDetail in list) { detail.StockOutQuantity += soDetail.Quantity; } e.DepartmentStockInDetail = detail; IList reStockInList = DepartmentStockInLogic.FindReStockIn(e.ProductId); if (reStockInList != null) { foreach (DepartmentStockInDetail inDetail in reStockInList) { e.DepartmentStockInDetail.ReStockQuantity += inDetail.Quantity; } } } e.EventResult = "Success"; }
/// <summary> /// Add DepartmentStockInDetail to database. /// </summary> /// <param name="data"></param> /// <returns></returns> public DepartmentStockInDetail Add(DepartmentStockInDetail data) { HibernateTemplate.Save(data); return data; }
void departmentStockInExtraView_LoadStockInByProductMaster(object sender, DepartmentStockInEventArgs e) { if(e.ProductMasterList == null || e.ProductMasterList.Count == 0 ) { return; } ObjectCriteria prdMasterCrit = new ObjectCriteria(); IList prdNames = new ArrayList(); foreach (ProductMaster list in e.ProductMasterList) { prdNames.Add(list.ProductName); } IList prdMasterList = new ArrayList(); foreach (ProductMaster master in e.ProductMasterList) { prdMasterList.Add(master); } /*prdMasterCrit.AddSearchInCriteria("ProductName", prdNames); prdMasterCrit.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); prdMasterList = ProductMasterLogic.FindAll(prdMasterCrit);*/ if (prdMasterList != null && prdMasterList.Count > 0) { IList prdMstIds = new ArrayList(); foreach (ProductMaster master in prdMasterList) { prdMstIds.Add(master.ProductMasterId); } IList stockOutList = new ArrayList(); ObjectCriteria stkCriteria = new ObjectCriteria(); stkCriteria.AddSearchInCriteria("ProductMaster.ProductMasterId", prdMstIds); stkCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); //stkCriteria.AddGreaterCriteria("GoodQuantity", (long)0); IList stockList = StockLogic.FindAll(stkCriteria); foreach (Stock inDetail in stockList) { DepartmentStockInDetail deptDetail = new DepartmentStockInDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.DepartmentStockInDetailPK = new DepartmentStockInDetailPK(); deptDetail.Product = inDetail.Product; deptDetail.ProductMaster = inDetail.Product.ProductMaster; deptDetail.Quantity = inDetail.Quantity; stockOutList.Add(deptDetail); } GetRemainStockNumber(stockOutList); MinusConfirmStockOut(stockOutList); e.SelectedStockOutDetails = stockOutList; } }
public DepartmentStockIn Add(DepartmentStockIn data) { string deptStr = ""; if(ClientSetting.IsSubStock()) { deptStr = string.Format("{0:00000}", data.DepartmentStockInPK.DepartmentId); } else { deptStr = string.Format("{0:000}", data.DepartmentStockInPK.DepartmentId); } string dateStr = data.StockInDate.ToString("yyMMdd"); var criteria = new ObjectCriteria(); if(ClientSetting.IsSubStock()) { criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "000"); } else { criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "00000"); } var maxId = DepartmentStockInDAO.SelectSpecificType(criteria, Projections.Max("DepartmentStockInPK.StockInId")); string stockInId = ""; if(ClientSetting.IsSubStock()) { stockInId = maxId == null ? dateStr + deptStr + "001" : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1)); } else { stockInId = maxId == null ? dateStr + deptStr + "00001" : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1)); } var stockInPk = new DepartmentStockInPK {DepartmentId = data.DepartmentId, StockInId = stockInId + ""}; data.DepartmentStockInPK = stockInPk; data.CreateDate = DateTime.Now; data.UpdateDate = DateTime.Now; data.UpdateId = ClientInfo.getInstance().LoggedUser.Name; data.CreateId = ClientInfo.getInstance().LoggedUser.Name; DepartmentStockInDAO.Add(data); // we will get the stock to get the data IList productMasterIds = new ArrayList(); foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails) { productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId); } criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddGreaterCriteria("Quantity", (long)0); criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds); criteria.AddOrder("ProductMaster.ProductMasterId", true); criteria.AddOrder("Product.ProductId", true); IList stockList = DepartmentStockDAO.FindAll(criteria); IList updateStockList = new ArrayList(); IList stockInDetailList = new ArrayList(); foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails) { long quantity = stockInDetail.Quantity; foreach (DepartmentStock stock in stockList) { long stockInQty = 0; if (stock.Product.ProductId.Equals(stockInDetail.ProductId) && stock.Quantity >= 0) { /*if (quantity >= stock.Quantity) { stockInQty = stock.Quantity; quantity -= stock.Quantity; stock.Quantity = 0; } else { stockInQty = quantity; stock.Quantity -= quantity; quantity = 0; }*/ if (quantity >= stock.GoodQuantity) { stockInQty = stock.GoodQuantity; quantity -= stock.GoodQuantity; stock.GoodQuantity = 0; } else { stockInQty = quantity; stock.GoodQuantity -= quantity; quantity = 0; } stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity + stock.LostQuantity + stock.UnconfirmQuantity; stock.UpdateDate = DateTime.Now; stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name; updateStockList.Add(stock); var pk = new DepartmentStockInDetailPK { DepartmentId = data.DepartmentId, ProductId = stock.Product.ProductId, StockInId = stockInId }; var detail = new DepartmentStockInDetail { DepartmentStockInDetailPK = pk, Quantity = stockInQty, CreateDate = DateTime.Now, UpdateDate = DateTime.Now, UpdateId = ClientInfo.getInstance().LoggedUser.Name, CreateId = ClientInfo.getInstance().LoggedUser.Name, ProductMaster = stock.ProductMaster }; var deptStock = new DepartmentStock { DepartmentStockPK = new DepartmentStockPK { DepartmentId = data.DepartmentId, ProductId = stock.Product.ProductId }, CreateDate = DateTime.Now, UpdateDate = DateTime.Now, UpdateId = ClientInfo.getInstance().LoggedUser.Name, CreateId = ClientInfo.getInstance().LoggedUser.Name, ProductMaster = stock.ProductMaster }; stockInDetailList.Add(detail); if (quantity == 0) { break; } } } if (quantity > 0) { data.DepartmentStockInPK.StockInId = null; throw new BusinessException("Số lượng xuất kho lớn hơn số lượng trong kho"); } } foreach (DepartmentStockInDetail detail in stockInDetailList) { DepartmentStockInDetailDAO.Add(detail); } foreach (Stock stock in updateStockList) { StockDAO.Update(stock); } return data; }
void departmentStockInExtraView_FindBarcodeInMainStockEvent(object sender, DepartmentStockInEventArgs e) { if (string.IsNullOrEmpty(e.ProductId)) { return; } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("Product.ProductId", e.ProductId); IList stockList = StockLogic.FindAll(criteria); if (stockList.Count == 0) { return; } IList stockOutList = new ArrayList(); foreach (Stock inDetail in stockList) { DepartmentStockInDetail deptDetail = new DepartmentStockInDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.DepartmentStockInDetailPK = new DepartmentStockInDetailPK(); deptDetail.Product = inDetail.Product; deptDetail.ProductMaster = inDetail.Product.ProductMaster; deptDetail.Quantity = 1; stockOutList.Add(deptDetail); } GetRemainStockNumber(stockOutList); MinusConfirmStockOut(stockOutList); e.SelectedStockOutDetails = stockOutList; e.EventResult = "Success"; }
public void departmentStockInExtraView_FindByStockInIdEvent(object sender, DepartmentStockInEventArgs e) { if (e.SelectedStockInIds.Count > 0) { ObjectCriteria objectCriteria = new ObjectCriteria(); objectCriteria.AddSearchInCriteria("StockInDetailPK.StockInId", e.SelectedStockInIds); IList list = StockInDetailLogic.FindAll(objectCriteria); IList stockOutList = new ArrayList(); foreach (StockInDetail inDetail in list) { DepartmentStockInDetail deptDetail = new DepartmentStockInDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.DepartmentStockInDetailPK = new DepartmentStockInDetailPK(); deptDetail.Product = inDetail.Product; deptDetail.ProductMaster = inDetail.Product.ProductMaster; deptDetail.Quantity = inDetail.Quantity; stockOutList.Add(deptDetail); } GetRemainStockNumber(stockOutList); MinusConfirmStockOut(stockOutList); e.SelectedStockOutDetails = stockOutList; } EventUtility.fireEvent(CompletedFindByStockInEvent,this,e); }
/// <summary> /// Delete DepartmentStockInDetail from database. /// </summary> /// <param name="data"></param> /// <returns></returns> public void Delete(DepartmentStockInDetail data) { HibernateTemplate.Delete(data); }
public DepartmentStockInDetail Add(DepartmentStockInDetail data) { DepartmentStockInDetailDAO.Add(data); return data; }
private DepartmentStockInDetail GetInResultList(IList<DepartmentStockInDetail> list, DepartmentStockInDetail detail) { foreach (DepartmentStockInDetail inDetail in list) { if(inDetail.Product.ProductMaster.ProductMasterId.Equals( detail.Product.ProductMaster.ProductMasterId)) { return inDetail; } } return null; }
public void Delete(DepartmentStockInDetail data) { DepartmentStockInDetailDAO.Delete(data); }
private static object[] AddProductToDataGrid(DepartmentStockInDetail stockInDetail) { var obj = new object[4]; obj[0] = stockInDetail.DepartmentStockIn.StockInDate.ToString("dd/MM/yyyy HH:mm:ss"); obj[1] = stockInDetail.Quantity.ToString("#,##", CultureInfo.CreateSpecificCulture("de-DE")); obj[2] = stockInDetail.Price.ToString("#,##", CultureInfo.CreateSpecificCulture("de-DE")); obj[3] = stockInDetail.OnStorePrice.ToString("#,##", CultureInfo.CreateSpecificCulture("de-DE")); return obj; }