Example #1
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");
                }
            }
        }
Example #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();
        }
Example #3
0
        private void ShowCargo(int Id)
        {
            cargo Cargo = Functions.FindCargo(Id);

            name.Text    = Cargo.Name;
            type.Text    = Cargo.Type;
            comment.Text = Cargo.Comment;
            if (Functions.FindStringIndex(Types, Cargo.Type) < 0)
            {
                type.Text = Cargo.Type;
            }
            else
            {
                type.Text = TypesPL[Functions.FindStringIndex(Types, Cargo.Type)];
            }
            adr.Checked = Boolean.Parse(Cargo.ADR);
            Boolean[] adrClass = Functions.ExpADR(Cargo.ADR_Class);
            foreach (var item in CheckBoxList)
            {
                item.Checked = adrClass[(int)item.Tag];
            }
        }