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; using System.Drawing; public partial class Controls_jobseekersearch : System.Web.UI.UserControl { public int iSearchType; protected void Page_Load(object sender, EventArgs e) { GridView1.Visible = false; 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["jobseekerrolename"])) { Response.Redirect("~/customerrorpages/NotAuthorized.aspx"); } if (!Page.IsPostBack) { FillCountries(); FillStates(); FillJobTypes(); FillCompanies(); //tblAddToFavorits.Style.Add("display", "none"); } 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) { lblMsg.Text = ""; GridView1.Visible = true; BindGrid(); } private void BindGrid() { int countryid = -1, stateid = -1, ProfIndustry = -1, ComapnyId = -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 (ddlCompany.SelectedItem != null) { ComapnyId = int.Parse(ddlCompany.SelectedValue); } if (ddlProfessionalIndustry.SelectedItem != null) { ProfIndustry = int.Parse(ddlProfessionalIndustry.SelectedValue); } if (txtTabIndex.Text == "2") { stateid = -1; countryid = -1; sSearch = string.Empty; sCity = string.Empty; ComapnyId = -1; } else if (txtTabIndex.Text == "3") { stateid = -1; countryid = -1; sCity = string.Empty; sSearch = string.Empty; ProfIndustry = -1; } else if (txtTabIndex.Text == "4") { sSearch = string.Empty; ProfIndustry = -1; ComapnyId = -1; } DataSet ds = JobPosting.SearchJobs (sSearch, countryid, stateid,txtCity.Text, ComapnyId,ProfIndustry); GridView1.DataSource = ds; GridView1.DataBind(); if (GridView1.Rows.Count <= 0) { lblMsg.Text = "Search Result:     No records found!"; lblMsg.ForeColor = Color.Red; //tblAddToFavorits.Style.Add("display", "none"); } else { // tblAddToFavorits.Style.Add("display", ""); lblMsg.ForeColor = Color.Green; lblMsg.Text = "Search Result:     Record(s) Found: " + GridView1.Rows.Count; } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton b = (LinkButton)e.Row.Cells[3].Controls[0]; b.CommandName = "viewdetails"; b.CommandArgument = GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); // b.PostBackUrl = "ApplyJob.aspx?id=" + b.CommandArgument; } } private void FillCountries() { ddlCountry.DataSource = Country.GetCountries(); ddlCountry.DataTextField = "CountryName"; ddlCountry.DataValueField = "CountryID"; ddlCountry.DataBind(); } private void FillJobTypes() { ddlProfessionalIndustry.DataSource = LookUp.GetProfessionalIndustries(); ddlProfessionalIndustry.DataTextField = "Description"; ddlProfessionalIndustry.DataValueField = "Id"; ddlProfessionalIndustry.DataBind(); ddlProfessionalIndustry.Items.Insert(0,new ListItem ("Not Set","-1")); } private void FillCompanies() { ddlCompany.DataSource = Company.GetCompanies(); ddlCompany.DataTextField = "CompanyName"; ddlCompany.DataValueField = "CompanyID"; ddlCompany.DataBind(); ddlCompany.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") { Response.Redirect("ApplyJob.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) { lblMsg.Text = ""; 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.UserName = Profile.UserName; obj.Criteria = SearchTxt.Text; obj.ProfessionalIndustry = int.Parse(ddlProfessionalIndustry.SelectedValue); obj.Company = int.Parse(ddlCompany.SelectedValue); MySearch.Insert (obj); } }