Exemplo n.º 1
0
 void InitViewBag(Avto model, bool IsPostMethod)
 {
     if (IsPostMethod)
     {
         var modelAvto = repModelAvto.Get(model.ModelAvtoId);
         ViewBag.BrandId     = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name", modelAvto.BrandId);
         ViewBag.ModelAvtoId = new SelectList(GetModelAvto(modelAvto.BrandId), "ModelAvtoId", "ModelName", model.ModelAvtoId);
     }
     else
     {
         if (model.ModelAvtoId == 0)
         {
             ViewBag.BrandId     = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name");
             ViewBag.ModelAvtoId = new SelectList(GetModelAvtoNull, "ModelAvtoId", "ModelName");
         }
         else
         {
             var modelAvto = repModelAvto.Get(model.ModelAvtoId);
             ViewBag.BrandId     = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name", modelAvto.BrandId);
             ViewBag.ModelAvtoId = new SelectList(GetModelAvto(modelAvto.BrandId), "ModelAvtoId", "ModelName", model.ModelAvtoId);
         }
     }
     ViewBag.DriveUnitId = new SelectList(GetDriveUnit.Union(repDriveUnit.GetAll()), "Id", "Name", model.DriveUnitId);
     ViewBag.AutoBodyId  = new SelectList(GetAutoBody.Union(repAutoBody.GetAll()), "Id", "Name", model.AutoBodyId);
     ViewBag.FuelId      = new SelectList(GetFuel.Union(repFuel.GetAll()), "Id", "Name", model.FuelId);
     ViewBag.KPPId       = new SelectList(GetKPP.Union(repKPP.GetAll()), "Id", "Name", model.KPPId);
 }
Exemplo n.º 2
0
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     if (CheckFields())
     {
         if (SelectedId == 0)
         {
             db.Avtos.Add(new Avto
             {
                 Marka     = Marka.Text,
                 Nomer     = Nomer.Text,
                 GruzPod   = Convert.ToDouble(GruzPod.Text),
                 IdVidGruz = db.VidGruzs.Where(e => e.NameVidGruz.Equals(VidGruz.Text)).Single().IdVidGruz,
                 Ispr      = Ispr.IsChecked.Value
             });
             LogInsert();
         }
         else
         {
             Avto avto = db.Avtos.Where(e => e.IdAvto == SelectedId).Single();
             LogUpdate(avto);
             avto.Marka     = Marka.Text;
             avto.Nomer     = Nomer.Text;
             avto.GruzPod   = Convert.ToDouble(GruzPod.Text);
             avto.IdVidGruz = db.VidGruzs.Where(e => e.NameVidGruz.Equals(VidGruz.Text)).Single().IdVidGruz;
             avto.Ispr      = Ispr.IsChecked.Value;
         }
         db.SaveChanges();
         Exit();
     }
 }
Exemplo n.º 3
0
    public void Odstranilastnistvoavtosalonanadavtom(int avtoid, int avtosalonid)
    {
        using (var db = new AvtosalonContext())
        {
            Avto      avto      = new Avto();
            Avtosalon avtosalon = new Avtosalon();

            foreach (var item in db.avti.ToList())
            {
                if (item.id == avtoid)
                {
                    avto = item;
                }
            }

            foreach (var item in db.avtosaloni.ToList())
            {
                if (item.id == avtosalonid)
                {
                    avtosalon = item;
                }
            }

            // db.avtoVAvtosaloni.Remove(new AvtoVAvtosalonu { avto = avto, avtosalon = avtosalon });

            db.SaveChanges();
        }
    }
Exemplo n.º 4
0
        public void DeleteAvto(int id)
        {
            Avto Avto = context.Avto.Find(id);

            context.Avto.Remove(Avto);
            context.SaveChanges();
        }
Exemplo n.º 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            groupBox1.Visible = false;

            amountel = 0;

            for (int i = 0; i < 10; i++)
            {
                comboBox2.Items.Add((Color)i);
            }

            for (int i = 0; i < 1000; i++)
            {
                MD[i] = new Avto();
            }
            for (int i = 0; i < amountel; i++)
            {
                comboBox1.Items.Add((Numbers)i);
            }

            using (FileStream fs = new FileStream("C:\\Users\\Mifa\\Desktop\\people.dat", FileMode.OpenOrCreate))
            {
                List <Mashin> deserilizeMashin = (List <Mashin>)formatter.Deserialize(fs);

                foreach (Mashin mashin in deserilizeMashin)
                {
                    list.Add(mashin);
                    comboBox1.Items.Add(mashin.Num);
                }
            };
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Person  janna = new Person("Janna", 40);
            Vehicle train = new Train("Podillya", 25000, janna, 8);

            train.Ride();
            train.Stop();
            Vehicle car = new Avto("Mersedes", 60, 4);
        }
Exemplo n.º 7
0
 public void DodajAvtosalonAvtu(int avtoid, int savtolonid)
 {
     using (var db = new AvtosalonContext())
     {
         Avto      avto      = db.avti.Find(avtoid);
         Avtosalon avtosalon = db.avtosaloni.Find(savtolonid);
         avto.avtosaloni.Add(avtosalon);
         db.avti.Add(avto);
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
    public void DodajAvto(string znamka, string model, int cena)
    {
        Avto avto = new Avto {
            znamka = znamka, model = model, cena = cena
        };

        using (var db = new AvtosalonContext())
        {
            db.avti.Add(avto);
            db.SaveChanges();
        }
    }
Exemplo n.º 9
0
 public static Avto[] BubbleSort_Avto(Avto[] avto)
 {
     for (int i = 0; i < avto.Length - 1; i++)
     {
         for (int j = i + 1; j < avto.Length; j++)
         {
             if (avto[i].b < avto[j].b)
             {
                 Avto temp = new Avto();
                 temp    = avto[i];
                 avto[i] = avto[j];
                 avto[j] = temp;
             }
         }
     }
     return(avto);
 }
Exemplo n.º 10
0
 public IActionResult Edit(Avto model)
 {
     if (ModelState.IsValid)
     {
         var ModelAvtoId = model.ModelAvtoId;
         if (model.AvtoId == 0)
         {
             repAvto.Add(model);
         }
         else
         {
             repAvto.Update(model, model.AvtoId);
         }
         repAvto.Save();
         return(RedirectToAction("Index"));
     }
     InitViewBag(model, true);//если неудача - проинициализировать ViewBag еще раз!
     return(View(model));
 }
Exemplo n.º 11
0
 private void LogUpdate(Avto avto)
 {
     try
     {
         System.IO.StreamWriter writer = new System.IO.StreamWriter(@"Log.txt", true);
         writer.WriteLine(DateTime.Now.ToString() + " Пользователь " + ActiveUser.NameUser + " отредактировал запись в таблице AVTO: " +
                          +avto.IdAvto + "^" + avto.Marka + "^" + avto.Nomer + "^" + avto.GruzPod + "^"
                          + db.VidGruzs.Where(e => e.IdVidGruz == avto.IdVidGruz).Single().NameVidGruz + "^" + avto.Ispr);
         writer.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception: " + ex.Message);
     }
     finally
     {
         Console.WriteLine("");
     }
 }
Exemplo n.º 12
0
 public void AddAvto([FromBody] Avto h)
 {
     context.Avto.Add(h);
     context.SaveChanges();
 }
Exemplo n.º 13
0
        public string Avto(int id)
        {
            Avto h = context.Avto.Find(id);

            return(h.Model);
        }
Exemplo n.º 14
0
 public void transmit(Avto a, int amountel)
 {
     for (int i = 0; i < 1000; i++)
     {
     }
 }