Exemple #1
0
        public InventarizacionnajaVedomost()
        {
            InitializeComponent();
            datePrevInvent = new DateTime();
            using (CRM_magEntities context = new CRM_magEntities())
            {
                try
                {
                    if (context.Materialy.FirstOrDefault().date_ostatok_cur != null)
                    {
                        txtBPrevInvent.Text = ((DateTime)context.spInventVed(dtCurInvent.SelectedDate).FirstOrDefault().date_ostatok_cur).ToString("dd/MM/yyyy");

                        datePrevInvent = (DateTime)context.spInventVed(dtCurInvent.SelectedDate).FirstOrDefault().date_ostatok_cur;
                    }
                    else
                    {
                        btnRun.IsEnabled = false;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error");
                }
            }
            Zapoln((DateTime)dtCurInvent.SelectedDate);
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        private void Zapoln(DateTime dt)
        {
            using (CRM_magEntities context = new CRM_magEntities())
            {
                try
                {
                    lstIntVed = new List <InventVed>();
                    foreach (var item in context.spInventVed(dt))
                    {
                        InventVed mt = new InventVed();

                        mt.id_material  = item.id_material;
                        mt.artikul      = item.artikul;
                        mt.NameMaterial = item.NameMaterial;
                        mt.id_ed_izm    = item.id_ed_izm;
                        Ed_izm ei = context.Ed_izm.Find(item.id_ed_izm);
                        mt.date_ostatok = (DateTime)item.date_ostatok_cur;
                        mt.nameEI       = ei.nameEI;
                        if (item.prih == null)
                        {
                            mt.prih = 0;
                        }
                        else
                        {
                            mt.prih = (decimal)item.prih;
                        }

                        if (item.rash == null)
                        {
                            mt.rash = 0;
                        }
                        else
                        {
                            mt.rash = (decimal)item.rash;
                        }


                        if (item.ostatok_cur == null)
                        {
                            mt.ostatok_cur = 0;
                        }
                        else
                        {
                            mt.ostatok_cur = (decimal)item.ostatok_cur;
                        }

                        if (item.ostatok_new == null)
                        {
                            mt.ostatok_new = 0;
                        }
                        else
                        {
                            mt.ostatok_new = (decimal)item.ostatok_new;
                        }

                        lstIntVed.Add(mt);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error");
                }
                dgInventVedomost.ItemsSource = null;
                dgInventVedomost.ItemsSource = lstIntVed;
            }
        }