private void getdata()
{
SqlDataAdapter mycmd= new SqlDataAdapter(mysql, mysqlcon);
DataTable dt= new DataTable();
mycmd.Fill(dt);
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
mysqlcon.Close();
}
//判断是否为全为数字
public bool IsNumeric(string strNumber)
{
strNumber="";
Regex NumberPattern=new Regex("[^0-9.-]");
return !NumberPattern.IsMatch(strNumber);
}
private void Page_Load(object sender, System.EventArgs e)
{
try
{
//根据传入参数判断用户请求
string jobkinds = Request.Params["jobkinds"].ToString ();
string jobname= Request.Params["jobname"].ToString ();
int model = Convert.ToInt32(Request.Params["model"].ToString ());
if(IsNumeric(Request.Params["model"].ToString ()))
{
switch( model)
{
//用户根据工作类别查看工作职位
case 1:
mysql = "select newjobs.comid, newjobs.jobname, newjobs.jobkinds, " +
" newjobs.peoplecount, newjobs.pubtime, newjobs.endtime, cominfor.comname " +
"from newjobs, cominfor where newjobs.comid= cominfor.comid and " +
" newjobs.jobkinds='" + jobkinds + "' and newjobs.endtime>getdate() " +
"and newjobs.jobstate=0 order by newjobs.id desc";
break;
//用户根据职位关键字与工作类别组合条件进行检索
case 2:
mysql = "select newjobs.comid, newjobs.jobname, newjobs.jobkinds, " +
" newjobs.peoplecount, newjobs.pubtime, newjobs.endtime, cominfor.comname " +
"from newjobs, cominfor where m newjobs.comid= cominfor.comid and " +
" newjobs.jobkinds='" + jobkinds + "' and newjobs.jobname like'%" + jobname + "%' and " +
"endtime>getdate() and newjobs.jobstate=0 order by newjobs.id desc";
break;
// 用户根据职位关键字进行检索
case 3:
mysql = "select newjobs.comid, newjobs.jobname, newjobs.jobkinds, newjobs.peoplecount," +
" newjobs.pubtime, newjobs.endtime, cominfor.comname from newjobs, cominfor where " +
" newjobs.comid= cominfor.comid and newjobs.jobname like'%" + jobname + "%' and " +
" newjobs.endtime>getdate() and newjobs.jobstate=0 order by newjobs.id desc";
break;
//所有职位
case 4:
mysql = "select newjobs.comid, newjobs.jobname, newjobs.jobkinds," +
" newjobs.peoplecount, newjobs.pubtime, newjobs.endtime,cominfor.comname " +
"from newjobs, cominfor where newjobs.comid= cominfor.comid and " +
" newjobs.endtime>getdate() and newjobs.jobstate=0 order by newjobs.id desc";
break;
}
getdata();
}
}
catch(Exception ee)
{
Response.Write (ee.Message);
}