Example #1
0
        private void updateitem()
        {
            string     sql    = "update Ordertbl set Quantity=@qty,Subprice=@sub where Name=@name";
            SqlCommand cmd    = new SqlCommand(sql, cnn);
            int        newqty = this.quantity + this.addqty;

            cnn.Open();
            cmd.Parameters.AddWithValue("@name", FName);
            cmd.Parameters.AddWithValue("@qty", newqty);
            int k        = Convert.ToInt32(FPrice.Trim());
            int subprice = newqty * k;

            cmd.Parameters.AddWithValue("@sub", subprice);
            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Example #2
0
        private void addfooditem()
        {
            string     sql = "INSERT INTO Ordertbl(Name,Quantity,SubPrice,Vendor) VALUES(@Name,@Quantity,@Subprice,@Vendor)";
            SqlCommand cmd = new SqlCommand(sql, cnn);

            cnn.Open();

            cmd.Parameters.AddWithValue("@Name", FName);
            cmd.Parameters.AddWithValue("@Quantity", this.quantity);
            int k        = Convert.ToInt32(FPrice.Trim());
            int subprice = k * this.quantity;

            cmd.Parameters.AddWithValue("@Subprice", subprice);
            cmd.Parameters.AddWithValue("@Vendor", FVendor);
            cmd.ExecuteNonQuery();

            cnn.Close();
        }