您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->学生管理信息系统+留言板>>Default.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:学生管理信息系统+留言板
当前文件:文件类型 StudentSys/Default.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 Default : System.Web.UI.Page 17 { 18 //该源码下载自www.51aspx.com(51a_s_px.com) 19 //定义默认控件声明 20 protected CCUtility Utility; 21 //登录表单、变量等的声名 22 protected System.Web.UI.WebControls.TextBox Login_name; 23 protected System.Web.UI.WebControls.TextBox Login_password; 24 protected System.Web.UI.WebControls.Button Login_login; 25 protected System.Web.UI.HtmlControls.HtmlTableRow Login_trname; 26 protected System.Web.UI.HtmlControls.HtmlTableRow Login_trpassword; 27 protected System.Web.UI.WebControls.Label Login_labelname; 28 protected System.Web.UI.WebControls.Label Login_message; 29 protected System.Web.UI.HtmlControls.HtmlInputHidden Login_querystring; 30 protected System.Web.UI.HtmlControls.HtmlInputHidden Login_ret_page; 31 32 //表格表单、相关控制变量声名 33 protected System.Web.UI.HtmlControls.HtmlTableRow Grid_no_records; 34 protected System.Web.UI.HtmlControls.HtmlTableRow AdminList_Title; 35 protected System.Web.UI.HtmlControls.HtmlTableRow AdminStu_Title; 36 protected System.Web.UI.HtmlControls.HtmlTableRow AdminClass_Title; 37 protected string Grid_sSQL; 38 protected string Grid_sCountSQL; 39 protected int Grid_CountPage; 40 41 protected System.Web.UI.WebControls.Repeater Grid_Repeater; 42 protected int i_Grid_curpage=1; 43 44 //查询表单、相关控制变量声名 45 protected System.Web.UI.WebControls.Button Search_search_button; 46 protected System.Web.UI.WebControls.DropDownList Search_dep_id; 47 protected System.Web.UI.WebControls.TextBox Search_name; 48 protected System.Web.UI.WebControls.TextBox Search_email; 49 50 //每月之星员工记录表单、相关变量声名 51 protected System.Web.UI.HtmlControls.HtmlTableRow EmpMonth_no_records; 52 protected string EmpMonth_sSQL; 53 protected string EmpMonth_sCountSQL; 54 protected int EmpMonth_CountPage; 55 56 protected System.Web.UI.WebControls.Repeater EmpMonth_Repeater; 57 protected int i_EmpMonth_curpage=1; 58 59 //每个相应表单事件保护字符串 60 protected string Grid_FormAction=".aspx?"; 61 protected string Search_FormAction="Default.aspx?"; 62 protected System.Web.UI.WebControls.Label EmpMonthForm_Title; 63 protected System.Web.UI.WebControls.Label LoginForm_Title; 64 protected System.Web.UI.WebControls.HyperLink Form_Field2; 65 protected System.Web.UI.WebControls.HyperLink Form_Field1; 66 protected System.Web.UI.WebControls.Label SearchForm_Title; 67 protected System.Web.UI.WebControls.Label GridForm_Title; 68 protected System.Web.UI.WebControls.LinkButton Grid_Column_name; 69 protected System.Web.UI.WebControls.LinkButton Grid_Column_title; 70 protected System.Web.UI.WebControls.LinkButton Grid_Column_dep_id; 71 protected System.Web.UI.WebControls.LinkButton Grid_Column_work_phone; 72 protected System.Web.UI.WebControls.LinkButton Grid_Column_email; 73 protected string EmpMonth_FormAction=".aspx?"; 74 75 public Default() 76 { 77 this.Init += new System.EventHandler(Page_Init); 78 } 79 80 //默认自定义控件声名结束 81 public void ValidateNumeric(object source, ServerValidateEventArgs args) { 82 try{ 83 Decimal temp=Decimal.Parse(args.Value); 84 args.IsValid=true; 85 }catch{ 86 args.IsValid=false; } 87 } 88 89 // Default Show begin 90 protected void Page_Load(object sender, EventArgs e) 91 { 92 Utility=new CCUtility(this); 93 if (Session["UserID"] != null && Int16.Parse(Session["UserID"].ToString()) > 0) 94 Login_logged = true; 95 //如果初次装载页面,执行Page_Show 96 if (!IsPostBack){ 97 AdminList_Title.Visible = false; 98 AdminStu_Title.Visible = false; 99 AdminClass_Title.Visible = false; 100 Page_Show(sender, e); 101 } 102 } 103 104//关闭页面过程 105 protected void Page_Unload(object sender, EventArgs e) 106 { 107 if(Utility!=null) Utility.DBClose(); 108 } 109 110//窗口中控件定义事件处理过程 111 protected void Page_Init(object sender, EventArgs e) 112 { 113 InitializeComponent(); 114 } 115 private void InitializeComponent() 116 { 117 this.Login_login.Click += new System.EventHandler(this.Login_login_Click); 118 this.Search_search_button.Click += new System.EventHandler(this.Search_search_Click); 119 this.Unload += new System.EventHandler(this.Page_Unload); 120 this.Load += new System.EventHandler(this.Page_Load); 121 122 } 123 124//页面中的数据显示过程 125 protected void Page_Show(object sender, EventArgs e) 126 { 127 Grid_Bind(); 128 Search_Show(); 129 EmpMonth_Bind(); 130 Login_Show(); 131 } 132 133// Default Show end 134//完成表单初始化 135 136//定义登录的控制变量,初始值为false,保证安全管理 137protected bool Login_logged = false; 138//登录表单显示过程函数 139 void Login_Show() { 140 if (Login_logged) { 141 //登录成功的处理 142 Login_login.Text = "退出"; 143 Login_trpassword.Visible = false; 144 Login_trname.Visible = false; 145 Login_labelname.Visible = true; 146 Login_labelname.Text = Utility.Dlookup("emps", "emp_login", "emp_id=" + Session["UserID"]) + "&nbsp;&nbsp;&nbsp;"; 147 Utility=new CCUtility(this); 148 if (Utility.CheckSecurity(3)) 149 { 150 AdminList_Title.Visible = true; 151 AdminStu_Title.Visible = true; 152 AdminClass_Title.Visible = true; 153 } 154 } else { 155 //未登录的处理 156 Login_login.Text = "登录"; 157 Login_trpassword.Visible = true; 158 Login_trname.Visible = true; 159 Login_labelname.Visible = false; 160 AdminList_Title.Visible = false; 161 AdminStu_Title.Visible = false; 162 AdminClass_Title.Visible = false; 163 } 164 } 165 166 //验证登录事件 167 void Login_login_Click(Object Src, EventArgs E) { 168 if (Login_logged) { 169 //已经登录成功则退出登录 170 Login_logged = false; 171 Session["UserID"] = 0; 172 Session["UserRights"] = 0; 173 Login_Show(); 174 175 } else { 176 177 //进行登录验证 178 int iPassed = Convert.ToInt32(Utility.Dlookup("emps", "count(*)", "emp_login ='" + Login_name.Text + "' and emp_password='" + CCUtility.Quote(Login_password.Text) + "'")); 179 if (iPassed > 0) { 180 Login_message.Visible = false; 181 Session["UserID"] = Convert.ToInt32(Utility.Dlookup("emps", "emp_id", "emp_login ='" + Login_name.Text + "' and emp_password='" + CCUtility.Quote(Login_password.Text) +"'")); 182 Login_logged = true; 183 184 Session["UserRights"] = Convert.ToInt32(Utility.Dlookup("emps", "emp_level", "emp_login ='" + Login_name.Text + "' and emp_password='" + CCUtility.Quote(Login_password.Text) + "'")); 185 186 string sQueryString = Utility.GetParam("querystring"); 187 string sPage = Utility.GetParam("ret_page"); 188 if (! sPage.Equals(Request.ServerVariables["SCRIPT_NAME"]) && sPage.Length > 0) { 189 Response.Redirect(sPage + "?" + sQueryString); 190 } else { 191 192 Response.Redirect(Search_FormAction); 193 } 194 } else { 195 Login_message.Visible = true; 196 } 197 // Login Login end 198 199 } 200 } 201 202//定义每页显示记录常数 203const int Grid_PAGENUM = 20; 204 205public void Grid_Repeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e){ 206 207// Grid Show Event begin 208if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem ) 209{ 210 ((Label)e.Item.FindControl("Grid_email")).Text ="<a href=\"mailto:" + ((DataRowView)e.Item.DataItem )["e_email"].ToString() + "\">" + ((DataRowView)e.Item.DataItem )["e_email"].ToString() + "</a>"; 211} 212// Grid Show Event end 213} 214 215 216 ICollection Grid_CreateDataSource() 217 { 218 219 220 //开始用于显示数据 221 Grid_sSQL = ""; 222 Grid_sCountSQL = ""; 223 string sWhere = "", sOrder = ""; 224 bool HasParam = false; 225 226 //建立排序方式(逆序或正序) 227 sOrder = " order by e.name Asc"; 228 if(Utility.GetParam("FormGrid_Sorting").Length>0&&!IsPostBack) 229 { 230 ViewState["SortColumn"]=Utility.GetParam("FormGrid_Sorting"); 231 ViewState["SortDir"]="ASC"; 232 } 233 if(ViewState["SortColumn"]!=null) 234 sOrder = " ORDER BY " + ViewState["SortColumn"].ToString()+" "+ViewState["SortDir"].ToString(); 235 236 //建立学生属性 237 System.Collections.Specialized.StringDictionary Params =new System.Collections.Specialized.StringDictionary(); 238 239 240 if(!Params.ContainsKey("dep_id")) 241 { 242 string temp=Utility.GetParam("dep_id"); 243 if (Utility.IsNumeric(null,temp) && temp.Length>0) { temp = CCUtility.ToSQL(temp, CCUtility.FIELD_TYPE_Number);} else {temp = "";} 244 Params.Add("dep_id",temp); 245 } 246 247 if(!Params.ContainsKey("email")) 248 { 249 string temp=Utility.GetParam("email"); 250 Params.Add("email",temp);} 251 252 if(!Params.ContainsKey("name")) 253 { 254 string temp=Utility.GetParam("name"); 255 Params.Add("name",temp);} 256 257 if (Params["dep_id"].Length>0) 258 { 259 HasParam = true; 260 sWhere +="e.[dep_id]=" + Params["dep_id"]; 261 } 262 if (Params["email"].Length>0) 263 { 264 if (sWhere.Length >0) sWhere +=" and "; 265 HasParam = true; 266 sWhere +="e.[email] like '%" + Params["email"].Replace( "'", "''") + "%'"; 267 } 268 if (Params["name"].Length>0) { 269 if (sWhere.Length >0) sWhere +=" and "; 270 HasParam = true; 271 sWhere +="e.[name] like '%" + Params["name"].Replace( "'", "''") + "%'"; 272 } 273 274 275 if(HasParam) 276 sWhere = " AND (" + sWhere + ")"; 277 278 //定义Sql语句 279 280 Grid_sSQL = "select [e].[dep_id] as e_dep_id, " + 281 "