Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (driver.SelectedIndex < 0 || car.SelectedIndex < 0 || freight.SelectedIndex < 0)
            {
                MessageBox.Show("Musi być określony kierowca, pojazd i zlecenie");
                return;
            }
            shipping Shipping = new shipping
            {
                CarId     = ((Transport)car.SelectedItem).Id,
                DriverId  = ((Transport)driver.SelectedItem).Id,
                FreightId = ((Transport)freight.SelectedItem).Id,
                //DepartTime = DateTime.Now,
                Delivered = "Not yet",
                // ArriveTime = null,
                Comment = comment.Text
            };
            freights Freight = Functions.FindFreights(Shipping.FreightId);
            cars     Car     = Functions.FindCar(Shipping.CarId);
            drivers  Driver  = Functions.FindDriver(Shipping.DriverId);
            cargo    Cargo   = Functions.FindCargo(Freight.CargoId);

            if (Freight.Weight > Car.Carry)
            {
                MessageBox.Show("Ten pojazd ma za małą ładowność");
                return;
            }
            if (Boolean.Parse(Cargo.ADR) && !Boolean.Parse(Driver.ADR_License))
            {
                MessageBox.Show("Kierowca nie może wieźć ładunku niebezpiecznego");
                return;
            }
            //Freight.Weight

            projektEntities context = new projektEntities();

            context.shipping.Add(Shipping);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Shipping.Id.ToString();
            updateResources();
        }
Exemplo n.º 2
0
        private void ShowDriver(int Id)
        {
            drivers Driver = Functions.FindDriver(Id);

            name.Text        = Driver.Name;
            surname.Text     = Driver.Surname;
            comment.Text     = Driver.Comment;
            wage.Value       = Driver.Wage;
            employed.Checked = Boolean.Parse(Driver.Employed);
            adr.Checked      = Boolean.Parse(Driver.ADR_License);
            if (Boolean.Parse(Driver.Busy))
            {
                this.employed.Hide();
            }
            else
            {
                this.employed.Show();
            }
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            drivers Driver = new drivers
            {
                Name        = name.Text,
                Surname     = surname.Text,
                Wage        = (int)wage.Value,
                ADR_License = adr.Checked.ToString(),
                Employed    = true.ToString(),
                Busy        = false.ToString(),
                Comment     = comment.Text
            };
            projektEntities context = new projektEntities();

            context.drivers.Add(Driver);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Driver.Id.ToString();
        }
Exemplo n.º 4
0
        private void ShowShipping(int Id)
        {
            shipping Shipping = Functions.FindShipping(Id);

            projektEntities ctx    = new projektEntities();
            var             result = (from fr in ctx.freights
                                      join ca in ctx.cargo on fr.CargoId equals ca.Id
                                      join st in ctx.companies on fr.From equals st.Id
                                      join stci in ctx.cities_list on st.CityId equals stci.Id
                                      join stco in ctx.company_name_list on st.CompanyId equals stco.Id
                                      join de in ctx.companies on fr.To equals de.Id
                                      join deci in ctx.cities_list on de.CityId equals deci.Id
                                      join deco in ctx.company_name_list on de.CompanyId equals deco.Id
                                      where fr.Id == Shipping.FreightId
                                      select new
            {
                Freight = fr,
                Cargo = ca,
                Start = st,
                StartCity = stci,
                StartCompany = stco,
                Destination = de,
                DestinationCity = deci,
                DestinationCompany = deco
            }).First();
            drivers Driver = Functions.FindDriver(Shipping.DriverId);
            cars    Car    = Functions.FindCar(Shipping.CarId);

            driver.Text = Driver.Surname + " " + Driver.Name;
            if (Boolean.Parse(Driver.Busy) || !Boolean.Parse(Driver.Employed))
            {
                driver.SelectedIndex = -1;
                driver.DropDownStyle = ComboBoxStyle.DropDown;
                driver.Enabled       = false;
                driver.Text          = Driver.Surname + " " + Driver.Name;
            }
            else
            {
                driver.DropDownStyle = ComboBoxStyle.DropDownList;
                driver.Enabled       = true;
            }

            car.Text = Car.Make + " " + Car.Model + ", " + Car.Number_plate;
            if (Boolean.Parse(Car.IsUsed) || Boolean.Parse(Car.Sold))
            {
                car.SelectedIndex = -1;
                car.DropDownStyle = ComboBoxStyle.DropDown;
                car.Enabled       = false;
                car.Text          = Car.Make + " " + Car.Model + ", " + Car.Number_plate;
            }
            else
            {
                car.DropDownStyle = ComboBoxStyle.DropDownList;
                car.Enabled       = true;
            }


            freight.Text = result.Cargo.Name + ": " + result.StartCompany.Company + ", " + result.StartCity.City + '\u279C' + result.DestinationCompany.Company + ", " + result.DestinationCity.City;
            if (result.Freight.Amount < 1)
            {
                freight.SelectedIndex = -1;
                freight.DropDownStyle = ComboBoxStyle.DropDown;
                freight.Enabled       = false;
                freight.Text          = result.Cargo.Name + ": " + result.StartCompany.Company + ", " + result.StartCity.City + '\u279C' + result.DestinationCompany.Company + ", " + result.DestinationCity.City;
            }
            else
            {
                freight.DropDownStyle = ComboBoxStyle.DropDownList;
                freight.Enabled       = true;
            }
            context.Dispose();
            comment.Text = Shipping.Comment;
            context.SaveChanges();
        }
Exemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            drivers Driver = new drivers
            {
                Name = name.Text,
                Surname = surname.Text,
                Wage = (int)wage.Value,
                ADR_License = adr.Checked.ToString(),
                Employed = true.ToString(),
                Busy = false.ToString(),
                Comment = comment.Text
            };
            projektEntities context = new projektEntities();
            context.drivers.Add(Driver);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Driver.Id.ToString();
        }