public MainPage Add(string Product, string Price, string Quantity, string Stock, string Order, string Level)
 {
     AllProducts.Click();
     CreateNew.Click();
     ProductName.SendKeys(Product);
     CategoryID.FindElement(By.XPath("//option[. = 'Seafood']")).Click();
     SupplierID.FindElement(By.XPath("//option[. = 'Leka Trading']")).Click();
     UnitPrice.SendKeys(Price);
     QuantityPerUnit.SendKeys(Quantity);
     UnitsInStock.SendKeys(Stock);
     UnitsOnOrder.SendKeys(Order);
     ReorderLevel.SendKeys(Level);
     Confirm.Click();
     return(new MainPage(driver));
 }
 public MainPage Exist()
 {
     AllProducts.Click();
     TestProduct.Click();
     Assert.AreEqual(ProductName.GetAttribute("value"), "Test Product");
     Assert.AreEqual(CategoryID.FindElement(By.XPath("//option[. = 'Seafood']")).GetAttribute("text"), "Seafood");
     Assert.AreEqual(SupplierID.FindElement(By.XPath("//option[. = 'Leka Trading']")).GetAttribute("text"), "Leka Trading");
     Assert.AreEqual(UnitPrice.GetAttribute("value"), "111,0000");
     Assert.AreEqual(QuantityPerUnit.GetAttribute("value"), "222");
     Assert.AreEqual(UnitsInStock.GetAttribute("value"), "333");
     Assert.AreEqual(UnitsOnOrder.GetAttribute("value"), "444");
     Assert.AreEqual(ReorderLevel.GetAttribute("value"), "555");
     Home.Click();
     logoutField.Click();
     return(new MainPage(driver));
 }
Beispiel #3
0
        public override int GetHashCode()
        {
            var hashCode = -931275965;

            hashCode = hashCode * -1521134295 + ProductID.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ProductName);

            hashCode = hashCode * -1521134295 + EqualityComparer <Supplier> .Default.GetHashCode(Supplier);

            hashCode = hashCode * -1521134295 + EqualityComparer <Category> .Default.GetHashCode(Category);

            hashCode = hashCode * -1521134295 + UnitsInStock.GetHashCode();
            hashCode = hashCode * -1521134295 + UnitsOnOrder.GetHashCode();
            hashCode = hashCode * -1521134295 + ReorderLevel.GetHashCode();
            return(hashCode);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ (ProductName != null ? ProductName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SupplierId;
         hashCode = (hashCode * 397) ^ CategoryId;
         hashCode = (hashCode * 397) ^ (QuantityPerUnit != null ? QuantityPerUnit.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ UnitPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ UnitsInStock.GetHashCode();
         hashCode = (hashCode * 397) ^ UnitsOnOrder.GetHashCode();
         hashCode = (hashCode * 397) ^ ReorderLevel.GetHashCode();
         hashCode = (hashCode * 397) ^ Discontinued.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Returns values in the collections.
        /// </summary>
        /// <returns>IEnumerator object</returns>
        public IEnumerator PropertyAndValuesCollection()
        {
            yield return("Product ID: " + ID.ToString());

            yield return("Product Name: " + ProductName);

            yield return("Supplier ID: " + SupplierID.ToString());

            yield return("Category ID: " + CategoryID.ToString());

            yield return("Quantity Per Unit: " + QuantityPerUnit);

            yield return("Unit Price: " + UnitPrice.ToString("c"));

            yield return("Units in Stock: " + UnitsInStock.ToString());

            yield return("Units On Order: " + UnitsOnOrder.ToString());

            yield return("ReOrder Level: " + ReOrderLevel.ToString());
        }
        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
                {
                }
            }
        }