public void TestFixtureSetUp()
 {
     formatInfo = new NameFormatInfo();
 }
Example #2
0
        private void SavePerson()
        {
            _personSaved = false;
            RecoverDatasFromUserControlsAddress();
            RecoverDataFromCombobox();

            _tempPerson.FirstContact     = dateTimePickerFirstContact.Value;
            _tempPerson.FirstAppointment = dateTimePickerFirstAppointment.Value;
            _tempPerson.Branch           = (Branch)cbBranch.SelectedItem;

            try
            {
                bool save = 0 == _tempPerson.Id;
                if (_tempPerson.FirstName != null)
                {
                    _tempPerson.FirstName = _tempPerson.FirstName.Trim();
                }
                if (_tempPerson.LastName != null)
                {
                    _tempPerson.LastName = _tempPerson.LastName.Trim();
                }
                if (_tempPerson.FatherName != null)
                {
                    _tempPerson.FatherName = _tempPerson.FatherName.Trim();
                }
                if (_tempPerson.IdentificationData != null)
                {
                    _tempPerson.IdentificationData = _tempPerson.IdentificationData.Trim();
                }
                _tempPerson.Nationality = textBoxNationality.Text;

                string result = ServicesProvider
                                .GetInstance()
                                .GetClientServices()
                                .SavePerson(ref _tempPerson, (tx, id) =>
                {
                    foreach (var extension in Extensions)
                    {
                        extension.Save(_tempPerson, tx);
                    }
                });

                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                es.LogClientSaveUpdateEvent(_tempPerson, save);

                if (result != string.Empty)
                {
                    MessageBox.Show(result, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                _personSaved    = true;
                buttonSave.Text = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");

                var formatInfo = new NameFormatInfo();
                var settings   = ServicesProvider.GetInstance().GetGeneralSettings();
                //var fnFormat = @"{0:" + settings.FirstNameFormat + @"}";
                //var lnFormat = @"{0:" + settings.LastNameFormat + @"}";
                textBoxFirstName.Text = string.Format(_tempPerson.FirstName);
                textBoxLastname.Text  = string.Format(_tempPerson.LastName);
                if (_tempPerson.FatherName != null)
                {
                    textBoxFatherName.Text = string.Format(_tempPerson.FatherName);
                }
                textBoxIdentificationData.Text = string.Format(_tempPerson.IdentificationData);
                //EnableDocuments();
                ResetImagesFlags();

                if (ApplicationSettings.GetInstance(User.CurrentUser.Md5).UseMandatorySavingAccount&&
                    Person.Savings.Count == 0)
                {
                    Person.Savings.Add(
                        ServicesProvider.GetInstance().GetSavingServices().AddAndActivateDefaultSavingAccount(Person));
                    DisplaySavings(Person.Savings);
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Example #3
0
        private void SavePerson()
        {
            _personSaved = false;
            RecoverDatasFromUserControlsAddress();
            RecoverDataFromCombobox();

            _tempPerson.FirstContact     = dateTimePickerFirstContact.Value;
            _tempPerson.FirstAppointment = dateTimePickerFirstAppointment.Value;
            _tempPerson.Branch           = (Branch)cbBranch.SelectedItem;

            try
            {
                bool save = 0 == _tempPerson.Id;
                if (_tempPerson.FirstName != null)
                {
                    _tempPerson.FirstName = _tempPerson.FirstName.Trim();
                }
                if (_tempPerson.LastName != null)
                {
                    _tempPerson.LastName = _tempPerson.LastName.Trim();
                }
                if (_tempPerson.FatherName != null)
                {
                    _tempPerson.FatherName = _tempPerson.FatherName.Trim();
                }
                if (_tempPerson.IdentificationData != null)
                {
                    _tempPerson.IdentificationData = _tempPerson.IdentificationData.Trim();
                }

                if (_advancedFieldsControl != null)
                {
                    _advancedFieldsControl.Check();
                }

                string result = ServicesProvider
                                .GetInstance()
                                .GetClientServices()
                                .SavePerson(ref _tempPerson, (tx, id) => _extensionPersons.ForEach(p => p.Save(_tempPerson, tx)));

                if (_tempPerson.Id > 0 && _advancedFieldsControl != null)
                {
                    _advancedFieldsControl.Save(_tempPerson.Id);
                }

                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                es.LogClientSaveUpdateEvent(_tempPerson, save);

                if (result != string.Empty)
                {
                    MessageBox.Show(result, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                _personSaved    = true;
                buttonSave.Text = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");

                var formatInfo = new NameFormatInfo();
                var settings   = ServicesProvider.GetInstance().GetGeneralSettings();
                var fnFormat   = @"{0:" + settings.FirstNameFormat + @"}";
                var lnFormat   = @"{0:" + settings.LastNameFormat + @"}";
                textBoxFirstName.Text = string.Format(_tempPerson.FirstName);
                textBoxLastname.Text  = string.Format(_tempPerson.LastName);
                if (_tempPerson.FatherName != null)
                {
                    textBoxFatherName.Text = string.Format(_tempPerson.FatherName);
                }
                textBoxIdentificationData.Text = string.Format(_tempPerson.IdentificationData);
                //EnableDocuments();
                ResetImagesFlags();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }