private void AddEmployeeData() { try { int empID = 0; bool isExist = false; string empCode = string.Empty; string fullName = string.Empty; string _userMailId = string.Empty; Rave.HR.BusinessLayer.Recruitment.Recruitment recruitmentBL = new Rave.HR.BusinessLayer.Recruitment.Recruitment(); BusinessEntities.Recruitment recruitment = null; BusinessEntities.Employee addEmployee = new BusinessEntities.Employee(); Rave.HR.BusinessLayer.Employee.Employee addEmployeeBAL = new Rave.HR.BusinessLayer.Employee.Employee(); addEmployee.Prefix = Convert.ToInt32(ddlPrefix.SelectedItem.Value); addEmployee.EMPCode = txtEmployeeCode.Text.Trim(); addEmployee.FirstName = txtFirstName.Text.Trim(); addEmployee.MiddleName = txtMiddleName.Text.Trim(); addEmployee.LastName = txtLastName.Text.Trim(); fullName = txtFirstName.Text.Trim() + " " + txtLastName.Text.Trim(); addEmployee.EmailId = txtEmailID.Text.Trim(); addEmployee.GroupId = Convert.ToInt32(ddlDepartment.SelectedItem.Value); addEmployee.Band = Convert.ToInt32(ddlBand.SelectedItem.Value); //addEmployee.JoiningDate = Convert.ToDateTime(txtJoiningDate.Text.Trim()); addEmployee.JoiningDate = Convert.ToDateTime(ucDatePicker.Text.Trim()); addEmployee.StatusId = (int)MasterEnum.EmployeeStatus.Active; addEmployee.DesignationId = Convert.ToInt32(ddlDesignation.SelectedItem.Value); addEmployee.EmailId = txtEmailID.Text.Trim().ToLower(); addEmployee.ReportingToId = hidReportingTo.Value.Trim().ToString(); AuthorizationManager authoriseduser = new AuthorizationManager(); string LoggedInUserMailId = authoriseduser.getLoggedInUser(); _userMailId = LoggedInUserMailId.Replace("co.in", "com"); addEmployee.CreatedByMailId = _userMailId; addEmployee.CreatedDate = DateTime.Today; addEmployee.LastModifiedByMailId = _userMailId; addEmployee.LastModifiedDate = DateTime.Today; addEmployee.Type = Convert.ToInt32(ddlEmployeeType.SelectedItem.Value); addEmployee.CreatedDate = DateTime.Now; addEmployee.MRFId = Convert.ToInt32(ddlMRFCode.SelectedItem.Value); string imgName = Path.GetFileName(imgEmp.ImageUrl); addEmployee.FileName = imgName; addEmployee.RelavantExperienceMonth = Convert.ToInt32(txtReleventMonths.Text); addEmployee.RelevantExperienceYear = Convert.ToInt32(txtReleventYears.Text); addEmployee.ResourceBussinessUnit = Convert.ToInt32(ddlResourceBussinesUnit.SelectedValue); addEmployee.ReportingToFMId = Convert.ToInt32(hidReportingToFM.Value.Trim().ToString()); addEmployee.Department = Convert.ToString(ddlDepartment.SelectedItem); addEmployee.Designation = Convert.ToString(ddlDesignation.SelectedItem); addEmployee.EmployeeType = Convert.ToString(ddlEmployeeType.SelectedItem); addEmployee.MRFcode = ddlMRFCode.SelectedItem.Text; recruitment = recruitmentBL.GetMrfDetailForEmployee(Convert.ToInt32(addEmployee.MRFId)); addEmployee.Location = recruitment.Location; addEmployee.EmpLocation = (ddlLocation.SelectedItem.Text).Trim().ToString(); //going google Mahendra 26-Jun-2013 addEmployee.WindowsUserName = txtWindowsUsername.Text.Trim().ToString(); int dataCount = addEmployeeBAL.IsEmployeeDataExists(addEmployee); //Mohamed : Issue 41065 : 05/04/2013 : Starts //Desc : "When X-Employee rejoin then its previous email id should be change and the same email id should be inserted" -- Code Changes in Sp //if (dataCount == 1) //{ // lblMessage.Text = "Emailid " + addEmployee.EmailId + " and Emplyee Code " + addEmployee.EMPCode + " already exists in the database."; // return; //} //if (dataCount == 2) //{ // lblMessage.Text = "Emailid " + addEmployee.EmailId + " already exists in the database."; // return; //} if (dataCount == 4) { lblMessage.Text = "Emailid " + addEmployee.EmailId + " is already assign to existing user."; return; } //Mohamed : Issue 41065 : 05/04/2013 : Ends if (dataCount == 3) { lblMessage.Text = "Employee Code " + addEmployee.EMPCode + " already exists in the database."; return; } empID = addEmployeeBAL.AddEmployee(addEmployee, ref empCode); if (empID > 0) { addEmployee.EMPId = empID; addEmployeeBAL.UpdateEmployeeMRFCode(addEmployee, (int)Common.MasterEnum.MRFStatus.PendingNewEmployeeAllocation); } else { return; } //--Get mailIds addEmployeeBAL.SendMailForAddEmployee(addEmployee); //for sending mail to the added employee to update his/her details //Only Rave domain employee should get this mail. //if (addEmployee.EmailId.Contains(RAVE_DOMAIN)) if (addEmployee.EmployeeType != ONSITECONTRACT) { addEmployeeBAL.SendMailForAddEmployeeToUpdateDetails(addEmployee); } //Refreshing the data after inserting it. this.RefreshControls(); lblConfirmationMessage.Text = "Employee: " + fullName + " added successfully with Employee Code: " + empCode; lblMessage.Text = string.Empty; imgEmp.ImageUrl = imagePath + BackSlash + NoImage; } catch (RaveHRException ex) { LogErrorMessage(ex); } catch (Exception ex) { RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "AddEmployee", EventIDConstants.RAVE_HR_EMPLOYEE_PRESENTATION_LAYER); LogErrorMessage(objEx); } }
protected void ddlMRFCode_SelectedIndexChanged(object sender, EventArgs e) { string mrfid = string.Empty; Rave.HR.BusinessLayer.Recruitment.Recruitment recruitmentBL = new Rave.HR.BusinessLayer.Recruitment.Recruitment(); BusinessEntities.Recruitment recruitment = null; mrfid = ddlMRFCode.SelectedItem.Value.ToString(); if (mrfid != CommonConstants.SELECT) { recruitment = recruitmentBL.GetMrfDetailForEmployee(Convert.ToInt32(mrfid)); if (recruitment != null) { ddlPrefix.SelectedValue = recruitment.PrefixId.ToString(); txtFirstName.Text = recruitment.FirstName; txtMiddleName.Text = recruitment.MiddleName; txtLastName.Text = recruitment.LastName; ddlDepartment.SelectedValue = recruitment.DepartmentId.ToString(); FillRoleDropdownAsPerDepartment(); hidReportingTo.Value = recruitment.ReportingId; txtReportingTo.Text = recruitment.ReportingTo; ddlDesignation.SelectedValue = recruitment.DesignationId.ToString(); //txtJoiningDate.Text = recruitment.ResourceJoinedDate == DateTime.MinValue ? string.Empty : recruitment.ResourceJoinedDate.ToShortDateString(); ucDatePicker.Text = recruitment.ResourceJoinedDate == DateTime.MinValue ? string.Empty : recruitment.ResourceJoinedDate.ToShortDateString(); ddlEmployeeType.SelectedValue = recruitment.EmployeeTypeId.ToString(); ddlBand.SelectedValue = recruitment.BandId.ToString(); ddlResourceBussinesUnit.SelectedValue = recruitment.ResourceBussinessUnit == 0 ? CommonConstants.SELECT : recruitment.ResourceBussinessUnit.ToString(); txtReleventYears.Text = recruitment.RelevantExperienceYear.ToString(); txtReleventMonths.Text = recruitment.RelavantExperienceMonth.ToString(); //ddlLocation.SelectedItem.Text = recruitment.Location.ToString(); ddlLocation.ClearSelection(); ddlLocation.Items.FindByText(recruitment.Location.ToString().Trim()).Selected = true; if (ddlEmployeeType.SelectedItem.Text == ONSITECONTRACT) { txtEmailID.Text = recruitment.CandidateEmailID.ToString(); //txtEmailID.Attributes.Add(ReadOnly, ReadOnly); imgEmpEmailPopulate.Visible = false; } else { txtEmailID.Text = ""; //txtEmailID.Attributes.Add(ReadOnly, ReadOnly); imgEmpEmailPopulate.Visible = true; } } } else { ddlPrefix.SelectedValue = CommonConstants.SELECT; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; ddlDepartment.SelectedValue = CommonConstants.SELECT; GetEmployeeDesignations(0); hidReportingTo.Value = string.Empty; txtReportingTo.Text = string.Empty; ddlDesignation.SelectedValue = CommonConstants.SELECT; //txtJoiningDate.Text = string.Empty; ucDatePicker.Text = string.Empty; ddlEmployeeType.SelectedValue = CommonConstants.SELECT; ddlBand.SelectedValue = CommonConstants.SELECT; txtReleventMonths.Text = string.Empty; txtReleventYears.Text = string.Empty; ddlResourceBussinesUnit.SelectedValue = CommonConstants.SELECT; ddlLocation.SelectedValue = CommonConstants.SELECT; } }