Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var query = (from driver in context.drivers
                         where driver.Id == Id
                         select new
                         {
                             Driver = driver
                         }).First();
            if (query.Driver == null)
            {
                MessageBox.Show("Nie znaleziono kierowcy o takim Id");
                return;
            }

            query.Driver.Name = name.Text;
            query.Driver.Surname = surname.Text;
            query.Driver.Comment = comment.Text;
            query.Driver.Wage = (int)wage.Value;
            query.Driver.Employed = employed.Checked.ToString();
            query.Driver.ADR_License = adr.Checked.ToString();

            context.Entry(query.Driver).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();

            var query = (from f in context.shipping
                         where f.Id == Id
                         select new
            {
                Shipping = f
            }).First();

            if (query.Shipping.ArriveTime.HasValue)
            {
                MessageBox.Show("To zlecenie zostało już ukończone");
                return;
            }
            query.Shipping.Comment    = comment.Text;
            query.Shipping.ArriveTime = DateTime.Now;

            context.Entry(query.Shipping).State = EntityState.Modified;
            context.SaveChanges();
            updateResources();
            ClearForm();
            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #3
0
        public CargoForm( int? id = null)
        {
            CheckBoxList = new List<CheckBox>();
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            DrawADRCheckBoxes();

            LoadData();

            //Console.WriteLine("laweta ma numer " + Functions.FindStringIndex(TypesPL,"a"));
            type.Items.Clear();
            type.Items.AddRange(TypesPL);
            type.Text = "Kontener";
            if (id.HasValue && id.Value >= 0)
            {
                try
                {
                    Functions.FindCargo((int)id);
                    this.id.Text = id + "";
                    ShowCargo(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }

            }
        }
Exemple #4
0
 public static void getFreights()
 {
     projektEntities ctx = new projektEntities();
     var query = 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
                 select new
                 {
                     Freight = fr,
                     Cargo = ca,
                     Start = st,
                     StartCity = stci,
                     StartCompany = stco,
                     Destination = de,
                     DestinationCity = deci,
                     DestinationCompany = deco
                 };
     FreightsForm.clearDataGridView();
     foreach (var result in query)
     {
         FreightsForm.fillDataGridView(result.Freight.Id, result.Cargo.Name,
             result.StartCompany.Company + ", " + result.StartCity.City,
             result.DestinationCompany.Company + ", " + result.DestinationCity.City,
             result.Freight.ScheduledArrive, result.Freight.Amount, result.Freight.Weight, result.Freight.Comment);
     }
 }
Exemple #5
0
        public static void getFreights()
        {
            projektEntities ctx   = new projektEntities();
            var             query = 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
                                    select new
            {
                Freight            = fr,
                Cargo              = ca,
                Start              = st,
                StartCity          = stci,
                StartCompany       = stco,
                Destination        = de,
                DestinationCity    = deci,
                DestinationCompany = deco
            };

            FreightsForm.clearDataGridView();
            foreach (var result in query)
            {
                FreightsForm.fillDataGridView(result.Freight.Id, result.Cargo.Name,
                                              result.StartCompany.Company + ", " + result.StartCity.City,
                                              result.DestinationCompany.Company + ", " + result.DestinationCity.City,
                                              result.Freight.ScheduledArrive, result.Freight.Amount, result.Freight.Weight, result.Freight.Comment);
            }
        }
Exemple #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0)
            {
                MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste");
                return;
            }
            freights Freight = new freights
            {
                Amount          = (byte)amount.Value,
                CargoId         = ((Transport)cargo.SelectedItem).Id,
                Comment         = comment.Text,
                From            = ((Transport)start.SelectedItem).Id,
                ScheduledArrive = date.Value,
                To     = ((Transport)destination.SelectedItem).Id,
                Weight = (int)weight.Value
            };

            projektEntities context = new projektEntities();

            context.freights.Add(Freight);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Freight.Id.ToString();
        }
