Exemple #1
0
    //AUTHOR : TAN WEN SONG
    protected void Page_Load(object sender, EventArgs e)
    {
        Employee user = (Employee)Session["emp"];

        if (user != null)
        {
            try
            {
                gvForStationeryCatalogue.DataSource = EFBroker_Item.GetCatalogueList();
            }
            catch (Exception sql)
            {
                Response.Redirect(LoginController.ErrorPageURI);
            }
            if (!IsPostBack)
            {
                gvForStationeryCatalogue.DataBind();
                DisplayClickableURL();
            }
        }
        else
        {
            Utility.logout();
        }
    }
Exemple #2
0
    //Generate short fall item list when Genereate Disbursement is clicked
    public List <RetrievalShortfallItem> CheckShortfall(int requisitionId, Dictionary <string, int> retrievedData)
    {
        RetrievalListDetailItemList = DisplayRetrievalListDetail(requisitionId);

        List <RetrievalShortfallItem> RetrievalShortfallItemList = new List <RetrievalShortfallItem>();

        foreach (KeyValuePair <string, int> kvp in retrievedData)
        {
            string itemCode     = kvp.Key;
            int    retrievedQty = kvp.Value;

            //Update Item Balance
            Item item = EFBroker_Item.GetItembyItemCode(itemCode);
            item.BalanceQty -= retrievedQty;
            EFBroker_Item.UpdateItem(item);

            foreach (RetrievalListDetailItem retListD in RetrievalListDetailItemList)
            {
                if (retListD.ItemCode == itemCode)
                {
                    if (retrievedQty < retListD.TotalRequestedQty)
                    {
                        RetrievalShortfallItem r = new RetrievalShortfallItem(retListD.Description, retrievedQty, retListD.ItemCode);
                        RetrievalShortfallItemList.Add(r);
                    }
                }
            }
        }
        return(RetrievalShortfallItemList);
    }
    private void LoadData()
    {
        //To populate Items dropDown List
        ddlAddNewItem.DataSource     = EFBroker_Item.GetActiveItemWithPrice();
        ddlAddNewItem.DataTextField  = "Description";
        ddlAddNewItem.DataValueField = "ItemCode";
        ddlAddNewItem.DataBind();

        //To populate Supervisor Name dropdown List
        ddlsupervisorNames.DataSource     = pCtrlr.GetSupervisorList();
        ddlsupervisorNames.DataTextField  = "EmpName";
        ddlsupervisorNames.DataValueField = "EmpID";
        ddlsupervisorNames.DataBind();


        if (Session["ReorderItem"] != null)
        {
            ritems = (List <ReorderItem>)Session["ReorderItem"];
            GvreorderItems.DataSource = ritems;
            GvreorderItems.DataBind();
        }
        else
        {
            //To add PurchaseItems to session if session is empty
            ritems = pCtrlr.GetReorderItemList();
            Session["ReorderItem"]    = ritems;
            GvreorderItems.DataSource = ritems;
            GvreorderItems.DataBind();
        }
    }
Exemple #4
0
    public static Item AddItem(string itemCode, string categoryName, string description, string reorderLevel, string reorderQty, string UOM, string bin)
    {
        Item item = new Item();

        categoryName       = Utility.FirstUpperCase(categoryName);
        item.ItemCode      = itemCode;
        item.Description   = description;
        item.ReorderLevel  = Convert.ToInt32(reorderLevel);
        item.ReorderQty    = Convert.ToInt32(reorderQty);
        item.UnitOfMeasure = UOM;
        item.Bin           = bin;
        item.ActiveStatus  = "C";
        item.BalanceQty    = 0;
        Category cat = EFBroker_Category.GetCategorybyName(categoryName);

        if (cat != null)
        {
            item.CategoryID = cat.CategoryID;
            EFBroker_Item.AddItem(item);
        }
        else
        {
            EFBroker_Item.AddItemAndCategory(item, categoryName);
            cat = EFBroker_Category.GetCategorybyName(categoryName);
        }
        item.Category = cat;
        return(item);
    }
