void UpdateCollection(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
            {
                if (e.NewItems != null && e.NewItems.Count > 0)
                {
                    foreach (SI_Events item in e.NewItems)
                    {
                        if (fk.Where(k => k.id_Event == item.id).Count() == 0)
                        {
                            var k = new Personen_Events();
                            k.id_Event        = item.id;
                            k.Firmen_Personen = CurrentPerson;


                            fk.Add(k);
                            db.AddToPersonen_Events(k);
                            db.SaveChanges();
                        }
                    }
                }

                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
            {
                if (e.OldItems != null && e.OldItems.Count > 0)
                {
                    foreach (SI_Events item in e.OldItems)
                    {
                        if (fk.Where(k => k.id_Event == item.id).Count() == 1)
                        {
                            var k = fk.Where(ka => ka.id_Event == item.id).SingleOrDefault();
                            fk.Remove(k);
                            db.DeleteObject(k);
                            db.SaveChanges();
                        }
                    }
                }
                break;
            }


            default:
            {
                break;
            }
            }
        }
Exemple #2
0
        void UpdateCollection(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
            {
                if (e.NewItems != null && e.NewItems.Count > 0)
                {
                    foreach (AuswahlEintraege item in e.NewItems)
                    {
                        if (fk.Where(k => k.id_FirmaEigenschaft == item.id).Count() == 0)
                        {
                            var k = new SI_SelectedTypFirmaEigenschaften();
                            k.id_FirmaEigenschaft = item.id;



                            fk.Add(k);
                            db.AddToSI_SelectedTypFirmaEigenschaften(k);
                            db.SaveChanges();
                        }
                    }
                }

                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
            {
                if (e.OldItems != null && e.OldItems.Count > 0)
                {
                    foreach (AuswahlEintraege item in e.OldItems)
                    {
                        if (fk.Where(k => k.id_FirmaEigenschaft == item.id).Count() == 1)
                        {
                            var k = fk.Where(ka => ka.id_FirmaEigenschaft == item.id).SingleOrDefault();
                            fk.Remove(k);
                            db.DeleteObject(k);
                            db.SaveChanges();
                        }
                    }
                }
                break;
            }


            default:
            {
                break;
            }
            }
        }
        private void FillList()
        {
            db.SaveChanges();
            db = new SteinbachEntities();
            var kto = from k in db.projekte
                      where k.firmenname == "Jets AS" && (k.landx == 0 || k.landx == null) && (k.schiff == 0 || k.schiff == null)
                      orderby k.datum
                      select k;

            EditkundenViewSource        = ((System.Windows.Data.CollectionViewSource)(this.FindResource("EditKunden_ViewSource")));
            EditkundenViewSource.Source = new ObjectCollections.ProjektCollection(kto.Skip(toSkip), db);
            EditkundenView = (ListCollectionView)EditkundenViewSource.View;
        }
        private bool DoSaveChanges()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Inventur konnte nicht gespeichert werden.");
            sb.AppendLine("Folgende Korrekturen sind nötig");
            sb.AppendLine();

            bool res = true;

            if (Inventurart == null)
            {
                sb.AppendLine("Inventurart kann nicht leer sein.");
                res = false;
            }

            if (!Verantwortlicher.HasValue)
            {
                sb.AppendLine("Verantwortlicher kann nicht leer sein.");
                res = false;
            }


            if (res == true)
            {
                Mapper.CreateMap <SI_InventurenViewModel, SI_Inventuren>();
                //.ForMember(dest => dest.SI_Firma, opt => opt.Ignore())
                //.ForMember(dest => dest.SI_Person, opt => opt.Ignore());

                ////Mapper.AssertConfigurationIsValid();
                Mapper.Map <SI_InventurenViewModel, SI_Inventuren>(this, Inventur);

                db.SaveChanges();
                id      = Inventur.id;
                isDirty = false;
            }
            else
            {
                MessageBox.Show(sb.ToString());
            }

            LockPositions();
            // MakeBuchungsbeleg();

            //CommonTools.Tools.LockProcess.enumResultLockProcess Buchungen = CommonTools.Tools.LockProcess.DoLockProcess(SaveBuchungen, "Inventurbuchung_Gesperrt");
            //Console.WriteLine(Buchungen.ToString());

            return(res);
        }
