Esempio n. 1
0
 private void SaveNewArtikel()
 {
     try
     {
         if (ArtState == ArtikelState.ArtikelNew)
         {
             if (ThisArtikel != null)
             {
                 using (var dbTemp = new SteinbachEntities())
                 {
                     db.AddTolagerlisten(ThisArtikel);
                     db.SaveChanges();
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     finally
     {
         ArtState    = ArtikelState.NoState;
         ThisArtikel = null;
     }
 }
Esempio n. 2
0
        private void FillList()
        {
            //db = new SteinbachEntities();
            ArtState                    = ArtikelState.NoState;
            pRepo                       = new ProjektRepository(this.db);
            db.SavingChanges           += new EventHandler(db_SavingChanges);
            KalkulationViewSource       = ((System.Windows.Data.CollectionViewSource)(this.FindResource("Kalkulation_ViewSource")));
            KalkulationDetailViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("KalkulationDetail_ViewSource")));
            SetsViewSource              = ((System.Windows.Data.CollectionViewSource)(this.FindResource("SetsViewSource")));

            // var calc = from k in db.kalkulationstabellen where k.id == CurrentProjektID select k;
            KalkulationViewSource.Source = pRepo.GetKalkukationByID(CurrentProjektID);
            KalkulationView              = (ListCollectionView)KalkulationViewSource.View;
            KalkulationDetailView        = (BindingListCollectionView)KalkulationDetailViewSource.View;
            LieferantenViewSource        = ((System.Windows.Data.CollectionViewSource)(this.FindResource("LieferantenViewSource")));
            LieferantenViewSource.Source = db.firmen.Where(id => id.istFirma == 1);
            SetsViewSource.Source        = db.StammLagerorte.Where(n => n.istSet == 1);

            if (CurrentProjektID == 0)
            {
                addNewKalkulation(ProjektNummer);
                db.SaveChanges();
            }


            var con = new Comma2PointConverter();

            this.ftbAufschlag.SetBinding("procent", BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged, con);
            var cbi = new C1.WPF.C1ComboBoxItem();

            // c1CboAufschlag.Items.Add((double)0);
            si.Add("0");

            for (int i = 100; i < 500; i += 5)
            {
                double res = (double)i / 10;
                //c1CboAufschlag.Items.Add(res);
                si.Add(res.ToString());
            }

            source = (IEnumerable <string>)si;
            ftbAufschlag.cBox.ItemsSource = source;

            try
            {
                KalkulationDetailView.CurrentChanged += new EventHandler(KalkulationDetailView_CurrentChanged);
                KalkulationView.CurrentChanged       += new EventHandler(KalkulationView_CurrentChanged);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
        private void c1GridDetais_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (bRowEditing)
                {
                    var    grid     = (C1.WPF.DataGrid.C1DataGrid)e.Source;
                    var    r        = (kalkulationstabelle_detail)grid.CurrentRow.DataItem;
                    string CellName = grid.CurrentCell.Column.Name;


                    if (grid.CurrentCell.Value != null)
                    {
                        string CellValue = grid.CurrentCell.Value.ToString();

                        using (SteinbachEntities dbLocal = new SteinbachEntities())
                        {
                            if (CellName == "artikelnr")
                            {
                                try
                                {
                                    //if (ArtState == ArtikelState.NoState)
                                    //{
                                    var q = from b in dbLocal.lagerlisten where b.artikelnr == CellValue select b;
                                    if (q.Count() > 0)
                                    {
                                        ArtState       = ArtikelState.Done;
                                        r.beschreibung = q.FirstOrDefault().beschreibungeng != null?q.FirstOrDefault().beschreibungeng : "";

                                        r.umrechnungeuro = q.FirstOrDefault().preisbrutto.HasValue ? (double)q.FirstOrDefault().preisbrutto : 0;
                                        r.einheit        = q.FirstOrDefault().einheit != null?q.FirstOrDefault().einheit : "";

                                        r.id_Lieferant = q.FirstOrDefault().id_lieferant.HasValue ? q.FirstOrDefault().id_lieferant : null;
                                    }
                                    //else
                                    //{
                                    //    ArtState = ArtikelState.ArtikelNew;
                                    //    ThisArtikel = new lagerliste();
                                    //    ThisArtikel.artikelnr = CellValue;
                                    //    grid.CurrentCell.Presenter.Background=Brushes.Yellow;
                                    //}
                                    //}
                                }
                                catch (Exception)
                                {
                                }
                            }
                            //else
                            //{
                            //    try
                            //    {
                            //        if (ArtState == ArtikelState.ArtikelNew)
                            //        {
                            //            if (CellName == "beschreibung")
                            //            {
                            //                ThisArtikel.beschreibungeng = CellValue;
                            //                ThisArtikel.bezeichnung = CellValue;
                            //            }

                            //            if (CellName == "umrechnungeuro")
                            //            {
                            //                ThisArtikel.preisbrutto = decimal.Parse(CellValue);
                            //            }

                            //            if (CellName == "id_Lieferant")
                            //            {
                            //                ThisArtikel.id_lieferant = int.Parse(CellValue);
                            //            }

                            //            if (CellName == "einheit")
                            //            {
                            //                ThisArtikel.einheit = CellValue;
                            //            }


                            //        }
                            //    }

                            //catch (Exception)
                            //{


                            //}
                        }
                    }
                }
            }
            //}
            catch (Exception)
            {
            }
        }