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 #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);
    }
Exemple #3
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 #4
0
    public static void ActivateItem(string itemCode)
    {
        Item item = EFBroker_Item.GetItembyItemCode(itemCode);

        item.ActiveStatus = "Y";
        EFBroker_Item.UpdateItem(item);
    }
    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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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);
        }
    }
    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");
                }
            }
        }
    }
Exemple #13
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
    }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        List <Discrepency> dList = new List <Discrepency>();
        bool complete            = true;
        bool monthly             = false;

        foreach (GridViewRow row in gvDiscrepancies.Rows)
        {
            string itemCode = (row.FindControl("lblItemCode") as Label).Text;
            string stock    = (row.FindControl("lblStock") as Label).Text;
            string actual   = (row.FindControl("lblActual") as Label).Text;
            int    adj      = Int32.Parse(actual) - Int32.Parse(stock);
            string remarks  = (row.FindControl("txtRemarks") as TextBox).Text;
            if (!ValidatorUtil.isEmpty(remarks))
            {
                if (remarks.Length <= maxChars)
                {
                    //update item table if any adjustment at disubrsement point
                    if (Session["ItemToUpdate"] != null)
                    {
                        if ((bool)Session["ItemToUpdate"])
                        {
                            Item i = EFBroker_Item.GetItembyItemCode(itemCode);
                            i.BalanceQty = (adj * -1) + i.BalanceQty;
                            EFBroker_Item.UpdateItem(i);
                        }
                    }

                    List <PriceList> plHistory  = EFBroker_PriceList.GetPriceListByItemCode(itemCode);
                    List <PriceList> itemPrices = new List <PriceList>();

                    foreach (PriceList pl in plHistory)
                    {    //Get only currently active suppliers for an item
                        if (pl.TenderYear == DateTime.Now.Year.ToString())
                        {
                            itemPrices.Add(pl);
                        }
                    }

                    decimal totalPrice = 0;

                    foreach (PriceList pl in itemPrices)
                    {
                        totalPrice += (decimal)pl.Price;
                    }

                    decimal averageUnitPrice = totalPrice / itemPrices.Count;

                    Discrepency d = new Discrepency();
                    d.ItemCode = itemCode;
                    if (Session["empID"] != null)
                    {
                        int empID = (int)Session["empID"];
                        d.RequestedBy = empID;
                    }
                    else
                    {
                        Utility.logout();
                    }
                    d.AdjustmentQty = adj;
                    d.Remarks       = remarks;
                    d.Date          = DateTime.Now;
                    if (Session["monthly"] != null)
                    {
                        if ((bool)Session["monthly"] == true)
                        {
                            d.Status = "Monthly";
                            monthly  = true;
                        }
                        else
                        {
                            d.Status = "Pending";
                            monthly  = false;
                        }
                    }
                    else
                    {
                        d.Status = "Pending";
                    }
                    d.TotalDiscrepencyAmount = adj * averageUnitPrice;
                    if (d.TotalDiscrepencyAmount < 250)
                    {
                        d.ApprovedBy = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].EmpID;
                    }
                    else
                    {
                        d.ApprovedBy = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Manager")[0].EmpID;
                    }
                    dList.Add(d);
                }
                else
                {
                    lblErrorCharLimit.Text = "Make sure all remarks are under 100 characters long";
                    row.BackColor          = Color.Yellow;
                    complete = false;
                    break;
                }
            }
            else
            {
                lblRequired.Text = "Please state the cause of discrepancies for all items in Remarks";
                complete         = false;
                break;
            }
        }

        if (complete)
        {
            if (monthly)
            {
                EFBroker_Discrepancy.MonthlyInventoryCheck(dList);
            }
            else
            {
                EFBroker_Discrepancy.SaveDiscrepencies(dList);
            }


            //bool informSupervisor = false;
            //bool informManager = false;
            informSupervisor = false;
            informManager    = false;
            foreach (Discrepency d in dList)
            {
                if (Math.Abs((decimal)d.TotalDiscrepencyAmount) < 250)
                {
                    informSupervisor = true;
                }
                else
                {
                    informManager = true;
                }
            }



            Session["discrepancyList"]            = null;
            Session["discrepancyDisplay"]         = null;
            Session["RetrievalShortfallItemList"] = null;
            Session["RetrievalID"] = null;

            Session["monthly"]      = null;
            Session["ItemToUpdate"] = null;


            ThreadStart emailThreadStart = new ThreadStart(DiscrepancyMailNotification);
            Thread      emailThread      = new Thread(emailThreadStart);
            emailThread.Start();

            string destination = "";

            if (Session["empRole"] != null)
            {
                string role = (string)Session["empRole"];
                if (role == "Store Supervisor" || role == "Store Manager")
                {
                    destination = "PurchaseOrderList.aspx";
                }
                else if (role == "Store Clerk")
                {
                    destination = "RequisitionListClerk.aspx";
                }
                else
                {
                    Utility.logout();
                }
            }
            else
            {
                Utility.logout();
            }

            Utility.AlertMessageThenRedirect("Discrepancies successfully reported", destination);
        }
    }
