public ManageStationeryRetrievalListControl(int retrievalId)
        {
            init();

            retrieval    = new Retrieval();
            retrieval.Id = retrievalId;
            retrieval    = retrievalBroker.GetRetrieval(retrieval);

            retrievalList            = new Dictionary <string, List <object> >();
            unfulfilledRetrievalList = new Dictionary <string, List <object> >();

            foreach (RetrievalDetail retrievalDetail in retrieval.RetrievalDetails)
            {
                if (unfulfilledRetrievalList.ContainsKey(retrievalDetail.Item.Id.Trim()))
                {
                    retrievalInfo    = unfulfilledRetrievalList[retrievalDetail.Item.Id];
                    retrievalInfo[2] = Converter.objToInt(retrievalInfo[2]) + Converter.objToInt(retrievalDetail.NeededQty);
                    ((RetrievalTable)retrievalInfo[4]).Add(retrievalDetail.Department.Name, retrievalDetail.NeededQty, retrievalDetail.ActualQty.HasValue ? retrievalDetail.ActualQty.Value : 0, DateTime.Now);// retrievalDetail.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[retrievalDetail.Item.Id] = retrievalInfo;
                    //}
                }
                else
                {
                    retrievalInfo = new List <object>();
                    retrievalInfo.Add(retrievalDetail.Item.Description);
                    retrievalInfo.Add(retrievalDetail.Item.Bin);
                    retrievalInfo.Add(retrievalDetail.NeededQty);
                    int currentItemBalance = itemBroker.GetCurrentBalance(retrievalDetail.Item);
                    retrievalInfo.Add(currentItemBalance);
                    retrievalInfo.Add(new RetrievalTable(retrievalDetail.Department.Name, retrievalDetail.NeededQty, retrievalDetail.ActualQty.HasValue ? retrievalDetail.ActualQty.Value : 0, DateTime.Now));// requisitionCollectionDetail.Requisition.CreatedDate));

                    //if (requisitionDetail.Qty <= currentItemBalance)
                    //{
                    //    retrievalList.Add(requisitionDetail.Item.Id, retrievalInfo);
                    //}
                    //else
                    //{
                    unfulfilledRetrievalList.Add(retrievalDetail.Item.Id.Trim(), retrievalInfo);
                    //}
                }
            }
        }
