예제 #1
0
        public override ValidationResult Validate(object value,
                                                  System.Globalization.CultureInfo cultureInfo)
        {
            Rashod_2 r_2    = (value as BindingGroup).Items[0] as Rashod_2;
            decimal  kolMat = 0;

            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    kolMat = Convert.ToDecimal(contextDB.spInventVed(DateTime.Now).FirstOrDefault().ostatok_new);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (r_2.kol > kolMat)
            {
                MessageBox.Show("На складе " + kolMat.ToString() + ".", "Ошибка!");
                return(new ValidationResult(false,
                                            "Start Date must be earlier than End Date."));
            }
            else
            {
                return(ValidationResult.ValidResult);
            }
        }
예제 #2
0
 public void BeginEdit()
 {
     if (inEdit)
     {
         return;
     }
     inEdit     = true;
     backupCopy = this.MemberwiseClone() as Rashod_2;
 }
예제 #3
0
 public void EndEdit()
 {
     if (!inEdit)
     {
         return;
     }
     inEdit     = false;
     backupCopy = null;
 }
예제 #4
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());
            }
        }