Exemple #7
0
        public CargoForm(int?id = null)
        {
            CheckBoxList = new List <CheckBox>();
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            DrawADRCheckBoxes();

            LoadData();

            //Console.WriteLine("laweta ma numer " + Functions.FindStringIndex(TypesPL,"a"));
            type.Items.Clear();
            type.Items.AddRange(TypesPL);
            type.Text = "Kontener";
            if (id.HasValue && id.Value >= 0)
            {
                try
                {
                    Functions.FindCargo((int)id);
                    this.id.Text = id + "";
                    ShowCargo(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }
            }
        }
Exemple #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();

            var query = (from f in context.shipping
                         where f.Id == Id
                         select new
            {
                Shipping = f
            }).First();

            query.Shipping.Comment = comment.Text;

            context.Entry(query.Shipping).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #9
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");
            }
        }
Exemple #10
0
        public ShippingForm()
        {
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();

            updateResources();
        }
Exemple #11
0
        public ShippingForm()
        {
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();

            updateResources();
        }
Exemple #12
0
 public static cars FindCar(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from car in context.cars
                 where car.Id == IdInBase
                 select new
                 {
                     Car = car
                 }).First();
     return query.Car;
 }
Exemple #13
0
        public CompaniesForm(int?id = null)
        {
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();
            if (id.HasValue && id.Value >= 0)
            {
                try
                {
                    Functions.FindCompanies((int)id);
                    this.id.Text = id + "";
                    ShowCompanies(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }
            }

            cities.Items.Clear();
            var query1 = (from city in context.cities_list
                          select new
            {
                city.City, city.Id
            });

            foreach (var item in query1)
            {
                cities.Items.Add(new Transport()
                {
                    Name = item.City,
                    Id   = item.Id
                });
            }

            companies.Items.Clear();
            var query2 = from company in context.company_name_list
                         select new
            {
                company
            };

            foreach (var item in query2)
            {
                companies.Items.Add(new Transport()
                {
                    Name = item.company.Company,
                    Id   = item.company.Id
                });
            }
        }
Exemple #14
0
        public static shipping FindShipping(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from c in context.shipping
                                       where c.Id == IdInBase
                                       select new
            {
                Shipping = c
            }).First();

            return(query.Shipping);
        }
Exemple #15
0
        public static freights FindFreights(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from c in context.freights
                                       where c.Id == IdInBase
                                       select new
            {
                Freight = c
            }).First();

            return(query.Freight);
        }
Exemple #16
0
        public static cargo FindCargo(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from c in context.cargo
                                       where c.Id == IdInBase
                                       select new
            {
                Cargo = c
            }).First();

            return(query.Cargo);
        }
Exemple #17
0
        public static cars FindCar(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from car in context.cars
                                       where car.Id == IdInBase
                                       select new
            {
                Car = car
            }).First();

            return(query.Car);
        }
Exemple #18
0
        public static drivers FindDriver(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from driver in context.drivers
                                       where driver.Id == IdInBase
                                       select new
            {
                Driver = driver
            }).First();

            return(query.Driver);
        }
Exemple #19
0
        public CompaniesForm( int? id = null)
        {
            InitializeComponent();
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();
            if (id.HasValue && id.Value >= 0)
            {
                try
                {
                    Functions.FindCompanies((int)id);
                    this.id.Text = id + "";
                    ShowCompanies(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }

            }

            cities.Items.Clear();
            var query1 = (from city in context.cities_list
                        select new
                        {
                            city.City, city.Id
                        });
            foreach (var item in query1)
            {
                cities.Items.Add(new Transport()
                {
                    Name = item.City,
                    Id = item.Id
                });
            }

            companies.Items.Clear();
            var query2 = from company in context.company_name_list
                        select new
                        {
                            company
                        };
            foreach (var item in query2)
            {
                companies.Items.Add(new Transport()
                {
                    Name = item.company.Company,
                    Id = item.company.Id
                });
            }
        }
Exemple #20
0
        public static companies FindCompanies(int IdInBase)
        {
            projektEntities context = new projektEntities();
            var             query   = (from c in context.companies
                                       join ci in context.cities_list on c.CityId equals ci.Id
                                       join co in context.company_name_list on c.CompanyId equals co.Id
                                       where c.Id == IdInBase
                                       select new
            {
                Companies = c
            }).First();

            return(query.Companies);
        }
Exemple #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var             query   = (from c in context.cargo
                                       where c.Id == Id
                                       select new
            {
                Cargo = c
            }).First();

            if (query.Cargo == null)
            {
                MessageBox.Show("Nie znaleziono auta o takim Id");
                return;
            }

            query.Cargo.Name    = name.Text;
            query.Cargo.ADR     = adr.Checked.ToString();
            query.Cargo.Type    = Types[Functions.FindStringIndex(TypesPL, type.Text)];
            query.Cargo.Comment = comment.Text;

            string adrClass = "";

            foreach (var item in CheckBoxList)
            {
                if (item.Checked)
                {
                    adrClass += Functions.classes[(int)item.Tag];
                }
                adrClass += ",";
                //Cargo.AdrClass[(int)item.Tag] = item.Checked;
            }
            adrClass = adrClass.Remove(adrClass.LastIndexOf(','));
            query.Cargo.ADR_Class            = adrClass;
            context.Entry(query.Cargo).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #22
0
        public static void getDrivers()
        {
            projektEntities ctx = new projektEntities();
            var query = from driver in ctx.drivers
                        select new
                        {
                            Driver = driver
                        };
            DriversForm.clearDataGridView();

            foreach (var result in query)
            {
                DriversForm.fillDataGridView(result.Driver.Id, result.Driver.Name,result.Driver.Surname,result.Driver.Wage,result.Driver.ADR_License,result.Driver.Employed,result.Driver.Busy,result.Driver.Comment);
            }
        }
Exemple #23
0
 public CarsForm(int? id = null )
 {
     //DataBase = dataBase;
     InitializeComponent();
     context = new projektEntities();
     make.Leave += Functions.textBox_Leave;
     model.Leave += Functions.textBox_Leave;
     LoadData();
     //if (id >= 0 && Functions.FindCar((int)id, DataBase.CarsList) >= 0)
     //{
     //    this.id.Text = id + "";
     //    ShowCar(Functions.FindCar((int)id,DataBase.CarsList));
     //}
         //MessageBox.Show("ustalony?");
 }
Exemple #24
0
        public static void getCars()
        {
            projektEntities ctx = new projektEntities();
            var query = from car in ctx.cars
                        select new
                        {
                            Car = car
                        };
            CarsForm.clearDataGridView();

            foreach (var result in query)
            {
                CarsForm.fillDataGridView(result.Car.Id, result.Car.Number_plate, result.Car.Make, result.Car.Model, result.Car.Carry, result.Car.IsUsed, result.Car.Sold, result.Car.Comment);
            }
        }
Exemple #25
0
 public CarsForm(int?id = null)
 {
     //DataBase = dataBase;
     InitializeComponent();
     context      = new projektEntities();
     make.Leave  += Functions.textBox_Leave;
     model.Leave += Functions.textBox_Leave;
     LoadData();
     //if (id >= 0 && Functions.FindCar((int)id, DataBase.CarsList) >= 0)
     //{
     //    this.id.Text = id + "";
     //    ShowCar(Functions.FindCar((int)id,DataBase.CarsList));
     //}
     //MessageBox.Show("ustalony?");
 }
Exemple #26
0
        public static void getCargo()
        {
            projektEntities ctx = new projektEntities();
            var query = from c in ctx.cargo
                        select new
                        {
                            Cargo = c
                        };
            CargoForm.clearDataGridView();

            foreach (var result in query)
            {
                CargoForm.fillDataGridView(result.Cargo.Id,result.Cargo.Name,result.Cargo.Type,result.Cargo.ADR,result.Cargo.ADR_Class,result.Cargo.Comment);
            }
        }
Exemple #27
0
        public static void getCars()
        {
            projektEntities ctx   = new projektEntities();
            var             query = from car in ctx.cars
                                    select new
            {
                Car = car
            };

            CarsForm.clearDataGridView();

            foreach (var result in query)
            {
                CarsForm.fillDataGridView(result.Car.Id, result.Car.Number_plate, result.Car.Make, result.Car.Model, result.Car.Carry, result.Car.IsUsed, result.Car.Sold, result.Car.Comment);
            }
        }
Exemple #28
0
        public static void getDrivers()
        {
            projektEntities ctx   = new projektEntities();
            var             query = from driver in ctx.drivers
                                    select new
            {
                Driver = driver
            };

            DriversForm.clearDataGridView();

            foreach (var result in query)
            {
                DriversForm.fillDataGridView(result.Driver.Id, result.Driver.Name, result.Driver.Surname, result.Driver.Wage, result.Driver.ADR_License, result.Driver.Employed, result.Driver.Busy, result.Driver.Comment);
            }
        }