Exemple #5
0
    public static bool IsValidItemFields(string itemCode, string categoryName, string description, string reorderLevel, string reorderQty, string UOM, string bin)
    {
        bool sucesss = true;
        int  level, qty;

        if (string.IsNullOrEmpty(itemCode) || string.IsNullOrEmpty(categoryName) || string.IsNullOrEmpty(description) || string.IsNullOrEmpty(UOM) || string.IsNullOrEmpty(reorderLevel) || string.IsNullOrEmpty(reorderQty))
        {
            sucesss = false;
        }
        else if (!(int.TryParse(reorderLevel, out level) && int.TryParse(reorderQty, out qty)))
        {
            sucesss = false;
        }
        else if (ValidatorUtil.IsInvalidfieldLength(itemCode, 10) || ValidatorUtil.IsInvalidfieldLength(categoryName, 10) || ValidatorUtil.IsInvalidfieldLength(description, 50) || ValidatorUtil.IsInvalidfieldLength(UOM, 10) || ValidatorUtil.IsInvalidfieldLength(bin, 10))
        {
            sucesss = false;
        }
        else
        {
            Item i = EFBroker_Item.GetItembyDescription(description);
            if (i != null && !itemCode.Equals(i.ItemCode))
            {
                sucesss = false;
            }
        }

        return(sucesss);
    }
    public string GetCatForGivenItemCode(string code)
    {
        int?   catFGI  = EFBroker_Item.GetItembyItemCode(code).CategoryID;
        string catFGI2 = EFBroker_Category.GetCategoryList().Where(z => z.CategoryID == catFGI).Select(d => d.CategoryName).FirstOrDefault();

        return(catFGI2);
    }
Exemple #7
0
    public static void ActivateItem(string itemCode)
    {
        Item item = EFBroker_Item.GetItembyItemCode(itemCode);

        item.ActiveStatus = "Y";
        EFBroker_Item.UpdateItem(item);
    }
    public List <Item> GetAllItemsForGivenCat(string cat)
    {
        int         catID   = EFBroker_Category.GetCategoryList().Where(c => c.CategoryName == cat).Select(x => x.CategoryID).FirstOrDefault();
        List <Item> itemFGC = EFBroker_Item.GetItemsbyCategoryID(catID).ToList();

        return(itemFGC);
    }
Exemple #9
0
    protected void EditRow(int index)
    {
        gvForStationeryCatalogue.EditIndex = index;
        gvForStationeryCatalogue.DataBind();
        GridViewRowCollection a   = gvForStationeryCatalogue.Rows;
        GridViewRow           row = a[index];
        Label        itemLabel    = (Label)row.FindControl("LblItemCode");
        DropDownList ddl          = (DropDownList)row.FindControl("DdlCategory");
        DropDownList ddl2         = (DropDownList)row.FindControl("DdlUOM");

        ddl.DataTextField  = "CategoryName";
        ddl.DataValueField = "CategoryID";
        List <Category> categories = EFBroker_Category.GetCategoryList();
        Item            item       = EFBroker_Item.GetItembyItemCode(itemLabel.Text);

        ddl.DataSource    = categories;
        ddl.SelectedValue = item.CategoryID.ToString();
        ddl.DataBind();

        ddl2.DataSource    = EFBroker_Item.GetDistinctUOMList();
        ddl2.SelectedValue = item.UnitOfMeasure;
        ddl2.DataBind();
        row.BackColor = Color.Yellow;
        return;
    }
Exemple #10
0
    protected void RemoveRow(int index)
    {
        Label  r        = (Label)gvForStationeryCatalogue.Rows[index].FindControl("LblItemCode");
        string itemCode = r.Text;

        EFBroker_Item.RemoveItem(itemCode);
        Utility.DisplayAlertMessage(Message.DeleteSuccessful);
        return;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            monthly = EFBroker_Discrepancy.GetMonthlyDiscrepancyList();
            List <Discrepency> pending = EFBroker_Discrepancy.GetPendingDiscrepancyList();

            Dictionary <Discrepency, Item> monthlySource = new Dictionary <Discrepency, Item>();
            Dictionary <Discrepency, Item> pendingSource = new Dictionary <Discrepency, Item>();

            foreach (Discrepency d in monthly)
            {
                Item    i = EFBroker_Item.GetItembyItemCode(d.ItemCode);
                decimal discrepancyAmount = Math.Abs((decimal)d.TotalDiscrepencyAmount);
                if (Session["empRole"] != null)
                {
                    string role = (string)Session["empRole"];
                    if (Session["empRole"].ToString() == "Store Manager" && discrepancyAmount >= 250)
                    {
                        monthlySource.Add(d, i);
                    }
                    else if (Session["empRole"].ToString() == "Store Supervisor" && discrepancyAmount < 250)
                    {
                        monthlySource.Add(d, i);
                    }
                }
            }
            gvMonthly.DataSource = monthlySource;
            gvMonthly.DataBind();

            foreach (Discrepency d in pending)
            {
                Item    i = EFBroker_Item.GetItembyItemCode(d.ItemCode);
                decimal discrepancyAmount = Math.Abs((decimal)d.TotalDiscrepencyAmount);
                if (Session["empRole"] != null)
                {
                    if (Session["empRole"].ToString() == "Store Manager" && discrepancyAmount >= 250)
                    {
                        pendingSource.Add(d, i);
                    }
                    else if (Session["empRole"].ToString() == "Store Supervisor" && discrepancyAmount < 250)
                    {
                        pendingSource.Add(d, i);
                    }
                }
                else
                {
                    Utility.logout();
                }
            }
            gvPending.DataSource = pendingSource;
            gvPending.DataBind();
        }
    }
