using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using WorkoPlus.BOL; public partial class Controls_employersearch : System.Web.UI.UserControl { public int iSearchType; protected void Page_Load(object sender, EventArgs e) { int iTabIndex = 1; txtTabIndex.Style.Add("display","none"); if(string.IsNullOrEmpty (txtTabIndex.Text) == false) { iTabIndex = Convert.ToInt32 (txtTabIndex.Text); } this.Page.ClientScript.RegisterStartupScript(this.GetType(), "callonload", "ShowSearchOption(" + iTabIndex.ToString () + ")", true); if (!Roles.IsUserInRole(ConfigurationManager.AppSettings["employerrolename"])) { Response.Redirect("~/customerrorpages/NotAuthorized.aspx"); } if (!Page.IsPostBack) { FillCountries(); FillStates(); FillExperinceLevels(); FillEducationLevels(); tbSearchResults.Style.Add("display", "none"); tblAddToFavorites.Style.Add("display", "none"); } else { tbSearchResults.Style.Add("display", ""); tblAddToFavorites.Style.Add("display", ""); } string sPath = Request.UrlReferrer.AbsolutePath.ToLower (); string strPage = sPath.Remove(0, sPath.LastIndexOf("/")+1); if (Request["mysearchid"] != null && strPage == "mysearches.aspx") { MySearch objSearch = MySearch.GetMySearch(Convert.ToInt32 (Request["mysearchid"])); ddlState.ClearSelection(); ddlCountry.ClearSelection(); ddlState.SelectedValue = objSearch.StateID.ToString (); ddlCountry .SelectedValue = objSearch.CountryID.ToString (); SearchTxt.Text = objSearch.Criteria; txtCity.Text = objSearch.City; BindGrid(); } } protected void lnkQuickSearch_Click(object sender, EventArgs e) { BindGrid(); } private void BindGrid() { int countryid = -1, stateid = -1, EducationLevelId = -1, ExperienceLevelId = -1; string sCity = txtCity.Text, sSearch = SearchTxt.Text; if (ddlCountry.SelectedItem != null) { countryid = int.Parse(ddlCountry.SelectedValue); } if (ddlState.SelectedItem != null) { stateid = int.Parse(ddlState.SelectedValue); } if (ddlEducation.SelectedItem != null) { EducationLevelId = int.Parse(ddlEducation.SelectedValue); } if (ddlExperience.SelectedItem != null) { ExperienceLevelId = int.Parse(ddlExperience.SelectedValue); } if (txtTabIndex.Text == "2") { stateid = -1; countryid = -1; sSearch = string.Empty; sCity = string.Empty; EducationLevelId = -1; } else if (txtTabIndex.Text == "3") { stateid = -1; countryid = -1; sCity = string.Empty; sSearch = string.Empty; ExperienceLevelId = -1; } else if (txtTabIndex.Text == "4") { sSearch = string.Empty; ExperienceLevelId = -1; EducationLevelId = -1; } DataSet ds = Resume.SearchResumes(sSearch, countryid, stateid, sCity, EducationLevelId, ExperienceLevelId); GridView1.DataSource = ds; GridView1.DataBind(); if (GridView1.Rows.Count <= 0) { lblMsg.Text = "     No records found!"; } else { lblMsg.Text = ""; } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton b = (LinkButton)e.Row.Cells[4].Controls[0]; b.CommandName = "viewdetails"; b.CommandArgument = GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); } } private void FillCountries() { ddlCountry.DataSource = Country.GetCountries(); ddlCountry.DataTextField = "CountryName"; ddlCountry.DataValueField = "CountryID"; ddlCountry.DataBind(); } private void FillExperinceLevels() { ddlExperience.DataSource = ExperienceLevel.GetExperienceLevels (); ddlExperience.DataTextField = "ExperienceLevelName"; ddlExperience.DataValueField = "ExperienceLevelId"; ddlExperience.DataBind(); ddlExperience.Items.Insert(0,new ListItem ("Not Set","-1")); } private void FillEducationLevels() { ddlEducation.DataSource = EducationLevel.GetEducationLevels (); ddlEducation.DataTextField = "EducationLevelName"; ddlEducation.DataValueField = "EducationLevelID"; ddlEducation.DataBind(); ddlEducation.Items.Insert(0, new ListItem("Not Set", "-1")); } private void FillStates() { ddlState.DataSource = State.GetStates(int.Parse(ddlCountry.SelectedValue)); ddlState.DataTextField = "StateName"; ddlState.DataValueField = "StateID"; ddlState.DataBind(); } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "viewdetails") { UserSubscription objSubscription = UserSubscription.GetByUserName(Profile.UserName,Convert.ToInt32(SubscriptionType.ResumePosting)); if(objSubscription == null) { Response.Redirect("Subscription.aspx"); } else if (objSubscription.Status != Constant.Active) { Response.Redirect("Subscription.aspx"); } Response.Redirect("viewresume.aspx?id=" + e.CommandArgument); } } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; BindGrid(); } protected void ddlCountry_SelectedIndexChanged1(object sender, EventArgs e) { FillStates(); } protected void lblAddtoFavorits_Click(object sender, EventArgs e) { MySearch obj = new MySearch(); obj.City = txtCity.Text; obj.CountryID = Convert.ToInt32(ddlCountry.SelectedValue); obj.StateID = Convert.ToInt32(ddlState.SelectedValue); obj.ExperienceLevel = Convert.ToInt32(ddlExperience.SelectedValue); obj.EducationLevel = Convert.ToInt32(ddlEducation.SelectedValue); obj.UserName = Profile.UserName; obj.Criteria = SearchTxt.Text; MySearch.Insert (obj); } }