public OrderDetailsForm(Customer selectedCustomer, CustomerContext context, Order editOrder = null)
 {
     _context = context;
     InitializeComponent();
     this.comboBoxClient.DataSource = _context.Customer.Local.ToBindingList();
     if (editOrder != null) // edit order
     {
         _order = editOrder;
         _updateMode = true;
         SetInitialData(editOrder);
     }
     else // add new order
     {
         _order = new Order();
         _updateMode = false;
         if (selectedCustomer != null)
             this.comboBoxClient.SelectedValue = selectedCustomer.CustomerId;
     }
     this.Shown += OrderDetailsForm_Shown;
 }
 private void SetInitialData(Order editOrder)
 {
     this.comboBoxClient.SelectedValue = editOrder.CustomerId;
     this.textBoxNumber.Text = editOrder.Number;
     this.textBoxAmount.Text = editOrder.Amount.ToString();
     this.textBoxDescription.Text = editOrder.Description;
     if (editOrder.DueTime != null)
     {
         this.dateTimePickerDueTime.Value = (DateTime)editOrder.DueTime;
         this.dateTimePickerDueTime.Checked = true;
     }
     else
     {
         this.dateTimePickerDueTime.Checked = false;
     }
     if (editOrder.ProcessedTime != null)
     {
         this.dateTimePickerProcessedTime.Value = (DateTime)editOrder.ProcessedTime;
         this.dateTimePickerProcessedTime.Checked = true;
     }
     else
     {
         this.dateTimePickerProcessedTime.Checked = false;
     }
 }