Exemple #12
0
 protected void CstTxtDescription_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (EFBroker_Item.GetItembyDescription(args.Value) != null)
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }
Exemple #13
0
    public static List <InventoryReportItem> GetSelectedInventoryReportItemList(string search)
    {
        List <InventoryReportItem> reportItemList = new List <InventoryReportItem>();
        List <Item> iList = EFBroker_Item.SearchItemsByItemCodeOrDesc(search);

        foreach (Item i in iList)
        {
            InventoryReportItem rItem = new InventoryReportItem(i);
            reportItemList.Add(rItem);
        }
        return(reportItemList);
    }
Exemple #14
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 #15
0
    public WCFCatalogueItem GetItem(string itemCode)
    {
        Item             i  = EFBroker_Item.GetItembyItemCode(itemCode);
        WCFCatalogueItem ci = null;

        if (i.BalanceQty != null)
        {
            int adjustments = GetAdjustmentSum(i);
            ci = WCFCatalogueItem.Make(i.ItemCode, i.Description, i.UnitOfMeasure, (int)i.BalanceQty, adjustments, i.Bin);
        }
        return(ci);
    }
Exemple #16
0
 public static void SaveDiscrepenciesWithItemUpdates(List <Discrepency> dList)
 {
     using (TransactionScope ts = new TransactionScope())
     {
         foreach (Discrepency d in dList)
         {
             Item i = EFBroker_Item.GetItembyItemCode(d.ItemCode);
             i.BalanceQty = i.BalanceQty + (d.AdjustmentQty * -1);
             EFBroker_Item.UpdateItem(i);
         }
         SaveDiscrepencies(dList);
         ts.Complete();
     }
 }
Exemple #17
0
    public List <WCFCatalogueItem> SearchItems(string search)
    {
        List <Item>             iList  = EFBroker_Item.SearchItemsByItemCodeOrDesc(search);
        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);
    }
Exemple #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UrlReferrer != null) // if previous page is not null
        {
            if (!IsPostBack)             //first time
            {
                if (Session["RetrievalID"] != null)
                {
                    int retrievalId = (int)Session["RetrievalID"];

                    List <RetrievalListDetailItem> RetrievalListDetailItemList = retCon.DisplayRetrievalListDetail(retrievalId);

                    gvRe.DataSource = RetrievalListDetailItemList;
                    gvRe.DataBind();

                    //RangeValidator
                    foreach (GridViewRow r in gvRe.Rows)
                    {
                        int    totalRequestedQty = Convert.ToInt32((r.FindControl("lblTotalRequestedQty") as Label).Text);
                        string code = (r.FindControl("hdnflditemCode") as HiddenField).Value;
                        Item   item = EFBroker_Item.GetItembyItemCode(code);
                        Label  l    = r.FindControl("lblAvailableQty") as Label;
                        l.Text = item.BalanceQty.ToString();
                        if (item.BalanceQty >= totalRequestedQty)
                        {
                            RangeValidator rv = r.FindControl("rng") as RangeValidator;
                            rv.MaximumValue = totalRequestedQty.ToString();
                        }
                        else
                        {
                            RangeValidator rv = r.FindControl("rng") as RangeValidator;
                            rv.MaximumValue = item.BalanceQty.ToString();
                        }
                    }
                    //
                }
                else
                {
                    Response.Redirect(LoginController.RequisitionListClerkURI);
                }
            }
        }
        else
        {
            Response.Redirect(LoginController.RequisitionListClerkURI);
        }
    }