Exemple #29
0
        public static void getCargo()
        {
            projektEntities ctx   = new projektEntities();
            var             query = from c in ctx.cargo
                                    select new
            {
                Cargo = c
            };

            CargoForm.clearDataGridView();

            foreach (var result in query)
            {
                CargoForm.fillDataGridView(result.Cargo.Id, result.Cargo.Name, result.Cargo.Type, result.Cargo.ADR, result.Cargo.ADR_Class, result.Cargo.Comment);
            }
        }
Exemple #30
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();
        }
Exemple #31
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                getOrAddCity(cities.SelectedIndex);
                getOrAddCompany(companies.SelectedIndex);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            companies Company = new companies
            {
                Address   = address.Text,
                Comment   = comment.Text,
                CityId    = ((Transport)cities.SelectedItem).Id,
                CompanyId = ((Transport)companies.SelectedItem).Id
            };
            projektEntities context = new projektEntities();

            try
            {
                context.companies.Add(Company);
                context.SaveChanges();

                LoadData();
                int currentRow = dataGridView.RowCount - 2;
                for (int i = 0; i < dataGridView.RowCount; i++)
                {
                    System.Console.WriteLine(dataGridView[0, i].Value.ToString());
                    if (int.Parse(dataGridView[0, i].Value.ToString()) == Company.Id)
                    {
                        currentRow = i;
                        break;
                    }
                }
                dataGridView.CurrentCell = dataGridView[0, currentRow];
                id.Text = Company.Id.ToString();
            } catch (Exception) {
                MessageBox.Show("Taka firma już istnieje");
            }
        }
Exemple #32
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var             query   = (from car in context.cars
                                       where car.Id == Id
                                       select new
            {
                Car = car
            }).First();

            if (query.Car == null)
            {
                MessageBox.Show("Nie znaleziono auta o takim Id");
                return;
            }
            if (!Functions.AllowedPlate(plate.Text) && plate.Text != query.Car.Number_plate)
            {
                MessageBox.Show("Taki numer rejestracji już występuje");
                return;
            }

            query.Car.Make         = make.Text;
            query.Car.Model        = model.Text;
            query.Car.Comment      = comment.Text;
            query.Car.Number_plate = plate.Text;
            query.Car.Carry        = (int)carry.Value;
            query.Car.Sold         = sold.Checked.ToString();

            context.Entry(query.Car).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #33
0
        public static void getCompanies()
        {
            projektEntities ctx = new projektEntities();
            var query = from c in ctx.companies
                        join ci in ctx.cities_list on c.CityId equals ci.Id
                        join co in ctx.company_name_list on c.CompanyId equals co.Id
                        select new
                        {
                            Company = c,
                            CompanyName = co,
                            CityName = ci
                        };
            CompaniesForm.clearDataGridView();

            foreach (var result in query)
            {
                CompaniesForm.fillDataGridView(result.Company.Id, result.CompanyName.Company, result.CityName.City, result.Company.Address, result.Company.Comment);
            }
        }
Exemple #34
0
        public static bool AllowedPlate(string newPlate)
        {
            projektEntities context = new projektEntities();

            //newPlate.Skip(5);
            newPlate = newPlate.ToLower();
            newPlate = System.Text.RegularExpressions.Regex.Replace(newPlate, @"\s", "");
            var query = from car in context.cars
                        select new
                        {
                            Plate = car.Number_plate
                        };
            foreach (var result in query)
            {
                if (String.Equals(newPlate, System.Text.RegularExpressions.Regex.Replace(result.Plate, @"\s", "").ToLower()))
                    return false;
            }
            return true;
        }
