List.aspx.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. //using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. //using System.Xml.Linq;
  13. namespace Com.Jpsoft.Hospital.Web.Module.EmployeeGroup
  14. {
  15. public partial class List : Com.Jpsoft.Hospital.Web.Common.BasePage
  16. {
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. if (!IsPostBack)
  20. {
  21. int iCurPage = 1;
  22. int id = 0;
  23. string cmd = string.Empty;
  24. FetchQueryString("curpage", out iCurPage);
  25. FetchQueryString("cmd", out cmd);
  26. FetchQueryString("id", out id);
  27. AspNetPager1.RecordCount = iCurPage * AspNetPager1.PageSize;
  28. AspNetPager1.CurrentPageIndex = iCurPage;
  29. if (cmd == "del")
  30. {
  31. Delete(id, iCurPage);
  32. }
  33. }
  34. BindData();
  35. }
  36. private void Delete(int id, int pageindex)
  37. {
  38. Com.Jpsoft.Hospital.BLL.jp_employee_group group = new BLL.jp_employee_group();
  39. try
  40. {
  41. group.Delete(id);
  42. Response.Write("<script>alert('删除成功!');window.navigate('List.aspx?curpage=" + pageindex + "');</script>");
  43. }
  44. catch (Exception ex)
  45. {
  46. Response.Write("<script>alert('错误原因:" + ex.ToString() + "');</script>");
  47. }
  48. }
  49. private void BindData()
  50. {
  51. int RecordCount = 0;
  52. string strWhere = " where 1=1 ";
  53. if (!string.IsNullOrEmpty(this.txtGroupName.Text))
  54. {
  55. strWhere += " and eg_name like '%" + this.txtGroupName.Text + "%' ";
  56. }
  57. string strOrder = " order by eg_id DESC";
  58. Com.Jpsoft.Hospital.BLL.jp_employee_groupEx bll = new BLL.jp_employee_groupEx();
  59. using (IDataReader idr = bll.SelectPage(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, strOrder))
  60. {
  61. if (idr.Read())
  62. {
  63. RecordCount = Convert.ToInt32(idr["RecordCount"]);
  64. }
  65. idr.NextResult();
  66. GridView1.DataSource = idr;
  67. GridView1.DataBind();
  68. }
  69. this.AspNetPager1.RecordCount = RecordCount;
  70. }
  71. protected void Button1_Click(object sender, EventArgs e)
  72. {
  73. this.AspNetPager1.CurrentPageIndex = 0;
  74. BindData();
  75. }
  76. protected void AspNetPager1_PageChanged(object sender, EventArgs e)
  77. {
  78. BindData();
  79. }
  80. }
  81. }