示例#1
0
        /// <summary>
        /// Fügt einen neuen Titel der Datenbank hinzu
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int Add(string name)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var title = new Title
                {
                    Name=name
                };

                db.Titles.AddObject(title);
                db.SaveChanges();

                return title.TitleID;
            }
        }
示例#2
0
        /// <summary>
        /// Speichert bei Korrektheit aller Tabs die veränderten Kunden, Kinder, Partner und Einkommensdaten
        ///
        /// Author: Antonios Fesenmeier, Georg Schmid
        /// </summary>
        /// <param name="button"></param>
        public void pbSaveEdit_Click(Button button)
        {
            TabControl tC = this.parentTabControl;

            pEditClientPerson       pPerson       = getPageFromTabs <pEditClientPerson>();
            pEditClientPartnerChild pPartnerChild = getPageFromTabs <pEditClientPartnerChild>();
            pEditClientRevenues     pRevenues     = getPageFromTabs <pEditClientRevenues>();

            bool _PersonIsValid       = pPerson.checkPersonTab(),
                 _ChildPartnerIsValid = pPartnerChild.checkPartnerChildTab(),
                 _RevenuesIsValid     = pRevenues.checkRevenuesTab();

            if (_PersonIsValid == false)
            {
                pPerson.getErrorMsg();
            }
            pPerson.clearErrorMsg();

            if (((TabItem)tC.Items.GetItemAt(1)).IsEnabled)
            {
                if (_PersonIsValid && _ChildPartnerIsValid == false)
                {
                    pPartnerChild.getErrorMsg();
                }
            }
            pPartnerChild.clearErrorMsg();

            if (((TabItem)tC.Items.GetItemAt(2)).IsEnabled)
            {
                if (_PersonIsValid && _ChildPartnerIsValid && _RevenuesIsValid == false)
                {
                    pRevenues.getErrorMsg();
                }
            }
            pRevenues.clearErrorMsg();

            if (_PersonIsValid && _ChildPartnerIsValid && _RevenuesIsValid)
            {
                try
                {
                    // Daten für Person holen
                    DB.Title       title = pPerson.cbTitle.SelectedItem as DB.Title;
                    DB.FamilyState fS    = pPerson.cbFamilyState.SelectedItem as DB.FamilyState;

                    String   firstName     = pPerson.txtFirstName.Text;
                    String   lastName      = pPerson.txtLastName.Text;
                    String   street        = pPerson.txtStreet.Text;
                    String   nationality   = pPerson.txtNationalCountry.Text;
                    DateTime birthday      = (DateTime)pPerson.dpBirthday.SelectedDate;
                    int      group         = Convert.ToInt32(pPerson.cbGroup.SelectedValue.ToString());
                    int      zipCode       = Convert.ToInt32(pPerson.txtZipCode.Text);
                    String   city          = pPerson.txtCity.Text;
                    DateTime startDate     = (DateTime)pPerson.dpStartDate.SelectedDate;
                    DateTime endDate       = (DateTime)pPerson.dpEndDate.SelectedDate;
                    int      childs        = Convert.ToInt32(pPerson.txtChildrens.Content);
                    String   nativeCountry = pPerson.txtNativeCountry.Text;
                    String   email         = pPerson.txtEmail.Text;
                    String   mobileNo      = pPerson.txtMobileNo.Text;
                    String   phoneNo       = pPerson.txtTelno.Text;
                    int      tableNo       = Convert.ToInt32(pPerson.txtTableNo.Text);
                    // Daten für Partner holen

                    String   firstNamePartner     = pPartnerChild.txtFirstName1.Text;
                    String   lastNamePartner      = pPartnerChild.txtLastName1.Text;
                    String   nationalityPartner   = pPartnerChild.txtNationalCountry1.Text;
                    DateTime?birthdayPartner      = pPartnerChild.dpBirthday1.SelectedDate;
                    String   nativeCountryPartner = pPartnerChild.txtNativeCountry1.Text;
                    String   maritalPhone         = pPartnerChild.txtTelno1.Text;
                    String   maritalMobile        = pPartnerChild.txtMobileNo1.Text;
                    String   maritalEmail         = pPartnerChild.txtEmail1.Text;

                    DB.Title maritalTitle = pPartnerChild.cbTitle1.SelectedItem as DB.Title;

                    //TeamID mit UserID beschreiben
                    int userID = _UserAccount.UserAccountID;


                    //Person aktualisieren
                    int personID = pPerson.getPersonID();
                    if (maritalTitle != null)
                    {
                        DB.Person.Update(personID, title.TitleID, fS.FamilyStateID, userID, firstName, lastName, zipCode, city, street, nationality, tableNo, phoneNo, mobileNo, null, nativeCountry, birthday, email, group, startDate, endDate, birthdayPartner, firstNamePartner, lastNamePartner, nationalityPartner, null, nativeCountryPartner, maritalPhone, maritalMobile, maritalEmail, maritalTitle.TitleID);
                    }
                    else
                    {
                        DB.Person.Update(personID, title.TitleID, fS.FamilyStateID, userID, firstName, lastName, zipCode, city, street, nationality, tableNo, phoneNo, mobileNo, null, nativeCountry, birthday, email, group, startDate, endDate, birthdayPartner, firstNamePartner, lastNamePartner, nationalityPartner, null, nativeCountryPartner, maritalPhone, maritalMobile, maritalEmail);
                    }


                    // Alle Kinder holen und speichern
                    IList <DB.Child> lChilds = new List <DB.Child>();
                    lChilds = pPartnerChild.getChilds();

                    foreach (DB.Child aChild in lChilds)
                    {
                        String   aChildLastName  = aChild.LastName;
                        String   aChildFirstName = aChild.FirstName;
                        bool     aChildIsFemale  = aChild.IsFemale;
                        DateTime aChildsBirthday = aChild.DateOfBirth;

                        if (aChild.ChildID == 0)
                        {
                            var childID = DB.Child.Add(personID, aChildFirstName, aChildLastName, aChildsBirthday, aChildIsFemale);
                        }
                        else
                        {
                            DB.Child.Update(aChild.ChildID, aChildFirstName, aChildLastName, aChildsBirthday, aChildIsFemale);
                        }
                    }

                    // Alle Revenues holen und speichern
                    IList <DB.Revenue> lRevs = new List <DB.Revenue>();
                    lRevs = pRevenues.getRevenues();

                    foreach (DB.Revenue aRev in lRevs)
                    {
                        Double amount   = aRev.Amount;
                        String desc     = aRev.Description;
                        int    revTypID = aRev.RevenueType.RevenueTypeID;

                        if (aRev.RevenueID == 0)
                        {
                            var revenueID = DB.Revenue.Add(personID, revTypID, amount, aRev.StartDate, aRev.EndDate, desc);
                        }
                        else
                        {
                            DB.Revenue.Update(aRev.RevenueID, revTypID, amount, desc, aRev.StartDate, aRev.EndDate);
                        }
                    }

                    //Gelöschte Childs aus Datenbank entfernen
                    List <int> deletedChilds = pPartnerChild.getDeletedChilds();
                    foreach (int dchildID in deletedChilds)
                    {
                        if (dchildID != 0)
                        {
                            DB.Child.Delete(dchildID);
                        }
                    }

                    //Gelöschte Revenues aus Datenbank entfernen
                    List <int> deletedRevenues = pRevenues.getDeletedRevenues();
                    foreach (int drevID in deletedRevenues)
                    {
                        if (drevID != 0)
                        {
                            DB.Revenue.Delete(drevID);
                        }
                    }

                    //Zurück zur Verwaltung
                    KPage      pageClientAdministration = new KöTaf.WPFApplication.Views.pClientAdministration(pagingStartValue);
                    SinglePage singlePage = new SinglePage(IniParser.GetSetting("CLIENT", "clientManagement"), pageClientAdministration);
                }
                catch
                {
                    MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "common"));
                }
            }
        }
