public PrihodWindow()
        {
            InitializeComponent();
            prihod2s = new ObservableCollection <Prihod2>();

            using (CRM_magEntities contextDB = new CRM_magEntities())
            {
                dgPrihod.ItemsSource = prihod2s;

                var dataPostavshik = from p in contextDB.Postavshiki
                                     select new { p.id_postavsh, p.name_postavsh };

                cmbPostavshik.ItemsSource       = dataPostavshik.ToList();
                cmbPostavshik.DisplayMemberPath = "name_postavsh";
                cmbPostavshik.SelectedValuePath = "id_postavsh";
                cmbPostavshik.SelectedValue     = -1;

                var materEdIzm = from m in contextDB.Materialy
                                 join ei in contextDB.tEdIzm on m.id_ed_izm equals ei.id
                                 select new
                {
                    IdMater   = m.id_material,
                    NameMater = m.NameMaterial + "  (" + ei.NameEI + ")",
                    IdEdIzm   = m.id_ed_izm,
                    Artikul   = m.artikul
                };


                listMat = new List <MaterEdIzm>();
                foreach (var n in materEdIzm)
                {
                    MaterEdIzm e = new MaterEdIzm();
                    e.IdMater1   = n.IdMater;
                    e.NameMater1 = n.NameMater;
                    e.IdEdIzm1   = n.IdEdIzm;
                    e.Artikul    = n.Artikul;
                    listMat.Add(e);
                }

                cmbMaterial.ItemsSource = listMat;

                cmbMaterial.DisplayMemberPath = "NameMater1";

                cmbMaterial.SelectedValuePath = "IdMater1";
                dtpDatePrih.SelectedDate      = DateTime.Now;
            }
        }
예제 #2
0
        public RashodWindow()
        {
            InitializeComponent();
            rashod2s = new ObservableCollection <Rashod_2>();

            using (CRM_magEntities contextDB = new CRM_magEntities())
            {
                dgRashod.ItemsSource = rashod2s;

                var dataMontajnik = from p in contextDB.Montazhniki
                                    select new { p.id_mont, p.full_name };

                cmbPoluchatel.ItemsSource       = dataMontajnik.ToList();
                cmbPoluchatel.DisplayMemberPath = "full_name";
                cmbPoluchatel.SelectedValuePath = "id_mont";
                cmbPoluchatel.SelectedValue     = -1;

                var materEdIzm = from m in contextDB.Materialy
                                 join ei in contextDB.tEdIzm on m.id_ed_izm equals ei.id
                                 select new
                {
                    IdMater   = m.id_material,
                    NameMater = m.NameMaterial + "  (" + ei.NameEI + ")",
                    IdEdIzm   = m.id_ed_izm,
                };

                listMat = new List <MaterEdIzm>();
                foreach (var n in materEdIzm)
                {
                    MaterEdIzm e = new MaterEdIzm();
                    e.IdMater1   = n.IdMater;
                    e.NameMater1 = n.NameMater;
                    e.IdEdIzm1   = n.IdEdIzm;
                    listMat.Add(e);
                }

                cmbMaterial.ItemsSource = listMat;

                cmbMaterial.DisplayMemberPath = "NameMater1";

                cmbMaterial.SelectedValuePath = "IdMater1";
                dtPRashod.SelectedDate        = DateTime.Now;
            }
        }