Exemple #1
0
    private int GetAdjustmentSum(Item i)
    {
        Discrepency        dMonthly = EFBroker_Discrepancy.GetPendingMonthlyDiscrepancyByItemCode(i.ItemCode);
        List <Discrepency> dList    = EFBroker_Discrepancy.GetPendingDiscrepanciesByItemCode(i.ItemCode);
        int adjustment = 0;

        if (dMonthly == null)
        {
            foreach (Discrepency d in dList)
            {
                adjustment += (int)d.AdjustmentQty;
            }
        }
        else
        {
            adjustment = (int)dMonthly.AdjustmentQty;

            foreach (Discrepency d in dList)
            {
                if ((int)d.DiscrepencyID > dMonthly.DiscrepencyID)
                {
                    adjustment += (int)d.AdjustmentQty;
                }
            }
        }
        return(adjustment);
    }
    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 BtnSearch_Click(object sender, EventArgs e)
    {        //Search button
        Dictionary <Item, String> searchResults = new Dictionary <Item, String>();
        string      search = txtSearch.Text.ToLower();
        List <Item> iList  = EFBroker_Item.SearchItemsByItemCodeOrDesc(search);

        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);

                searchResults.Add(i, adjStr);
            }
            else
            {
                string adjStr = GetPartialAdjustmentsString(dList, dMonthly);
                searchResults.Add(i, adjStr);
            }
        }

        gvItemList.DataSource = searchResults;
        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;
        }
    }