Exemple #5
0
        public void SaveChanges(SteinbachEntities db)
        {
            if (isDirty)
            {
                Personen_Telefon tel;
                if (id == 0)
                {
                    tel = new Personen_Telefon();
                    db.AddToPersonen_Telefon(tel);
                }
                else
                {
                    tel = db.Personen_Telefon.Where(i => i.id == id).SingleOrDefault();
                }

                if (tel != null)
                {
                    Mapper.Map <Firmen_TelefonViewModel, Personen_Telefon>(this, tel);
                    //  tel.id_Person = this.id_Person;
                    db.SaveChanges();
                    this.id = tel.id;
                    isDirty = false;
                }
            }
        }
        public SaveChangesEnum SaveChanges(MessageBoxButton Button)
        {
            if (this.isDirty())
            {
                var res = (MessageBox.Show("Änderungen speichern ?", "Sicherheitsabfrage", Button));
                if (res == MessageBoxResult.Yes || res == MessageBoxResult.OK)
                {
                    db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);


                    return(SaveChangesEnum.AllDone);
                }
                else if (res == MessageBoxResult.No)
                {
                    return(SaveChangesEnum.No);
                }
                else if (res == MessageBoxResult.Cancel)
                {
                    return(SaveChangesEnum.Cancel);
                }
            }
            else
            {
                return(SaveChangesEnum.AllDone);
            }

            return(SaveChangesEnum.noResult);
        }
        public void DoWriteFirmannummer()
        {
            try
            {
                using (var db = new SteinbachEntities())
                {
                    var query = from f in db.firmen
                                where f.istFirma == 1
                                select new
                    {
                        f.KdNr,
                        f.name
                    };


                    foreach (var item in query)
                    {
                        var project = from p in db.projekte where p.firmenname == item.name select p;
                        foreach (var pro in project)
                        {
                            pro.FirmenNr = item.KdNr;
                        }
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ErrorMethods.GetExceptionMessageInfo(ex));
            }
        }
Exemple #8
0
        public static bool addDatabaseLogging(string level, int priority, string Text, LogState State)
        {
            int s = (int)State;

            if (s >= DAL.Session.LogState)
            {
                try
                {
                    var log = new logging();
                    log.created  = DateTime.Now;
                    log.level    = level;
                    log.priority = priority;
                    Text        += " : User : "******"CheckMailReminder", "addLogin", DAL.Tools.LoggingTool.LogState.low);
                    return(false);
                }
            }

            return(true);
        }