Exemple #15
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);
    }
Exemple #16
0
 public static bool ValidateNewItemfields(string itemCode, string categoryName, string description, string reorderLevel, string reorderQty, string UOM, string bin)
 {
     if (IsValidItemFields(itemCode, categoryName, description, reorderLevel, reorderQty, UOM, bin) && EFBroker_Item.GetItembyItemCode(itemCode.ToUpper()) == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #17
0
 public static Item GetItembyItemCode(string itemCode)
 {
     return(EFBroker_Item.GetItembyItemCode(itemCode));
 }
    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);
            }
        }
    }
    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();
    }
    public Item GetItemForGivenItemCode(string itemCode)
    {
        Item itemName = EFBroker_Item.GetItembyItemCode(itemCode);

        return(itemName);
    }
Exemple #21
0
    protected void BtnAddItem_Click(object sender, EventArgs e)
    {
        Dictionary <Item, int>    discrepancies      = null;
        Dictionary <Item, String> discrepancyDisplay = null;

        if (Session["discrepancyList"] == null)
        {
            discrepancies = new Dictionary <Item, int>();
        }
        else
        {
            discrepancies = (Dictionary <Item, int>)Session["discrepancyList"];
        }

        if (Session["discrepancyDisplay"] == null)
        {
            discrepancyDisplay = new Dictionary <Item, String>();
        }
        else
        {
            discrepancyDisplay = (Dictionary <Item, String>)Session["discrepancyDisplay"];
        }

        bool alreadyInDiscrepancyList         = false;
        KeyValuePair <Item, int> toBeReplaced = new KeyValuePair <Item, int>();

        foreach (KeyValuePair <Item, int> kvp in discrepancies)
        {
            if (kvp.Key.ItemCode == lblItemCode.Text)
            {
                alreadyInDiscrepancyList = true;
                toBeReplaced             = kvp;
                break;
            }
        }

        Item item = EFBroker_Item.GetItembyItemCode(lblItemCode.Text);

        int adjustment = 0;

        if (Int32.TryParse(txtAdj.Text, out adjustment))
        {
            if (adjustment != 0)
            {
                if (item.BalanceQty + adjustment >= 0)
                {
                    int    actualQuantity = (int)item.BalanceQty + adjustment;
                    string adjStr         = "";

                    if (adjustment > 0)
                    {
                        adjStr = "+" + adjustment.ToString();
                    }
                    else
                    {
                        adjStr = adjustment.ToString();
                    }

                    if (alreadyInDiscrepancyList)
                    {
                        //discrepancies.Remove(toBeReplaced.Key);
                        //discrepancyDisplay.Remove(toBeReplaced.Key);
                        discrepancies[toBeReplaced.Key]      = adjustment;
                        discrepancyDisplay[toBeReplaced.Key] = adjStr;
                    }
                    else
                    {
                        discrepancies.Add(item, adjustment);
                        discrepancyDisplay.Add(item, adjStr);
                    }

                    Session["discrepancyList"]    = discrepancies;
                    Session["discrepancyDisplay"] = discrepancyDisplay;
                    Response.Redirect(LoginController.GenerateDiscrepancyV2URI);
                }
                else
                {
                    lblErrorMsg.Text = "Adjustment cannot reduce stock to less than 0";
                }
            }
            else
            {
                lblErrorMsg.Text = "Please enter a non-zero integer for adjustment amount (either positive or negative)";
            }
        }
        else
        {
            lblErrorMsg.Text = "Please enter an integer for adjustment amount (either positive or negative)";
        }
    }
