public Constants.ACTION_STATUS AddItem(string itemId, int qty, double price) { Constants.ACTION_STATUS addStatus = Constants.ACTION_STATUS.UNKNOWN; Item item = new Item(); item.Id = itemId; item = itemBroker.GetItem(item); if (item != null && qty > 0 && price > 0) { if (!addedItemList.ContainsKey(item)) { List <double> other = new List <double>(); other.Add(qty); other.Add(price); addedItemList.Add(item, other); addStatus = Constants.ACTION_STATUS.SUCCESS; } else { addStatus = Constants.ACTION_STATUS.FAIL; } } else { addStatus = Constants.ACTION_STATUS.FAIL; } return(addStatus); }
//public DataTable GetStockCard(string itemDescription) //{ // Item item = new Item(); // item.Description = itemDescription; // item = itemBroker.GetItem(item); // List<StockCardDetail> list = item.StockCardDetails.ToList(); // DataTable dt = new DataTable(); // DataRow dr; // foreach(StockCardDetail temp in list){ // dr = dt.NewRow(); // dr["date"] = temp.CreatedDate; // dr["dept/supplier"] = temp.Description; // dr["qty"] = temp.Qty; // dr["balance"] = temp.Balance; // dt.Rows.Add(dr); // } // return dt; //} /// <summary> /// Show stockCardDetail according to the entered itemDescription /// Created By:JinChengCheng /// Created Date:26-01-2012 /// Modified By: /// Modified Date: /// Modification Reason: /// Modified By: /// Modified Date: /// Modification Reason: /// </summary> /// <param name="itemDescription"></param> /// <returns>The return type of this method is datatable.</returns> //public DataTable GetStockCardDetails(string itemDescription) //{ // dt = new DataTable(); // //item = Util.GetItem(itemBroker, itemDescription); // item = new Item(); // item.Description = itemDescription; // item = itemBroker.GetItem(item); // supplierList = itemPriceBroker.GetPrioritySupplier(item); // dt.Columns.AddRange(dataColumn); // stockCardDetailList = itemBroker.GetAllStockCardDetail(item); // if (stockCardDetailList != null) // { // foreach (StockCardDetail stockCardDetail in stockCardDetailList) // { // dr = dt.NewRow(); // dr[columnName[0]] = SystemStoreInventorySystemUtil.Converter.dateTimeToString(Converter.DATE_CONVERTER.DATE, stockCardDetail.CreatedDate); // dr[columnName[1]] = stockCardDetail.Description; // dr[columnName[2]] = stockCardDetail.Qty; // dr[columnName[3]] = stockCardDetail.Balance; // dt.Rows.Add(dr); // } // } // return dt; //} public DataTable GetStockCardDetails(string itemDescription) { dt = new DataTable(); //item = Util.GetItem(itemBroker, itemDescription); item = new Item(); item.Description = itemDescription; item = itemBroker.GetItem(item); supplierList = itemPriceBroker.GetPrioritySupplier(item); dt.Columns.AddRange(dataColumn); stockCardDetailList = itemBroker.GetAllStockCardDetail(item); if (stockCardDetailList != null) { foreach (StockCardDetail stockCardDetail in stockCardDetailList) { dr = dt.NewRow(); dr[columnName[0]] = SystemStoreInventorySystemUtil.Converter.dateTimeToString(Converter.DATE_CONVERTER.DATE, stockCardDetail.CreatedDate); dr[columnName[1]] = stockCardDetail.Description; dr[columnName[2]] = stockCardDetail.Qty; dr[columnName[3]] = stockCardDetail.Balance; dt.Rows.Add(dr); } } return(dt); }
/// <summary> /// Show the added item in the table /// Created By:JinChengCheng /// Created Date:26-01-2012 /// Modified By: /// Modified Date: /// Modification Reason: /// Modified By: /// Modified Date: /// Modification Reason: /// </summary> /// <param name="discrepancyDetail"></param> /// <returns>The return type of this method is datatable.</returns> public Constants.ACTION_STATUS SelectAdd(string itemId, int qty, string reason) { Item item = new Item(); item.Id = itemId; item = itemBroker.GetItem(item); if (item != null && reason != String.Empty) { DiscrepancyDetail dd = new DiscrepancyDetail(); //dd.Discrepancy = discrepancy; dd.Item = item; int amount = qty * (int)item.Cost; if (amount >= 250) { dd.DiscrepancyType = Converter.objToInt(Constants.DISCREPANCY_TYPE.MANAGER); } else { dd.DiscrepancyType = Converter.objToInt(Constants.DISCREPANCY_TYPE.SUPERVISOR); } dd.Qty = qty; dd.Remarks = reason; dd.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW); discrepancy.DiscrepancyDetails.Add(dd); } return(Constants.ACTION_STATUS.SUCCESS); }
public static Item GetItem(IItemBroker itemBroker, string itemDescription) { Item item = new Item(); item.Description = itemDescription; item = itemBroker.GetItem(item); // need to add a method to return list of item in broker return(item); }
public Constants.ACTION_STATUS UpdateRequisitionCollection(Dictionary <string, int> itemsCollected) { Constants.ACTION_STATUS updateStatus = Constants.ACTION_STATUS.UNKNOWN; int addedItem = 0; foreach (string key in itemsCollected.Keys) { if (requisitionCollection.RequisitionCollectionItems.Where(x => x.Item.Id == key).Count() > 0) { RequisitionCollectionItem requisitionCollectionItem = requisitionCollection.RequisitionCollectionItems.Where(x => x.Item.Id == key).First(); requisitionCollectionItem.Qty = itemsCollected[key]; } else { Item item = new Item(); item.Id = key; item = itemBroker.GetItem(item); Employee employee = new Employee(); employee.Id = currentEmployee.Id; employee = employeeBroker.GetEmployee(employee); requisitionCollection.RequisitionCollectionItems.Add(new RequisitionCollectionItem(requisitionCollectionItemBroker.GetRequisitionCollectionItemId() + (addedItem++), requisitionCollection, item, itemsCollected[key], DateTime.Now, employee, Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW))); } } if (requisitionCollectionBroker.Update(requisitionCollection) == Constants.DB_STATUS.SUCCESSFULL) { updateStatus = Constants.ACTION_STATUS.SUCCESS; } else { updateStatus = Constants.ACTION_STATUS.FAIL; } return(updateStatus); }
public Constants.ACTION_STATUS AddToTable(string itemId) { Constants.ACTION_STATUS status = Constants.ACTION_STATUS.UNKNOWN; RequisitionDetail requisitionDetail; Item item = new Item(); item.Id = itemId; item = itemBroker.GetItem(item); if (item != null) { if (requisition.RequisitionDetails.Where(x => x.Item.Id == itemId).Count() == 0) { requisitionDetail = new RequisitionDetail(); requisitionDetail.Id = requisitionBroker.GetRequisitionDetailId() + (itemAdded++); requisitionDetail.Requisition = requisition; requisitionDetail.Item = item; requisitionDetail.Qty = 1; requisition.RequisitionDetails.Add(requisitionDetail); status = Constants.ACTION_STATUS.SUCCESS; } else { status = Constants.ACTION_STATUS.FAIL; } } else { status = Constants.ACTION_STATUS.FAIL; } return(status); }
public static Item GetItem(IItemBroker itemBroker, string itemDescription) { Item item = new Item(); item.Description = itemDescription; item = itemBroker.GetItem(item); // need to add a method to return list of item in broker return item; }
public ManageStationeryRetrievalListControl(object obj) { if (obj is List <RequisitionCollection> ) { init(); requisitionCollectionBroker = new RequisitionCollectionBroker(inventory); List <RequisitionCollection> requisitionCollectionList = (List <RequisitionCollection>)obj; retrieval = new Retrieval(retrievalBroker.GetRetrievalId(), DateTime.Now, Util.GetEmployee(employeeBroker), Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW)); retrievalList = new Dictionary <string, List <object> >(); unfulfilledRetrievalList = new Dictionary <string, List <object> >(); foreach (RequisitionCollection requisitionCollection in requisitionCollectionList) { foreach (RequisitionCollectionDetail requisitionCollectionDetail in requisitionCollection.RequisitionCollectionDetails) { foreach (RequisitionDetail requisitionDetail in requisitionCollectionDetail.Requisition.RequisitionDetails) { if (unfulfilledRetrievalList.ContainsKey(requisitionDetail.Item.Id.Trim())) { retrievalInfo = unfulfilledRetrievalList[requisitionDetail.Item.Id]; retrievalInfo[2] = Converter.objToInt(retrievalInfo[2]) + Converter.objToInt(requisitionDetail.Qty); ((RetrievalTable)retrievalInfo[4]).Add(requisitionCollectionDetail.Requisition.Department.Name, requisitionDetail.Qty, 0, requisitionCollectionDetail.Requisition.CreatedDate); // have the same total with current balance / fulfilled //if (Converter.objToInt(retrievalInfo[2]) <= Converter.objToInt(retrievalInfo[3])) //{ // ((RetrievalTable)retrievalInfo[4]).FullFill(); // retrievalList.Add(requisitionDetail.Item.Id, retrievalInfo); // unfulfilledRetrievalList.Remove(requisitionDetail.Item.Id); //} //else //{ unfulfilledRetrievalList[requisitionDetail.Item.Id] = retrievalInfo; //} } else { retrievalInfo = new List <object>(); retrievalInfo.Add(requisitionDetail.Item.Description); retrievalInfo.Add(requisitionDetail.Item.Bin); retrievalInfo.Add(requisitionDetail.Qty); int currentItemBalance = itemBroker.GetCurrentBalance(requisitionDetail.Item); retrievalInfo.Add(currentItemBalance); retrievalInfo.Add(new RetrievalTable(requisitionCollectionDetail.Requisition.Department.Name, requisitionDetail.Qty, 0, requisitionCollectionDetail.Requisition.CreatedDate)); //if (requisitionDetail.Qty <= currentItemBalance) //{ // retrievalList.Add(requisitionDetail.Item.Id, retrievalInfo); //} //else //{ unfulfilledRetrievalList.Add(requisitionDetail.Item.Id.Trim(), retrievalInfo); //} } } } requisitionCollection.Status = Converter.objToInt(Constants.COLLECTION_STATUS.NEED_TO_COLLECT); requisitionCollectionBroker.Update(requisitionCollection); } List <string> keyToBeRemoved = new List <string>(); foreach (string key in unfulfilledRetrievalList.Keys) { retrievalInfo = unfulfilledRetrievalList[key]; if (((RetrievalTable)retrievalInfo[4]).GetTotalQty("NeededQty") <= Converter.objToInt(retrievalInfo[3])) { ((RetrievalTable)retrievalInfo[4]).FullFill(); retrievalList.Add(key, retrievalInfo); keyToBeRemoved.Add(key); } } foreach (string key in keyToBeRemoved) { unfulfilledRetrievalList.Remove(key); } int addedId = 0; foreach (string key in retrievalList.Keys) { retrievalInfo = retrievalList[key]; Item item = new Item(); item.Id = key; item = itemBroker.GetItem(item); foreach (DataRow dr in ((RetrievalTable)retrievalInfo[4]).Rows) { RetrievalDetail retrievalDetail = new RetrievalDetail(); retrievalDetail.Id = retrievalBroker.GetRetrievalDetailId() + (addedId++); retrievalDetail.Item = item; Department department = new Department(); department.Name = dr["Department"].ToString(); department = departmentBroker.GetDepartment(department); retrievalDetail.Department = department; retrievalDetail.NeededQty = Converter.objToInt(dr["NeededQty"]); retrievalDetail.ActualQty = Converter.objToInt(dr["ActualQty"]); retrieval.RetrievalDetails.Add(retrievalDetail); } } foreach (string key in unfulfilledRetrievalList.Keys) { retrievalInfo = unfulfilledRetrievalList[key]; Item item = new Item(); item.Id = key; item = itemBroker.GetItem(item); foreach (DataRow dr in ((RetrievalTable)retrievalInfo[4]).Rows) { RetrievalDetail retrievalDetail = new RetrievalDetail(); retrievalDetail.Id = retrievalBroker.GetRetrievalDetailId() + (addedId++); retrievalDetail.Item = item; Department department = new Department(); department.Name = dr["Department"].ToString(); department = departmentBroker.GetDepartment(department); retrievalDetail.Department = department; retrievalDetail.NeededQty = Converter.objToInt(dr["NeededQty"]); retrievalDetail.ActualQty = Converter.objToInt(dr["ActualQty"]); retrieval.RetrievalDetails.Add(retrievalDetail); } } if (retrievalBroker.Insert(retrieval) == Constants.DB_STATUS.FAILED) { // do something } } }