예제 #1
0
        private void viewOrderDetail_SelectionChanged(object sender, EventArgs e)
        {
            int           idDetail      = Convert.ToInt32(this.viewOrderDetail.CurrentRow.Cells[0].Value);
            OrderDetail   orderDetail   = db.OrderDetails.First(f => f.IdDetail == idDetail);
            OrderCustomer orderCustomer = db.OrderCustomers.First(f => f.IdOrderCustomer == orderDetail.IdOrderCustomer);

            dateTimeStart.Value = orderCustomer.OrderDate;
        }
예제 #2
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");
        }