private void Button_Click(object sender, RoutedEventArgs ex)
        {
            vehicle_assign vehicle_assign = (vehicle_assign)VehicleAssignComboBox.SelectedItem;
            employee       employee       = (employee)EmployeeComboBox.SelectedItem;
            customer       customer       = (customer)CustomerComboBox.SelectedItem;
            float          income         = float.Parse(IncomeTextBox.Text);

            if ((employee.license_number == null || employee.employee_type.license_type == "D1") && vehicle_assign.vehicle.sits > 20)
            {
                if (employee.license_number == null)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Please choose a driver!");
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Please choose a D driver!");
                }

                return;
            }

            transportation o = new transportation();

            o.vehicle_assign_id = vehicle_assign.Id;
            o.employee_id       = employee.Id;
            o.customer_id       = customer.Id;
            o.income            = income;

            db.transportation.Add(o);

            db.SaveChanges();

            this.Close();
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            transportation transportation = (transportation)TransportationComboBox.SelectedItem;
            passenger      passenger      = (passenger)PassengerComboBox.SelectedItem;

            t.transportation_id = transportation.Id;
            t.passenger_id      = passenger.Id;

            db.transportation_passangers.AddOrUpdate(t);

            db.SaveChanges();

            this.Close();
        }
Ejemplo n.º 3
0
        private void EditTransportation_Click(object sender, RoutedEventArgs e)
        {
            transportation s = (transportation)TransportationDataGrid.SelectedItem;

            if (s == null)
            {
                return;
            }
            EditTransportation window = new EditTransportation(s);

            Hide();
            window.ShowDialog();
            Show();
            UpdateTransportationDataGrid();
        }
        public EditTransportation(transportation o)
        {
            InitializeComponent();

            VehicleAssignComboBox.ItemsSource       = db.vehicle_assign.ToList();
            VehicleAssignComboBox.DisplayMemberPath = "vehicle.car_number";
            EmployeeComboBox.ItemsSource            = db.employee.ToList();
            EmployeeComboBox.DisplayMemberPath      = "name";
            CustomerComboBox.ItemsSource            = db.customer.ToList();
            CustomerComboBox.DisplayMemberPath      = "last_name";

            t = o;

            VehicleAssignComboBox.SelectedValue = db.vehicle_assign.ToList().First(d => d.Id == t.vehicle_assign_id);
            EmployeeComboBox.SelectedValue      = db.employee.ToList().First(d => d.Id == t.employee_id);
            CustomerComboBox.SelectedValue      = db.customer.ToList().First(d => d.Id == t.customer_id);
            IncomeTextBox.Text = t.income.ToString();
        }