protected void btnSave_Click(object sender, EventArgs e) { var employee = new Employee(); if (employeeId != 0) { var originalEmployee = HumanResourcesManager.GetEmployee(Company.CompanyId, employeeId); employee.CopyPropertiesFrom(originalEmployee); } employee.ModifiedByUser = User.Identity.UserName; HidrateEmployee(employee); HumanResourcesManager.SaveEmployee(employee); if (employeeId == 0) Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='Employees.aspx';", true); }
public InsertCompanyStatus InsertUser(int companyId, User user, Profile profile, int? depositId) { // // If ProfileId equal 0 then the profile no exists in bd // var pManager = new ProfileManager(this); if (profile.ProfileId == 0) pManager.Insert(profile); // //method to insert a new user // var provider = Membership.Provider as VivinaMembershipProvider; MembershipCreateStatus status; var membershipManager = new MembershipManager(this); user.ProfileId = profile.ProfileId; membershipManager.Insert(user, out status, provider.RequiresValidEmail); // //verify if the status of the inclusion is ok // if (status != MembershipCreateStatus.Success) { DataManager.Rollback(); switch (status) { case MembershipCreateStatus.InvalidPassword: return InsertCompanyStatus.InvalidPassword; case MembershipCreateStatus.DuplicateEmail: return InsertCompanyStatus.DuplicatedAdminEmail; } } // // Associate the User with company // AssociateUser(companyId, user.UserId, depositId, true); // // Insert a Employee // var humanResourcesManager = new HumanResourcesManager(this); var employee = new Employee(); employee.IsActive = true; employee.ProfileId = profile.ProfileId; employee.CompanyId = companyId; humanResourcesManager.InsertEmployee(employee, new List<EmployeeAdditionalInformation>()); return InsertCompanyStatus.Success; }
/// <summary> /// Populate the employee object to be inserted/updated. Need to be revise /// since the button is outside of Iframe /// </summary> /// <param name="employee"></param> public void HidrateEmployee(Employee employee) { // // Initialize nullables fields // employee.OrganizationlevelId = null; employee.BankId = null; employee.AlienationId = null; employee.AlienationDate = null; employee.ConfederacyContributionId = null; employee.AssociatedContribution1Id = null; employee.AssociatedContribution2Id = null; employee.SindicalContributionId = null; employee.SupportContributionId = null; employee.Agency = txtAgency.Text; employee.AccountNumber = txtAccountingNumber.Text; employee.Salary = ucCurrFieldSalary.CurrencyValue; employee.HH = ucCurrFieldtxtHH.CurrencyValue; employee.Ctps = txtCtps.Text; employee.CtpsSerial = txtCtpsSerial.Text; employee.Pis = txtPis.Text; employee.ModifiedDate = DateTime.Now; employee.WorkingHours = ucCurrrFieldHoursWeek.IntValue; employee.IsSalesperson = chkIsSalesPerson.Checked; employee.IsTechnical = chkIsTechnical.Checked; employee.Comission = ucCurrComission.CurrencyValue; employee.AdmissionDate = ucDtAdmissionDate.DateTime; employee.Enrollment = txtEnrollment.Text; employee.CompanyId = Company.CompanyId; if (!String.IsNullOrEmpty(cboOrgLevel.SelectedValue)) employee.OrganizationlevelId = Convert.ToInt32(cboOrgLevel.SelectedValue); if (!String.IsNullOrEmpty(cboBank.SelectedValue)) employee.BankId = Convert.ToInt32(cboBank.SelectedValue); if (ucCurrFieldWorkingHours.CurrencyValue.HasValue) employee.WorkingHours = Convert.ToInt32(ucCurrFieldWorkingHours.CurrencyValue.Value); if (ucCurrFieldFGTS.CurrencyValue.HasValue) employee.Fgts = ucCurrFieldFGTS.CurrencyValue.Value; if (ucCurrFieldHealthFuless.CurrencyValue.HasValue) employee.Healthfulless = ucCurrFieldHealthFuless.CurrencyValue.Value; if (ucCurrFieldHazardPay.CurrencyValue.HasValue) employee.HazardPay = ucCurrFieldHazardPay.CurrencyValue.Value; if (ucCurrFieldOtherIncomes.CurrencyValue.HasValue) employee.OtherIncomes = ucCurrFieldOtherIncomes.CurrencyValue.Value; if (ucCurrFieldAnuency.CurrencyValue.HasValue) employee.Anuency = ucCurrFieldAnuency.CurrencyValue.Value; if (!String.IsNullOrEmpty(cboBond.SelectedValue)) employee.BondId = Convert.ToInt32(cboBond.SelectedValue); if (!String.IsNullOrEmpty(cboPost.SelectedValue)) employee.PostId = Convert.ToInt32(cboPost.SelectedValue); if (!String.IsNullOrEmpty(cboShift.SelectedValue)) employee.ShiftId = Convert.ToInt32(cboShift.SelectedValue); if (!String.IsNullOrEmpty(cboWorkJourney.SelectedValue)) employee.WorkJourneyId = Convert.ToInt32(cboWorkJourney.SelectedValue); if (!String.IsNullOrEmpty(txtJourneyBegin.Text)) employee.JourneyBegin = Convert.ToDateTime(txtJourneyBegin.Text); if (!String.IsNullOrEmpty(txtJourneyEnd.Text)) employee.JourneyEnd = Convert.ToDateTime(txtJourneyEnd.Text); if (!String.IsNullOrEmpty(txtIntervalBegin.Text)) employee.IntervalBegin = Convert.ToDateTime(txtIntervalBegin.Text); if (!String.IsNullOrEmpty(txtIntervalEnd.Text)) employee.IntervalEnd = Convert.ToDateTime(txtIntervalEnd.Text); if (rbtAway.Checked) { employee.IsActive = false; employee.AlienationId = Convert.ToInt32(cboEmployeeAlienationCause.SelectedValue); employee.AlienationDate = ucDtEmployeeAwayDate.DateTime; } else employee.IsActive = true; }