public MainWindow()
        {
            InitializeComponent();

            // create new OrderDB object to show all orders
            OrderDB orders = new OrderDB();

            orders.GetAllOrders(lstBoxOrders);
            // enable buttons based on user interaction
            btnOrderDetails.IsEnabled  = false;
            btnShippingDate.IsEnabled  = false;
            lstBoxProductIDs.IsEnabled = false;
        }
Example #2
0
 private void frmOrders_Load(object sender, EventArgs e)
 {
     //load orders data
     try
     {
         orders = OrderDB.GetAllOrders();
         orderDataGridView.DataSource = orders;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error while loading orders data: " +
                         ex.Message, ex.GetType().ToString());
     }
 }
Example #3
0
 private void orderDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == EDIT_BUTTON_INDX)// user clicked in the buttons collumn
     {
         frmUpdate updateForm = new frmUpdate();
         updateForm.order = orders[e.RowIndex];         // pass current customer to the update form
         DialogResult result = updateForm.ShowDialog(); // display modal
         if (result == DialogResult.OK)                 // update accepted
         {
             // refresh the grid contents
             CurrencyManager cm = (CurrencyManager)orderDataGridView.BindingContext[orders];
             cm.Refresh();
         }
         else  // update cancelled or failed
         {
             orders = OrderDB.GetAllOrders();
             orderDataGridView.DataSource = orders;
         }
     }
 }
Example #4
0
 /*Denne metode returner en liste af orders*/
 public IEnumerable <Order> getAllOrders()
 {
     return(oDb.GetAllOrders());
 }