Пример #1
0
        /// <summary>
        /// Author: Georg Schmid
        /// </summary>
        /// <param name="senderButton"></param>
        public void pbNextEdit_Click(Button senderButton)
        {
            pEditClientPerson pPerson = getPageFromTabs <pEditClientPerson>();
            TabControl        tC      = this.parentTabControl;

            pPerson.EnableTabs();

            if (((TabItem)tC.Items.GetItemAt(0)).IsSelected)
            {
                if (((TabItem)tC.Items.GetItemAt(1)).IsEnabled)
                {
                    ((TabItem)tC.Items.GetItemAt(1)).Focus();
                }
                else
                {
                    ((TabItem)tC.Items.GetItemAt(2)).Focus();
                }
            }
            else if (((TabItem)tC.Items.GetItemAt(1)).IsSelected)
            {
                ((TabItem)tC.Items.GetItemAt(2)).Focus();
            }
        }
Пример #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"));
                }
            }
        }