Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (purData == null)
            {
                purData = new PurchaserData();
            }


            if (purData.Purchaser == null)
            {
                purData.Purchaser = new Purchaser();
            }


            Purchaser pur = purData.Purchaser;

            //purData = new PurchaserData();
            pur.HomeAdress = new Adress();
            InputEvaluator ie   = new InputEvaluator();
            bool           save = true;

            if (doubles())
            {
                SystemSounds.Asterisk.Play();
                switch (MessageBox.Show("Es existiert bereits ein Auftraggeber mit diesem Namen. Soll er wirklich hinzugefügt werden?",
                                        "Achtung!",
                                        MessageBoxButton.YesNo, MessageBoxImage.Question))
                {
                case MessageBoxResult.No:
                    save = false;
                    break;

                case MessageBoxResult.Yes:
                    break;
                }
            }


            if (save)
            {
                if (ie.Evaluate(this))
                {
                    pur.FirstName = FirstName.getContent();
                    pur.LastName  = LastName.getmustContent();
                    pur.EMail     = Email.getContent();
                    if (PhoneNr.getContent() != null)
                    {
                        pur.PhoneNumber = PhoneNr.getContent();
                    }
                    if (MobileNr.getContent() != null)
                    {
                        pur.MobilePhone = MobileNr.getContent();
                    }
                    pur.HomeAdress.Street      = Street.getContent();
                    pur.HomeAdress.StairNumber = parseInt(StairNr.getContent());
                    pur.HomeAdress.HouseNumber = parseInt(HNr.getContent());
                    pur.HomeAdress.Etage       = parseInt(Etage.getContent());
                    pur.HomeAdress.DoorNumber  = parseInt(DoorNr.getContent());
                    pur.HomeAdress.City        = City.getContent();
                    pur.HomeAdress.Country     = Country.getContent();
                    pur.HomeAdress.ZipCode     = parseInt(ZIP.getContent());
                    pur.BIC                       = BIC.getContent();
                    pur.IBAN                      = IBAN.getContent();
                    pur.SVN                       = parseLong(SVN.getContent());
                    pur.AccountHolder             = kontoinhaber.getContent();
                    pur.EntryDate                 = EntryDate.SelectedDate;
                    pur.ApprovalBegin             = ApprovelFrom.SelectedDate;
                    pur.ApprovalEnd               = ApprovelTo.SelectedDate;
                    pur.nationality               = nationality.getContent();
                    purData.HourlyRate            = parseDecimal(PayperHour.getContent());
                    purData.TravellingAllowanceKM = parseDecimal(KmPay.getContent());
                    purData.HourlyRatePayoff      = parseDecimal(billablePayperHour.getContent());
                    purData.Income                = parseDecimal(Income.getContent());
                    purData.AssistenceDemand      = parseInt(Needof.getContent());
                    purData.InputIncome           = parseDecimal(IncomeBetrag.getContent());
                    purData.CareAllowance         = parseInt((string)CareAllowence.SelectedValue);
                    pur.DistrictCommision         = districtcommission.getContent();
                    if ((bool)activeRadioBtn.IsChecked)
                    {
                        pur.Active = true;
                    }

                    if ((bool)einfuehrungskurs.IsChecked)
                    {
                        pur.hasContract = true;
                    }
                    if ((bool)contract.IsChecked)
                    {
                        pur.hasIntroCourse = true;
                    }

                    //switch to Übersicht
                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window.GetType() == typeof(Main))
                        {
                            (window as Main).FrameÜbersicht.Source = new Uri("../Personenverwaltung/AG/AGÜbersicht.xaml", UriKind.Relative);
                        }
                    }
                    purData.Purchaser = pur;
                    if (pur.FirstName != null && pur.LastName != null)
                    {
                        _bl.CreatePurchaser(purData);
                    }

                    //add PA connection
                    PAtoPurchaserBL PBL = new PAtoPurchaserBL();

                    foreach (PersonalAssistant pa in addedPAs)
                    {
                        foreach (PersonalAssistant pad in deletedPAs)
                        {
                            if (pa.Id == pad.Id)
                            {
                                addedPAs.Remove(pa);
                                deletedPAs.Remove(pad);
                            }
                        }
                    }


                    foreach (PersonalAssistant pa in addedPAs)
                    {
                        PBL.add(pa, pur);
                    }

                    //delete PA connection
                    foreach (PersonalAssistant pa in deletedPAs)
                    {
                        PBL.delete(pa, pur);
                    }
                }
            }
        }
