Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (Functions.AllowedPlate(plate.Text))
            {
                cars Car = new cars
                {
                    Make         = make.Text,
                    Model        = model.Text,
                    Comment      = comment.Text,
                    Number_plate = plate.Text,
                    Carry        = (int)carry.Value,
                    IsUsed       = false.ToString(),
                    Sold         = false.ToString()
                };
                projektEntities context = new projektEntities();
                context.cars.Add(Car);
                context.SaveChanges();

                LoadData();
                dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
                id.Text = Car.Id.ToString();
            }
            else
            {
                MessageBox.Show("Istnieje już auto o takiej rejestracji");
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        private void ShowCar(int Id)
        {
            cars Car = Functions.FindCar(Id);

            make.Text    = Car.Make;
            model.Text   = Car.Model;
            comment.Text = Car.Comment;
            plate.Text   = Car.Number_plate;
            carry.Value  = Car.Carry;
            sold.Checked = Boolean.Parse(Car.Sold);
            if (Boolean.Parse(Car.IsUsed))
            {
                this.sold.Hide();
            }
            else
            {
                this.sold.Show();
            }
        }
Esempio 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();
        }
Esempio n. 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (Functions.AllowedPlate(plate.Text))
            {
                cars Car = new cars
                {
                    Make = make.Text,
                    Model = model.Text,
                    Comment = comment.Text,
                    Number_plate = plate.Text,
                    Carry = (int)carry.Value,
                    IsUsed=false.ToString(),
                    Sold = false.ToString()
                };
                projektEntities context = new projektEntities();
                context.cars.Add(Car);
                context.SaveChanges();

                LoadData();
                dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount-2];
                id.Text = Car.Id.ToString();
            }
            else
            {
                MessageBox.Show("Istnieje już auto o takiej rejestracji");
            }
        }