Example #1
0
        public ORDERS_DISHES AddORDERS_DISHES(ORDERS_DISHES orders_dishes)
        {
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "INSERT INTO ORDERS_DISHES VALUES(@Quantity, GETDATE(), @Fk_Id_Dishes, @Fk_Id_Orders); SELECT SCOPE_IDENTITY()";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@Quantity", orders_dishes.Quantity);
                    cmd.Parameters.AddWithValue("@Fk_Id_Dishes", orders_dishes.Fk_Id_Dishes);
                    cmd.Parameters.AddWithValue("@Fk_Id_Orders", orders_dishes.Fk_Id_Orders);

                    cn.Open();

                    orders_dishes.Id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orders_dishes);
        }
Example #2
0
        public int createNewOrdersDishes(string [] stab, int orderNumber)
        {
            ORDERS_DISHES orders_dishes = new ORDERS_DISHES();

            orders_dishes.Quantity     = Convert.ToInt32(stab[1]);
            orders_dishes.Fk_Id_Dishes = Convert.ToInt32(stab[0]);
            orders_dishes.Fk_Id_Orders = orderNumber;

            ORDERS_DISHES_DB.AddORDERS_DISHES(orders_dishes);

            return(orderNumber);
        }