예제 #1
0
 public static bool DeleteOrder(Order SelectedOrder)
 {
     try
     {
         DataAccessLayer.DeleteObject(SelectedOrder);
         DataAccessLayer.SaveChanges(System.Data.Objects.SaveOptions.None);
     }
     catch (Exception ex)
     {
         string s = ex.ToString();
         DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedOrder);
         return false;
     }
     DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedOrder);
     return true;
 }
예제 #2
0
        public static Order GetOrderById(int? id)
        {
            if (id != null)
            {
            IQueryable<Order> OrderQuery =
                               from p in DataAccessLayer.Orders
                               where p.OrderId == id
                               select p;

                return OrderQuery.ToList()[0];
            }
            else
            {
                Order o = new Order();
                o.OrderName = "";
                return o;
            }
        }
예제 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (OrderDataAccess.DeleteOrder(SelectedOrder) == false)
            {
                MessageBox.Show("Cannot delete, child nodes still exist", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            SelectedOrder = null;
            LoadData();
            try
            {
                dgOrders.CurrentCell = dgOrders.Rows[0].Cells[0];
                dgOrders.Rows[0].Selected = true;
            }
            catch
            {
                btnFamily.Enabled = false;
                txtOrderId.Text = "";
                txtOrderName.Text = "";
            }
        }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders(Order order)
 {
     base.AddObject("Orders", order);
 }
예제 #5
0
 /// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="orderId">Initial value of the OrderId property.</param>
 public static Order CreateOrder(global::System.Int32 orderId)
 {
     Order order = new Order();
     order.OrderId = orderId;
     return order;
 }
예제 #6
0
 private void SelectOrder(int id)
 {
     try
     {
         SelectedOrder = OrderDataAccess.GetOrderById(id);
         txtOrderName.Text = SelectedOrder.OrderName;
         txtOrderId.Text = SelectedOrder.OrderId.ToString();
         txtNumberinOrder.Text = SelectedOrder.NumberInOrder.ToString();
         txtNotes.Text = SelectedOrder.Notes;
         btnFamily.Enabled = true;
     }
     catch { }
 }
예제 #7
0
 public static int SaveOrder(Order SelectedOrder)
 {
     return DataAccessLayer.SaveChanges();
 }