Exemple #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string itemCode     = Request.QueryString["itemCode"];
        string adjustment   = "Adjustment";  //strings for stock card transaction type
        string disbursement = "Disbursement";
        string purchase     = "Purchase";

        if (!ValidatorUtil.isEmpty(itemCode))
        {
            Item             item        = EFBroker_Item.GetItembyItemCode(itemCode);
            string           currentYear = DateTime.Now.Year.ToString();
            List <PriceList> plList      = EFBroker_PriceList.GetPriceListByItemCode(itemCode).Where(c => c.TenderYear == currentYear).ToList();
            if (item != null && plList.Count > 0)
            {
                lblItemCode.Text = item.ItemCode;
                lblItemName.Text = item.Description;
                lblBin.Text      = item.Bin;
                lblUom.Text      = item.UnitOfMeasure;

                foreach (PriceList pl in plList)
                {
                    switch (pl.SupplierRank)
                    {
                    case 1:
                        lblSupp1.Text = pl.SupplierCode;
                        break;

                    case 2:
                        lblSupp2.Text = pl.SupplierCode;
                        break;

                    case 3:
                        lblSupp3.Text = pl.SupplierCode;
                        break;
                    }
                }

                if (plList.Count < 3)   // N/A on supplier labels if there are less than 3 suppliers
                {
                    lblSupp3.Text = "N/A";
                    if (plList.Count < 2)
                    {
                        lblSupp2.Text = "N/A";
                    }
                }

                List <StockCard>           scList        = EFBroker_StockCard.GetStockCardsByItemCode(itemCode);
                List <StockCardDisplayRow> scDisplayList = new List <StockCardDisplayRow>();

                foreach (StockCard sc in scList)
                {
                    if (sc.TransactionType == adjustment || sc.TransactionType == disbursement || sc.TransactionType == purchase)
                    {
                        //Possible to display 3 types of stock card entries (each accessing different tables)
                        StockCardDisplayRow scdr = new StockCardDisplayRow();
                        if (sc.TransactionType == adjustment)
                        {
                            Discrepency d = EFBroker_Discrepancy.GetDiscrepancyById((int)sc.TransactionDetailID);
                            scdr.TransDate    = ((DateTime)d.Date).ToShortDateString();
                            scdr.TransDetails = "Adjustment ID. " + sc.TransactionDetailID;
                            scdr.Quantity     = "ADJ " + GetQuantityString((int)sc.Qty);
                        }
                        else if (sc.TransactionType == purchase)
                        {
                            PurchaseOrder po = EFBroker_PurchaseOrder.GetPurchaseOrderById((int)sc.TransactionDetailID);
                            scdr.TransDate    = ((DateTime)po.ExpectedDate).ToShortDateString();
                            scdr.TransDetails = "Supplier - " + po.SupplierCode;
                            Item_PurchaseOrder ipo = EFBroker_PurchaseOrder.GetPurchaseOrderItem(po.PurchaseOrderID, itemCode);
                            scdr.Quantity = GetQuantityString((int)sc.Qty);
                        }
                        else if (sc.TransactionType == disbursement)
                        {
                            Disbursement db = EFBroker_Disbursement.GetDisbursmentbyDisbID((int)sc.TransactionDetailID);
                            scdr.TransDate    = ((DateTime)db.CollectionDate).ToShortDateString();
                            scdr.TransDetails = EFBroker_DeptEmployee.GetDepartByDepCode(db.DeptCode).DeptName;
                            scdr.Quantity     = GetQuantityString((int)sc.Qty);
                        }
                        scdr.Balance = (int)sc.Balance;
                        scDisplayList.Add(scdr);
                    }
                }

                gvTransactions.DataSource = scDisplayList;
                gvTransactions.DataBind();
            }
            else    //if item is not found or no entries found in price list table
            {
                Response.Redirect(LoginController.StationeryCatalogueURI);
            }
        }
        else   //if there is no itemCode in querystring
        {
            Response.Redirect(LoginController.StationeryCatalogueURI);
        }
    }