Exemple #35
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();

            var query = (from company in context.companies
                         where company.Id == Id
                         select new
            {
                company
            }).First();

            try
            {
                getOrAddCity(cities.SelectedIndex);
                getOrAddCompany(companies.SelectedIndex);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            query.company.Address   = address.Text;
            query.company.Comment   = comment.Text;
            query.company.CityId    = ((Transport)cities.SelectedItem).Id;
            query.company.CompanyId = ((Transport)companies.SelectedItem).Id;

            context.Entry(query.company).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #36
0
        public static void getCompanies()
        {
            projektEntities ctx   = new projektEntities();
            var             query = from c in ctx.companies
                                    join ci in ctx.cities_list on c.CityId equals ci.Id
                                    join co in ctx.company_name_list on c.CompanyId equals co.Id
                                    select new
            {
                Company     = c,
                CompanyName = co,
                CityName    = ci
            };

            CompaniesForm.clearDataGridView();

            foreach (var result in query)
            {
                CompaniesForm.fillDataGridView(result.Company.Id, result.CompanyName.Company, result.CityName.City, result.Company.Address, result.Company.Comment);
            }
        }
Exemple #37
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();
        }
Exemple #38
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var             query   = (from driver in context.drivers
                                       where driver.Id == Id
                                       select new
            {
                Driver = driver
            }).First();

            if (query.Driver == null)
            {
                MessageBox.Show("Nie znaleziono kierowcy o takim Id");
                return;
            }


            query.Driver.Name        = name.Text;
            query.Driver.Surname     = surname.Text;
            query.Driver.Comment     = comment.Text;
            query.Driver.Wage        = (int)wage.Value;
            query.Driver.Employed    = employed.Checked.ToString();
            query.Driver.ADR_License = adr.Checked.ToString();

            context.Entry(query.Driver).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #39
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var query = (from car in context.cars
                         where car.Id == Id
                         select new
                         {
                             Car = car
                         }).First();
            if (query.Car == null)
            {
                MessageBox.Show("Nie znaleziono auta o takim Id");
                return;
            }
            if (!Functions.AllowedPlate(plate.Text) && plate.Text != query.Car.Number_plate)
            {
                MessageBox.Show("Taki numer rejestracji już występuje");
                return;
            }

            query.Car.Make = make.Text;
            query.Car.Model = model.Text;
            query.Car.Comment = comment.Text;
            query.Car.Number_plate = plate.Text;
            query.Car.Carry = (int)carry.Value;
            query.Car.Sold = sold.Checked.ToString();

            context.Entry(query.Car).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #40
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;

            if (id.Text == "")
            {
                return;
            }
            int Id = int.Parse(id.Text);

            if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0)
            {
                MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste");
                return;
            }
            projektEntities context = new projektEntities();

            var query = (from f in context.freights
                         where f.Id == Id
                         select new
            {
                Freight = f
            }).First();

            query.Freight.Amount          = (byte)amount.Value;
            query.Freight.CargoId         = ((Transport)cargo.SelectedItem).Id;
            query.Freight.Comment         = comment.Text;
            query.Freight.From            = ((Transport)start.SelectedItem).Id;
            query.Freight.ScheduledArrive = date.Value;
            query.Freight.To     = ((Transport)destination.SelectedItem).Id;
            query.Freight.Weight = (int)weight.Value;

            context.Entry(query.Freight).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #41
0
 public CarsForm(int?id = null)
 {
     InitializeComponent();
     context      = new projektEntities();
     make.Leave  += Functions.textBox_Leave;
     model.Leave += Functions.textBox_Leave;
     Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
     dataGridView = dataGridView1;
     LoadData();
     if (id.HasValue && id.Value >= 0)
     {
         try
         {
             Functions.FindCar((int)id);
             this.id.Text = id + "";
             ShowCar(id.Value);
         }
         catch (Exception e)
         {
             MessageBox.Show("Nie znaleziono takiego rekordu");
         }
     }
 }
Exemple #42
0
        private void ShowCompanies(int Id)
        {
            projektEntities ctx   = new projektEntities();
            var             query = (from c in ctx.companies
                                     join ci in ctx.cities_list on c.CityId equals ci.Id
                                     join co in ctx.company_name_list on c.CompanyId equals co.Id
                                     where c.Id == Id
                                     select new
            {
                Company = c,
                CompanyName = co,
                CityName = ci
            }).First();

            comment.Text   = query.Company.Comment;
            address.Text   = query.Company.Address;
            cities.Text    = query.CityName.City;
            companies.Text = query.CompanyName.Company;

            int a = cities.SelectedIndex;

            System.Console.WriteLine(a);
        }