示例#3
0
        /// <summary>
        /// Überprüft alle Untertabs auf Vollständigkeit/ Korrektheit und speichert
        /// bei Korrektheit alle Kinder, Partner, die Person selbst und deren Einkommen
        /// mit allen Abhängigkeiten in die Datenbank
        ///
        /// Author: Antonios Fesenmeier
        /// </summary>
        /// <param name="button"></param>
        public void pbSave_Click(Button button)
        {
            TabControl tC = this.parentTabControl;

            pNewClientPerson       pPerson       = getPageFromTabs <pNewClientPerson>();
            pNewClientPartnerChild pPartnerChild = getPageFromTabs <pNewClientPartnerChild>();
            pNewClientRevenues     pRevenues     = getPageFromTabs <pNewClientRevenues>();

            bool _PersonIsValid       = pPerson.checkPersonTab(),
                 _ChildPartnerIsValid = pPartnerChild.checkPartnerChildTab(),
                 _RevenuesIsValid     = pRevenues.checkRevenuesTab();

            if (_PersonIsValid == false)
            {
                pPerson.getErrorMsg();
            }
            pPerson.clearErrorMsg();

            if (((TabItem)tC.Items.GetItemAt(1)).IsEnabled)
            {
                if (_PersonIsValid && _ChildPartnerIsValid == false)
                {
                    pPartnerChild.getErrorMsg();
                }
            }
            pPartnerChild.clearErrorMsg();

            if (((TabItem)tC.Items.GetItemAt(2)).IsEnabled)
            {
                if (_PersonIsValid && _ChildPartnerIsValid && _RevenuesIsValid == false)
                {
                    pRevenues.getErrorMsg();
                }
            }
            pRevenues.clearErrorMsg();

            if (_PersonIsValid && _ChildPartnerIsValid && _RevenuesIsValid)
            {
                try
                {
                    // Daten für Person holen
                    DB.Title       title = pPerson.cbTitle.SelectedItem as DB.Title;
                    DB.FamilyState fS    = pPerson.cbFamilyState.SelectedItem as DB.FamilyState;

                    String   firstName     = pPerson.txtFirstName.Text;
                    String   lastName      = pPerson.txtLastName.Text;
                    String   street        = pPerson.txtStreet.Text;
                    String   nationality   = pPerson.txtNationalCountry.Text;
                    DateTime birthday      = (DateTime)pPerson.dpBirthday.SelectedDate;
                    int      group         = Convert.ToInt32(pPerson.cbGroup.SelectedValue.ToString());
                    int      zipCode       = Convert.ToInt32(pPerson.txtZipCode.Text);
                    String   city          = pPerson.txtCity.Text;
                    DateTime startDate     = (DateTime)pPerson.dpStartDate.SelectedDate;
                    DateTime endDate       = (DateTime)pPerson.dpEndDate.SelectedDate;
                    int      childs        = Convert.ToInt32(pPerson.txtChildrens.Content);
                    String   nativeCountry = pPerson.txtNativeCountry.Text;
                    String   email         = pPerson.txtEmail.Text;
                    String   mobileNo      = pPerson.txtMobileNo.Text;
                    String   phoneNo       = pPerson.txtTelno.Text;
                    int      tableNo       = Convert.ToInt32(pPerson.txtTableNo.Text);
                    // Daten für Partner holen

                    String   firstNamePartner     = pPartnerChild.txtFirstName1.Text;
                    String   lastNamePartner      = pPartnerChild.txtLastName1.Text;
                    String   nationalityPartner   = pPartnerChild.txtNationalCountry1.Text;
                    DateTime?birthdayPartner      = pPartnerChild.dpBirthday1.SelectedDate;
                    String   nativeCountryPartner = pPartnerChild.txtNativeCountry1.Text;
                    String   maritalPhone         = pPartnerChild.txtTelno1.Text;
                    String   maritalMobile        = pPartnerChild.txtMobileNo1.Text;
                    String   maritalEmail         = pPartnerChild.txtEmail1.Text;

                    DB.Title maritalTitle   = pPartnerChild.cbTitle1.SelectedItem as DB.Title;
                    int      maritalTitleID = maritalTitle.TitleID;

                    //UserID beschreiben
                    int userID = _UserAccount.UserAccountID;

                    // Person speichern
                    var personID = DB.Person.Add(title.TitleID, fS.FamilyStateID, firstName, lastName, street, nationality, birthday, group, zipCode, city, startDate, endDate,
                                                 userID, nativeCountry, email, mobileNo, phoneNo, firstNamePartner, lastNamePartner, nationalityPartner, birthdayPartner, nativeCountryPartner, maritalPhone, maritalMobile, maritalEmail, maritalTitle.TitleID, null, tableNo);

                    // Alle Kinder holen und speichern
                    IList <DB.Child> lChilds = new List <DB.Child>();
                    lChilds = pPartnerChild.getChilds();

                    foreach (DB.Child aChild in lChilds)
                    {
                        String   aChildLastName  = aChild.LastName;
                        String   aChildFirstName = aChild.FirstName;
                        bool     aChildIsFemale  = aChild.IsFemale;
                        DateTime aChildsBirthday = aChild.DateOfBirth;

                        var childID = DB.Child.Add(personID, aChildFirstName, aChildLastName, aChildsBirthday, aChildIsFemale);
                    }

                    // Alle Revenues holen und speichern
                    IList <DB.Revenue> lRevs = new List <DB.Revenue>();
                    lRevs = pRevenues.getRevenues();

                    foreach (DB.Revenue aRev in lRevs)
                    {
                        Double amount   = aRev.Amount;
                        String desc     = aRev.Description;
                        int    revTypID = aRev.RevenueType.RevenueTypeID;


                        var revenueID = DB.Revenue.Add(personID, revTypID, amount, aRev.StartDate, aRev.EndDate, desc);
                    }

                    //Wenn erfolgreich Dokumente Drucken
                    MessageBoxResult result1 = MessageBoxEnhanced.Question("Möchten Sie für diesen neuen Kunden das Aufnahmeformular jetzt drucken?");
                    if (result1 == MessageBoxResult.Yes)
                    {
                        PrintForms.printClientEnrolmentForm(personID);
                    }

                    MessageBoxResult result2 = MessageBoxEnhanced.Question("Möchten Sie für diesen neuen Kunden die Widerrufbelehrung jetzt drucken?");
                    if (result2 == MessageBoxResult.Yes)
                    {
                        PrintForms.printClientDisclaimer(personID);
                    }

                    //Zurück zur Verwaltung
                    KPage      pageClientAdministration = new KöTaf.WPFApplication.Views.pClientAdministration();
                    SinglePage singlePage = new SinglePage(IniParser.GetSetting("CLIENT", "clientManagement"), pageClientAdministration);
                }
                catch
                {
                    MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "common"));
                }
            }
        }
示例#4
0
 /// <summary>
 /// Erstellt ein neues Title-Objekt.
 /// </summary>
 /// <param name="titleID">Anfangswert der Eigenschaft TitleID.</param>
 /// <param name="name">Anfangswert der Eigenschaft Name.</param>
 public static Title CreateTitle(global::System.Int32 titleID, global::System.String name)
 {
     Title title = new Title();
     title.TitleID = titleID;
     title.Name = name;
     return title;
 }
示例#5
0
 /// <summary>
 /// Veraltete Methode zum Hinzufügen eines neuen Objekts zum EntitySet 'Titles'. Verwenden Sie stattdessen die Methode '.Add' der zugeordneten Eigenschaft 'ObjectSet&lt;T&gt;'.
 /// </summary>
 public void AddToTitles(Title title)
 {
     base.AddObject("Titles", title);
 }