コード例 #1
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();
        }
コード例 #2
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;
            }
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: ShippingForm.cs プロジェクト: lukadut/bazy
        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();
        }
コード例 #5
0
ファイル: FreightsForm.cs プロジェクト: lukadut/bazy
        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();
        }