Exemple #1
0
        private void ZakazTable_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ZakazList list = new ZakazList();

            list.Initialize((dynamic)ZakazTable.SelectedItem);
            list.Show();
        }
Exemple #2
0
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     if (CheckFields())
     {
         string[]      gruz      = Gruz.SelectedItem.ToString().Split(" ");
         ZakazEditCase item      = (dynamic)ZakazEditTable.SelectedItem;
         string[]      FIOVod    = item.FIOVod.Split(" ");
         string[]      FIOKlient = Klient.Text.Split(" ");
         if (SelectedId == 0)
         {
             db.Zakazs.Add(new Zakaz
             {
                 DateZakaz  = DateZakaz.SelectedDate.Value,
                 IdGruz     = db.Gruzs.Where(e => e.NameGruz.Equals(gruz[0])).Single().IdGruz,
                 Otkuda     = Otkuda.Text,
                 Kuda       = Kuda.Text,
                 DateVypoln = DateVypoln.SelectedDate.Value,
                 IdAvto     = db.Avtos.Where(e => e.Marka.Equals(item.Marka)).Single().IdAvto,
                 IdVod      = db.Vods.Where(e => e.F.Equals(FIOVod[0]) && e.I.Equals(FIOVod[1]) && e.O.Equals(FIOVod[2])).Single().IdVod,
                 Summa      = Convert.ToDouble(Summa.Content.ToString()),
                 IdKlient   = db.Klients.Where(e => e.FIO.Equals(FIOKlient[0] + " " + FIOKlient[1] + " " + FIOKlient[2])).Single().IdKlient,
                 Kol        = Convert.ToDouble(Kol.Text)
             });
         }
         else
         {
             Zakaz zakaz = db.Zakazs.Where(e => e.IdZakaz == SelectedId).Single();
             LogUpdate(zakaz);
             zakaz.DateZakaz  = DateZakaz.SelectedDate.Value;
             zakaz.IdGruz     = db.Gruzs.Where(e => e.NameGruz.Equals(gruz[0])).Single().IdGruz;
             zakaz.Otkuda     = Otkuda.Text;
             zakaz.Kuda       = Kuda.Text;
             zakaz.DateVypoln = DateVypoln.SelectedDate.Value;
             zakaz.IdAvto     = db.Avtos.Where(e => e.Marka.Equals(item.Marka)).Single().IdAvto;
             zakaz.IdVod      = db.Vods.Where(e => e.F.Equals(FIOVod[0]) || e.I.Equals(FIOVod[1]) || e.O.Equals(FIOVod[2])).Single().IdVod;
             zakaz.Summa      = Convert.ToDouble(Summa.Content.ToString());
             zakaz.IdKlient   = db.Klients.Where(e => e.FIO.Equals(FIOKlient[0] + " " + FIOKlient[1] + " " + FIOKlient[2])).Single().IdKlient;
             zakaz.Kol        = Convert.ToInt32(Kol.Text);
         }
         db.SaveChanges();
         ZakazList list = new ZakazList();
         list.Initialize(new ZakazCase
         {
             IdZakaz    = SelectedId,
             DateZakaz  = DateZakaz.SelectedDate.Value,
             NameGruz   = gruz[0],
             Otkuda     = Otkuda.Text,
             Kuda       = Kuda.Text,
             DateVypoln = DateVypoln.SelectedDate.Value,
             Marka      = item.Marka,
             FIOVod     = FIOVod[0] + " " + FIOVod[1] + " " + FIOVod[2],
             Summa      = Convert.ToDouble(Summa.Content.ToString()),
             FIOKlient  = FIOKlient[0] + " " + FIOKlient[1] + " " + FIOKlient[2],
             Kol        = Convert.ToInt32(Kol.Text),
         });
         list.Show();
         Exit();
     }
 }