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) => { foreach (var extension in Extensions) extension.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(); } }
public void TestFixtureSetUp() { formatInfo = new NameFormatInfo(); }
public void UpdatePerson(Person person, SqlTransaction sqlTransac) { UpdateTiers(person, sqlTransac); const string q = @"UPDATE [Persons] SET [first_name]=@firstName ,[sex]=@sex ,[identification_data]=@identificationData ,[last_name]=@lastName ,[birth_date]=@birthDate ,[activity_id]=@activityId ,[father_name]=@fathername ,[image_path]=@image ,[birth_place] = @birthPlace ,[nationality] = @nationality WHERE id = @id"; using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac)) { var formatInfo = new NameFormatInfo(); var settings = ApplicationSettings.GetInstance(""); //var fnFormat = @"{0:" + settings.FirstNameFormat + @"}"; //var lnFormat = @"{0:" + settings.LastNameFormat + @"}"; //person.FirstName = string.Format(formatInfo, fnFormat, person.FirstName); //person.LastName = string.Format(formatInfo, lnFormat, person.LastName); person.FirstName = string.Format(formatInfo, person.FirstName); person.LastName = string.Format(formatInfo, person.LastName); c.AddParam("@birthPlace", person.BirthPlace); c.AddParam("@nationality", person.Nationality); c.AddParam("@id", person.Id); c.AddParam("@firstName", person.FirstName); c.AddParam("@sex", person.Sex); c.AddParam("@identificationData", person.IdentificationData); c.AddParam("@lastName", person.LastName); c.AddParam("@birthDate", person.DateOfBirth); c.AddParam("@fathername", person.FatherName); c.AddParam("@image", person.Image); if (person.Activity != null) c.AddParam("@activityId", person.Activity.Id); else c.AddParam("@activityId", null); c.ExecuteNonQuery(); } }
public void UpdatePerson(Person person, SqlTransaction sqlTransac) { UpdateTiers(person, sqlTransac); const string q = @"UPDATE [Persons] SET [first_name]=@firstName ,[sex]=@sex ,[identification_data]=@identificationData ,[last_name]=@lastName ,[birth_date]=@birthDate ,[household_head]=@householdHead ,[nb_of_dependents]=@nbOfDependents ,[nb_of_children]=@nbOfChildren ,[children_basic_education]=@childrenBasicEducation ,[livestock_number]=@livestockNumber ,[livestock_type]=@livestockType ,[landplot_size]=@landPlotSize ,[home_size]=@homeSize ,[home_time_living_in]=@homeTimeLivingIn ,[capital_other_equipments]=@capitalOtherEquipments ,[activity_id]=@activityId ,[experience]=@experience ,[nb_of_people]=@nbOfPeople ,[father_name]=@fathername ,[mother_name]=@mothername ,[image_path]=@image ,[study_level] = @studyLevel ,[birth_place] = @birthPlace ,[nationality] = @nationality ,[SS] = @SS ,[CAF] = @CAF ,[housing_situation] = @housing_situation ,[unemployment_months] = @UnemploymentMonths ,[handicapped] = @handicapped ,[professional_situation] = @ProfessionalSituation ,[professional_experience] = @ProfessionalExperience ,[first_contact] = @firstContact ,[first_appointment] = @firstAppointment ,[family_situation] = @family_situation ,[povertylevel_healthsituation]=@povertyLevelHealthSituation ,[povertylevel_childreneducation]=@povertyLevelChildrenEducation ,[povertylevel_socialparticipation]=@povertyLevelSocialParticipation ,[povertylevel_economiceducation]= @povertyLevelEconomicEducation WHERE id = @id"; using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac)) { var formatInfo = new NameFormatInfo(); var settings = ApplicationSettings.GetInstance(""); var fnFormat = @"{0:" + settings.FirstNameFormat + @"}"; var lnFormat = @"{0:" + settings.LastNameFormat + @"}"; person.FirstName = string.Format(formatInfo, fnFormat, person.FirstName); person.LastName = string.Format(formatInfo, lnFormat, person.LastName); c.AddParam("@handicapped", person.Handicapped); c.AddParam("@studyLevel", person.StudyLevel); c.AddParam("@firstContact", person.FirstContact); c.AddParam("@firstAppointment", person.FirstAppointment); c.AddParam("@ProfessionalSituation", person.ProfessionalSituation); c.AddParam("@ProfessionalExperience", person.ProfessionalExperience); c.AddParam("@birthPlace", person.BirthPlace); c.AddParam("@nationality", person.Nationality); c.AddParam("@UnemploymentMonths", person.UnemploymentMonths); c.AddParam("@SS", person.SSNumber); c.AddParam("@CAF", person.CAFNumber); c.AddParam("@housing_situation", person.HousingSituation); c.AddParam("@id", person.Id); c.AddParam("@firstName", person.FirstName); c.AddParam("@sex", person.Sex); c.AddParam("@identificationData", person.IdentificationData); c.AddParam("@lastName", person.LastName); c.AddParam("@birthDate", person.DateOfBirth); c.AddParam("@householdHead", person.HouseHoldHead); c.AddParam("@nbOfDependents", person.NbOfDependents); c.AddParam("@nbOfChildren", person.NbOfChildren); c.AddParam("@childrenBasicEducation", person.ChildrenBasicEducation); c.AddParam("@livestockNumber", person.LivestockNumber); c.AddParam("@livestockType", person.LivestockType); c.AddParam("@landPlotSize", person.LandplotSize); c.AddParam("@homeSize", person.HomeSize); c.AddParam("@homeTimeLivingIn", person.HomeTimeLivingIn); c.AddParam("@capitalOtherEquipments", person.CapitalOthersEquipments); c.AddParam("@experience", person.Experience); c.AddParam("@nbOfPeople", person.NbOfPeople); c.AddParam("@fathername", person.FatherName); c.AddParam("@mothername", person.MotherName); c.AddParam("@image", person.Image); c.AddParam("@family_situation", person.FamilySituation); c.AddParam("@povertyLevelChildrenEducation", person.PovertyLevelIndicators.ChildrenEducation); c.AddParam("@povertyLevelHealthSituation", person.PovertyLevelIndicators.HealthSituation); c.AddParam("@povertyLevelSocialParticipation", person.PovertyLevelIndicators.SocialParticipation); c.AddParam("@povertyLevelEconomicEducation", person.PovertyLevelIndicators.EconomicEducation); if (person.Activity != null) c.AddParam("@activityId", person.Activity.Id); else c.AddParam("@activityId", null); c.ExecuteNonQuery(); } }