Exemplo n.º 1
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();
        }
Exemplo n.º 2
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];
            }
        }
Exemplo n.º 3
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");
            //////}
        }
Exemplo n.º 4
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");
            //////}
        }