private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection Connection = new SqlConnection(Con.ConnectionString());

            if (Cat.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select a Catagory";
                Cat.Focus();
            }
            else if (SubCat.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select Sub Catagory ";
                SubCat.Focus();
            }
            else if (ItemNo.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Item No";
                ItemNo.Text = "";
                ItemNo.Focus();
            }
            else if (Units.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Units";
                Units.Text = "";
                Units.Focus();
            }
            else if (StockPrice.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Stock Price";
                StockPrice.Text            = "";
                StockPrice.Focus();
            }
            else if (SalesPrice.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Sales Price";
                SalesPrice.Text            = "";
                SalesPrice.Focus();
            }
            else if (UnitsInStock.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter how many Units have in Stock";
                UnitsInStock.Text          = "";
                UnitsInStock.Focus();
            }
            else if (ROL.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter ReOrder Level";
                ROL.Text = "";
                ROL.Focus();
            }
            else if (Convert.ToDecimal(Profit.Text) < 0)
            {
                MessageBox.Show("Your Stock price larger than Sales Price" + Environment.NewLine + "Enter Correct Value or Change the Discount Rate", "Data Entry Problem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);;
                SalesPrice.Focus();
            }
            else
            {
                try
                {
                    Connection.Open();
                    if (button4.Text.ToString() == "Save")
                    {
                        SqlCommand INSERT = new SqlCommand("INSERT INTO ItemList(ItemNo,Descriptions,Units,Catagory,SubCatagory,StockPrice,SalesPrice,Discount,UnitsInStock,ROL) VALUES(@ItemNo,@Descriptions,@Units,@Catagory,@SubCatagory,@StockPrice,@SalesPrice,@Discount,@UnitsInStock,@ROL)", Connection);
                        INSERT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Units", Units.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        INSERT.Parameters.AddWithValue("@SubCatagory", SubCat.SelectedItem.ToString());
                        INSERT.Parameters.AddWithValue("@StockPrice", Convert.ToDecimal(StockPrice.Text));
                        INSERT.Parameters.AddWithValue("@SalesPrice", Convert.ToDecimal(SalesPrice.Text));
                        INSERT.Parameters.AddWithValue("@Discount", Convert.ToInt16(Discount.Text));
                        INSERT.Parameters.AddWithValue("@UnitsInStock", Convert.ToInt64(UnitsInStock.Text));
                        INSERT.Parameters.AddWithValue("@ROL", Convert.ToInt32(ROL.Text));


                        if (INSERT.ExecuteNonQuery() == 1)
                        {
                            toolStripStatusLabel1.Text = "Sucessfully Saved";
                            ItemNo2.Items.Add(ItemNo.Text.ToString());
                            ItemNo.Text = "";
                            Des.Text    = "";
                            Units.Text  = "";
                            StockPrice.Clear();
                            SalesPrice.Text   = "";
                            Discount.Text     = "";
                            UnitsInStock.Text = "";
                            ROL.Text          = "";
                            Profit.Text       = "0.0";
                            ItemNo.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error Item Not Saved";
                        }
                    }
                    else
                    {
                        SqlCommand UPDES = new SqlCommand("UPDATE ItemList SET Descriptions=@Descriptions WHERE ItemNo=@ItemNo", Connection);
                        UPDES.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());
                        UPDES.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPUNIT = new SqlCommand("UPDATE ItemList SET Units=@Units WHERE ItemNo=@ItemNo", Connection);
                        UPUNIT.Parameters.AddWithValue("@Units", Units.Text.ToString());
                        UPUNIT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPCAT = new SqlCommand("UPDATE ItemList SET Catagory=@Catagory WHERE ItemNo=@ItemNo", Connection);
                        UPCAT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPCAT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSUBCAT = new SqlCommand("UPDATE ItemList SET SubCatagory=@SubCatagory WHERE ItemNo=@ItemNo", Connection);
                        UPSUBCAT.Parameters.AddWithValue("@SubCatagory", SubCat.SelectedItem.ToString());
                        UPSUBCAT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSTOCKPRICE = new SqlCommand("UPDATE ItemList SET StockPrice=@StockPrice WHERE ItemNo=@ItemNo", Connection);
                        UPSTOCKPRICE.Parameters.AddWithValue("@StockPrice", Convert.ToDecimal(StockPrice.Text));
                        UPSTOCKPRICE.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSALESPRICE = new SqlCommand("UPDATE ItemList SET SalesPrice=@SalesPrice WHERE ItemNo=@ItemNo", Connection);
                        UPSALESPRICE.Parameters.AddWithValue("@SalesPrice", Convert.ToDecimal(SalesPrice.Text));
                        UPSALESPRICE.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPDISCOUNT = new SqlCommand("UPDATE ItemList SET Discount=@Discount WHERE ItemNo=@ItemNo", Connection);
                        UPDISCOUNT.Parameters.AddWithValue("@Discount", Convert.ToInt16(Discount.Text));
                        UPDISCOUNT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPUNITSINSTOCK = new SqlCommand("UPDATE ItemList SET UnitsInStock=@UnitsInStock WHERE ItemNo=@ItemNo", Connection);
                        UPUNITSINSTOCK.Parameters.AddWithValue("@UnitsInStock", Convert.ToInt64(UnitsInStock.Text));
                        UPUNITSINSTOCK.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPROL = new SqlCommand("UPDATE ItemList SET ROL=@ROL WHERE ItemNo=@ItemNo", Connection);
                        UPROL.Parameters.AddWithValue("@ROL", Convert.ToInt32(ROL.Text));
                        UPROL.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        int a, b, c, d, ei, f, g, h, i;
                        a  = UPDES.ExecuteNonQuery();
                        b  = UPUNIT.ExecuteNonQuery();
                        c  = UPSTOCKPRICE.ExecuteNonQuery();
                        d  = UPSALESPRICE.ExecuteNonQuery();
                        ei = UPDISCOUNT.ExecuteNonQuery();
                        f  = UPUNITSINSTOCK.ExecuteNonQuery();
                        g  = UPROL.ExecuteNonQuery();
                        h  = UPCAT.ExecuteNonQuery();
                        i  = UPSUBCAT.ExecuteNonQuery();

                        if ((a == 1) && (b == 1) && (c == 1) && (d == 1) && (ei == 1) && (f == 1) && (g == 1) && (h == 1) && (i == 1))
                        {
                            toolStripStatusLabel1.Text = "Update Sucessfully";
                            ItemNo.Text            = "";
                            Des.Text               = "";
                            Units.Text             = "";
                            StockPrice.Text        = "";
                            SalesPrice.Text        = "";
                            Discount.SelectedIndex = 0;
                            UnitsInStock.Text      = "";
                            ROL.Text               = "";
                            Profit.Text            = "0.0";
                            Cat.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error, Item Not Updated";
                        }
                    }
                    Connection.Close();
                }
                catch
                {
                }
            }
        }