Exemple #1
0
    public static List <InventoryReportItem> GetInventoryReportItemList()
    {
        List <InventoryReportItem> reportItemList = new List <InventoryReportItem>();
        List <Item> iList = EFBroker_Item.GetActiveItemList();

        foreach (Item i in iList)
        {
            InventoryReportItem rItem = new InventoryReportItem(i);
            reportItemList.Add(rItem);
        }
        return(reportItemList);
    }
Exemple #2
0
    public List <WCFCatalogueItem> GetAllItems()
    {
        List <Item>             iList  = EFBroker_Item.GetActiveItemList();
        List <WCFCatalogueItem> ciList = new List <WCFCatalogueItem>();

        foreach (Item i in iList)
        {
            if (i.BalanceQty != null)
            {
                int adjustments     = GetAdjustmentSum(i);
                WCFCatalogueItem ci = WCFCatalogueItem.Make(i.ItemCode, i.Description, i.UnitOfMeasure, (int)i.BalanceQty, adjustments, i.Bin);
                ciList.Add(ci);
            }
        }
        return(ciList);
    }
    private void ShowAll()
    {
        List <Item> iList = new List <Item>();

        iList = EFBroker_Item.GetActiveItemList();
        Dictionary <Item, String> displayItems = new Dictionary <Item, String>();

        foreach (Item i in iList)
        {
            //If a monthly inventory check discrepancy is not yet approved, the sum of only
            //discrepancies starting from the monthly one will be displayed
            Discrepency        dMonthly = EFBroker_Discrepancy.GetPendingMonthlyDiscrepancyByItemCode(i.ItemCode);
            List <Discrepency> dList    = EFBroker_Discrepancy.GetPendingDiscrepanciesByItemCode(i.ItemCode);
            if (dMonthly == null)
            {
                string adjStr = GetAdjustmentsString(dList);
                displayItems.Add(i, adjStr);
            }
            else
            {
                string adjStr = GetPartialAdjustmentsString(dList, dMonthly);
                displayItems.Add(i, adjStr);
            }
        }

        gvItemList.DataSource = displayItems;
        gvItemList.DataBind();

        foreach (GridViewRow row in gvItemList.Rows)
        {
            HyperLink link     = row.FindControl("hlkDesc") as HyperLink;
            Label     lbl      = row.FindControl("lblItemCodeItem") as Label;
            string    itemCode = lbl.Text;
            link.NavigateUrl = LoginController.AddItemDiscrepancyURI + "?itemCode=" + itemCode;
        }
    }
    protected void BtnGenerateDiscrepancy_Click(object sender, EventArgs e)
    {      //Generate discrepancy button
        Dictionary <Item, int>    discrepancyList    = new Dictionary <Item, int>();
        Dictionary <Item, String> discrepancyDisplay = new Dictionary <Item, String>();
        List <String>             missed             = new List <String>();

        itemError = false;      //Whether there are any rows with errors in the whole page
        for (int i = 0; i < gvItemList.Rows.Count; i++)
        {
            GridViewRow row       = gvItemList.Rows[i];
            bool        ticked    = (row.FindControl("cbxCorrect") as CheckBox).Checked;
            string      txtActual = (row.FindControl("txtActual") as TextBox).Text;
            string      itemCode  = (row.FindControl("lblItemCodeItem") as Label).Text;
            bool        error     = false;                   //Whether a row has an error

            if (!ticked)                                     //If a row is not checked
            {
                if (!(txtActual == "" || txtActual == null)) //Check whether actual quantity is blank
                {
                    row.BackColor = Color.Transparent;
                    ErrorClear();

                    int actualQuantity = 0;
                    if (Int32.TryParse(txtActual, out actualQuantity))
                    {
                        //Calculate the adjustment needed, then add to gvDiscrepancyList
                        string quantity = (row.FindControl("lblStockItem") as Label).Text;
                        int    adj      = actualQuantity - Int32.Parse(quantity);
                        Item   item     = EFBroker_Item.GetItembyItemCode(itemCode);
                        string actual   = actualQuantity.ToString();
                        if (adj != 0 && actualQuantity >= 0)
                        {
                            discrepancyList.Add(item, adj);
                            discrepancyDisplay.Add(item, actual);
                        }
                        else
                        {
                            itemError = true;
                            error     = true;
                        }
                    }
                    else   //If a row is not checked but has a non integer actual quantity
                    {
                        itemError = true;
                        error     = true;
                    }
                }
                else    //If a row is neither checked nor has an actual quantity
                {
                    ErrorClear();
                    row.BackColor       = Color.Transparent;
                    lblErrorMissed.Text = "Some items have not been checked yet. ";
                    itemError           = true;
                    error = true;
                }
            }
            else
            {
                ErrorClear();
                row.BackColor = Color.Transparent;
                if (!(txtActual == "" || txtActual == null))   //if a row is checked and has an actual quantity
                {
                    itemError = true;
                    error     = true;
                }
            }

            if (error)
            {
                row.BackColor     = Color.Yellow;
                lblErrorBase.Text = "Please double-check the highlighted items.";
                missed.Add(itemCode);
            }
        }   //end of iterating through gridview rows

        string missedMessage = "Items with issues: ";

        if (missed.Count > 0)     //Create message listing items with issues
        {
            for (int i = 0; i < missed.Count; i++)
            {
                if (i > 0)
                {
                    missedMessage += ", ";
                }
                missedMessage += missed[i];
            }
            lblErrorMissedItems.Text = missedMessage;
        }
        Session["itemError"] = itemError;

        //Indicate monthly inventory check mode if the number of items in gvItemList
        //when generating discrepancies matches the number of active items in the database
        if (gvItemList.Rows.Count == EFBroker_Item.GetActiveItemList().Count)
        {
            Session["monthly"] = true;
        }
        else
        {
            Session["monthly"] = false;
        }

        Session["discrepancyList"]    = discrepancyList;
        Session["discrepancyDisplay"] = discrepancyDisplay;

        gvDiscrepancyList.DataSource = discrepancyDisplay;
        gvDiscrepancyList.DataBind();
    }