Exemple #9
0
        protected override void RemoveItem(int index)
        {
            try
            {
                // vwLagerListenOberartikel project = this[index];
                using (var db = new SteinbachEntities())
                {
                    int id      = this[index].id;
                    var artikel = db.lagerlisten.Where(s => s.id == id);
                    Console.WriteLine(artikel.FirstOrDefault().beschreibung);
                    db.DeleteObject(artikel.FirstOrDefault());
                    db.SaveChanges();
                }



                base.RemoveItem(index);
            }
            catch (Exception ex)
            {
                string Message;
                Message = ex.Message;
                if (ex.InnerException != null)
                {
                    Message += '\n';
                    Message += ex.InnerException.Message;
                }
                throw new Exception(Message);
            }
        }
        public void Termine_DeletingRows(C1.WPF.DataGrid.DataGridDeletingRowsEventArgs e)
        {
            if (e.DeletedRows.Count() > 0)
            {
                try
                {
                    if (MessageBox.Show(string.Format("{0} ausgewählte Termine endgültig löschen ?", e.DeletedRows.Count()), "Sicherheitsabfrage",
                                        MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        foreach (var item in e.DeletedRows)
                        {
                            var adr = (CRMTermine)item.DataItem;
                            CommonTools.ObjectFactories.TerminFactory.DeleteTermine(adr.id);
                        }

                        db.SaveChanges();
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
                catch (Exception ex)
                {
                    CommonTools.Tools.ErrorMethods.ShowErrorMessage(ex, true);
                }
            }
        }
        public static int DeleteTermine(int id)
        {
            try
            {
                using (var db = new SteinbachEntities())
                {
                    var adr = db.CRMTermine.Where(t => t.id == id).SingleOrDefault();
                    //TeilnehmerSI Löschen wegen Ref. Integritätfehler
                    //var tsi = db.Termine_TeilnehmerSI.Where(s => s.id_Termin == adr.id);
                    foreach (var teilnehmerSI in adr.Termine_TeilnehmerSI.ToList())
                    {
                        db.DeleteObject(teilnehmerSI);
                    }
                    //TeilnehmerExtern Löschen wegen Ref. Integritätfehler
                    //var tex = db.Termin_TeilnehmerExtern.Where(t => t.id_Termin == adr.id);
                    foreach (var TeilnehmerExtern in adr.Termin_TeilnehmerExtern.ToList())
                    {
                        db.DeleteObject(TeilnehmerExtern);
                    }
                    //Termin löschen
                    db.DeleteObject(adr);

                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(0);
            }
        }
        public void CheckAppointments()
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                using (SteinbachEntities db = new SteinbachEntities())
                {
                    DateTime Von = DateTime.Now.AddMinutes(-30);
                    DateTime Bis = DateTime.Now.AddMinutes(15);

                    var ap = from t in db.CRMTermine
                             where (t.EmailSent == null || t.EmailSent == 0) && t.Erinnerung == 1 &&
                             t.ErinerungDatum >= Von && t.ErinerungDatum <= Bis
                             select t;



                    foreach (var item in ap)
                    {
                        var m = from i in db.Termine_TeilnehmerSI
                                where i.id_Termin == item.id
                                select i;

                        foreach (var itemM in m)
                        {
                            string appShort = string.Empty;
                            person Person   = (from p in db.personen
                                               where p.id == itemM.id_Teilnehmer
                                               select p).SingleOrDefault();
                            sb.Clear();
                            sb.Append("Termin von :");
                            sb.AppendLine(item.TerminVon.ToString());
                            sb.Append("Termin bis :");
                            sb.AppendLine(item.TerminBis.ToString());
                            sb.AppendLine();
                            sb.Append("Betreff :");
                            sb.AppendLine(item.Betreff);
                            sb.AppendLine();
                            sb.AppendLine("Details :");
                            sb.AppendLine(item.Details);
                            appShort = sb.ToString();

                            DoSendMail(Person.email, "EMail Erinnerung für " + item.Betreff, sb.ToString());
                            Eventlogging.log(MailAppointment, "Mail versandt an :" + Person.email, "Termin : " + item.id.ToString(), appShort);
                        }

                        item.EmailSent     = 1;
                        item.EmailSentDate = DateTime.Now;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Eventlogging.log(VerarbeitungFehler, System.Diagnostics.EventLogEntryType.Error, "Fehler bei EMailversand Terminerinnerung"
                                 , ex.Message
                                 , ex.InnerException == null ? "" :ex.InnerException.Message);
            }
        }
Exemple #13
0
        public bool Lagerbuchung(int id_Lagerort, int id_Artikel, int BewegungsMenge)
        {
            try
            {
                using (var db = new SteinbachEntities())
                {
                    var lb = db.Lagerbestaende.Where(n => n.id_Lagerliste == id_Artikel && n.id_Lagerort == id_Lagerort).SingleOrDefault();
                    if (lb == null)
                    {
                        lb = new Lagerbestaende();
                        lb.id_Lagerliste = id_Artikel;
                        lb.id_Lagerort   = id_Lagerort;
                        lb.Lagerbestand  = 0;
                        db.AddToLagerbestaende(lb);
                    }

                    if (!lb.Lagerbestand.HasValue)
                    {
                        lb.Lagerbestand = 0;
                    }

                    lb.Lagerbestand += BewegungsMenge;
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonTools.Tools.ErrorMethods.HandleStandardError(ex, "Lagerbuchung fehlgeschlagen.");

                return(false);
                // throw;
            }
        }
        public static int?CreateArtikel(string artNr, double?preis, string bezeichnung, string einheit, int?hersteller, bool Handelsware)
        {
            try
            {
                using (var db = new SteinbachEntities())
                {
                    if (artNr == string.Empty || artNr == null)
                    {
                        throw new ArgumentNullException("Artikelmnummer", ArtikelnummerKannNichtNullOderLeerSeinMessage);
                    }



                    var Art = new lagerliste();
                    Art.created         = DateTime.Now;
                    Art.artikelnr       = artNr;
                    Art.bezeichnung     = bezeichnung;
                    Art.beschreibungeng = bezeichnung;
                    Art.beschreibung    = bezeichnung;
                    Art.einheit         = einheit;
                    Art.id_lieferant    = hersteller;
                    Art.Handelsware     = Handelsware == true ? (short)1 : (short)0;

                    db.AddTolagerlisten(Art);
                    db.SaveChanges();
                    return(Art.id);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #15
0
        public void CorrectBesuchsbericht()
        {
            using (var db = new SteinbachEntities())
            {
                foreach (var item in db.Firmen_Kundenbesuche)
                {
                    if (item.id_siperson != null)
                    {
                        var sip = new Kundenbesuche_TeilnehmerSI();
                        sip.id_TeilnemerSI = item.id_siperson;
                        sip.id_besuch      = item.id;
                        db.AddToKundenbesuche_TeilnehmerSI(sip);
                        Console.WriteLine(string.Format("Hinzugefügt {0} zu {1} ", item.person.benutzername, item.besuchsthema));
                    }

                    if (item.id_vertretenefirma != null)
                    {
                        var vf = new Kundenbesuche_VertreteneFirmen();
                        vf.id_VertreteneFirma = item.id_vertretenefirma;
                        vf.id_besuch          = item.id;
                        db.AddToKundenbesuche_VertreteneFirmen(vf);
                        Console.WriteLine(string.Format("Hinzugefügt {0} zu {1} ", item.firma1.name, item.besuchsthema));
                    }
                }

                db.SaveChanges();
                Console.ReadLine();
            }
        }
        public void DoAddCustomers()
        {
            using (SteinbachEntities db = new SteinbachEntities())
            {
                var projects = (from p in db.projekte select new { p.kundenname }).Distinct();

                foreach (var po in projects)
                {
                    var q = from k in db.firmen where k.name.Equals(po.kundenname, StringComparison.CurrentCulture) select k;
                    if (q.Count() == 0)
                    {
                        var f = new firma();
                        f.name     = po.kundenname;
                        f.created  = DateTime.Now;
                        f.istFirma = 3;
                        db.firmen.AddObject(f);
                    }
                }


                db.SaveChanges();

                Console.WriteLine("Done . . . . . .");
            }
        }
        public void CopyProjektAnlagen2SChiffAnlagen()
        {
            using (var db = new SteinbachEntities())
            {
                var query = from p in db.schiffe select p;
                foreach (var s in query)
                {
                    if (s.brplantnr != string.Empty)
                    {
                        AddSchiffAnlage(s, s.brplantnr, db);
                    }

                    if (s.brplantnr2 != string.Empty)
                    {
                        AddSchiffAnlage(s, s.brplantnr2, db);
                    }

                    if (s.brplantnr3 != string.Empty)
                    {
                        AddSchiffAnlage(s, s.brplantnr3, db);
                    }

                    if (s.brplantnr4 != string.Empty)
                    {
                        AddSchiffAnlage(s, s.brplantnr4, db);
                    }
                }

                db.SaveChanges();
            }
        }
        public static int DeleteBesuchsbericht(int id)
        {
            string Rights = "admin suCRM";

            if (!Rights.Contains(Session.User.rights))
            {
                return(0);
            }

            using (var db = new SteinbachEntities())
            {
                var besuch = db.Firmen_Kundenbesuche.Where(m => m.id == id).SingleOrDefault();
                if (besuch != null)
                {
                    foreach (var item in besuch.Kundenbesuche_TeilnehmerExtern.ToList())
                    {
                        db.DeleteObject(item);
                    }

                    db.DeleteObject(besuch);
                    return(db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave));
                }
                else
                {
                    return(0);
                }
            }
        }
        private bool SaveChanges()
        {
            try
            {
                var om = this.db.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified | System.Data.EntityState.Added);
                foreach (var o in om)
                {
                    if (o.Entity is person)
                    {
                        var p = (person)o.Entity;
                        if (p.EntityState == System.Data.EntityState.Added)
                        {
                            bool KeyInUse = db.personen.Any(c => c.nachname == p.nachname);

                            if (KeyInUse)
                            {
                                MessageBox.Show(String.Format("Der Name {0} wird schon benutzt.", p.nachname));
                                return(false);
                            }
                        }
                    }
                }

                db.SaveChanges();
                db.Dispose();
                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        public void WaWi_AddArtikelAndCreateValidRecord()
        {
            using (var db = new SteinbachEntities())
            {
                Session.Login("J. Steinbach", "jörg");

                string guid = Guid.NewGuid().ToString();
                guid = guid.Replace("-", "");


                var ll = new DAL.lagerliste();
                ll.artikelnr    = guid;
                ll.beschreibung = DateTime.Now.ToString();
                ll.id_lieferant = 14;

                ll.einheit     = "Pcs";
                ll.preiseuro   = 10.00m;
                ll.preisbrutto = 11.90m;

                db.AddTolagerlisten(ll);
                db.SaveChanges();

                var bu = new WaWi.Lagerbuchungen.Lagerbuchungen.Lagerbuchungen(db);



                var disp = System.Windows.Threading.Dispatcher.CurrentDispatcher;
                var Cur  = System.Windows.Input.Cursors.Wait;


                var BelegeVM = new ProjektDB.ViewModels.SI_BelegeViewModel(0, disp, Cur);
                BelegeVM.InitModel(0);
                BelegeVM.SelectedBelegarten = db.StammBelegarten.Where(n => n.id == "we").SingleOrDefault();
                BelegeVM.SelectedFirmen     = GetFirmensourceByID(14, db);


                BelegeVM.AddScannerPosition(guid, "5");
                BelegeVM.AddScannerPosition(guid, "7");
                BelegeVM.id_user = Session.User.id;

                BelegeVM.DoSaveChanges();
                int bestand = bu.GetBestandLagerort(guid, 1);
                Assert.AreEqual(bestand, 12);

                db.SaveChanges();
            }
        }
        void fcbArtikel_OnFcb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cbo = (ComboBox)sender;
            //var i = cbo.SelectedIndex;
            var x = (Tools.LagerListeOberArtikel)cbo.SelectedItem;
            var l = dbArt.lagerlisten.Where(p => p.id == x.id).FirstOrDefault();

            if (MessageBox.Show(string.Format("Artikel {0} als Unterartikel hinzufügen ?", x.bezeichnung), "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
            {
                if (x.id_parent != ID)
                {
                    l.id_parent = ID;
                }
            }


            dbArt.SaveChanges();
            RefreshUnterartikelListe();
        }
        public static enumResultLockProcess DoLockProcess(Func <bool> FuncName, string key, int repeat = 5, int TimeoutMilliseconds = 500)
        {
            bool Success = false;
            int  counter = 0;
            enumResultLockProcess Result = enumResultLockProcess.Init;

            while (counter < repeat && Success == false)
            {
                using (var db = new SteinbachEntities())
                {
                    config res = db.config.Where(n => n.mkey == key).SingleOrDefault();
                    if (res == null)
                    {
                        res = LockProcess.addKeyIfMissing(db, key);
                        if (res == null)
                        {
                            Success = false;
                            Result  = enumResultLockProcess.KeyNotFoundAndUnableToBeAdded;
                        }
                    }

                    if (res != null && res.value == "0")
                    {
                        res.value = "1";
                        db.SaveChanges();

                        Success = true;
                        Result  = FuncName() == false ? enumResultLockProcess.FunctionReportsFalse : enumResultLockProcess.Succes;
                    }
                }
                counter++;
                LockProcess.wait(new TimeSpan(0, 0, 0, 0, TimeoutMilliseconds));
            }

            if (!Success)
            {
                if (Result != enumResultLockProcess.KeyNotFoundAndUnableToBeAdded)
                {
                    Result = enumResultLockProcess.TimeOutWhileTryToLock;
                }
            }

            if (Success)
            {
                using (var db = new SteinbachEntities())
                {
                    config res = db.config.Where(n => n.mkey == key).SingleOrDefault();
                    res.value = "0";
                    db.SaveChanges();
                }
            }


            return(Result);
        }
Exemple #23
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         LoggingTool.LogExeption(ex, "EditProjekt", "Save_Click");
     }
 }
Exemple #24
0
 public void Save()
 {
     try
     {
         db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
     }
     catch (Exception ex)
     {
         CommonTools.Tools.ErrorMethods.ShowErrorMessage(ex, true);
     }
 }
Exemple #25
0
        void c1Scheduler1_AppointmentAdded(object sender, C1.WPF.Schedule.AppointmentActionEventArgs e)
        {
            var cd = e.Appointment.CustomData;

            if (cd == null)
            {
                CRMTermine t = new CRMTermine();
                t.TerminVon       = e.Appointment.Start;
                t.TerminBis       = e.Appointment.End;
                t.TerminDauer     = e.Appointment.Duration.Ticks;
                t.Betreff         = e.Appointment.Subject;
                t.Standort        = e.Appointment.Location;
                t.AppointmentType = "Termin";
                t.Details         = e.Appointment.Body;

                var r = e.Appointment.Reminder;
                db.AddToCRMTermine(t);
                db.SaveChanges();
            }
        }
Exemple #26
0
        public bool SaveChanges()
        {
            db.SaveChanges();
            if (_RaiseEvents != null)
            {
                _RaiseEvents.Publish(new SelectUIEvent(true, SelectUIEvent.EnumActivateModule.Kunde));
                _RaiseEvents.Publish(new ConfigureUITermineDaten(0, "10"));
                _RaiseEvents.Publish(new TerminSavedEvent(CurrentTermin.id));
            }

            return(true);
        }
Exemple #27
0
        public static bool DeleteCustumer(int id)
        {
            using (var db = new SteinbachEntities())
            {
                var cust = db.firmen.Where(c => c.id == id).SingleOrDefault();
                if (cust != null)
                {
                    db.DeleteObject(cust);
                    db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
                }
            }

            return(false);
        }
 private static config addKeyIfMissing(SteinbachEntities Context, string key)
 {
     try
     {
         var res = new config();
         res.mkey  = key;
         res.value = "0";
         Context.AddToconfig(res);
         Context.SaveChanges();
         return(res);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #29
0
        public static void TransferLagerbestaende()
        {
            using (var db = new SteinbachEntities())
            {
                var ll = db.lagerlisten;
                foreach (var item in ll)
                {
                    var lb = new Lagerbestaende();
                    lb.id_Lagerliste = item.id;
                    lb.id_Lagerort   = 1;
                    lb.Lagerbestand  = item.anzahlauflager;
                    db.AddToLagerbestaende(lb);
                }

                db.SaveChanges();
            }
        }
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            using (var test = new SteinbachEntities())
            {
                var beleg = new SI_Belege();
                beleg.id_Quelllager = 1;
                beleg.id_Ziellager  = 2;
                test.AddToSI_Belege(beleg);

                var bwg = test.lagerliste_addremove.Where(i => i.id == 16471).SingleOrDefault();
                bwg.id_Quelllager = 2;
                bwg.id_Ziellager  = 1;
                //test.AddTolagerliste_addremove(bwg);

                test.SaveChanges();
            }
        }