Exemple #43
0
        public static bool AllowedPlate(string newPlate)
        {
            projektEntities context = new projektEntities();


            //newPlate.Skip(5);
            newPlate = newPlate.ToLower();
            newPlate = System.Text.RegularExpressions.Regex.Replace(newPlate, @"\s", "");
            var query = from car in context.cars
                        select new
            {
                Plate = car.Number_plate
            };

            foreach (var result in query)
            {
                if (String.Equals(newPlate, System.Text.RegularExpressions.Regex.Replace(result.Plate, @"\s", "").ToLower()))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #44
0
        public CarsForm(int? id = null)
        {
            InitializeComponent();
            context = new projektEntities();
            make.Leave += Functions.textBox_Leave;
            model.Leave += Functions.textBox_Leave;
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();
            if (id.HasValue && id.Value>=0)
            {
                try
                {
                    Functions.FindCar((int)id);
                    this.id.Text = id + "";
                    ShowCar(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }

            }
        }
Exemple #45
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();

            var query = (from f in context.shipping
                         where f.Id == Id
                         select new
                         {
                             Shipping = f
                         }).First();
            query.Shipping.Comment = comment.Text;

            context.Entry(query.Shipping).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #46
0
        private void updateResources()
        {
            driver.Items.Clear();
            car.Items.Clear();
            freight.Items.Clear();

            projektEntities ctx = new projektEntities();
            var queryDrivers = from d in ctx.drivers
                         where ((d.Employed == "True") && (d.Busy == "False"))

                         select new{
                             Driver = d
                         };
            var queryCars = from c in ctx.cars
                            where ((c.Sold == "False") && (c.IsUsed == "False"))
                            select new
                            {
                                Car = c
                            };

            var queryFreights = 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.Amount > 0
                                select new
                                {
                                    Freight = fr,
                                    Cargo = ca,
                                    Start = st,
                                    StartCity = stci,
                                    StartCompany = stco,
                                    Destination = de,
                                    DestinationCity = deci,
                                    DestinationCompany = deco
                                };
            foreach (var result in queryCars)
            {
                car.Items.Add(new Transport
                {
                    Id = result.Car.Id,
                    Name = result.Car.Make + " " + result.Car.Model + ", " + result.Car.Number_plate
                });
            }
            foreach (var result in queryDrivers)
            {
                driver.Items.Add(new Transport
                {
                    Id = result.Driver.Id,
                    Name = result.Driver.Surname + " " + result.Driver.Name
                });
            }
            foreach (var result in queryFreights)
            {
                freight.Items.Add(new Transport
                {
                    Id = result.Freight.Id,
                    Name = result.Cargo.Name + ": " + result.StartCompany.Company + ", " + result.StartCity.City + '\u279C' + result.DestinationCompany.Company + ", " + result.DestinationCity.City
                });
            }
        }
Exemple #47
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);
            if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0)
            {
                MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste");
                return;
            }
            projektEntities context = new projektEntities();

            var query = (from f in context.freights
                         where f.Id == Id
                         select new
                         {
                             Freight = f
                         }).First();
            query.Freight.Amount = (byte)amount.Value;
            query.Freight.CargoId = ((Transport)cargo.SelectedItem).Id;
            query.Freight.Comment = comment.Text;
            query.Freight.From = ((Transport)start.SelectedItem).Id;
            query.Freight.ScheduledArrive = date.Value;
            query.Freight.To = ((Transport)destination.SelectedItem).Id;
            query.Freight.Weight = (int)weight.Value;

            context.Entry(query.Freight).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #48
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();
        }
Exemple #49
0
        private void button4_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();

            var query = (from f in context.shipping
                         where f.Id == Id
                         select new
                         {
                             Shipping = f
                         }).First();
            if (query.Shipping.ArriveTime.HasValue)
            {
                MessageBox.Show("To zlecenie zostało już ukończone");
                return;
            }
            query.Shipping.Comment = comment.Text;
            query.Shipping.ArriveTime = DateTime.Now;

            context.Entry(query.Shipping).State = EntityState.Modified;
            context.SaveChanges();
            updateResources();
            ClearForm();
            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #50
0
 public static cargo FindCargo(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from c in context.cargo
                  where c.Id == IdInBase
                  select new
                  {
                      Cargo = c
                  }).First();
     return query.Cargo;
 }
