您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->学生管理信息系统+留言板>>DepsGrid.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:学生管理信息系统+留言板
当前文件:文件类型 StudentSys/DepsGrid.cs打开代码结构图
普通视图
		            
1namespace StudentSys 2{ 3 using System; 4 using System.Collections; 5 using System.ComponentModel; 6 using System.Data; 7 using System.Data.OleDb; 8 using System.Drawing; 9 using System.Web; 10 using System.Web.SessionState; 11 using System.Web.UI; 12 using System.Web.UI.WebControls; 13 using System.Web.UI.HtmlControls; 14 using StudentSys.Module; 15 16 public class DepsGrid : System.Web.UI.Page 17 { 18 //部门管理窗口自定义控件的声名 19 protected CCUtility Utility; 20 //该源码下载自www.51aspx.com(5_1_a_s_p_x.com) 21 22 //数据表格表单、变量等的声名 23 protected System.Web.UI.HtmlControls.HtmlTableRow deps_no_records; 24 protected string deps_sSQL; 25 protected string deps_sCountSQL; 26 protected int deps_CountPage; 27 protected CCPager deps_Pager;protected System.Web.UI.WebControls.LinkButton deps_insert; 28 protected System.Web.UI.WebControls.Repeater deps_Repeater; 29 protected int i_deps_curpage=1; 30 protected System.Web.UI.WebControls.Label ClassForm_Title; 31 protected System.Web.UI.WebControls.LinkButton deps_Column_name; 32 33 //定义各表单事件保护字符串 34 protected string deps_FormAction="DepsRecord.aspx?"; 35 36 37//初始化事件对象 38 public DepsGrid() 39 { 40 this.Init += new System.EventHandler(Page_Init); 41 } 42 43//AdminMenu中的自定义包含控件结束 44 public void ValidateNumeric(object source, ServerValidateEventArgs args) { 45 try{ 46 Decimal temp=Decimal.Parse(args.Value); 47 args.IsValid=true; 48 }catch{ 49 args.IsValid=false; } 50 } 51//定义登录窗口显示控件过程 52//初始化页面过程,创建一个Utility实例,并调用其相应的各方法 53 protected void Page_Load(object sender, EventArgs e) 54 { 55 Utility=new CCUtility(this); 56 Utility.CheckSecurity(3); 57 // 完成窗口安全验证 58 if (!IsPostBack){ 59 Page_Show(sender, e); 60 } 61 } 62 63//页面关闭过程 64 protected void Page_Unload(object sender, EventArgs e) 65 { 66 67 if(Utility!=null) Utility.DBClose(); 68 } 69 70//窗口中控件定义事件处理过程 71 protected void Page_Init(object sender, EventArgs e) 72 { 73 InitializeComponent(); 74 } 75 private void InitializeComponent() 76 { 77 this.deps_insert.Click += new System.EventHandler(this.deps_insert_Click); 78 this.Unload += new System.EventHandler(this.Page_Unload); 79 this.Load += new System.EventHandler(this.Page_Load); 80 81 } 82 83//定义整体显示页面过程 84 protected void Page_Show(object sender, EventArgs e) 85 { 86 deps_Bind(); 87 } 88 89// DepsGrid Show end 90//完成表单初始化 91 92//定义每一页显示的部门记录数 93const int deps_PAGENUM = 20; 94 95//查询数据库中部门记录数据集合 96ICollection deps_CreateDataSource() { 97 98 deps_sSQL = ""; 99 deps_sCountSQL = ""; 100 string sWhere = "", sOrder = ""; 101 102 bool HasParam = false; 103 104 //记录显示的排序方式 105 sOrder = " order by d.name Asc"; 106 if(Utility.GetParam("Formdeps_Sorting").Length>0&&!IsPostBack) 107 {ViewState["SortColumn"]=Utility.GetParam("Formdeps_Sorting"); 108 ViewState["SortDir"]="ASC";} 109 if(ViewState["SortColumn"]!=null) sOrder = " ORDER BY " + ViewState["SortColumn"].ToString()+" "+ViewState["SortDir"].ToString(); 110 111 System.Collections.Specialized.StringDictionary Params =new System.Collections.Specialized.StringDictionary(); 112 113 deps_sSQL = "select [d].[dep_id] as d_dep_id, " + 114 "[d].[name] as d_name " + 115 " from [deps] d "; 116 117 //组合Sql语句 118 deps_sSQL = deps_sSQL + sWhere + sOrder; 119 if (deps_sCountSQL.Length== 0) { 120 int iTmpI = deps_sSQL.ToLower().IndexOf("select "); 121 int iTmpJ = deps_sSQL.ToLower().LastIndexOf(" from ")-1; 122 deps_sCountSQL = deps_sSQL.Replace(deps_sSQL.Substring(iTmpI + 7, iTmpJ-6), " count(*) "); 123 iTmpI = deps_sCountSQL.ToLower().IndexOf(" order by"); 124 if (iTmpI > 1) deps_sCountSQL = deps_sCountSQL.Substring(0, iTmpI); 125 } 126 127 //数据联结 128 129 OleDbDataAdapter command = new OleDbDataAdapter(deps_sSQL, Utility.Connection); 130 DataSet ds = new DataSet(); 131 132 command.Fill(ds, (i_deps_curpage - 1) * deps_PAGENUM, deps_PAGENUM,"deps"); 133 OleDbCommand ccommand = new OleDbCommand(deps_sCountSQL, Utility.Connection); 134 int PageTemp=(int)ccommand.ExecuteScalar(); 135 deps_Pager.MaxPage=(PageTemp%deps_PAGENUM)>0?(int)(PageTemp/deps_PAGENUM)+1:(int)(PageTemp/deps_PAGENUM); 136 bool AllowScroller=deps_Pager.MaxPage==1?false:true; 137 138 DataView Source; 139 Source = new DataView(ds.Tables[0]); 140 141 if (ds.Tables[0].Rows.Count == 0){ 142 deps_no_records.Visible = true; 143 AllowScroller=false;} 144 else 145 {deps_no_records.Visible = false; 146 AllowScroller=AllowScroller&&true;} 147 148 deps_Pager.Visible=AllowScroller; 149 return Source; 150 //显示完成 151 } 152 153//定义导航页 154 protected void deps_pager_navigate_completed(Object Src, int CurrPage) 155 { 156 i_deps_curpage=CurrPage; 157 deps_Bind(); 158 } 159 160//绑定数据 161 void deps_Bind() { 162 deps_Repeater.DataSource = deps_CreateDataSource(); 163 deps_Repeater.DataBind(); 164 165 } 166 167//插入按钮事件 168 void deps_insert_Click(Object Src, EventArgs E) { 169 string sURL = deps_FormAction+""; 170 Response.Redirect(sURL); 171 } 172//正反排序事件 173 protected void deps_SortChange(Object Src, EventArgs E) { 174 if(ViewState["SortColumn"]==null || ViewState["SortColumn"].ToString()!=((LinkButton)Src).CommandArgument){ 175 ViewState["SortColumn"]=((LinkButton)Src).CommandArgument; 176 ViewState["SortDir"]="ASC"; 177 }else{ 178 ViewState["SortDir"]=ViewState["SortDir"].ToString()=="ASC"?"DESC":"ASC"; 179 } 180 deps_Bind(); 181 } 182 183 184 185 } 186}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:学生管理信息系统+留言板
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号