Exemple #1
0
        public void UnpackFirmen(XmlElement root)
        {
            foreach (XmlNode element in root.ChildNodes)
            {
                Models.Firma firma = new Models.Firma();

                foreach (XmlNode item in element.ChildNodes)
                {
                    if (item.Name == "ID")
                    {
                        firma.ID = item.InnerText;
                    }
                    if (item.Name == "Name")
                    {
                        firma.Name = item.InnerText;
                    }
                    if (item.Name == "UID")
                    {
                        firma.UID = item.InnerText;
                    }
                    if (item.Name == "Adresse")
                    {
                        firma.Adresse = item.InnerText;
                    }
                    if (item.Name == "Ort")
                    {
                        firma.Ort = item.InnerText;
                    }
                    if (item.Name == "PLZ")
                    {
                        firma.PLZ = item.InnerText;
                    }
                    if (item.Name == "RechnungsAdresse")
                    {
                        firma.RechnungsAdresse = item.InnerText;
                    }
                    if (item.Name == "RechnungsOrt")
                    {
                        firma.RechnungsOrt = item.InnerText;
                    }
                    if (item.Name == "RechnungsPLZ")
                    {
                        firma.RechnungsPLZ = item.InnerText;
                    }
                    if (item.Name == "LieferAdresse")
                    {
                        firma.LieferAdresse = item.InnerText;
                    }
                    if (item.Name == "LieferOrt")
                    {
                        firma.LieferOrt = item.InnerText;
                    }
                    if (item.Name == "LieferPLZ")
                    {
                        firma.LieferPLZ = item.InnerText;
                    }
                }
                Firmen.Add(firma);
            }
        }
        public Firmen CreateFirmen(Firmen firmen)
        {
            var firmennew = _db.Firmens.Add(firmen);

            _db.SaveChanges();
            return(firmennew);
        }
        public Firmen UpdateFirmen(Firmen editedFirmen)
        {
            var updatedFirmen = (from f in _db.Firmens
                                 where f.FirmenId == editedFirmen.FirmenId
                                 select f).Single();

            updatedFirmen.Firma      = editedFirmen.Firma;
            updatedFirmen.StrHausnum = editedFirmen.StrHausnum;
            updatedFirmen.Plz        = editedFirmen.Plz;
            updatedFirmen.Ort        = editedFirmen.Ort;
            updatedFirmen.Telefon    = editedFirmen.Telefon;
            updatedFirmen.FaxNr      = editedFirmen.FaxNr;
            updatedFirmen.Email      = editedFirmen.Email;
            updatedFirmen.WWW        = editedFirmen.WWW;
            updatedFirmen.National   = editedFirmen.National;

            try
            {
                _db.Entry(updatedFirmen).State = EntityState.Modified;
                _db.SaveChanges();
                MessageBox.Show("Firma wurde erfolgreich speichert!", "Erfolg", MessageBoxButton.OK, MessageBoxImage.None);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                // Update the values of the entity that failed to save from the database
                ex.Entries.Single().Reload();
                MessageBox.Show("Der Datensatz, an dem Sie arbeiten, wurde von einem anderen Benutzer geändert. Die neuen Werte für diesen Datensatz werden jetzt aktualisiert." + Environment.NewLine + "Änderungen, die Sie vorgenommen haben, wurden nicht gespeichert. Bitte erneut einreichen.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(updatedFirmen);
        }
        // Initializes a new instance of the FirmenViewModel class.
        public FirmenViewModel(IFirmenDB firmenDB, IDialogService dialogservice)
        {
            try
            {
                _firmenDB      = firmenDB;
                _dialogservice = dialogservice;

                CurrentFirmen = new Firmen();

                FirmenList = new ObservableCollection <Firmen>();
                FirmenList = _firmenDB.GetAllFirmen();

                SelectedFirmen = FirmenList[0];

                //Command to Add new Firmen details
                ShowAddFirmenCommand = new RelayCommand(ShowAddFirmaView);

                // Command to Save Firmen details to FirmenDB
                SaveFirmenCommand = new RelayCommand(SaveFirmen, CanSaveFirmen);

                //Command to cancel action
                CancelFirmenCommand = new RelayCommand(CancelFirmaAction);

                //Command to delete Firma from table
                DeleteFirmenCommand = new RelayCommand(DeleteFirma, CanDeleteFirma);

                RefreshCommand = new RelayCommand(RefreshExecute);

                CurrentFirmen.IsOkChanged += OnCurrentFirmenPropertyChanged;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public bool FirmenExists(Firmen firmen)
        {
            var firmenExists = _db.Firmens.Any(f =>
                                               f.Firma == firmen.Firma &&
                                               f.Ort == firmen.Ort);

            return(firmenExists);
        }
        public ActionResult Details(int?id)
        {
            Firmen f = db.Firmen.Where(x => x.Id == id).FirstOrDefault();

            var pl = f.PersonenListe.ToList();

            return(View(f));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Firmen firmen = db.Firmen.Find(id);

            db.Firmen.Remove(firmen);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,PLZ")] Firmen firmen)
 {
     if (ModelState.IsValid)
     {
         db.Entry(firmen).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(firmen));
 }
        public Firmen DeleteFirmen(Firmen firmen)
        {
            var delFirmen = (from f in _db.Firmens
                             where f.FirmenId == firmen.FirmenId
                             select f).Single();

            _db.Firmens.Remove(delFirmen);
            _db.SaveChanges();
            return(delFirmen);
        }
        public ActionResult Create([Bind(Include = "Id,Name,PLZ")] Firmen firmen)
        {
            if (ModelState.IsValid)
            {
                db.Firmen.Add(firmen);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(firmen));
        }
 public void SearchList()
 {
     Firmen.Clear();
     foreach (Models.Firma item in FirmenList)
     {
         if (item.Name.Contains(Suche))
         {
             Firmen.Add(item);
         }
     }
 }
 private void UpdateFirma()
 {
     try
     {
         Firmen updatedFirma = _firmenDB.UpdateFirmen(CurrentFirmen);
         SelectedFirmen = updatedFirma;
     }
     catch (Exception e)
     {
         MessageBox.Show("Firma wurde nicht speichert. Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
        // GET: FirmenEF/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Firmen firmen = db.Firmen.Find(id);

            if (firmen == null)
            {
                return(HttpNotFound());
            }
            return(View(firmen));
        }
        public ActionResult FirmaZuordnenNeu(FormCollection fc)
        {
            int      pid = Convert.ToInt32(fc[0]);
            Personen p   = db.Personens.Where(x => x.Id == pid).FirstOrDefault();

            int    fid = Convert.ToInt32(fc[1]);
            Firmen f   = db.Firmen.Where(x => x.Id == fid).FirstOrDefault();

            p.FirmenListe.Add(f);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        //Checks if Dozent already exists in database
        private void CheckFirmaExists(Firmen newFirma)
        {
            bool FirmaExists = _firmenDB.FirmenExists(newFirma);

            if (FirmaExists)
            {
                MessageBox.Show("Firma Name und Ort existiert bereits.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                CreateFirmen(newFirma);
            }

            Messenger.Default.Send(new NotificationMessage("CloseAddFirmaView"));
            Cleanup();
        }
Exemple #16
0
        }                                               //Command to cancel/close window

        #endregion

        #region Ctor

        // Initializes a new instance of the AddFirmaViewModel class.
        public AddFirmaViewModel()
        {
            try
            {
                NewFirma = new Firmen();

                // Command to Add Firma details to Firmen DB
                AddCommand    = new RelayCommand(AddFirma, CanAddFirma);
                CancelCommand = new RelayCommand(CancelFirma);

                NewFirma.IsOkChanged += OnFirmaPropertyChanged;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        //To add Firma to DB
        private void CreateFirmen(Firmen firmen)
        {
            try
            {
                //Add new firma to DB
                Firmen FirmenAdded = _firmenDB.CreateFirmen(firmen);

                //Add new Firmen to ObservableCollection
                FirmenList.Add(FirmenAdded);

                MessageBox.Show("Firma wurde erfolgreich hinzufügt!", "Erfolg", MessageBoxButton.OK, MessageBoxImage.None);

                SelectedFirmen = FirmenAdded;
            }
            catch (Exception e)
            {
                MessageBox.Show("Firma wurde nicht hinzufügt. Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Exemple #18
0
        public void GeneralCommandMethod(object param)
        {
            switch (param as string)
            {
            case "Firma":
                Firmen.Clear();
                SearchFirma();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                Proceed();
                break;

            case "Person":
                Personen.Clear();
                SearchPerson();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                Proceed();
                break;

            case "Rechnung":
                Rechnungen.Clear();
                SearchRechnung();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                Proceed();
                break;

            case "ViewFirma":
                lViewDoubleClickFirma();
                break;

            case "ViewRechnung":
                lViewDoubleClickRechnung();
                break;

            case "ViewPerson":
                lViewDoubleClickPerson();
                break;

            case "AddFirma":
                Firma = new Models.Firma();
                lViewDoubleClickFirma();
                break;

            case "AddPerson":
                Person = new Models.Person();
                lViewDoubleClickPerson();
                break;

            case "AddRechnung":
                Rechnung = new Models.Rechnung();
                lViewDoubleClickRechnung();
                break;

            case "SearchRechnungen":
                Rechnungen.Clear();
                SearchRechnung();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                Proceed();
                break;

            case "DeleteFirma":
                DeleteFirma();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                break;

            case "DeletePerson":
                DeletePerson();
                Proxy.Instance.Send(data);
                Proxy.Instance.Receive();
                break;

            default:
                //DetailedInformationWindow window = new DetailedInformationWindow();
                //window.Show();
                break;
            }
        }
        private void DeleteFirma()
        {
            Firmen deletedFirmen = _firmenDB.DeleteFirmen(SelectedFirmen);

            FirmenList.Remove(deletedFirmen);
        }