Exemple #51
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0)
            {
                MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste");
                return;
            }
            freights Freight = new freights
            {
                Amount = (byte)amount.Value,
                CargoId = ((Transport)cargo.SelectedItem).Id,
                Comment = comment.Text,
                From = ((Transport)start.SelectedItem).Id,
                ScheduledArrive = date.Value,
                To = ((Transport)destination.SelectedItem).Id,
                Weight = (int)weight.Value
            };

            projektEntities context = new projektEntities();
            context.freights.Add(Freight);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Freight.Id.ToString();
        }
Exemple #52
0
        public FreightsForm(int? id = null)
        {
            InitializeComponent();
            date.Value = DateTime.Now;
            context = new projektEntities();
            Functions.addColumnsToDataGridView(dataGridView1, ColumnNames);
            dataGridView = dataGridView1;
            LoadData();

            cargo.Items.Clear();
            var query1 = from c in context.cargo
                         select new
                         {
                             Cargo = c
                         };
            foreach (var result in query1)
            {
                cargo.Items.Add(new Transport
                {
                    Id = result.Cargo.Id,
                    Name = result.Cargo.Name + " - " + //CargoForm.TypesPL[
                    CargoForm.TypesPL[(int)Enum.Parse(typeof(Functions.Types), result.Cargo.Type)]

                });
            }
            destination.Items.Clear();
            start.Items.Clear();
            var query2 = from c in context.companies
                         join ci in context.cities_list on c.CityId equals ci.Id
                         join co in context.company_name_list on c.CompanyId equals co.Id
                         select new
                         {
                             Company = c.Id,
                             Address = c.Address,
                             City = ci.City,
                             Name = co.Company
                         };
            foreach (var result in query2)
            {
                Transport t = new Transport
                {
                    Id = result.Company,
                    Name = result.Name + ", " + result.City + ", " + result.Address
                };
                destination.Items.Add(t);
                start.Items.Add(t);
            }
            if (id.HasValue && id.Value >= 0)
            {
                try
                {
                    Functions.FindFreights((int)id);
                    this.id.Text = id + "";
                    ShowFreight(id.Value);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Nie znaleziono takiego rekordu");
                }

            }
        }
Exemple #53
0
 public static shipping FindShipping(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from c in context.shipping
                  where c.Id == IdInBase
                  select new
                  {
                      Shipping = c
                  }).First();
     return query.Shipping;
 }
Exemple #54
0
 public static freights FindFreights(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from c in context.freights
                  where c.Id == IdInBase
                  select new
                  {
                      Freight = c
                  }).First();
     return query.Freight;
 }
Exemple #55
0
 public static drivers FindDriver(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from driver in context.drivers
                  where driver.Id == IdInBase
                  select new
                  {
                      Driver = driver
                  }).First();
     return query.Driver;
 }
Exemple #56
0
 public static companies FindCompanies(int IdInBase)
 {
     projektEntities context = new projektEntities();
     var query = (from c in context.companies
                  join ci in context.cities_list on c.CityId equals ci.Id
                  join co in context.company_name_list on c.CompanyId equals co.Id
                  where c.Id == IdInBase
                  select new
                  {
                      Companies = c
                  }).First();
     return query.Companies;
 }
