//To CheckDuplicateStaff #region [Check Duplicate Staff] public int CheckDuplicateStaff_DL(EWA_Staff objEWA) { try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "CheckData"; // prmList[2] = "@StaffName"; // prmList[3] = objEWA.StName; DataSet dsData = ObjHelper.FillControl(prmList, "SP_Employee"); if (dsData.Tables[0].Rows.Count > 0) { return(1); } else { return(0); } } catch (Exception) { //GeneralErr(exp.Message.ToString()); throw; //return 1; } }
//Get MaxStaffId #region [Max Staff Id] public DataSet GetStaffCode_DL(EWA_Staff objEWA) { DataSet ds = new DataSet(); try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "GetCountEmpId"; prmList[2] = "@OrgId"; prmList[3] = Convert.ToString(objEWA.OrgId); ds = ObjHelper.FillControl(prmList, "SP_Employee"); if (ds.Tables[0].Rows.Count > 0) { return(ds); } return(ds); } catch (Exception) { //GeneralErr(exp.Message.ToString()); throw; } }
//Bind Caste Category Bind Caste Category_BL #region [Bind CasteCategory] public DataSet BindCasteCategory_BL(EWA_Staff objEWA) { try { DL_Staff objDL = new DL_Staff(); DataSet ds = objDL.BindCasteCategory_DL(objEWA); return(ds); } catch (Exception) { throw; } }
//Save Event #region [Save Event] protected void btnSave_Click(object sender, EventArgs e) { try { BL_Staff objBL = new BL_Staff(); EWA_Staff objEWA = new EWA_Staff(); Action("Save"); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To Check Duplicate Data Of Staff #region [CheckDuplicateStaff] public int CheckDuplicateStaff_BL(EWA_Staff objEWA) { try { DL_Staff objDL = new DL_Staff(); int i = objDL.CheckDuplicateStaff_DL(objEWA); return(i); } catch (Exception) { throw; } finally { objDL = null; } }
//Insert Update Delete operaeion on Staff Table #region [ActionPerformed For Staff] public DataTable StaffAction_BL(EWA_Staff objEWA) { try { DL_Staff objDL = new DL_Staff(); DataTable flag = objDL.staffAction(objEWA); return(flag); } catch (Exception ex) { throw ex; } finally { objDL = null; } }
//To Fetch CourseId #region [Fetch StaffId] public DataSet GetStaffCode_BL(EWA_Staff objEWA) { try { DL_Staff objStaffClass = new DL_Staff(); DataSet ds = objDL.GetStaffCode_DL(objEWA); return(ds); } catch (Exception) { throw; } finally { objDL = null; } }
//Bind Staff Id #region [Bind Staff Id] private void BindStaffId() { try { EWA_Staff objEWA = new EWA_Staff(); BL_Staff objBL = new BL_Staff(); //Send it from Session objEWA.OrgId = 1; DataSet StaffIdds = objBL.GetStaffCode_BL(objEWA); string StaffId = StaffIdds.Tables[0].Rows[0][0].ToString(); lblEmpCode.Text = objEWA.OrgId + StaffId; ViewState["EmpCode"] = lblEmpCode.Text; txtUserName.Text = ViewState["EmpCode"].ToString(); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//protected void btnPre2_Click(object sender, EventArgs e) //{ // try // { // Panel_ContactGeneralInfo.Visible = true; // Panel_QualificationBankingDetails.Visible = false; // } // catch (Exception exp) // { // GeneralErr(exp.Message.ToString()); // } //} protected void btnSave_Click(object sender, EventArgs e) { try { BL_Staff objBL = new BL_Staff(); EWA_Staff objEWA = new EWA_Staff(); //if (txtPassword.Text == txtConfirmPassword.Text) //{ Action("Save"); //Response.Redirect("~/Forms/Admin/Admin_Home.aspx?", false); //} //else //{ // msgBox.ShowMessage("Password and confirm password not match !!!", "Saved", UserControls.MessageBox.MessageStyle.Critical); //} } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Save Click #region [Save Event] protected void btnSave_Click1(object sender, EventArgs e) { BL_Staff objBL = new BL_Staff(); EWA_Staff objEWA = new EWA_Staff(); try { if (txtEmail.Text == "") { msgBox.ShowMessage("Please enter staff email !!!", "Information", UserControls.MessageBox.MessageStyle.Information); } else { Action("Save"); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); //throw; } }
//Bind Staff Id #region [Bind Staff Id] private void BindStaffId() { try { EWA_Staff objEWA = new EWA_Staff(); BL_Staff objBL = new BL_Staff(); //Send it from Session objEWA.OrgId = orgId; float ID = DB.getDb_Value("select max(EmpId) from tblEmployee where OrgId='" + objEWA.OrgId + "'"); ID++; string newid = "00" + ID.ToString(); //DataSet StaffIdds = objBL.GetStaffCode_BL(objEWA); //string StaffId = StaffIdds.Tables[0].Rows[0][0].ToString(); lblEmpCode.Text = objEWA.OrgId + newid.ToString(); ViewState["EmpCode"] = lblEmpCode.Text; txtUserName.Text = ViewState["EmpCode"].ToString(); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
// Bind Class BindCastCategory #region [Bind Category] public DataSet BindCasteCategory_DL(EWA_Staff objEWA) { DataSet ds = null; try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "FetchCasteCategory"; prmList[2] = "@OrgId"; prmList[3] = Convert.ToString(objEWA.OrgId); ds = ObjHelper.FillControl(prmList, "SP_Employee"); if (ds.Tables[0].Rows.Count > 0) { return(ds); } return(ds); } catch (Exception) { throw; } }
//Perform Action for Employee #region [Perform Action] private void Action(string strAction) { EWA_Staff objEWA = new EWA_Staff(); BL_Staff objBL = new BL_Staff(); try { objEWA.Action = strAction; //if (strAction == "Update" || strAction == "Delete") //{ // objEWA.StaffId = Convert.ToInt32(ViewState["DocumentId"].ToString()); //} //objEWA.EmpCode = lblEmpCode.Text; objEWA.EmpCode = ViewState["EmpCode"].ToString(); objEWA.DesignationTypeId = rbtnDesignationType.SelectedValue; objEWA.FirstName = txtFirstName.Text.Trim(); objEWA.MiddleName = txtMiddleName.Text.Trim(); objEWA.LastName = txtLastName.Text.Trim(); objEWA.MotherName = txtMotherName.Text.Trim(); objEWA.Gender = rbtnGender.SelectedValue; objEWA.DOB = (txt_BirthDate.Text); objEWA.BloodGroup = ddlBloodGroup.SelectedValue; objEWA.MaritalStatus = rbtnMaritalStatus.SelectedValue; objEWA.Handicap = ddl_Handicap.SelectedValue; objEWA.HandicapPercentage = Convert.ToInt32(txtHandicapPercentage.Text.Trim()); objEWA.PresentAddress = txtPresentAddress.Text.Trim(); objEWA.PresentCountry = ddlPresentCountry.SelectedItem.ToString(); objEWA.PresentState = ddlPresentState.SelectedItem.ToString(); objEWA.PresentCity = ddlPresentCity.SelectedItem.ToString(); objEWA.PresentPinCode = Convert.ToInt32(txtPresentPinCode.Text); objEWA.PermanentAddress = txtPermanentAddress.Text.Trim(); objEWA.PermanentCountry = ddlPermanentCountry.SelectedItem.ToString(); objEWA.PermanentState = ddlPermanentState.SelectedItem.ToString(); objEWA.PermanentCity = ddlPermanentCity.SelectedItem.ToString(); objEWA.PermanentPinCode = Convert.ToInt32(txtPermanentPinCode.Text); objEWA.PhoneNo = txtPhoneNumber.Text; objEWA.Mobile = txtMobileNumber.Text; objEWA.Fax = txtFaxNumber.Text; objEWA.Email = txtEmail.Text.Trim(); objEWA.CasteCategory = ddlCasteCategory.SelectedItem.ToString(); objEWA.Nationality = txtNationality.Text.Trim(); // objEWA.WebsiteBlog=txtwebsiteBlog.Text; objEWA.PanCardNo = txtPanCardNo.Text; objEWA.DateOfJoining = (txtJoiningDate.Text); objEWA.UGDegree = ddlUGDegree.SelectedItem.ToString(); objEWA.PGDegree = ddlPGDegree.SelectedItem.ToString(); objEWA.DoctrateDegree = txtDocterateDegree.Text.Trim(); objEWA.OtherQualification = txtOtherQualification.Text.Trim(); objEWA.Specialization = txtSpecialization.Text.Trim(); objEWA.TeachingExperience = txtTeachingExperience.Text.Trim(); objEWA.WebsiteBlog = txtWebsiteBlog.Text.Trim(); objEWA.PreviousPackage = txtPreviousPackage.Text; objEWA.PayScale = Convert.ToInt32(txtPayScale.Text); objEWA.SalaryMode = ddlSalaryMode.SelectedItem.ToString(); objEWA.PFNumber = txtPFNumber.Text.Trim(); objEWA.BankAccountNumber = txtAccountNumber.Text; objEWA.BankName = txtBankName.Text.Trim(); objEWA.BankBranchName = txtBranchName.Text.Trim(); objEWA.BankIFSCCode = txtIFSCCode.Text; //Insert data into User Table objEWA.UserType = "Staff"; objEWA.UserName = txtUserName.Text.Trim(); objEWA.Password = txtPassword.Text.Trim(); objEWA.Role = rbtnDesignationType.SelectedItem.ToString(); objEWA.UserTypeId = lblEmpCode.Text; objEWA.Status = "Permanent"; //Below Values Need to be pass from session objEWA.OrgId = orgId; // int length = 0; // byte[] imgLogobyte = null; //if (PhotoUpload.HasFile) //{ // length = PhotoUpload.PostedFile.ContentLength; // imgLogobyte = new byte[length]; // HttpPostedFile img1 = PhotoUpload.PostedFile; // img1.InputStream.Read(imgLogobyte, 0, length); //} //objEWA.Photo = imgLogobyte; if (PhotoUpload.HasFile) { string fileName = PhotoUpload.PostedFile.FileName; string fileExtension = System.IO.Path.GetExtension(fileName); string fileMimeType = PhotoUpload.PostedFile.ContentType; int fileLengthInKB = PhotoUpload.PostedFile.ContentLength / 1024; string[] matchExtension = { ".jpg", ".png", ".gif" }; string[] matchMimeType = { "image/jpeg", "image/png", "image/gif" }; if (matchExtension.Contains(fileExtension) && matchMimeType.Contains(fileMimeType)) { if (fileLengthInKB > 1024) { int length = PhotoUpload.PostedFile.ContentLength; objEWA.Photo = new byte[length]; HttpPostedFile img1 = PhotoUpload.PostedFile; img1.InputStream.Read(objEWA.Photo, 0, length); } else { //Please choose a file less than 1MB } } else { //Please choose only jpg, png or gif file. } } else { //Please choose a file. } objEWA.IsActive = "True"; DataTable data = objBL.StaffAction_BL(objEWA); if (data.Rows.Count > 0) { if (strAction == "Save") { SendEmails(); clear(); msgBox.ShowMessage("Staff Registered Successfully and Email Sent !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); } } else { if (strAction == "Save") { msgBox.ShowMessage("Unable to Save !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To Perform Insert,Update,Delete and Search Actions On Staff Table #region [Perform Actions On Staff] public DataTable staffAction(EWA_Staff objEWA) { try { cmd = new SqlCommand("SP_Employee", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", objEWA.Action); cmd.Parameters.AddWithValue("@EmpCode", objEWA.EmpCode); cmd.Parameters.AddWithValue("@DesignationTypeId", objEWA.DesignationTypeId); cmd.Parameters.AddWithValue("@FirstName", objEWA.FirstName); cmd.Parameters.AddWithValue("@MiddleName", objEWA.MiddleName); cmd.Parameters.AddWithValue("@LastName", objEWA.LastName); cmd.Parameters.AddWithValue("@MotherName", objEWA.MotherName); cmd.Parameters.AddWithValue("@Gender", objEWA.Gender); cmd.Parameters.AddWithValue("@DOB", objEWA.DOB); cmd.Parameters.AddWithValue("@BloodGroup", objEWA.BloodGroup); cmd.Parameters.AddWithValue("@MaritalStatus", objEWA.MaritalStatus); //cmd.Parameters.AddWithValue("@Handicap", objEWA.Handicap); //cmd.Parameters.AddWithValue("@HandicapPercentage", objEWA.HandicapPercentage); //Address details cmd.Parameters.AddWithValue("@PresentAddress", objEWA.PresentAddress); cmd.Parameters.AddWithValue("@PresentCountry", objEWA.PresentCountry); cmd.Parameters.AddWithValue("@PresentState", objEWA.PresentState); cmd.Parameters.AddWithValue("@PresentCity", objEWA.PresentCity); cmd.Parameters.AddWithValue("@PresentPinCode", objEWA.PresentPinCode); //cmd.Parameters.AddWithValue("@PermanentAddress", objEWA.PermanentAddress); //cmd.Parameters.AddWithValue("@PermanentCountry", objEWA.PermanentCountry); //cmd.Parameters.AddWithValue("@PermanentState", objEWA.PermanentState); //cmd.Parameters.AddWithValue("@PermanentCity", objEWA.PermanentCity); //cmd.Parameters.AddWithValue("@PermanentPinCode", objEWA.PermanentPinCode); //Contact Deyails cmd.Parameters.AddWithValue("@PhoneNo", objEWA.PhoneNo); cmd.Parameters.AddWithValue("@Mobile", objEWA.Mobile); //cmd.Parameters.AddWithValue("@Fax", objEWA.Fax); //other Details cmd.Parameters.AddWithValue("@Email", objEWA.Email); cmd.Parameters.AddWithValue("@CasteCategory", objEWA.CasteCategory); cmd.Parameters.AddWithValue("@Nationality", objEWA.Nationality); cmd.Parameters.AddWithValue("@PanCardNo", objEWA.PanCardNo); cmd.Parameters.AddWithValue("@DateOfJoining", objEWA.DateOfJoining); //Educational Qualification cmd.Parameters.AddWithValue("@UGDegree", objEWA.UGDegree); cmd.Parameters.AddWithValue("@PGDegree", objEWA.PGDegree); //cmd.Parameters.AddWithValue("@DoctorateDegree", objEWA.DoctrateDegree); cmd.Parameters.AddWithValue("@OtherQualification", objEWA.OtherQualification); cmd.Parameters.AddWithValue("@Specialization", objEWA.Specialization); cmd.Parameters.AddWithValue("@TeachingExperience", objEWA.TeachingExperience); //cmd.Parameters.AddWithValue("@WebsiteBlog", objEWA.WebsiteBlog); //cmd.Parameters.AddWithValue("@PreviousPackage", objEWA.PreviousPackage); //cmd.Parameters.AddWithValue("@PayScale", objEWA.PayScale); //cmd.Parameters.AddWithValue("@SalaryMode", objEWA.SalaryMode); //cmd.Parameters.AddWithValue("@PFNumber", objEWA.PFNumber); cmd.Parameters.AddWithValue("@BankAccountNumber", objEWA.BankAccountNumber); cmd.Parameters.AddWithValue("@BankName", objEWA.BankName); cmd.Parameters.AddWithValue("@BankBranchName", objEWA.BankBranchName); //cmd.Parameters.AddWithValue("@BankIFSCCode", objEWA.BankIFSCCode); cmd.Parameters.AddWithValue("@Photo", objEWA.Photo); //User Table Data cmd.Parameters.AddWithValue("@UserCode", objEWA.EmpCode); cmd.Parameters.AddWithValue("@UserType", objEWA.UserType); cmd.Parameters.AddWithValue("@UserName", objEWA.UserName); cmd.Parameters.AddWithValue("@Password", objEWA.Password); cmd.Parameters.AddWithValue("@Role", objEWA.Role); //cmd.Parameters.AddWithValue("@UserTypeId", objEWA.UserTypeId); cmd.Parameters.AddWithValue("@Status", objEWA.Status); cmd.Parameters.AddWithValue("@OrgId", objEWA.OrgId); cmd.Parameters.AddWithValue("@IsActive", objEWA.IsActive); cmd.Parameters.AddWithValue("@DesignationID", objEWA.DesignationId); cmd.Parameters.AddWithValue("@DepartmentId", objEWA.DepartmentId); //con.Open(); // sqlTransaction = con.BeginTransaction(); // cmd.Transaction = sqlTransaction; DataTable tbl = new DataTable(); using (con) { using (SqlDataAdapter ad = new SqlDataAdapter(cmd)) { ad.Fill(tbl); } } //int flag = cmd.ExecuteNonQuery(); int flag = Convert.ToInt32(tbl.Rows[0]["Username"].ToString()); //sqlTransaction.Commit(); return(tbl); } catch (Exception ex) { int err = ((System.Data.SqlClient.SqlException)(ex)).Number; if (err == 547 && objEWA.Action == "Delete") { throw new SystemException("Record is in use !!!"); } else { throw ex; } } finally { cmd.Dispose(); con.Close(); } }
//Perform Action for Employee #region [Perform Action] private void Action(string strAction) { EWA_Staff objEWA = new EWA_Staff(); BL_Staff objBL = new BL_Staff(); try { if (Session["StaffMob"] != null) { if (Session["StaffMob"].ToString() == (txtFirstName.Text.Trim() + txtMobileNumber.Text)) { //msgBox.ShowMessage("Record already present !!!", "Information", UserControls.MessageBox.MessageStyle.Successfull); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Information", "alert('Admission Completed Successfully ')", true); Response.Redirect("~/Forms/Admin/Admin_Home.aspx?Msg=" + ViewState["msg"]); //return; } } else { Session["StaffMob"] = ((txtFirstName.Text.Trim() + txtMobileNumber.Text)); } objEWA.Action = strAction; //if (strAction == "Update" || strAction == "Delete") //{ // objEWA.StaffId = Convert.ToInt32(ViewState["DocumentId"].ToString()); //} //objEWA.EmpCode = lblEmpCode.Text; //objEWA.EmpCode = ViewState["EmpCode"].ToString(); objEWA.DesignationTypeId = rbtnDesignationType.SelectedValue; objEWA.FirstName = txtFirstName.Text.Trim(); objEWA.MiddleName = txtMiddleName.Text.Trim(); objEWA.LastName = txtLastName.Text.Trim(); objEWA.MotherName = txtMotherName.Text.Trim(); objEWA.Gender = rbtnGender.SelectedValue; objEWA.DOB = txt_BirthDate.Text; objEWA.BloodGroup = ddlBloodGroup.SelectedValue; objEWA.MaritalStatus = rbtnMaritalStatus.SelectedValue; //objEWA.Handicap = ddl_Handicap.SelectedValue; //objEWA.HandicapPercentage = Convert.ToInt32(txtHandicapPercentage.Text.Trim()); objEWA.PresentAddress = txtPresentAddress.Text.Trim(); objEWA.PresentCountry = ddlPresentCountry.SelectedItem.ToString(); objEWA.PresentState = ddlPresentState.SelectedItem.ToString(); objEWA.PresentCity = ddlPresentCity.SelectedItem.ToString(); objEWA.PresentPinCode = Convert.ToInt32(txtPresentPinCode.Text); //objEWA.PermanentAddress = txtPermanentAddress.Text.Trim(); //objEWA.PermanentCountry = txtPermanentCountry.Text; //objEWA.PermanentState = txtPermanentState.Text; //objEWA.PermanentCity = txtPermanentCity.Text; //objEWA.PermanentPinCode = Convert.ToInt32(txtPermanentPinCode.Text); objEWA.PhoneNo = txtPhoneNumber.Text; objEWA.Mobile = txtMobileNumber.Text; //objEWA.Fax = txtFaxNumber.Text; objEWA.Email = txtEmail.Text.Trim(); objEWA.CasteCategory = ddlCasteCategory.SelectedItem.ToString(); objEWA.Nationality = txtNationality.Text.Trim(); // objEWA.WebsiteBlog=txtwebsiteBlog.Text; objEWA.PanCardNo = txtPanCardNo.Text; objEWA.DateOfJoining = txtJoiningDate.Text; objEWA.UGDegree = txtUGDegree.Text; objEWA.PGDegree = txtPGDegree.Text; //objEWA.DoctrateDegree = txtDocterateDegree.Text.Trim(); objEWA.OtherQualification = txtOtherQualification.Text.Trim(); objEWA.Specialization = txtSpecialization.Text.Trim(); objEWA.TeachingExperience = txtTeachingExperience.Text.Trim(); //objEWA.WebsiteBlog = txtWebsiteBlog.Text.Trim(); //objEWA.PreviousPackage = txtPreviousPackage.Text; //objEWA.PayScale = Convert.ToInt32(txtPayScale.Text); //objEWA.SalaryMode = ddlSalaryMode.SelectedItem.ToString(); //objEWA.PFNumber = txtPFNumber.Text.Trim(); objEWA.BankAccountNumber = txtAccountNumber.Text; objEWA.BankName = txtBankName.Text.Trim(); objEWA.BankBranchName = txtBranchName.Text.Trim(); //objEWA.BankIFSCCode = txtIFSCCode.Text; //if (DDL_Role.SelectedItem.Text == "Staff") { objEWA.DepartmentId = ddlDepartment.SelectedValue; objEWA.DesignationId = ddlDesignation.SelectedValue; } //Insert data into User Table objEWA.UserType = DDL_Role.SelectedItem.Text; //objEWA.UserName = txtUserName.Text.Trim(); objEWA.Password = txtPassword.Text.Trim(); objEWA.Role = DDL_Role.SelectedItem.Text; //objEWA.UserTypeId = lblEmpCode.Text; objEWA.Status = "Permanent"; //Below Values Need to be pass from session objEWA.OrgId = orgId; objEWA.Photo = (byte[])ViewState["FacultyPhoto"]; if (PhotoUpload.HasFile) { string fileName = PhotoUpload.PostedFile.FileName; string fileExtension = System.IO.Path.GetExtension(fileName); string fileMimeType = PhotoUpload.PostedFile.ContentType; int fileLengthInKB = PhotoUpload.PostedFile.ContentLength / 1024; string[] matchExtension = { ".jpg", ".png", ".gif" }; string[] matchMimeType = { "image/jpeg", "image/png", "image/gif" }; if (matchExtension.Contains(fileExtension) && matchMimeType.Contains(fileMimeType)) { if (fileLengthInKB > 1024) { //int length = PhotoUpload.PostedFile.ContentLength; //objEWA.Photo = new byte[length]; //HttpPostedFile img1 = PhotoUpload.PostedFile; //img1.InputStream.Read(objEWA.Photo, 0, length); } else { //Please choose a file less than 1MB } } else { //Please choose only jpg, png or gif file. } } else { //Please choose a file. } objEWA.IsActive = "True"; DataTable data = objBL.StaffAction_BL(objEWA); if (data.Rows.Count > 0) { if (strAction == "Save") { //msgBox.ShowMessage("Staff Registered Successfully and Email Sent !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); SendEmails(data.Rows[0][0].ToString(), data.Rows[0][1].ToString()); // System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), "Saved", "alert('Staff Registered Successfully and Email Sent !!!');", true); //Response.Write("<script>alert('Staff Registered Successfully and Email Sent !!!')</script>"); clear(); ViewState["msg"] = data.Rows[0][0]; Response.Redirect("~/Forms/Admin/Admin_Home.aspx?Msg=" + data.Rows[0][0]); } } else { if (strAction == "Save") { msgBox.ShowMessage("Unable to Save !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }