Пример #1
0
        public VvodPervonachalnOstatkov()
        {
            InitializeComponent();
            using (CRM_magEntities context = new CRM_magEntities())
            {
                try
                {
                    lstVvPervOst = new List <InventVed>();

                    foreach (var item in context.Materialy)
                    {
                        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.nameEI = ei.nameEI;
                        if (item.ostatok_cur == null)
                        {
                            mt.ostatok_cur = 0;
                        }

                        lstVvPervOst.Add(mt);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error");
                }
                dgInventVedomost.ItemsSource = lstVvPervOst;
            }
        }
Пример #2
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;
            }
        }