Exemple #1
0
 public static void DodajTracePEm(trace_pe_m poz)
 {
     using (var db = new ecoplastolEntities())
     {
         db.trace_pe_m.Add(poz);
         db.SaveChanges();
     }
 }
Exemple #2
0
 public static void PoprawTracePEm(trace_pe_m poz)
 {
     using (var db = new ecoplastolEntities())
     {
         db.Entry(poz).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemple #3
0
 public static void UsunTracePEm(trace_pe_m poz)
 {
     using (var db = new ecoplastolEntities())
     {
         db.trace_pe_m.Attach(poz);
         db.trace_pe_m.Remove(poz);
         db.SaveChanges();
     }
 }
        private void BtnDodaj_Click(object sender, RoutedEventArgs e)
        {
            akcja                  = "D";
            grdBookmark            = grdLista.SelectedIndex;
            grdLista.IsEnabled     = false;
            grdPozycje.IsEnabled   = true;
            btnDodaj.IsEnabled     = false;
            btnKlonuj.IsEnabled    = false;
            btnPopraw.IsEnabled    = false;
            btnUsun.IsEnabled      = false;
            btnAnuluj.IsEnabled    = true;
            btnZatwierdz.IsEnabled = true;

            trace_pe_m poz = new trace_pe_m();

            grdPozycje.DataContext = poz;
        }
        private void BtnKlonuj_Click(object sender, RoutedEventArgs e)
        {
            akcja = "K";
            grdLista.IsEnabled     = false;
            grdPozycje.IsEnabled   = true;
            btnDodaj.IsEnabled     = false;
            btnKlonuj.IsEnabled    = false;
            btnPopraw.IsEnabled    = false;
            btnUsun.IsEnabled      = false;
            btnAnuluj.IsEnabled    = true;
            btnZatwierdz.IsEnabled = true;

            trace_pe_m poz = new trace_pe_m();

            poz.parametr           = rowTracePEm.parametr;
            poz.wartosc            = rowTracePEm.wartosc;
            poz.opis               = rowTracePEm.opis;
            grdPozycje.DataContext = poz;
        }
        private void BtnZatwierdz_Click(object sender, RoutedEventArgs e)
        {
            grdLista.IsEnabled     = true;
            grdPozycje.IsEnabled   = false;
            btnDodaj.IsEnabled     = true;
            btnKlonuj.IsEnabled    = true;
            btnPopraw.IsEnabled    = true;
            btnUsun.IsEnabled      = true;
            btnAnuluj.IsEnabled    = false;
            btnZatwierdz.IsEnabled = false;

            switch (akcja)
            {
            case "D":
            case "K":
                if (grdPozycje.DataContext is trace_pe_m)
                {
                    var row = new trace_pe_m();
                    row       = grdPozycje.DataContext as trace_pe_m;
                    row.id    = PanelTrace_db.IdTracePEm();
                    row.opw   = frmLogin.LoggedUser.login;
                    row.czasw = DateTime.Now;
                    row.opm   = frmLogin.LoggedUser.login;
                    row.czasm = DateTime.Now;
                    PanelTrace_db.DodajTracePEm(row);
                }
                break;

            case "P":
                rowTracePEm.opm   = frmLogin.LoggedUser.login;
                rowTracePEm.czasm = DateTime.Now;
                PanelTrace_db.PoprawTracePEm(rowTracePEm);
                break;

            default:
                break;
            }
            listTracePEm         = PanelTrace_db.PobierzTracePem();
            grdLista.ItemsSource = listTracePEm;
        }
 private void GrdLista_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     rowTracePEm            = grdLista.SelectedItem as trace_pe_m;
     grdPozycje.DataContext = rowTracePEm;
 }