public bool deleteRestaurantItemInDB(IRestaurantItem item)
 {
     try
     {
         ds = new DataSet();
         string sql = "SELECT * From restaurantitems";
         da = new SqlDataAdapter(sql, con);
         da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
         cb = new SqlCommandBuilder(da);  //Generates
         da.Fill(ds, "ItemsData");
         DataRow findRow = ds.Tables["ItemsData"].Rows.Find(item.ItemID);
         if (findRow != null)
         {
             findRow.Delete(); //mark row as deleted
         }
         da.Update(ds, "ItemsData"); //remove row from database table
     }
     catch (System.Exception excep)
     {
         MessageBox.Show(excep.Message);
         if (getConnection().ToString() == "Open")
             closeConnection();
         Application.Exit();
     }
     return true;
 }
 private void CurrentSaleItemR(IRestaurantItem product)
 {
     string currentItemName = product.Name;
     string currentItemPrice = string.Format("{0:c}", product.Price);
     string currentItemNamePadded = currentItemName.PadRight(20);
     textBoxSaleItem.Text = currentItemNamePadded + currentItemPrice;
 }
 public void addNewRestaurantItemToDB(IRestaurantItem item)
 {
     try
     {
         DataSet ds = new DataSet();
         string sql = "SELECT * From restaurantitems";
         SqlDataAdapter da = new SqlDataAdapter(sql, con);
         SqlCommandBuilder cb = new SqlCommandBuilder(da);  //Generates
         da.Fill(ds, "ItemsData");
         totalRestaurantItems = ds.Tables["ItemsData"].Rows.Count;
         DataRow dRow = ds.Tables["ItemsData"].NewRow();
         dRow[0] = Convert.ToInt16(item.ItemID);
         dRow[1] = item.Name.ToString();
         dRow[2] = item.Category.ToString();
         dRow[3] = item.Description.ToString();
         dRow[4] = Convert.ToDouble(item.Price);
         ds.Tables["ItemsData"].Rows.Add(dRow);
         da.Update(ds, "ItemsData");
     }
     catch (System.Exception excep)
     {
         if (con.State.ToString() == "Open")
             con.Close();
         Application.Exit();
         //Environment.Exit(0); //Force the application to close
     }
 }
        public bool modifyRestaurantItemInDB(IRestaurantItem item)
        {
            try
            {
                ds = new DataSet();
                string sql = "SELECT * From restaurantitems";
                da = new SqlDataAdapter(sql, con);
                da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                cb = new SqlCommandBuilder(da);  //Generates
                da.Fill(ds, "ItemsData");
                DataRow findRow = ds.Tables["ItemsData"].Rows.Find(item.ItemID);
                if (findRow != null)
                {
                    //findRow[0] = user.userID.ToString();
                    findRow[2] = item.Category;
                    findRow[3] = item.Description;
                    findRow[4] = Convert.ToDouble(item.Price);

                }
                da.Update(ds, "ItemsData"); //remove row from database table
            }
            catch (System.Exception excep)
            {
                MessageBox.Show(excep.Message);
                if (getConnection().ToString() == "Open")
                    closeConnection();
                Application.Exit();
            }
            return true;
        }
 public static void SetRestaurantItem(IRestaurantItem rItem)
 {
     item = rItem;
 }
 public bool modifyRestaurantItem(IRestaurantItem item)
 {
     DataLayer.modifyRestaurantItemInDB(item);
     return true;
 }
 public bool deleteRestaurantItem(IRestaurantItem item)
 {
     DataLayer.deleteRestaurantItemInDB(item);
     RestaurantItemsList.Remove(item); //remove object from collection
     return true;
 }