//Adds a new stock order to the database-Grace
        public bool AddNewStockOrder(DateTime orderCreated, int supplierID, string deliverTo, double orderTotal, string status)
        {
            try
            {
                StockOrderList = DataLayer.getAllOrders();
                int maxId = 0;

                foreach (StockOrder order in StockOrderList)
                {
                    if (order.orderID > maxId)
                    {
                        maxId = order.orderID;
                    }
                }
                IStockOrder theOrder = StockOrderFactory.GetStockOrder(maxId + 1, orderCreated, supplierID, deliverTo, orderTotal, status);
                // Using a Factory to create the user entity object. ie seperating object creation from business logic
                _stockOrderList.Add(theOrder);            // Add a reference to the newly created object to the Models UserList
                DataLayer.AddNewStockOrderToDB(theOrder); //Gets the DataLayer to add the new user to the DB.
                return(true);
            }
            catch (System.Exception excep)
            {
                return(false);
            }
        }
예제 #2
0
 public Boolean addnewStockOrder(int stockOrderID, int UserID, string date)
 {
     try
     {
         IStockOrder aStockOrder = StockOrderFactory.GetStockOrder(stockOrderID, UserID, date); // Using a Factory to create the user entity object. ie seperating object creation from business logic
         StockOrderList.Add(aStockOrder);                                                       // Add a reference to the newly created object to the Models UserList
         DataLayer.addNewStockOrderToDB(aStockOrder);                                           //Gets the DataLayer to add the new user to the DB.
         return(true);
     }
     catch (System.Exception excep)
     {
         return(false);
     }
 }
 //Edits stock order details in the DB-Grace
 public bool ReceiveStockOrder(IStockOrder stockOrder)
 {
     DataLayer.ReceiveStockOrderInDB(stockOrder);
     return(true);
 }
 public void addNewRestaurantOrder(IStockOrder order)
 {
     try
     {
         DataSet ds = new DataSet();
         string sql = "SELECT * From stockorders";
         SqlDataAdapter da = new SqlDataAdapter(sql, con);
         SqlCommandBuilder cb = new SqlCommandBuilder(da);  //Generates
         da.Fill(ds, "OrderData");
         totalRestaurantItems = ds.Tables["OrderData"].Rows.Count;
         DataRow dRow = ds.Tables["OrderData"].NewRow();
         dRow[0] = order.OrderId;
         dRow[1] = order.Date;
         dRow[2] = order.Supplier.SupplierId;
         ds.Tables["OrderData"].Rows.Add(dRow);
         da.Update(ds, "OrderData");
     }
     catch (System.Exception excep)
     {
         if (con.State.ToString() == "Open")
             con.Close();
         Application.Exit();
     }
 }
예제 #5
0
 public static void SetStockOrder(IStockOrder aStockOrder)
 {
     StockOrder = aStockOrder;
 }
 public static void SetNewStockRoom(IStockOrder aStockOrder)
 {
     newStockOrder = aStockOrder;
 }
예제 #7
0
 public bool deleteStockOrder(IStockOrder StockOrder)
 {
     DataLayer.deleteStockOrderFromDB(StockOrder);
     StockOrderList.Remove(StockOrder); //remove object from collection
     return(true);
 }
예제 #8
0
 public bool editStockOrder(IStockOrder StockOrder)
 {
     DataLayer.editStockOrderInDB(StockOrder);
     return(true);
 }