コード例 #2
0
        private List <Item> GetReorderItemList(string supplierCode)
        {
            List <Item> reorderList = new List <Item>();
            List <Item> itemList    = itemBroker.GetAllItem();
            ItemPrice   itemPrice;

            foreach (Item item in itemList)
            {
                itemPrice            = new ItemPrice();
                itemPrice.ItemId     = item.Id;
                itemPrice.SupplierId = supplierCode;
                itemPrice            = itemPriceBroker.GetItemPrice(itemPrice);

                if (itemPrice != null)
                {
                    int bal = itemBroker.GetCurrentBalance(item);

                    decimal price = (decimal)Converter.objToDouble(itemPrice.Price);

                    item.Cost = price; // set the price

                    if (bal + purchaseOrderBroker.GetPendingQuantity(item) < item.ReorderLevel)
                    {
                        reorderList.Add(item);
                    }
                }
            }

            return(reorderList);
        }
        public Constants.ACTION_STATUS CreateAdjustment()
        {
            Constants.ACTION_STATUS status   = Constants.ACTION_STATUS.UNKNOWN;
            Constants.DB_STATUS     dbStatus = discrepancyBroker.Insert(stockAdjustment);
            if (dbStatus == Constants.DB_STATUS.SUCCESSFULL)
            {
                status = Constants.ACTION_STATUS.SUCCESS;
            }
            else
            {
                status = Constants.ACTION_STATUS.FAIL;
            }
            //   discrepancy.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.HIDDEN);
            List <DiscrepancyDetail> dd = GetList(discrepancy.DiscrepancyDetails.ToList());

            foreach (DiscrepancyDetail temp in dd)
            {
                StockCardDetail stockCardDetail = new StockCardDetail();
                stockCardDetail.Id          = itemBroker.GetStockCardDetailId();
                stockCardDetail.Item        = temp.Item;
                stockCardDetail.Description = "Stock Adjsutment " + stockAdjustment.Id;
                stockCardDetail.Qty         = temp.Qty;
                stockCardDetail.CreatedDate = DateTime.Now;
                stockCardDetail.CreatedBy   = Util.GetEmployee(employeeBroker);
                stockCardDetail.Status      = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW);
                stockCardDetail.Balance     = itemBroker.GetCurrentBalance(temp.Item) + Converter.objToInt(temp.Qty);
                itemBroker.Insert(stockCardDetail);
                temp.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.HIDDEN);
                //discrepancyBroker.Update(temp);
            }

            bool flag = false;

            foreach (DiscrepancyDetail temp in discrepancy.DiscrepancyDetails)
            {
                if (temp.Status == Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                discrepancy.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.HIDDEN);
            }
            else
            {
                discrepancy.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW);
            }
            discrepancyBroker.Update(discrepancy);


            return(status);
        }
        public Constants.ACTION_STATUS ClickReceived(DataTable dt, string deliveryNo, string poNumber)
        {
            Constants.ACTION_STATUS status = Constants.ACTION_STATUS.UNKNOWN;
            string        itemNo, itemDesc, quantity, remark;
            PurchaseOrder po = new PurchaseOrder();

            po.Id = Converter.objToInt(poNumber);
            po    = purchaseOrderBroker.GetPurchaseOrder(po);
            po.DeliveryOrderNumber = deliveryNo;
            po.DeliveryDate        = DateTime.Now;
            po.AcceptedBy          = Util.GetEmployee(employeeBroker);

            List <PurchaseOrderDetail> poDetailList = po.PurchaseOrderDetails.ToList();

            foreach (DataRow dr in dt.Rows)
            {
                itemNo = dr[detail[0]].ToString();

                itemDesc = dr[detail[1]].ToString();

                quantity = dr[detail[2]].ToString();

                remark = dr[detail[3]].ToString();

                foreach (PurchaseOrderDetail poDetail in poDetailList)
                {
                    if (poDetail.Item.Id.Equals(itemNo))
                    {
                        poDetail.AcceptedQty = Converter.objToInt(quantity);
                        Item item = poDetail.Item;
                        item.Cost = poDetail.Price;
                        itemBroker.Update(item);
                        StockCardDetail stockCardDetail = new StockCardDetail();
                        stockCardDetail.Item        = item;
                        stockCardDetail.Description = "Supplier-" + po.Supplier.Id;
                        stockCardDetail.Qty         = Converter.objToInt(quantity);
                        stockCardDetail.CreatedDate = DateTime.Now;
                        stockCardDetail.CreatedBy   = Util.GetEmployee(employeeBroker);
                        stockCardDetail.Status      = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW);
                        //List<StockCardDetail> stockCardDetailList = itemBroker.GetAllStockCardDetail().ToList();
                        //List<StockCardDetail> newList = new List<StockCardDetail>();
                        //foreach(StockCardDetail scd in stockCardDetailList){
                        //    if(scd.Item.Id.Equals(item.Id)){
                        //        newList.Add(scd);
                        //    }
                        //}

                        //StockCardDetail scDetail = newList.Last<StockCardDetail>();
                        stockCardDetail.Balance = itemBroker.GetCurrentBalance(item) + Converter.objToInt(quantity);
                        stockCardDetail.Id      = itemBroker.GetStockCardDetailId();
                        itemBroker.Insert(stockCardDetail);
                        // add remark later
                    }
                }
            }

            Constants.DB_STATUS dbStatus = purchaseOrderBroker.Update(po);
            if (dbStatus == Constants.DB_STATUS.SUCCESSFULL)
            {
                status = Constants.ACTION_STATUS.SUCCESS;
            }
            else
            {
                status = Constants.ACTION_STATUS.FAIL;
            }
            return(status);
        }