Пример #1
0
 public void CancelEdit()
 {
     if (!inEdit)
     {
         return;
     }
     inEdit           = false;
     this.id_rashod_2 = backupCopy.id_rashod_2;
     this.id          = backupCopy.id;
     this.id_material = backupCopy.id_material;
     this.kod_ed_izm  = backupCopy.kod_ed_izm;
     this.kol         = backupCopy.kol;
     this.cena        = backupCopy.cena;
     this.Materialy   = backupCopy.Materialy;
     this.Rashod1     = backupCopy.Rashod1;
 }
Пример #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    Rashod1 rash1 = new Rashod1();
                    rash1.data_nakl = (DateTime)dtPRashod.SelectedDate;
                    if (cmbPoluchatel.SelectedValue != null)
                    {
                        rash1.id_mont = Convert.ToInt32(cmbPoluchatel.SelectedValue);
                    }
                    contextDB.Rashod1.Add(rash1);
                    contextDB.SaveChanges();

                    idRash1 = rash1.id;
                    txtBNomerNakladnoj.Text = idRash1.ToString();

                    foreach (Rashod_2 item in rashod2s)
                    {
                        Rashod_2 rashod2 = new Rashod_2();
                        rashod2.id          = idRash1;
                        rashod2.id_material = item.id_material;

                        rashod2.kod_ed_izm = contextDB.Materialy.Find(item.id_material).id_ed_izm;


                        rashod2.kol  = item.kol;
                        rashod2.cena = item.cena;
                        contextDB.Rashod_2.Add(rashod2);
                    }

                    contextDB.SaveChanges();
                    dgRashod.ItemsSource = null;
                    dgRashod.ItemsSource = rashod2s;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }