Exemplo n.º 1
0
        private void acceptBtn_Click(object sender, EventArgs e)
        {
            OrderCustomer newOrderCustomer = new OrderCustomer();

            //IdCustomer
            foreach (Customer cust in db.Customers)
            {
                if (cust.CustomerName == customerName)
                {
                    newOrderCustomer.IdCustomer = cust.IdCustomer;
                }
            }
            //IdEmployee
            if (employeeCb.SelectedIndex == -1)
            {
                MessageBox.Show("Nie wybrano pracownika");
                employeeCb.BackColor = Color.Red;
                return;
            }
            else
            {
                foreach (Employee emp in db.Employees)
                {
                    if ((emp.EmployeeName + " " + emp.EmployeeSurname).ToString() == employeeCb.Text.ToString())
                    {
                        newOrderCustomer.IdEmployee = emp.IdEmployee;
                    }
                }
            }
            //OrderDate
            if (orderDtp.Value.ToShortDateString() == DateTime.Today.ToShortDateString())
            {
                MessageBox.Show("Wybrano dzisiejszą datę");
                orderDtp.CalendarTitleForeColor = Color.Red;
                return;
            }
            else
            {
                newOrderCustomer.OrderDate = orderDtp.Value;
            }
            if (isMarkupCorrect)
            {
                newOrderCustomer.Markup = double.Parse(markupTb.Text.Trim());
                newOrderCustomer.Cost   = 0;
                db.OrderCustomers.Add(newOrderCustomer);
                db.SaveChanges();
                this.Hide();
                MessageBox.Show("Dodaj szczegół zamówienia");
                AddNewOrderDetailForm newOrderDetail = new AddNewOrderDetailForm(db, newOrderCustomer.IdOrderCustomer, salesForm);
                newOrderDetail.ShowDialog();
                this.Close();
                return;
            }
            MessageBox.Show("Coś poszło nie tak");
        }
Exemplo n.º 2
0
 private void addNewOrderDetailBtn_Click(object sender, EventArgs e)
 {
     //EXCEPTION PROTECTION
     if (ordersDgv.SelectedCells.Count == 0)
     {
         MessageBox.Show("Wybierz zamówienie");
     }
     else
     {
         this.Hide();
         AddNewOrderDetailForm newOrderDetail = new AddNewOrderDetailForm(db, this.ordersDgv.CurrentRow.Cells[0].Value, previousForm);
         newOrderDetail.ShowDialog();
     }
 }