public override int GetHashCode() { return(Emp_Id.GetHashCode()); }
//private void MartialStatus_CheckedChanged(object sender, EventArgs e) //{ // if (txt_MartialStatus.SelectedItem.Text == "Married") // { // txt_MarriageDate.Visible = true; // txt_Kids.Visible = true; // lbl_MarriageDate.Visible = true; // lbl_kids.Visible = true; // } // else // { // txt_MarriageDate.Visible = false; // txt_Kids.Visible = false; // lbl_MarriageDate.Visible = false; // lbl_kids.Visible = false; // } //} protected void Save_Click(object sender, EventArgs e) { string MainSite = "/Pages/Home.aspx"; int Emp_Id; try { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Web.Url)) { using (SPWeb web = site.OpenWeb()) { //Required Field validations if (txt_FirstName.Text != null) { TextBox tx = (TextBox)this.FindControl( required_Firstname.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_Firstname.ErrorMessage = "Please Enter the First Name"; } } if (txt_LastName.Text != null) { TextBox tx = (TextBox)this.FindControl( required_Lastname.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_Lastname.ErrorMessage = "Please Enter the Last Name"; } } if (txt_PersentAddress.Text != null) { TextBox tx = (TextBox)this.FindControl( required_PresentAddress.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_PresentAddress.ErrorMessage = "Please Enter the Present Address"; } } if (txt_PermanentAddress.Text != null) { TextBox tx = (TextBox)this.FindControl( required_PermanentAddress.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_PermanentAddress.ErrorMessage = "Please Enter the Permanent Address"; } } if (txt_MobileNo.Text != null) { TextBox tx = (TextBox)this.FindControl( required_EmpMobileNo.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_EmpMobileNo.ErrorMessage = "Please Enter the Mobile Number"; } } if (txt_Aadharno.Text != null) { TextBox tx = (TextBox)this.FindControl( required_AadharNumber.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_AadharNumber.ErrorMessage = "Please Enter the Aadhar Number"; } } if (txt_PANno.Text != null) { TextBox tx = (TextBox)this.FindControl( required_PANno.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_PANno.ErrorMessage = "Please Enter the PAN Number"; } } if (txt_ReferenceName1.Text != null) { TextBox tx = (TextBox)this.FindControl( required_ReferenceName1.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_ReferenceName1.ErrorMessage = "Please Enter the Reference Name"; } } if (txt_RefrenceContactNo1.Text != null) { TextBox tx = (TextBox)this.FindControl( required_ReferenceMobileNo1.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_ReferenceMobileNo1.ErrorMessage = "Please Enter the Reference Mobile Number"; } } //if (file_EmployeePhoto.f != null) //{ // TextBox tx = (TextBox)this.FindControl( // required_Empphoto.ControlToValidate); // if (string.IsNullOrEmpty(tx.Text)) // { // required_Firstname.ErrorMessage = // "Please Enter the First Name"; // } //} if (txt_placeSigned.Text != null) { TextBox tx = (TextBox)this.FindControl( required_Placesigned.ControlToValidate); if (string.IsNullOrEmpty(tx.Text)) { required_Placesigned.ErrorMessage = "Please Enter the Place"; } } // Get Form Entries Get_FormInputCollections(); web.AllowUnsafeUpdates = true; var EmpInfo = web.Lists.TryGetList(Constant.EmployeeInformation); var FamilyDetails = web.Lists.TryGetList(Constant.FamilyDetails); var MedicalCondition = web.Lists.TryGetList(Constant.MedicalCondition); var EmergencyContactDetails = web.Lists.TryGetList(Constant.EmergencyContactDetails); var EducationQualification = web.Lists.TryGetList(Constant.EducationQualification); var EmployeeIdentityandAddressProofs = web.Lists.TryGetList(Constant.EmployeeIdentityandAddressProofs); var EmployeeReferences = web.Lists.TryGetList(Constant.EmployeeReferences); var EmployeePreviousWorkingDetails = web.Lists.TryGetList(Constant.EmployeePreviousExperience); var EmployeesPhotos = web.Lists.TryGetList(Constant.EmployeesPhotos); var EmployeesSignature = web.Lists.TryGetList(Constant.EmployeesSignature); var Employeetype = web.Lists.TryGetList(Constant.EmployementType); // Employee Information List if (EmpInfo != null) { SPListItem newItem_EmployeeInformation = EmpInfo.Items.Add(); newItem_EmployeeInformation[Constant.EmployementType] = hdnEmpType.Value; newItem_EmployeeInformation[Constant.FirstName] = txt_FirstName.Text; newItem_EmployeeInformation[Constant.LastName] = txt_LastName.Text; newItem_EmployeeInformation[Constant.EmployeeName] = web.CurrentUser.LoginName; newItem_EmployeeInformation[Constant.DateOfBirth] = Convert.ToDateTime(txt_DateOfBirth.SelectedDate.ToString()); newItem_EmployeeInformation[Constant.Gender] = txt_Gender.SelectedValue.ToString(); newItem_EmployeeInformation[Constant.persentAddress] = txt_PersentAddress.Text; newItem_EmployeeInformation[Constant.permanentAddress] = txt_PermanentAddress.Text; newItem_EmployeeInformation[Constant.ResidenceNo] = txt_SecondResiNo.Text; newItem_EmployeeInformation[Constant.ResidenceNo1] = txt_FirstResiNo.Text; newItem_EmployeeInformation[Constant.MobileNo] = txt_MobileNo.Text; newItem_EmployeeInformation[Constant.MartialStatus] = txt_MartialStatus.SelectedValue.ToString(); newItem_EmployeeInformation[Constant.MarriageDate] = Convert.ToDateTime(txt_MarriageDate.SelectedDate.ToString()); newItem_EmployeeInformation[Constant.NoOfkids] = txt_Kids.Text; newItem_EmployeeInformation[Constant.DateSigned] = Convert.ToDateTime(txt_dateSigned.SelectedDate.ToString()); newItem_EmployeeInformation[Constant.PlaceSigned] = txt_placeSigned.Text; newItem_EmployeeInformation.Update(); Emp_Id = newItem_EmployeeInformation.ID; SPListItem toUpdateEmpItem = EmpInfo.Items.GetItemById(Emp_Id); SPFieldUrlValue hyperLink = new SPFieldUrlValue(); hyperLink.Description = Constant.RedirectionLink_Description; hyperLink.Url = Constant.RedirectionLink + Emp_Id.ToString(); toUpdateEmpItem[Constant.ViewDetailLink] = hyperLink; toUpdateEmpItem.Update(); //Employee Photos Details if (EmployeesPhotos != null) { SPDocumentLibrary documentLib = web.Lists[Constant.EmployeesPhotos] as SPDocumentLibrary; //SPListItem newItem_employeesPhotos = EmployeesPhotos.Items.Add(); Stream fStream = file_EmployeePhoto.PostedFile.InputStream; byte[] _byteArray = new byte[fStream.Length]; fStream.Read(_byteArray, 0, (int)fStream.Length); fStream.Close(); string filepath = file_EmployeePhoto.FileName.Split(',')[0]; string _fileUrl = documentLib.RootFolder.Url + "/" + file_EmployeePhoto.FileName; string candidateResumeLink = documentLib.RootFolder.ServerRelativeUrl + "/" + file_EmployeePhoto.FileName; bool IsOverwriteFile = true; SPFile file = documentLib.RootFolder.Files.Add(_fileUrl, _byteArray, IsOverwriteFile); SPListItem item = file.Item; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); item["Title"] = file_EmployeePhoto.FileName.Split('.')[0]; item["Name"] = file_EmployeePhoto.FileName; item[Constant.EmployeeName] = lookupvalues; item.Update(); file.Update(); } // Push Family Details if (collection_FamilyDetails.Count > 0) { foreach (var item in collection_FamilyDetails) { SPListItem newItem_FamilyDetail = FamilyDetails.Items.Add(); //string lookUpValue = web.CurrentUser.LoginName; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_FamilyDetail[Constant.EmployeeName] = lookupvalues; newItem_FamilyDetail[Constant.FamilyName] = item.FamilyName; newItem_FamilyDetail[Constant.FamilyDateOfBirth] = item.FamilyDateOfBirth; newItem_FamilyDetail[Constant.FamilyGender] = item.FamilyGender; newItem_FamilyDetail[Constant.FamilyRelationship] = item.FamilyRelationship; newItem_FamilyDetail[Constant.FamilyOccupation] = item.FamilyOccupation; newItem_FamilyDetail.Update(); } } // Medical List if (MedicalCondition != null) { SPListItem newItem_MedicalCondition = MedicalCondition.Items.Add(); SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_MedicalCondition[Constant.EmployeeName] = lookupvalues; newItem_MedicalCondition[Constant.BloodGroup] = txt_Bloodgroup.Text; newItem_MedicalCondition[Constant.Ailments] = txt_ailments.Text; newItem_MedicalCondition[Constant.Allergies] = txt_Allergies.Text; newItem_MedicalCondition[Constant.OtherMedical] = txt_othermedications.Text; newItem_MedicalCondition.Update(); } // Push Emergency Contact Details if (collection_EmergencyContactDetails.Count > 0) { foreach (var item in collection_EmergencyContactDetails) { SPListItem newItem_EmergencyDetails = EmergencyContactDetails.Items.Add(); //string lookUpValue = web.CurrentUser.LoginName; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EmergencyDetails[Constant.EmployeeName] = lookupvalues; newItem_EmergencyDetails[Constant.ContactPersonName] = item.ContactPersonName; newItem_EmergencyDetails[Constant.ContactRelations] = item.ContactRelations; newItem_EmergencyDetails[Constant.EmergencyLandlineno] = item.EmergencyLandlineno; newItem_EmergencyDetails[Constant.EmergencyMobileNumber] = item.EmergencyMobileNumber; newItem_EmergencyDetails.Update(); } } // Education Qualification List if (collection_EducationQualifications.Count > 0) { foreach (var item in collection_EducationQualifications) { SPListItem newItem_EducationQualifications = EducationQualification.Items.Add(); //string lookUpValue = web.CurrentUser.LoginName; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EducationQualifications[Constant.EmployeeName] = lookupvalues; newItem_EducationQualifications[Constant.Degree] = item.Degree; newItem_EducationQualifications[Constant.university] = item.university; newItem_EducationQualifications[Constant.From] = item.From; newItem_EducationQualifications[Constant.To] = item.To; newItem_EducationQualifications[Constant.Percentage] = item.Percentage; newItem_EducationQualifications.Update(); } } //Permanent Employee Identity and Address Proofs if (hdnEmpType.Value == Constant.EmployeeType_Permanent) { if (EmployeeIdentityandAddressProofs != null) { SPListItem newItem_EmployeeIdentityandAddressProofs = EmployeeIdentityandAddressProofs.Items.Add(); SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EmployeeIdentityandAddressProofs[Constant.EmployeeName] = lookupvalues; newItem_EmployeeIdentityandAddressProofs[Constant.AadharNumber] = txt_Aadharno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PancardNumber] = txt_PANno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PassportNumber] = txt_Passportno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.BankAc] = txt_BankAc.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PF] = txt_PfAc.Text; newItem_EmployeeIdentityandAddressProofs[Constant.UAN] = txt_UANno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.ESIC] = txt_ESICno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.twowheeler] = txt_twowheeler.Text; newItem_EmployeeIdentityandAddressProofs[Constant.fourwheeler] = txt_Fourwheeler.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PublicTransport] = txt_Publictransport.Text; newItem_EmployeeIdentityandAddressProofs.Update(); } } //Contract Employee Identity and Address Proofs if (hdnEmpType.Value == Constant.EmployeeType_Contract) { if (EmployeeIdentityandAddressProofs != null) { SPListItem newItem_EmployeeIdentityandAddressProofs = EmployeeIdentityandAddressProofs.Items.Add(); SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EmployeeIdentityandAddressProofs[Constant.EmployeeName] = lookupvalues; newItem_EmployeeIdentityandAddressProofs[Constant.AadharNumber] = txt_Aadharno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PancardNumber] = txt_PANno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PassportNumber] = txt_Passportno.Text; newItem_EmployeeIdentityandAddressProofs[Constant.twowheeler] = txt_twowheeler.Text; newItem_EmployeeIdentityandAddressProofs[Constant.fourwheeler] = txt_Fourwheeler.Text; newItem_EmployeeIdentityandAddressProofs[Constant.PublicTransport] = txt_Publictransport.Text; newItem_EmployeeIdentityandAddressProofs.Update(); } } //Push Employee Reference Details if (collection_EmployeeReferences.Count > 0) { foreach (var item in collection_EmployeeReferences) { SPListItem newItem_EmployeeReference = EmployeeReferences.Items.Add(); //string lookUpValue = web.CurrentUser.LoginName; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EmployeeReference[Constant.EmployeeName] = lookupvalues; newItem_EmployeeReference[Constant.ReferenceName] = item.ReferenceName; newItem_EmployeeReference[Constant.ReferenceWorkingIn] = item.ReferenceWorkingIn; newItem_EmployeeReference[Constant.ReferenceWorkingAs] = item.ReferenceWorkingAs; newItem_EmployeeReference[Constant.ReferenceContactNo] = item.ReferenceContactNo; newItem_EmployeeReference.Update(); } } //Push Employee Previous Company Details if (hdnEmpType.Value == Constant.EmployeeType_Permanent) { if (collection_EmployeePreviousExperience.Count > 0) { foreach (var item in collection_EmployeePreviousExperience) { SPListItem newItem_EmployeePreviousExperience = EmployeePreviousWorkingDetails.Items.Add(); //string lookUpValue = web.CurrentUser.LoginName; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_EmployeePreviousExperience[Constant.EmployeeName] = lookupvalues; newItem_EmployeePreviousExperience[Constant.PreviousCompany] = item.PreviousCompany; newItem_EmployeePreviousExperience[Constant.PreviousDesignation] = item.PreviousDesignation; newItem_EmployeePreviousExperience[Constant.PreviousDateofjoining] = item.PreviousDateofjoining; newItem_EmployeePreviousExperience[Constant.PreviousDateofRelieving] = item.PreviousDateofRelieving; newItem_EmployeePreviousExperience[Constant.PreviousContactNo] = item.PreviousContactNo; newItem_EmployeePreviousExperience[Constant.PreviousReason] = item.PreviousReason; newItem_EmployeePreviousExperience.Update(); } } } if (hdnEmpType.Value == Constant.EmployeeType_Contract) { if (collection_ContractDetails.Count > 0) { foreach (var item in collection_ContractDetails) { SPListItem newItem_ContractDetails = EmployeePreviousWorkingDetails.Items.Add(); SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); newItem_ContractDetails[Constant.EmployeeName] = lookupvalues; newItem_ContractDetails[Constant.PreviousCompany] = item.ContractCompany; newItem_ContractDetails[Constant.PreviousDesignation] = item.ContractDesignation; newItem_ContractDetails[Constant.PreviousDateofjoining] = item.ContractDOJ; newItem_ContractDetails[Constant.ContractDuration] = item.ContractDuration; newItem_ContractDetails[Constant.ContractContactPerson] = item.ContractContactPerson; newItem_ContractDetails[Constant.PreviousContactNo] = item.ContractContactNo; newItem_ContractDetails.Update(); } } } //Employee Signature Details if (EmployeesSignature != null) { SPDocumentLibrary documentLib = web.Lists[Constant.EmployeesSignature] as SPDocumentLibrary; Stream fStream = fileupload_signature.PostedFile.InputStream; byte[] _byteArray = new byte[fStream.Length]; fStream.Read(_byteArray, 0, (int)fStream.Length); fStream.Close(); string filepath = fileupload_signature.FileName.Split(',')[0]; string _fileUrl = documentLib.RootFolder.Url + "/" + fileupload_signature.FileName; string candidateResumeLink = documentLib.RootFolder.ServerRelativeUrl + "/" + fileupload_signature.FileName; bool IsOverwriteFile = true; SPFile file = documentLib.RootFolder.Files.Add(_fileUrl, _byteArray, IsOverwriteFile); SPListItem item = file.Item; SPFieldLookupValue lookupvalues = new SPFieldLookupValue(Emp_Id, web.CurrentUser.Name); item["Title"] = fileupload_signature.FileName.Split('.')[0]; item["Name"] = fileupload_signature.FileName; item[Constant.EmployeeName] = lookupvalues; item.Update(); file.Update(); } } web.AllowUnsafeUpdates = false; Page.Response.Redirect(SPContext.Current.Site.Url + MainSite, false); } } }); } catch (Exception ex) { } }
public bool Equals(Employee employee) { return(Emp_Id.Equals(employee.Emp_Id)); }