您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->学生管理信息系统+留言板>>DepsRecord.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:学生管理信息系统+留言板
当前文件:文件类型 StudentSys/DepsRecord.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 DepsRecord : System.Web.UI.Page 17 { 18 19//更新窗口定义控件的声名 20 protected CCUtility Utility; 21 22 //更新记录表单、变量等的声名 23 protected System.Web.UI.WebControls.Label deps_ValidationSummary; 24 protected System.Web.UI.HtmlControls.HtmlInputButton deps_insert; 25 protected System.Web.UI.HtmlControls.HtmlInputButton deps_update; 26 protected System.Web.UI.HtmlControls.HtmlInputButton deps_delete; 27 protected System.Web.UI.HtmlControls.HtmlInputButton deps_cancel; 28 protected System.Web.UI.HtmlControls.HtmlInputHidden deps_dep_id; 29 protected System.Web.UI.WebControls.TextBox deps_name; 30 31 //定义各表单事件保护字符串 32 protected string deps_FormAction="DepsGrid.aspx?"; 33 protected System.Web.UI.WebControls.Label GridForm_Title; 34 protected System.Web.UI.HtmlControls.HtmlInputHidden p_deps_dep_id; 35 36//初始化事件 37 public DepsRecord() 38 { 39 this.Init += new System.EventHandler(Page_Init); 40 } 41//DepsRecord中的自定义包含控件结束 42 43 public void ValidateNumeric(object source, ServerValidateEventArgs args) { 44 try{ 45 Decimal temp=Decimal.Parse(args.Value); 46 args.IsValid=true; 47 }catch{ 48 args.IsValid=false; } 49 } 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 60 p_deps_dep_id.Value = Utility.GetParam("dep_id");Page_Show(sender, e); 61 } 62 } 63 64//页面关闭过程 65 protected void Page_Unload(object sender, EventArgs e) 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.ServerClick += new System.EventHandler(this.deps_Action); 78 this.deps_update.ServerClick += new System.EventHandler(this.deps_Action); 79 this.deps_delete.ServerClick += new System.EventHandler(this.deps_Action); 80 this.deps_cancel.ServerClick += new System.EventHandler(this.deps_Action); 81 this.Unload += new System.EventHandler(this.Page_Unload); 82 this.Load += new System.EventHandler(this.Page_Load); 83 84 } 85 86//定义整体显示页面过程 87 protected void Page_Show(object sender, EventArgs e) 88 { 89 deps_Show(); 90 91 } 92// DepsRecord Show end 93//完成表单初始化 94 95 96//定义控制函数,控制按钮的的显示与否 97//如,当插入记录时,应显示插入、取消按钮,而修改时应显示修改、删除、取消按钮 98private bool deps_Validate(){ 99 bool result=true; 100 deps_ValidationSummary.Text=""; 101 102 for(int i=0;i<Page.Validators.Count;i++){ 103 if(((System.Web.UI.WebControls.BaseValidator)Page.Validators[i]).ID.ToString().StartsWith("deps")){ 104 if(!Page.Validators[i].IsValid){ 105 deps_ValidationSummary.Text+=Page.Validators[i].ErrorMessage+"<br>"; 106 result=false; 107 } 108 } 109 } 110 111 deps_ValidationSummary.Visible=(!result); 112 return result; 113} 114 115//更新记录的显示过程 116void deps_Show() { 117 118 bool ActionInsert=true; 119 120 if (p_deps_dep_id.Value.Length > 0 ) { 121 string sWhere = ""; 122 123 sWhere += "dep_id=" + CCUtility.ToSQL(p_deps_dep_id.Value, CCUtility.FIELD_TYPE_Number); 124 125 string sSQL = "select * from deps where " + sWhere; 126 OleDbDataAdapter dsCommand = new OleDbDataAdapter(sSQL, Utility.Connection); 127 DataSet ds = new DataSet(); 128 DataRow row; 129 130 if (dsCommand.Fill(ds, 0, 1, "deps") > 0) { 131 row = ds.Tables[0].Rows[0]; 132 133 deps_dep_id.Value = CCUtility.GetValue(row, "dep_id"); 134 135 136 deps_name.Text = CCUtility.GetValue(row, "name"); 137 deps_insert.Visible=false; 138 ActionInsert=false; 139 }} 140 141 if(ActionInsert){ 142 143 String pValue; 144 145 pValue = Utility.GetParam("dep_id");deps_dep_id.Value = pValue;deps_delete.Visible=false; 146 deps_update.Visible=false; 147 148} 149 150 } 151 152//插入新记录事件代码 153bool deps_insert_Click(Object Src, EventArgs E) { 154 string sSQL=""; 155 bool bResult=deps_Validate(); 156 157 if(bResult){ 158 159 160 string p2_name=CCUtility.ToSQL(Utility.GetParam("deps_name"), CCUtility.FIELD_TYPE_Text) ; 161 162 sSQL = "insert into deps (" + 163 "name)" + 164 " values (" + 165 p2_name + ")"; 166 OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection); 167 try { 168 cmd.ExecuteNonQuery(); 169 } catch(Exception e) { 170 deps_ValidationSummary.Text += e.Message; 171 deps_ValidationSummary.Visible = true; 172 return false; 173 } 174 } 175 return bResult; 176 } 177 178 179 180//更新记录事件代码 181 bool deps_update_Click(Object Src, EventArgs E) { 182 string sWhere = ""; 183 string sSQL =""; 184 185 bool bResult=deps_Validate(); 186 if(bResult){ 187 188 if (p_deps_dep_id.Value.Length > 0) { 189 sWhere = sWhere + "dep_id=" + CCUtility.ToSQL(p_deps_dep_id.Value, CCUtility.FIELD_TYPE_Number); 190 } 191 192 if (bResult){ 193 194 sSQL = "update deps set " + 195 "[name]=" +CCUtility.ToSQL(Utility.GetParam("deps_name"),CCUtility.FIELD_TYPE_Text) ; 196 197 198 sSQL = sSQL + " where " + sWhere; 199 200 OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection); 201 try { 202 cmd.ExecuteNonQuery(); 203 } catch(Exception e) { 204 deps_ValidationSummary.Text += e.Message; 205 deps_ValidationSummary.Visible = true; 206 return false; 207 } 208 } 209 210 } 211 return bResult; 212 } 213 214//删除记录代码 215bool deps_delete_Click(Object Src, EventArgs E) { 216 string sWhere = ""; 217 218 if (p_deps_dep_id.Value.Length > 0) { 219 sWhere += "dep_id=" + CCUtility.ToSQL(p_deps_dep_id.Value, CCUtility.FIELD_TYPE_Number); 220 } 221 222 string sSQL = "delete from deps where " + sWhere; 223 224 OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection); 225 try { 226 cmd.ExecuteNonQuery(); 227 } catch(Exception e) { 228 deps_ValidationSummary.Text += e.Message; 229 deps_ValidationSummary.Visible = true; 230 return false; 231 } 232 return true; 233} 234 235//取消更新代码 236bool deps_cancel_Click(Object Src, EventArgs E) { 237 return true; 238 } 239 240//为各按钮点击事件参数函数代码 241void deps_Action(Object Src, EventArgs E) { 242bool bResult=true; 243if(((HtmlInputButton)Src).ID.IndexOf("insert")>0) bResult=deps_insert_Click(Src,E); 244if(((HtmlInputButton)Src).ID.IndexOf("update")>0) bResult=deps_update_Click(Src,E); 245if(((HtmlInputButton)Src).ID.IndexOf("delete")>0) bResult=deps_delete_Click(Src,E); 246if(((HtmlInputButton)Src).ID.IndexOf("cancel")>0) bResult=deps_cancel_Click(Src,E); 247if(bResult)Response.Redirect(deps_FormAction+""); 248} 249 250 } 251}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:学生管理信息系统+留言板
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号