예제 #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);
    }
예제 #2
0
    protected void BtnProcess_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow row in gvActionSummary.Rows)
            {
                int    discID = Int32.Parse((row.FindControl("lblDiscID") as Label).Text);
                string action = (row.FindControl("lblAction") as Label).Text;

                Discrepency d = EFBroker_Discrepancy.GetDiscrepancyById(discID);
                if (d.Status == "Monthly")
                {
                    if (action == "Approved")
                    {
                        List <Discrepency> dList = EFBroker_Discrepancy.GetPendingDiscrepanciesByItemCode(d.ItemCode);

                        foreach (Discrepency d2 in dList)
                        {
                            if (d2.DiscrepencyID < d.DiscrepencyID)
                            {   //Negating discrepancies reported before the monthly discrepancy after it is approved
                                EFBroker_Discrepancy.ProcessDiscrepancy(d2.DiscrepencyID, "Resolved");
                            }
                        }
                    }
                }

                EFBroker_Discrepancy.ProcessDiscrepancy(discID, action);

                if (action == "Approved")
                {    //only update stock card and item tables if discrepancy is approved
                    StockCard sc = new StockCard();

                    StockCard lastEntry = EFBroker_StockCard.GetStockCardsByItemCode(d.ItemCode).Last();

                    sc.ItemCode            = d.ItemCode;
                    sc.TransactionType     = "Adjustment";
                    sc.Qty                 = d.AdjustmentQty;
                    sc.Balance             = lastEntry.Balance + d.AdjustmentQty;
                    sc.TransactionDetailID = d.DiscrepencyID;

                    EFBroker_StockCard.ResolveDiscrepancy(sc, sc.ItemCode, (int)sc.Balance);
                }
            }
            Session["discrepancySummary"] = null;
            Utility.AlertMessageThenRedirect("Adjustments processed", "StockAdjustment.aspx");
        }
        catch (Exception ex)
        {
            Session["discrepancySummary"] = null;
            Utility.AlertMessageThenRedirect("Failed to process adjustments, please try again", "StockAdjustment.aspx");
        }
    }
예제 #3
0
    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;
        }
    }
예제 #4
0
    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;
        }
    }