Exemple #19
0
    public static void UpdateItem(string itemCode, string categoryName, string description, int reorderLevel, int reorderQty, string unitOfMeasure, string bin)
    {
        Category category = EFBroker_Category.GetCategorybyName(categoryName);
        Item     i        = EFBroker_Item.GetItembyItemCode(itemCode);

        if (i != null)
        {
            i.CategoryID    = category.CategoryID;
            i.Description   = description;
            i.ReorderLevel  = reorderLevel;
            i.ReorderQty    = reorderQty;
            i.UnitOfMeasure = unitOfMeasure;
            i.Bin           = bin;
        }
        EFBroker_Item.UpdateItem(i);
        return;
    }
Exemple #20
0
    protected void BtnFinalizeDisbursmentList_Click(object sender, EventArgs e)
    {
        int retrievalId = (int)Session["RetrievalID"];

        List <RetrievalShortfallItem> RetrievalShortfallItemList = new List <RetrievalShortfallItem>();

        Dictionary <Item, int> discToUpdate = new Dictionary <Item, int>();  //shortfall item + adjustment qty

        RetrievalShortfallItemList = SaveRetrievalQty();

        if (retCon.CheckInvalidDisbursement(retrievalId))
        {
            if (RetrievalShortfallItemList.Count != 0)  //if there's shortfall
            {
                foreach (RetrievalShortfallItem r in RetrievalShortfallItemList)
                {
                    Item i       = EFBroker_Item.GetItembyItemCode(r.ItemCode);
                    int  balance = (int)i.BalanceQty;
                    if (balance > r.Qty)
                    {
                        int discQty = r.Qty - balance;
                        discToUpdate.Add(i, discQty);
                    }
                }

                Session["discrepancyList"]            = discToUpdate;
                Session["RetrievalShortfallItemList"] = RetrievalShortfallItemList;
                Response.Redirect("RetrievalShortfall.aspx");
            }
            else //if there is no short fall go to collectionpoint
            {
                //update all actual qty to be same as requested qty if no shortfall
                retCon.UpdateAllActaulQty(retrievalId);

                Session["discrepancyList"]            = null;
                Session["RetrievalShortfallItemList"] = null;
                Response.Redirect("CollectionPointUpdate.aspx");
            }
        }
        else
        {
            Response.Redirect("RetrievalListDetailErrorPage.aspx");
        }
    }
Exemple #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ItemBusinessLogic ilogic  = new ItemBusinessLogic();
        List <Category>   catList = EFBroker_Category.GetCategoryList();
        Category          temp    = new Category();

        temp.CategoryID   = 0;
        temp.CategoryName = "Other";
        catList.Add(temp);
        DdlCategory.DataSource     = catList;
        DdlCategory.DataTextField  = "CategoryName";
        DdlCategory.DataValueField = "CategoryID";
        List <string> UOMList = EFBroker_Item.GetDistinctUOMList();

        UOMList.Add("Other");
        DdlUOM.DataSource = UOMList;
        if (Session["itemlist"] == null)
        {
            iList = new List <Item>();
            LblSubtitle.Visible = false;
        }
        else
        {
            iList = (List <Item>)Session["itemlist"];
            if (iList.Count != 0)
            {
                LblSubtitle.Visible = true;
            }
        }

        // data population
        gvItemAdded.DataSource = iList;
        gvItemAdded.DataBind();
        if (!IsPostBack)
        {
            DdlUOM.DataBind();
            DdlCategory.DataBind();
        }
        ControlToUpdate(TxtCategory, DdlCategory);
        ControlToUpdate(TxtUOM, DdlUOM);
    }
Exemple #22
0
    //AUTHOR : TAN WEN SONG
    public static bool ValidateNewItem(CustomValidator control, string itemCode)
    {
        Item item = EFBroker_Item.GetItembyItemCode(itemCode.ToUpper());

        if (item == null)
        {
            return(true);
        }
        else
        {
            if (item.ActiveStatus == "Y")
            {
                control.ErrorMessage = "ItemCode is in use by existing item";
            }
            else
            {
                control.ErrorMessage = "ItemCode is used for archived item";
            }
            return(false);
        }
    }
Exemple #23
0
    public ReorderItem AddPurchaseItem(String itemCode)
    {
        Item        item         = EFBroker_Item.GetActiveItembyItemCode(itemCode);
        ReorderItem purchaseItem = new ReorderItem
        {
            ItemCode      = item.ItemCode,
            Description   = item.Description,
            ReorderQty    = item.ReorderQty,
            ReorderLevel  = item.ReorderLevel,
            UnitOfMeasure = item.UnitOfMeasure,
        };

        if (item.BalanceQty == null || item.BalanceQty == 0)
        {
            purchaseItem.Balance = 0;
        }
        else
        {
            purchaseItem.Balance = item.BalanceQty;
        }
        return(purchaseItem);
    }
    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;
        }
    }
