Beispiel #1
0
        protected void BindGrid()
        {
            List <InventoryCatalogue> cList = InventoryLogic.GetAllCatalogue();

            GridViewCatalogue.DataSource = cList;
            GridViewCatalogue.DataBind();
            Session["CatalogueList"] = cList;
        }
        protected void BindGrid()
        {
            InventoryLogic            il       = new InventoryLogic();
            List <InventoryCatalogue> itemList = InventoryLogic.GetAllCatalogue().Where(x => x.Discontinued != "Y").ToList();

            GridViewAddRequest.DataSource = itemList;
            GridViewAddRequest.DataBind();
        }
Beispiel #3
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string ItemID           = TxtItemID.Text;
                string BIN              = TxtBIN.Text;
                string Shelf            = TxtShelf.Text;
                int    Level            = Convert.ToInt32(TxtLevel.Text);
                string CategoryID       = Convert.ToString(DdlCategoryID.SelectedValue);
                string Description      = TxtDescription.Text;
                int    ReorderLevel     = Convert.ToInt32(TxtReorderLevel.Text);
                int    UnitsInStock     = Convert.ToInt32(TxtUnitsInStock.Text);
                int    ReorderQty       = Convert.ToInt32(TxtReorderQty.Text);
                string UOM              = TxtUOM.Text;
                string Discontinued     = "N";
                int    UnitsOnOrder     = Convert.ToInt32(TxtUnitsOnOrder.Text);
                int    BufferStockLevel = 0;
                int    BFSProportion    = 10;


                string supplier1 = DdlSupplier1.SelectedValue;
                string supplier2 = DdlSupplier2.SelectedValue;
                string supplier3 = DdlSupplier3.SelectedValue;
                double price1;
                double price2;
                double price3;
                bool   isprice1legit = false;
                if (Double.TryParse(TxtPriceS1.Text, out price1) && price1 > 0)
                {
                    isprice1legit = true;
                }
                bool isprice2legit = false;
                if (Double.TryParse(TxtPriceS2.Text, out price2) && price2 > 0)
                {
                    isprice2legit = true;
                }
                bool isprice3legit = false;
                if (Double.TryParse(TxtPriceS3.Text, out price3) && price3 > 0)
                {
                    isprice3legit = true;
                }


                string input = TxtItemID.Text;
                //This part is written by Pradeep
                //Here call a list of all InventoryCatalogue, and check if the itemID exist. InventoryCatalogues.;
                bool Exist = InventoryLogic.GetAllCatalogue().Any(i => i.ItemID == input);
                if (!Exist)
                {
                    if (supplier1 != string.Empty)
                    {
                        if (isprice1legit)
                        {
                            if (supplier2 != string.Empty)
                            {
                                if (supplier1 != supplier2)
                                {
                                    if (isprice2legit)
                                    {
                                        if (supplier3 != string.Empty)
                                        {
                                            if (supplier1 != supplier3 && supplier2 != supplier3)
                                            {
                                                if (isprice3legit)
                                                {
                                                    BusinessLogic.InventoryLogic.AddCatalogue(ItemID, BIN, Shelf, Level, CategoryID, Description,
                                                                                              ReorderLevel, UnitsInStock, ReorderQty, UOM, Discontinued, UnitsOnOrder, BufferStockLevel, BFSProportion);
                                                    InventoryLogic.AddSupplierCatalogue(supplier1, ItemID, price1, 1, UOM);
                                                    InventoryLogic.AddSupplierCatalogue(supplier2, ItemID, price2, 2, UOM);
                                                    InventoryLogic.AddSupplierCatalogue(supplier3, ItemID, price3, 3, UOM);
                                                    Response.Redirect("ViewCatalogue.aspx");
                                                }
                                                else
                                                {
                                                    statusMessage.Text      = "Please enter a valid price for 3rd Supplier";
                                                    statusMessage.Visible   = true;
                                                    statusMessage.ForeColor = Color.Red;
                                                }
                                            }
                                            else
                                            {
                                                statusMessage.Text      = "Please choose different suppliers";
                                                statusMessage.Visible   = true;
                                                statusMessage.ForeColor = Color.Red;
                                            }
                                        }
                                        else
                                        {
                                            BusinessLogic.InventoryLogic.AddCatalogue(ItemID, BIN, Shelf, Level, CategoryID, Description,
                                                                                      ReorderLevel, UnitsInStock, ReorderQty, UOM, Discontinued, UnitsOnOrder, BufferStockLevel, BFSProportion);
                                            InventoryLogic.AddSupplierCatalogue(supplier1, ItemID, price1, 1, UOM);
                                            InventoryLogic.AddSupplierCatalogue(supplier2, ItemID, price2, 2, UOM);
                                            Response.Redirect("ViewCatalogue.aspx");
                                        }
                                    }
                                    else
                                    {
                                        statusMessage.Text      = "Please enter a valid price for 2nd Supplier";
                                        statusMessage.Visible   = true;
                                        statusMessage.ForeColor = Color.Red;
                                    }
                                }
                                else
                                {
                                    statusMessage.Text      = "Please choose different suppliers";
                                    statusMessage.Visible   = true;
                                    statusMessage.ForeColor = Color.Red;
                                }
                            }
                            else
                            {
                                BusinessLogic.InventoryLogic.AddCatalogue(ItemID, BIN, Shelf, Level, CategoryID, Description,
                                                                          ReorderLevel, UnitsInStock, ReorderQty, UOM, Discontinued, UnitsOnOrder, BufferStockLevel, BFSProportion);
                                InventoryLogic.AddSupplierCatalogue(supplier1, ItemID, price1, 1, UOM);
                                Response.Redirect("ViewCatalogue.aspx");
                            }
                        }
                        else
                        {
                            statusMessage.Text      = "Please enter a valid price for 1st Supplier";
                            statusMessage.Visible   = true;
                            statusMessage.ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        statusMessage.Text      = "Please choose a supplier";
                        statusMessage.Visible   = true;
                        statusMessage.ForeColor = Color.Red;
                    }
                }

                else
                {
                    statusMessage.Text      = "Item already exists";
                    statusMessage.Visible   = true;
                    statusMessage.ForeColor = Color.Red;
                }
            }
            catch
            {
                statusMessage.Text      = "Input is required for all fields";
                statusMessage.Visible   = true;
                statusMessage.ForeColor = Color.Red;
            }
        }
//-------------------------------------Binding all the records from inventory table to datagrid view--------------------//
        public void GridBind()
        {
            allList         = InventoryLogic.GetAllCatalogue();
            Session["list"] = allList;
            DatagridBind(allList);
        }