protected void FindBtn_Click(object sender, EventArgs e)
        {
            string itemcode = TxtItemCode.Text;
            int    bufferstocklevel;

            LblItemCode.Text = itemcode;
            try
            {
                InventoryCatalogue i = InventoryLogic.GetInventoryItem(itemcode);
                bufferstocklevel = PurchasingLogic.GetCurrentBufferStock(itemcode);
                if (bufferstocklevel >= 0)
                {
                    AutomationStatusLbl.Text = "The current buffer stock level is " + bufferstocklevel + ".";
                }
                else
                {
                    AutomationStatusLbl.Text = "The buffer stock level is currently calculated automatically.";
                }
                LblItemDescription.Text    = i.Description;
                MultiView1.ActiveViewIndex = 1;
                statusMessage.Visible      = false;
            }
            catch
            {
                statusMessage.Text      = "Item does not exist.";
                statusMessage.Visible   = true;
                statusMessage.ForeColor = Color.Red;
            }
        }
        // Creating a single PODetails entry
        public static bool CreateSinglePODetails(ReorderRecord r)
        {
            using (SA45Team12AD context = new SA45Team12AD())
            {
                try
                {
                    // Finding the newly created PO record
                    PORecord pr = context.PORecords.OrderByDescending(x => x.PONumber).First();

                    // Req to populate the values for the new entry
                    InventoryCatalogue iv = context.InventoryCatalogues.Where(x => x.ItemID.Equals(r.ItemID)).First();                                              // To retrieve UOM
                    SupplierCatalogue  sc = context.SupplierCatalogues.Where(x => x.ItemID.Equals(r.ItemID)).Where(y => y.SupplierID.Equals(r.SupplierID)).First(); // TO retrieve price

                    // Creating our new entry...
                    PORecordDetail pd = new PORecordDetail();
                    pd.PONumber  = pr.PONumber;
                    pd.ItemID    = r.ItemID;
                    pd.Quantity  = r.OrderedQuantity;
                    pd.UOM       = iv.UOM;
                    pd.UnitPrice = sc.Price;

                    context.PORecordDetails.Add(pd);
                    context.SaveChanges();

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Beispiel #3
0
 protected void TxtItemCode_TextChanged(object sender, EventArgs e)
 {
     statusMessage.Visible = false;
     try
     {
         GridViewRow        currentRow    = (GridViewRow)((TextBox)sender).Parent.Parent.Parent.Parent;
         TextBox            txtItemCode   = currentRow.FindControl("TxtItemCode") as TextBox;
         InventoryCatalogue inventoryItem = InventoryLogic.GetInventoryItem(txtItemCode.Text);
         string             itemName      = inventoryItem.Description;
         string             uom           = inventoryItem.UOM;
         Label lblDesc = currentRow.FindControl("LblDesc") as Label;
         Label lblUOM  = currentRow.FindControl("LblUOM") as Label;
         if (lblDesc != null)
         {
             lblDesc.Text = itemName;
         }
         if (lblUOM != null)
         {
             lblUOM.Text = uom;
         }
     }catch (Exception ex)
     {
         statusMessage.ForeColor = Color.Red;
         statusMessage.Text      = "Invalid Item Code Entered: ";
         Console.WriteLine(ex.ToString());
         statusMessage.Visible = true;
     }
 }
        protected void BtnAddRequest_Click(object sender, EventArgs e)
        {
            Button                    btnAddRequest = sender as Button;
            GridViewRow               row           = btnAddRequest.NamingContainer as GridViewRow;
            string                    itemId        = GridViewAddRequest.DataKeys[row.RowIndex].Values[0].ToString();
            InventoryCatalogue        item          = InventoryLogic.GetInventoryItem(itemId);
            List <InventoryCatalogue> cartList;

            if (Session["CartList"] != null)
            {
                cartList = (List <InventoryCatalogue>)Session["CartList"];
                bool Exist = cartList.Any(x => x.ItemID == itemId);
                if (Exist)
                {
                    LblCount.Text      = "You cannot request same item twice.";
                    LblCount.ForeColor = Color.Red;
                    return;
                }
                else
                {
                    cartList.Add(item);
                    Session["CartList"] = cartList;
                    Response.Redirect("~/DepartmentEmployee/ViewCatalogue.aspx");
                }
            }

            else
            {
                cartList = new List <InventoryCatalogue>();
                cartList.Add(item);
                Session["CartList"] = cartList;
                Response.Redirect("~/DepartmentEmployee/ViewCatalogue.aspx");
            }
        }
        public static List <InventoryCatalogue> DeleteOrder(List <InventoryCatalogue> _itemList, string ItemID)
        {
            List <InventoryCatalogue> itemList   = _itemList;
            InventoryCatalogue        removeItem = itemList.Where(i => i.ItemID == ItemID).First();

            itemList.Remove(removeItem);
            return(itemList);
        }
Beispiel #6
0
 protected void GridViewRequisitionForm_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         InventoryCatalogue ic     = (InventoryCatalogue)e.Row.DataItem;
         string             ItemID = ic.ItemID;
     }
 }
 public static void UpdateBufferStockLevel(string itemid, int newbufferstocklevel)
 {
     using (SA45Team12AD entities = new SA45Team12AD())
     {
         InventoryCatalogue inventory = entities.InventoryCatalogues.Where(x => x.ItemID == itemid).Single();
         inventory.BufferStockLevel = newbufferstocklevel;
         inventory.BFSProportion    = 0;
         entities.SaveChanges();
     }
 }
Beispiel #8
0
//--------------------------To get the item details---------------------------------------------------------------------//
        public void details(string itemid)
        {
//--------------------------from InventoryCatalogue table(BIN,Description,UOM)------------------------------------------//
            detFromInventory = InventoryLogic.GetInventoryDetails(itemid);
            LblDesD.Text     = detFromInventory.Description;
            LblUomD.Text     = detFromInventory.UOM;
            LblBinD.Text     = detFromInventory.BIN;
            LblIdD.Text      = detFromInventory.ItemID;
//---------------------------from SupplierCatalogue table(Supplier details)--------------------------------------------//
            sCatList    = InventoryLogic.GetCatalogueDetails(itemid);
            LblS1D.Text = sCatList[0].SupplierID;
            LblS2D.Text = sCatList[1].SupplierID;
            LblS3D.Text = sCatList[2].SupplierID;
        }
 public static string GetCurrentAutomationStatus(string itemid)
 {
     using (SA45Team12AD entities = new SA45Team12AD())
     {
         InventoryCatalogue inventory = entities.InventoryCatalogues.Where(x => x.ItemID == itemid).First <InventoryCatalogue>();
         if (inventory.BufferStockLevel == null)
         {
             return("The buffer stock level is currently calculated automatically for the current item.");
         }
         else
         {
             return("The buffer stock level for the current item is " + inventory.BufferStockLevel.ToString());
         }
     }
 }
        // Setting a proportional level for buffer stock
        public static void SetProportionalBFS(string itemID, int propValue)
        {
            using (SA45Team12AD context = new SA45Team12AD())
            {
                // Finding the week no for the year (aka our period currently)
                DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
                Calendar           cal = dfi.Calendar;
                int currentPeriod      = cal.GetWeekOfYear(DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

                // Creating our obj from DB
                ForecastedData     f = context.ForecastedDatas.Where(x => x.ItemID.Equals(itemID)).Where(y => y.Season == DateTime.Now.Year).Where(z => z.Period == currentPeriod + 1).First(); // +1 to capture the next period
                InventoryCatalogue i = context.InventoryCatalogues.Where(x => x.ItemID.Equals(itemID)).First();

                // Changing our values
                i.BFSProportion    = propValue;
                i.BufferStockLevel = Convert.ToInt32(Math.Ceiling((Convert.ToDouble(propValue) * Convert.ToDouble(f.ForecastedDemand)) / 100));

                context.SaveChanges();
            }
        }
Beispiel #11
0
        // Setting automated buffer stock handling  --- Auto is set to 10%
        public static void SetAutomatedlBFS(string itemID)
        {
            using (SA45Team12AD context = new SA45Team12AD())
            {
                // Finding the week no for the year (aka our period currently)
                DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
                Calendar           cal = dfi.Calendar;
                int currentPeriod      = cal.GetWeekOfYear(DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

                // Creating our obj from DB
                ForecastedData     f = context.ForecastedDatas.Where(x => x.ItemID.Equals(itemID)).Where(y => y.Season == DateTime.Now.Year).Where(z => z.Period == currentPeriod + 1).First();
                InventoryCatalogue i = context.InventoryCatalogues.Where(x => x.ItemID.Equals(itemID)).First();

                // Changing our values
                i.BFSProportion    = 10;
                i.BufferStockLevel = Convert.ToInt32(Math.Ceiling((10.0 * Convert.ToDouble(f.High95)) / 100));   // We take high95 cos it possesses the expected Dd with the highest confidence interval determinable (just to be safe)

                context.SaveChanges();
            }
        }
Beispiel #12
0
        protected void GridViewCatalogue_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                InventoryCatalogue catalogue = (InventoryCatalogue)e.Row.DataItem;
                string             ItemID    = catalogue.ItemID;

                Label lblCatName = e.Row.FindControl("LblCatalogueName") as Label;
                if (lblCatName != null)
                {
                    lblCatName.Text = InventoryLogic.GetCatalogueName(catalogue.CategoryID);
                }

                DropDownList ddl = e.Row.FindControl("DdlCategoryID") as DropDownList;
                if (ddl != null)
                {
                    ddl.DataSource     = InventoryLogic.CategoryID();
                    ddl.DataTextField  = "CategoryID";
                    ddl.DataValueField = "CategoryID";
                    ddl.DataBind();
                }
            }
        }
Beispiel #13
0
//-----------------------Find transaction details button click event----------------------------------------------------//
        protected void BtnFind_Click(object sender, EventArgs e)
        {
            try {
                DatgridViewRefresh();
                ControlVisibleTrue();

//-----------------------------Getting the value from the date time picker----------------------------------------------//
                try
                {
                    date1 = DateTime.ParseExact(Request.Form["datepicker"], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    date2 = DateTime.ParseExact(Request.Form["datepicker2"], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                catch
                { }


//--------------convert date to string----------------------------------------------------------------------------------//
                string d1 = Convert.ToString(date1);
                string d2 = Convert.ToString(date2);

//---------If user wont select a date default value is "1/1/0001 12:00:00 AM".setting that to null here-----------------//
                if (d1 == "1/1/0001 12:00:00 AM" || d2 == "1/1/0001 12:00:00 AM")
                {
                    d1 = null;
                    d2 = null;
                }

//----------------------------Search based on item code & transaction dates-------------------------------------------//
//-------------Datagrid view load with transaction records of selected item within the selected dates--------------//

                //To get the item name corresponding to the item code selected
                InventoryCatalogue i  = InventoryLogic.GetInventoryDetails(TxtId.Text);
                string             d0 = date1.ToString("yyyy-MM-dd");
                string             d  = date2.ToString("yyyy-MM-dd");

                if (TxtId.Text != string.Empty && d1 != null && d2 != null)
                {
                    tList = InventoryLogic.GetTransactionByDate(date1, date2, TxtId.Text);
                    details(TxtId.Text);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();

                    LblMsg.Visible = true;


                    LblMsg.Text = "*Showing transaction records of " + i.Description + " within the date range " + d0 + " and " + d;
                }

//-----------------------------Transaction records of selected item----here user not selected any dates-----------------//
                else if (TxtId.Text != string.Empty && d1 == null && d2 == null)
                {
                    string id = TxtId.Text;
                    tList = InventoryLogic.GetStockCardList(TxtId.Text);
                    details(TxtId.Text);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Showing transaction records of " + i.Description;
                }
//--------------------------------Transaction records within the selected date range------------------------------------//
                else if (TxtId.Text == string.Empty && d1 != null && d2 != null)
                {
                    tList = InventoryLogic.GetAllTransactionByDate(date1, date2);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Showing transaction records " + "within the date range " + d0 + " and " + d;
                    ControlVisibleFalse();
                }
//--------------------user don't give any input.just click search button.then this condition will fire------------------//
                else if (TxtId.Text == string.Empty && d1 == null && d2 == null)
                {
                    ControlVisibleFalse();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Please give valid data to search in the inventory";
                }
            }
//-----------------------catch the invalid item code-----------display status message-----------------------------------//
            catch
            {
                ControlVisibleFalse();
            }
        }
        // Creating our list to be populated into the stationery retrieval list --- Priority is assessed and done here.
        public static List <TempInventoryRetrieval> CreateTempList(List <RequisitionRecordDetail> tempList, string itemID)
        {
            List <TempInventoryRetrieval> result = new List <TempInventoryRetrieval>();

            using (SA45Team12AD context = new SA45Team12AD())
            {
                // Declare attrs
                int totalReqQty = 0;
                int existingQty = 0;

                // Det total REQUESTED quantity
                foreach (var item in tempList)
                {
                    totalReqQty += (int)item.RequestedQuantity;
                }

                // Det EXISTING qty
                InventoryCatalogue temp = context.InventoryCatalogues.Where(x => x.ItemID.Equals(itemID)).First();
                existingQty = temp.UnitsInStock;

                // Will immediately return with the completed list if existing qty in the inventory is currently zero.
                if (existingQty == 0)
                {
                    foreach (var item in tempList)
                    {
                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, 0);
                        result.Add(t);
                    }
                    return(result);
                }

                // Check if total req items for the row exceeds existing inventory level
                if (totalReqQty > existingQty)
                {
                    List <RequisitionRecordDetail> priorityList = new List <RequisitionRecordDetail>();

                    //Populating the priority list if any
                    foreach (var item in tempList)
                    {
                        if (item.Priority.Equals("Yes"))
                        {
                            priorityList.Add(item);
                        }
                    }

                    // If none are remarked to be priority by the system, remaining qty will be divided equally between all the products.
                    if (priorityList.Count == 0)
                    {
                        int dividedQty = existingQty / tempList.Count;

                        foreach (var item in tempList)
                        {
                            TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, dividedQty);
                            result.Add(t);
                        }
                    }
                    else //Means some requests are considered priority requests...
                    {
                        // Check if all is priority
                        if (priorityList.Count == tempList.Count)
                        {
                            int dividedQty = existingQty / tempList.Count;

                            foreach (var item in tempList)
                            {
                                TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, dividedQty);
                                result.Add(t);
                            }
                        }
                        else  // If not all in the list are priority requests...
                        {
                            // Det total qty of all priority requests
                            int priorityTotalReq = 0;
                            foreach (var item in priorityList)
                            {
                                priorityTotalReq += (int)item.RequestedQuantity;
                            }

                            // Check if priority's total req is more than the existing stock level
                            if (priorityTotalReq > existingQty)
                            {
                                int dividedQty = existingQty / priorityList.Count;

                                foreach (var item in tempList)
                                {
                                    if (item.Priority.Equals("Yes"))    // Partially satisfy priority's requested qty
                                    {
                                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, dividedQty);
                                        result.Add(t);
                                    }
                                    else
                                    {
                                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, 0);  // zero for non-priority
                                        result.Add(t);
                                    }
                                }
                            }
                            else
                            {
                                int rmd = (existingQty - priorityTotalReq) / (tempList.Count - priorityList.Count);

                                // If priority's total req is not more than the existing inventory level
                                foreach (var item in tempList)
                                {
                                    if (item.Priority.Equals("Yes"))    // Satisfy priority's requested qty
                                    {
                                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, (int)item.RequestedQuantity);
                                        result.Add(t);
                                    }
                                    else
                                    {
                                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, rmd);
                                        result.Add(t);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in tempList)
                    {
                        TempInventoryRetrieval t = new TempInventoryRetrieval(item.RequestID, item.RequestDetailID, itemID, GetDeptID(item.RequestID), (int)item.RequestedQuantity, (int)item.RequestedQuantity);
                        result.Add(t);
                    }
                }
                return(result);
            }
        }
Beispiel #15
0
        // Creating new entry
        public string SubmitInventoryRetrieval(List <WCF_TempInventoryRetrieval> tempList, string token)
        {
            //Check if user is authorizated to use this method. If is not authorized, it will return a json with -1 in the primary key
            if (!IsAuthanticateUser(token))
            {
                List <WCF_TempInventoryRetrieval> wcf_UnAuthObj = new List <WCF_TempInventoryRetrieval>();
                WCF_TempInventoryRetrieval        wcfUnAuth     = new WCF_TempInventoryRetrieval();
                wcfUnAuth.RequestID = -1;
                wcf_UnAuthObj.Add(wcfUnAuth);
                return("Invalid user.");
            }

            bool anyErrors1 = false;
            bool anyErrors2 = true;

            // Checking against existing quantity in the store currently
            string itemID            = "";
            int    totalRetrievedQty = 0;

            foreach (var item in tempList)
            {
                itemID             = item.ItemID;
                totalRetrievedQty += item.ActualQty;
            }
            int currentQty = InventoryLogic.GetQuantity(itemID);

            if (totalRetrievedQty > currentQty)
            {
                anyErrors1 = true;
            }

            bool isEnough = true;

            // If still no errors, will perform more checks till an error is found.
            if (!anyErrors1)
            {
                foreach (var item in tempList)
                {
                    InventoryCatalogue ic = InventoryLogic.FindItemByItemID(itemID);

                    //Check if there is insufficient quantity in the inventory
                    if (ic.UnitsInStock < item.RequestedQty || ic.UnitsInStock < item.RequestedQty)
                    {
                        isEnough = false;

                        if (!isEnough && ic.UnitsInStock < item.RequestedQty)
                        {
                            anyErrors1 = true;
                        }
                    }

                    //If inventory is not enough and isOverride is true
                    if (item.IsOverride)
                    {
                        isEnough   = false;
                        anyErrors2 = false;
                    }

                    //Check if user is withdrawing more than requested
                    if (item.RequestedQty < item.ActualQty)
                    {
                        anyErrors1 = true;
                    }

                    //Check if user is withdrawing less than requested despite having enough in the inventory
                    if (isEnough && item.RequestedQty > item.ActualQty && !item.IsOverride)
                    {
                        anyErrors1 = true;
                    }


                    if (anyErrors1)
                    {
                        break;
                    }
                }
            }

            // If there is a single error, the process will terminate without updating any of the entries
            if (anyErrors1 && anyErrors2)
            {
                return("Failure.");
            }
            else
            {
                foreach (WCF_TempInventoryRetrieval item in tempList)
                {
                    string str = InventoryLogic.CreateNewInventoryRetrievalEntry(item.RequestID, item.RequestDetailID, item.ItemID, item.DepartmentID, item.RequestedQty, item.ActualQty, item.IsOverride);
                }

                return("Success.");
            }
        }