protected void ImgSrs_Click3(object sender, EventArgs e) { getUser1(uID); getUser2(uID); GridBind(getUser3(uID)); Pagination1.Refresh(); }
/// <summary> /// 发送给全部用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSendAll_Click(object sender, EventArgs e) { string sql = string.Format(@"select * from dbo.ML_Member a left join ( select * from ML_NewsClassMain where sid0={0} ) b on a.nID=b.sid1 where b.sid1 is null", _ID); DataTable dt = her.ExecuteDataTable(sql); if (dt.Rows.Count > 0) { U_ShowDivPic(this.Page, "正在导入中…"); foreach (DataRow dr in dt.Rows) { XueYuan_Add(dr["nID"].ToString()); } GridBind(); Pagination1.Refresh(); this.Page.Response.Write("<script language=javascript>;HideWait();</script>"); } else { AjaxAlert.AlertMsgAndNoFlush(this, "无未发送学员"); //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('无未发送学员')</script>"); } }
public DataTable News_sel() { //分頁用 int currentPage = Request["page"] == null ? 1 : int.Parse(Request["page"]); SqlConnection Conn = new SqlConnection(); Conn.ConnectionString = ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString; DataTable dt = new DataTable(); try { string CmdString = @""; CmdString = @"with tstation as ( select row_number() over(order by inday desc) as rownumber, * from News )select *from tstation where rownumber>=@start and rownumber <=@end "; SqlCommand cmd = new SqlCommand(CmdString, Conn); cmd.Parameters.Add("@start", SqlDbType.Int); cmd.Parameters["@start"].Value = ((currentPage - 1) * PageSize) + 1; cmd.Parameters.Add("@end", SqlDbType.Int); cmd.Parameters["@end"].Value = currentPage * PageSize; Conn.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); dt.Load(dr); //分頁 SqlCommand totalcommand; totalcommand = new SqlCommand(@"select count('x') from News ", Conn); SqlDataAdapter totalAdapter = new SqlDataAdapter(totalcommand); DataTable totalTable = new DataTable(); totalAdapter.Fill((totalTable)); int total = Convert.ToInt32(totalTable.Rows[0][0]); Pagination1.totalitems = total; Pagination1.limit = PageSize; Pagination1.targetpage = "News.aspx"; //技巧:利用這種方式才可以呼叫usercontrol裡的public method Pagination1.showPageControls(); return(dt); } catch (Exception ex) { DB_string.log("News:", ex.ToString()); return(null); } finally { Conn.Close(); } }
private void show(string keyword) { int currentPage = Request["page"] == null ? 1 : int.Parse(Request["page"]); string search = ""; if (!string.IsNullOrEmpty(keyword)) { search = " and 地址 like '%'+@keyword+'%' ";//參數sql語法 Session["search"] = keyword; } string commandstring = $@"with tstation as (select row_number() over(order by id asc) as rownumber,* from test$ where 1 =1 {search})select *from tstation where rownumber>=@start and rownumber <=@end"; string connectstring = WebConfigurationManager.ConnectionStrings["PoliceConnectionString"].ToString(); SqlConnection connect = new SqlConnection(connectstring); SqlCommand sqlCommand = new SqlCommand(commandstring, connect); sqlCommand.Parameters.Add("@start", SqlDbType.Int); sqlCommand.Parameters["@start"].Value = ((currentPage - 1) * PageSize) + 1; sqlCommand.Parameters.Add("@end", SqlDbType.Int); sqlCommand.Parameters["@end"].Value = currentPage * PageSize; sqlCommand.Parameters.AddWithValue("@keyword", keyword); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill((dataTable)); GridView1.DataSource = dataTable; GridView1.DataBind(); SqlCommand totalcommand = new SqlCommand($@"select count(*) from [dbo].[test$] where 1=1 {search}", connect); totalcommand.Parameters.AddWithValue("@keyword", keyword); SqlDataAdapter totalAdapter = new SqlDataAdapter(totalcommand); DataTable totalTable = new DataTable(); totalAdapter.Fill((totalTable)); int total = Convert.ToInt32(totalTable.Rows[0][0]); Pagination1.totalitems = total; Pagination1.limit = PageSize; Pagination1.targetpage = "WebForm1.aspx"; //技巧:利用這種方式才可以呼叫usercontrol裡的public method Pagination1.showPageControls(); }
protected void imgdelete_Click(object sender, EventArgs e) { for (int i = 0; i < gridField.Rows.Count; i++) { CheckBox ckb = (CheckBox)gridField.Rows[i].FindControl("CheckSel"); if (ckb.Checked) { //bool success = Menber.MemberDelete(gridField.DataKeys[i].Value.ToString()); //if (!success) //{ // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('发生未知错误!请重试')</script>"); //} } } GridBind(); Pagination1.Refresh(); }
/// <summary> /// 选中发送 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void imgdelete_Click(object sender, EventArgs e) { for (int i = 0; i < gridField.Rows.Count; i++) { CheckBox ckb = (CheckBox)gridField.Rows[i].FindControl("CheckSel"); if (ckb.Checked) { bool success = XueYuan_Add(gridField.DataKeys[i].Value.ToString()); //if (!success) //{ // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('发生未知错误!请重试')</script>"); //} //else //{ // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功')</script>"); //} } } GridBind(); Pagination1.Refresh(); AjaxAlert.AlertMsgAndNoFlush(this, "发送成功"); //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('发送成功')</script>"); }
protected void ImgSrs_Click(object sender, EventArgs e) { GridBind(); Pagination1.Refresh(); }
public DataTable Detail(string id) { //分頁用 int currentPage = Request["page"] == null ? 1 : int.Parse(Request["page"]); SqlConnection Conn = new SqlConnection(); Conn.ConnectionString = ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString; DataTable dt = new DataTable(); try { string CmdString = @""; if (id == "") { //CmdString = @"select * from DealersD d // join DealersR r on d.R_no = r.R_no // join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no // where d.R_no=(select top 1 R_no from DealersR) "; CmdString = @"with tstation as ( select row_number() over(order by d.R_no asc) as rownumber, d.R_no,d.C_no,d.D_no,D.Info,D.Img, c.Country, r.Region from DealersD d join DealersR r on d.R_no = r.R_no join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no where d.R_no=(select top 1 R_no from DealersR))select *from tstation where rownumber>=@start and rownumber <=@end"; } else { //CmdString = @"select * from DealersD d // join DealersR r on d.R_no = r.R_no // join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no // where d.R_no=@id "; CmdString = @"with tstation as ( select row_number() over(order by d.R_no asc) as rownumber, d.R_no,d.C_no,d.D_no,D.Info,D.Img, c.Country, r.Region from DealersD d join DealersR r on d.R_no = r.R_no join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no where d.R_no=@id)select *from tstation where rownumber>=@start and rownumber <=@end"; } SqlCommand cmd = new SqlCommand(CmdString, Conn); cmd.Parameters.AddWithValue("id", id); //分頁 cmd.Parameters.Add("@start", SqlDbType.Int); cmd.Parameters["@start"].Value = ((currentPage - 1) * PageSize) + 1; cmd.Parameters.Add("@end", SqlDbType.Int); cmd.Parameters["@end"].Value = currentPage * PageSize; Conn.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); dt.Load(dr); title.InnerText = dt.Rows[0]["Region"].ToString(); //title title_nav.InnerText = dt.Rows[0]["Region"].ToString(); //title //分頁 SqlCommand totalcommand; if (id == "") { totalcommand = new SqlCommand(@"select count('x') from DealersD d join DealersR r on d.R_no = r.R_no join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no where d.R_no=(select top 1 R_no from DealersR) ", Conn); } else { totalcommand = new SqlCommand(@"select count('x') from DealersD d join DealersR r on d.R_no = r.R_no join DealersC c on c.R_no = r.R_no and c.C_no = d.C_no where d.R_no=@id ", Conn); } totalcommand.Parameters.AddWithValue("id", id); SqlDataAdapter totalAdapter = new SqlDataAdapter(totalcommand); DataTable totalTable = new DataTable(); totalAdapter.Fill((totalTable)); int total = Convert.ToInt32(totalTable.Rows[0][0]); Pagination1.totalitems = total; Pagination1.limit = PageSize; Pagination1.targetpage = "Dealers.aspx?id=" + id; //技巧:利用這種方式才可以呼叫usercontrol裡的public method Pagination1.showPageControls(); return(dt); } catch (Exception ex) { DB_string.log("Dealers_Detail:", ex.ToString()); return(null); } finally { Conn.Close(); } }