Пример #2
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            Purchaser purU = new Purchaser();


            if (purData.Purchaser.ContactPerson != null)
            {
                purU.ContactPerson = new Person();
                purU.ContactPerson = purData.Purchaser.ContactPerson;
            }

            PurchaserData purDataU = new PurchaserData();

            purU.HomeAdress = new Adress();
            InputEvaluator ie = new InputEvaluator();


            if (ie.Evaluate(this))
            {
                purU.Id        = AGidx;
                purU.FirstName = FirstName.getContent();
                purU.LastName  = LastName.getmustContent();
                purU.EMail     = Email.getContent();
                if (PhoneNr.getContent() != null)
                {
                    purU.PhoneNumber = PhoneNr.getContent();
                }
                if (MobileNr.getContent() != null)
                {
                    purU.MobilePhone = MobileNr.getContent();
                }
                purU.HomeAdress.AdressId    = purData.Purchaser.HomeAdress.AdressId;
                purU.HomeAdress.Street      = Street.getContent();
                purU.HomeAdress.StairNumber = parseInt(StairNr.getContent());
                purU.HomeAdress.HouseNumber = parseInt(HNr.getContent());
                purU.HomeAdress.Etage       = parseInt(Etage.getContent());
                purU.HomeAdress.DoorNumber  = parseInt(DoorNr.getContent());
                purU.HomeAdress.City        = City.getContent();
                purU.HomeAdress.Country     = Country.getContent();
                purU.HomeAdress.ZipCode     = parseInt(ZIP.getContent());
                purU.EntryDate         = EntryDate.DisplayDate;
                purU.ApprovalBegin     = ApprovelFrom.DisplayDate;
                purU.ApprovalEnd       = ApprovelTo.DisplayDate;
                purU.DistrictCommision = districtcommission.getContent();
                purU.nationality       = nationality.getContent();
                purU.SVN = parseLong(SVN.getContent());


                purDataU.HourlyRate            = parseDecimal(PayperHour.getContent());
                purDataU.TravellingAllowanceKM = parseDecimal(KmPay.getContent());
                purDataU.HourlyRatePayoff      = parseDecimal(billablePayperHour.getContent());
                purDataU.Income              = parseDecimal(Income.getContent());
                purDataU.AssistenceDemand    = parseInt(Needof.getContent());
                purDataU.InputIncome         = parseDecimal(IncomeBetrag.getContent());
                purDataU.CareAllowance       = parseInt((string)CareAllowence.SelectedValue);
                purDataU.Purchaser.InfoField = purData.Purchaser.InfoField;
                purDataU.Year      = purData.Year;
                purDataU.Month     = purData.Month;
                purU.IBAN          = IBAN.getContent();
                purU.BIC           = BIC.getContent();
                purU.AccountHolder = kontoinhaber.getContent();

                if ((bool)activeRadioBtn.IsChecked)
                {
                    purU.Active = true;
                }
                else if ((bool)inactiveRadioBtn.IsChecked)
                {
                    purU.Active = false;
                }


                if ((bool)einfuehrungskurs.IsChecked)
                {
                    purU.hasContract = true;
                }
                if ((bool)contract.IsChecked)
                {
                    purU.hasIntroCourse = true;
                }

                if (purDataU.Purchaser.Employees != null)
                {
                    foreach (EmploymentStatus emp in purData.Purchaser.Employees)
                    {
                        bool found = false;
                        foreach (PersonalAssistant pa in employedPA)
                        {
                            if (pa.Id.Equals(emp.Assistant.Id))
                            {
                                found = true;
                            }
                        }
                        if (found)
                        {
                            purU.Employees.Add(emp);
                        }
                    }
                }

                //add PA connection
                PAtoPurchaserBL PBL = new PAtoPurchaserBL();

                foreach (PersonalAssistant pa in addedPAs)
                {
                    foreach (PersonalAssistant pad in deletedPAs)
                    {
                        if (pa.Id == pad.Id)
                        {
                            addedPAs.Remove(pa);
                            deletedPAs.Remove(pad);
                        }
                    }
                }


                foreach (PersonalAssistant pa in addedPAs)
                {
                    PBL.add(pa, purU);
                }

                //delete PA connection
                foreach (PersonalAssistant pa in deletedPAs)
                {
                    PBL.delete(pa, purU);
                }


                //delete PA connection

                //AKTIV RADIO BOXEN NAMEN

                //switch to Übersicht



                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Main))
                    {
                        (window as Main).FrameÜbersicht.Source = new Uri("../Personenverwaltung/AG/AGÜbersicht.xaml", UriKind.Relative);
                    }
                }
            }
            purU.InfoField     = purData.Purchaser.InfoField;
            purDataU.Purchaser = purU;
            if (purU.FirstName != null && purU.LastName != null)
            {
                bl.UpdatePurchaser(purDataU);
            }
        }