Ejemplo n.º 1
0
        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (dataGridView.CurrentRow.Index >= dataGridView.RowCount - 1)
            {
                return;
            }
            id.Text = dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString();
            int Id = int.Parse(id.Text);

            ShowFreight(Id);
            freights Freight = Functions.FindFreights(Id);

            if (dataGridView1.CurrentCell.ColumnIndex == 1)
            {
                CargoForm CF = new CargoForm(Freight.CargoId);
                CF.Show();
                return;
            }
            if (dataGridView1.CurrentCell.ColumnIndex == 2)
            {
                CompaniesForm CF = new CompaniesForm(Freight.From);
                CF.Show();
                return;
            }
            if (dataGridView1.CurrentCell.ColumnIndex == 3)
            {
                CompaniesForm CF = new CompaniesForm(Freight.To);
                CF.Show();
                return;
            }
        }
Ejemplo n.º 2
0
        private void ShowFreight(int Id)
        {
            freights Freight = Functions.FindFreights(Id);

            start.SelectedIndex       = Functions.findIndexItemWithIdInCollection(Freight.From, start.Items);
            destination.SelectedIndex = Functions.findIndexItemWithIdInCollection(Freight.To, destination.Items);
            cargo.SelectedIndex       = Functions.findIndexItemWithIdInCollection(Freight.CargoId, cargo.Items);
            comment.Text = Freight.Comment;
            amount.Value = Freight.Amount;
            weight.Value = Freight.Weight;
            date.Value   = Freight.ScheduledArrive;
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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");
                }
            }
        }