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 System.Data.SqlClient; public partial class Default : System.Web.UI.Page { public string num; protected void Page_Load(object sender, EventArgs e) { num = "1540"; if (!this.Page.IsPostBack) { DataSet set = DB.Area_DataSet(); this.dr_area.DataSource = set; this.dr_area.DataTextField = "areaText"; this.dr_area.DataValueField = "areavalue"; this.dr_area.DataBind(); this.dr_area.Items.Insert(0, new ListItem("=不限制=", "0")); DataListBing_cl_ass(); DataListBing_FriendLink(); DataListBing_NewJob(); DataListBing_Article(); DataListBing_Tb_Column(); DataListBing_Tb_Column2(); num = GetRandomint(); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string str = "stop=0 and checked=1 and addtime <=getdate() and Is_View=1 "; string str2 = base.Request.Form.Get("pt33"); string str3 = base.Request.Form.Get("key22"); string selectedValue = this.dr_area.SelectedValue; if (str2 != "0") { str = str + " and datediff(day,lastedit,getdate()) <= " + str2 + ""; } if (str3 != "") { string str5 = str; str = str5 + " and (jobname like '%" + str3 + "%' or cname like '%" + str3 + "%')"; } if (selectedValue != "0") { str = str + " and area_Value = " + selectedValue + ""; } this.clearCookies(); HttpCookie cookie = new HttpCookie("gaojiJob"); cookie.Value = HttpUtility.UrlEncode(str); base.Response.AppendCookie(cookie); base.Response.Redirect("Job_List2.aspx?Classid=1"); } public void clearCookies() { HttpCookie cookie = base.Request.Cookies["gaojiJob"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1.0); } } private void DataListBing_cl_ass() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select * from cl_ass where cl_ass_id<1000 "; conn.Open(); adp.Fill(ds, "cl_ass"); conn.Close(); conn.Dispose(); DataList_cl_ass.DataSource = ds.Tables["cl_ass"]; DataList_cl_ass.DataBind(); } private void DataListBing_FriendLink() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select * from FriendLink where linktype=0 order by id desc"; conn.Open(); adp.Fill(ds, "FriendLink"); conn.Close(); conn.Dispose(); DataList_FriendLink.DataSource = ds.Tables["FriendLink"]; DataList_FriendLink.DataBind(); } private void DataListBing_NewJob() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select top 18 [id],[cid],[cname],[jobname],xl_text,renshu,addtime,showjob,showc,[money] from job where stop=0 and checked=1 and addtime <=getdate() and Is_View=1 order by LastEdit Desc,id desc"; conn.Open(); adp.Fill(ds, "job"); conn.Close(); conn.Dispose(); DataList_NewJob.DataSource = ds.Tables["job"]; DataList_NewJob.DataBind(); } private void DataListBing_Article() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select top 100 [id],Substring([title],0,30) as [title],addtime,hits,classname,show_news,Column_ID,Column_Name " + " from Article,Tb_Column where Article.classid=Tb_Column.Column_ID AND id <> -1 order by id desc"; //cmd.CommandText = "select top 11 [id],Substring([title],0,30) as [title],addtime,hits,classname,show_news,Column_ID,Column_Name " + //" from Article,Tb_Column where Article.classid=Tb_Column.Column_ID AND id <> -1 and classid in(2,11,12,13,15,16) order by id desc"; conn.Open(); adp.Fill(ds, "Article"); conn.Close(); conn.Dispose(); DataList_Article.DataSource = ds.Tables["Article"]; DataList_Article.DataBind(); } private void DataListBing_Tb_Column() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select Column_Id,Parent_ID,Column_Name,Column_Depth,Column_img from Tb_Column where parent_ID=1 order by Column_Order"; conn.Open(); adp.Fill(ds, "Tb_Column"); conn.Close(); conn.Dispose(); DataList_tb_column.DataSource = ds.Tables["Tb_Column"]; DataList_tb_column.DataBind(); } private void DataListBing_Tb_Column2() { SqlConnection conn = DB.CreatCon(); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); ds.Clear(); cmd.Connection = conn; adp.SelectCommand = cmd; cmd.CommandText = "select Column_Id,Parent_ID,Column_Name,Column_Depth,Column_img from Tb_Column where parent_ID=3 order by Column_Order"; conn.Open(); adp.Fill(ds, "Tb_Column"); conn.Close(); conn.Dispose(); DataList_tb_column2.DataSource = ds.Tables["Tb_Column"]; DataList_tb_column2.DataBind(); } public string GetRandomint() { string Temp_RondNum = string.Empty; Temp_RondNum = "1208"; Random random = new Random(); //当天00:00至当天09:00 if (DateTime.Now >= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "00:00") && DateTime.Now <= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "09:00") ) { Temp_RondNum = random.Next(200, 500).ToString(); } //当天09:00至当天12:00 if (DateTime.Now >= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "09:00") && DateTime.Now <= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "12:00") ) { Temp_RondNum = random.Next(1200, 1500).ToString(); } //当天12:00至当天18:00 if (DateTime.Now >= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "12:00") && DateTime.Now <= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "18:00") ) { Temp_RondNum = random.Next(2100, 3519).ToString(); } //当天18:00至当天23:59 if (DateTime.Now >= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "18:00") && DateTime.Now <= System.Convert.ToDateTime(ChangeDateStr(DateTime.Now) + " " + "23:59") ) { Temp_RondNum = random.Next(500, 1200).ToString(); } return Temp_RondNum; } private string ChangeDateStr(DateTime DateTimeStr) { string TempDateStr = ""; string TempYearStr = "";//存放年 string TempMonthStr = "";//存放月 string TempDayStr = "";//存放日 TempYearStr = System.Convert.ToString(DateTimeStr.Year); if (System.Convert.ToString(DateTimeStr.Month).Length < 2) { TempMonthStr = "0" + System.Convert.ToString(DateTimeStr.Month); } else { TempMonthStr = System.Convert.ToString(DateTimeStr.Month); } if (System.Convert.ToString(DateTimeStr.Day).Length < 2) { TempDayStr = "0" + System.Convert.ToString(DateTimeStr.Day); } else { TempDayStr = System.Convert.ToString(DateTimeStr.Day); } TempDateStr = TempYearStr + "-" + TempMonthStr + "-" + TempDayStr; return TempDateStr; } }