Exemple #57
0
        private void button3_Click(object sender, EventArgs e)
        {
            //////FreightsList.Types a = FreightsList.Types.Container;
            //////string b = "Flatbed";
            //////a = (FreightsList.Types)2;
            //////Console.WriteLine("Types a = " + a + (int)a);
            //////Console.WriteLine(b + " == " + a + "  asasd ");
            //////Console.WriteLine((string)a.ToString() == b);
            //////Console.WriteLine("");
            //////MessageBox.Show(dataGridView1.Rows[1].Cells[4].Value.ToString());

            string adrClass = "";
            foreach (var item in CheckBoxList)
            {
                if (item.Checked)
                {
                    adrClass += Functions.classes[(int)item.Tag];
                }
                adrClass += ",";
                //Cargo.AdrClass[(int)item.Tag] = item.Checked;
            }
            adrClass = adrClass.Remove(adrClass.LastIndexOf(','));

            cargo Cargo = new cargo()
            {
                Name = name.Text,
                ADR = adr.Checked.ToString(),
                Type = Types[Functions.FindStringIndex(TypesPL, type.Text)],
                Comment = comment.Text,
                ADR_Class = adrClass
            };

            projektEntities context = new projektEntities();
            context.cargo.Add(Cargo);
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[0, dataGridView.RowCount - 2];
            id.Text = Cargo.Id.ToString();
            ////string adrClass = "";
            ////foreach (var item in CheckBoxList)
            ////{
            ////    if (item.Checked)
            ////    {
            ////        adrClass += Functions.classes[(int)item.Tag] + ",";
            ////    }
            ////}
            ////if (adrClass.Length > 0)
            ////    adrClass.Remove(adrClass.Length - 1, 1);
            ////else
            ////    adr.Checked = false;
            ////DataBase.AddFreightsList(name.Text, Types[Functions.FindStringIndex(TypesPL, type.Text)], adrClass, adr.Checked, comment.Text);
            ////LoadData(DataBase);

            //////if (Functions.AllowedPlate(plate.Text, DataBase.CarsList))
            //////{
            //////    //DataBase.AddCar(plate.Text, make.Text, model.Text, (uint)carry.Value, false, false, comment.Text);
            //////    //DataBase.CarsList.Add(new Cars());
            //////    //LoadData(DataBase);
            //////}
            //////else
            //////{
            //////    MessageBox.Show("Istnieje już auto o takiej rejestracji");
            //////}
        }
Exemple #58
0
        private void button1_Click(object sender, EventArgs e)
        {
            int currentRow = dataGridView1.CurrentRow.Index;
            int currentCol = dataGridView1.CurrentCell.ColumnIndex;
            if (id.Text == "")
                return;
            int Id = int.Parse(id.Text);

            projektEntities context = new projektEntities();
            var query = (from c in context.cargo
                         where c.Id == Id
                         select new
                         {
                             Cargo = c
                         }).First();
            if (query.Cargo == null)
            {
                MessageBox.Show("Nie znaleziono auta o takim Id");
                return;
            }

            query.Cargo.Name = name.Text;
            query.Cargo.ADR = adr.Checked.ToString();
            query.Cargo.Type = Types[Functions.FindStringIndex(TypesPL, type.Text)];
            query.Cargo.Comment = comment.Text;

            string adrClass = "";
            foreach (var item in CheckBoxList)
            {
                if (item.Checked)
                {
                    adrClass += Functions.classes[(int)item.Tag];
                }
                adrClass += ",";
                //Cargo.AdrClass[(int)item.Tag] = item.Checked;
            }
            adrClass = adrClass.Remove(adrClass.LastIndexOf(','));
            query.Cargo.ADR_Class = adrClass;
            context.Entry(query.Cargo).State = EntityState.Modified;
            context.SaveChanges();

            LoadData();
            dataGridView.CurrentCell = dataGridView[currentCol, currentRow];
        }
Exemple #59
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();
        }
Exemple #60
0
 public static void getShipping()
 {
     projektEntities ctx = new projektEntities();
     var query = from ship in ctx.shipping
                 join car in ctx.cars on ship.CarId equals car.Id
                 join dri in ctx.drivers on ship.DriverId equals dri.Id
                 join fr in ctx.freights on ship.FreightId equals fr.Id
                 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
                 select new
                 {
                     Shipping = ship,
                     Car = car,
                     Driver = dri,
                     Freight = fr,
                     Cargo = ca,
                     Start = st,
                     StartCity = stci,
                     StartCompany = stco,
                     Destination = de,
                     DestinationCity = deci,
                     DestinationCompany = deco
                 };
     ShippingForm.clearDataGridView();
     foreach (var result in query)
     {
         ShippingForm.fillDataGridView(result.Shipping.Id, result.Driver.Surname + " " + result.Driver.Name, result.Car.Make + " " + result.Car.Model + ", " + result.Car.Number_plate,
             result.Cargo.Name + ": " + result.StartCompany.Company + ", " + result.StartCity.City + '\u279C' + result.DestinationCompany.Company + ", " + result.DestinationCity.City,
             result.Shipping.DepartTime, result.Shipping.ArriveTime, result.Shipping.Delivered, result.Shipping.Comment);
     }
 }