Exemple #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["monthly"] != null)
        {
            if ((bool)Session["monthly"] == true)
            {
                Session["discrepancyList"]    = new Dictionary <Item, int>();
                Session["discrepancyDisplay"] = new Dictionary <Item, String>();
            }
        }

        Session["monthly"] = false;
        string itemCode = Request.QueryString["itemCode"];

        if (!ValidatorUtil.isEmpty(itemCode))
        {
            Item item = EFBroker_Item.GetItembyItemCode(itemCode);

            if (item != null)
            {
                lblItemCode.Text = item.ItemCode;
                lblItemName.Text = item.Description;
                lblUom.Text      = item.UnitOfMeasure;
                lblStock.Text    = item.BalanceQty.ToString();
            }
            else
            {
                Response.Redirect(LoginController.GenerateDiscrepancyV2URI);
            }
        }
        else
        {
            Response.Redirect(LoginController.GenerateDiscrepancyV2URI);
        }
        lblErrorMsg.Text = "";      //Resetting error text field
    }
    private void ProcessApprovalAndRejections(GridView gdv, Dictionary <KeyValuePair <Discrepency, Item>, String> summary)
    {
        foreach (GridViewRow row in gdv.Rows)
        {
            RadioButtonList rbl = row.FindControl("rblAction") as RadioButtonList;

            if (rbl.SelectedIndex == 0 || rbl.SelectedIndex == 1)
            {
                string      itemCode = (row.FindControl("lblItemCode") as Label).Text;
                int         discID   = Int32.Parse((row.FindControl("lblDiscID") as Label).Text);
                Item        i        = EFBroker_Item.GetItembyItemCode(itemCode);
                Discrepency d        = EFBroker_Discrepancy.GetDiscrepancyById(discID);
                KeyValuePair <Discrepency, Item> kvp = new KeyValuePair <Discrepency, Item>(d, i);
                if (rbl.SelectedIndex == 0)
                {
                    summary.Add(kvp, "Approved");
                }
                else if (rbl.SelectedIndex == 1)
                {
                    summary.Add(kvp, "Rejected");
                }
            }
        }
    }
    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;
        }
    }
Exemple #28
0
    public List <RetrievalListDetailItem> DisplayRetrievalListDetail(int requisitionId)
    {
        List <RetrievalListDetailItem> retrievalListDetailItemDisplayList = new List <RetrievalListDetailItem>();

        //get retrievalStatus by requisitionId

        string retrievalStatus = EFBroker_Disbursement.GetRetrievalStatusByRequisitionId(requisitionId);

        // dictionary with itemcode + totalrequestedQty
        Dictionary <string, int> itemcodeAndTotalRequestedQtyDictionary = new Dictionary <string, int>();

        HashSet <String> uniqueItemcodeHashSet = new HashSet <string>();

        List <Disbursement> disbursementList = EFBroker_Disbursement.GetDisbursmentListbyRetrievalID(requisitionId);

        // remove repeated itemcode in disbursementList
        foreach (Disbursement d in disbursementList)
        {
            foreach (Disbursement_Item dI in d.Disbursement_Item)
            {
                uniqueItemcodeHashSet.Add(dI.ItemCode);
            }
        }

        // accumulate totalRequestedQty if there is same itemCode in Disbursement, then
        foreach (string i in uniqueItemcodeHashSet)
        {
            string itemCode          = i;
            int    totalRequestedQty = 0;
            foreach (Disbursement d in disbursementList)
            {
                foreach (Disbursement_Item dI in d.Disbursement_Item)
                {
                    if (dI.ItemCode == itemCode)
                    {
                        totalRequestedQty += (int)dI.TotalRequestedQty;
                    }
                }
            }
            itemcodeAndTotalRequestedQtyDictionary.Add(itemCode, totalRequestedQty);
        }

        //create RetrievalListDetailItem to display in DisplayRetrievalListDetail base on retrievalStatus
        foreach (KeyValuePair <string, int> kvp in itemcodeAndTotalRequestedQtyDictionary)
        {
            int retrievedQty = 0;
            if (retrievalStatus == "Pending")
            {
                //default retrievedQty is same as totalRequestedQty
                retrievedQty = kvp.Value;
            }
            if (retrievalStatus == "InProgress")
            {
                //retrievedQty is same as value which inputted in warehouse
                retrievedQty = EFBroker_Disbursement.GetRetrievedQtyByRequisitionIdNItemCode(requisitionId, kvp.Key);
            }

            Item   item        = EFBroker_Item.GetItembyItemCode(kvp.Key);
            string bin         = item.Bin;
            string description = item.Description;

            RetrievalListDetailItem retDetail = new RetrievalListDetailItem(bin, description, kvp.Value, kvp.Key, retrievedQty);
            retrievalListDetailItemDisplayList.Add(retDetail);
        }
        return(retrievalListDetailItemDisplayList);
    }
    protected void btnAck_Click(object sender, EventArgs e)
    {
        int disbId = (int)Session["SelectedDisb"];

        List <DisbursementDetailListItems> retrievedItem = new List <DisbursementDetailListItems>();

        retrievedItem = disbCon.GvDisbursementDetailPopulate(disbId);

        List <RequestedItem>   shortfallItem = new List <RequestedItem>();
        List <int>             actualQtyList = new List <int>();
        List <string>          disbRemark    = new List <string>();
        Dictionary <Item, int> discToUpdate  = new Dictionary <Item, int>();
        RequestedItem          reqItem;
        bool check = true;

        foreach (GridViewRow r in gvDisbDetail.Rows)
        {
            //get disbursement remarks for each items
            string remark;
            try
            {
                remark = (r.FindControl("txtremarks") as TextBox).Text;
            }
            catch
            {
                remark = "";
            }

            //add remarks to list to save to database
            disbRemark.Add(remark);


            //get retrieved item to compare
            int index        = r.RowIndex;
            int retrievedQty = retrievedItem[index].ActualQty;

            //get actual qty to verify
            int reqQty = Convert.ToInt32((r.FindControl("lblreqQty") as Label).Text);

            //get actual qty to verify
            int actualQty = Convert.ToInt32((r.FindControl("txtactualQty") as TextBox).Text);

            //make actual qty list to update database
            actualQtyList.Add(actualQty);

            //check if any shortfall
            if (actualQty < reqQty)
            {
                //make short fall item list
                string iCode        = (r.FindControl("hdnflditemCode") as HiddenField).Value;
                string iDesc        = (r.FindControl("lblitemDesc") as Label).Text;
                int    shortfallQty = reqQty - actualQty;
                string uom          = EFBroker_Item.GetUnitbyItemCode(iCode);
                reqItem = new RequestedItem(iCode, iDesc, shortfallQty, uom);
                shortfallItem.Add(reqItem);

                //check if any discrepancy
                if (actualQty < retrievedQty)
                {
                    //make discrepancy item list
                    int    disQty   = actualQty - retrievedQty;
                    Item   disItem  = EFBroker_Item.GetItembyItemCode(iCode);
                    string finalQty = (disItem.BalanceQty + disQty).ToString();
                    discToUpdate.Add(disItem, disQty);
                }
            }
            else if (actualQty > retrievedQty)
            {
                check = false;
                (r.FindControl("lblActualError") as Label).Text = "Actual cannot be more than retrieved quantity";
            }
        }
        if (check)
        {
            //check access code
            if (disbCon.CheckAccessCode(disbId, txtAccessCode.Text))
            {
                //update Disbursement table (actual qty + status)
                disbCon.UpdateDisbursement(disbId, actualQtyList, disbRemark);

                //redirect to Regenerate Request page if any shortfall
                if (shortfallItem.Count != 0)
                {
                    Session["discrepancyList"] = discToUpdate;
                    Session["RegenerateDate"]  = disbCon.GetRegenrateDate(disbId);
                    Session["RegenerateDep"]   = lblDepartment.Text;
                    Session["RequestedByName"] = EFBroker_DeptEmployee.GetDeptRepByDeptCode(lblDepartment.Text);
                    Session["RegenerateItems"] = shortfallItem;

                    Response.Redirect(LoginController.RegenerateRequestURI);
                }
                //redirect back to Disbursement List page if no shortfall
                else
                {
                    Session["SelectedDisb"]  = null;
                    Session["disbItemsList"] = null;
                    Response.Redirect(LoginController.DisbursementListURI);
                }
            }
            else
            {
                string message = "Incorrect Access Code!";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true);
            }
        }
    }
Exemple #30
0
 //GET ITEM UOM
 public static String getUOM(string item)
 {
     return(EFBroker_Item.GetUnitbyItemCode(item));
 }