Asp.net源码专业站
首页->商务办公->Asp.net考勤系统源码>>adminEight.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net考勤系统源码
当前文件:文件类型 kaoqin/adminEight.aspx.cs[5K,2009-6-12 11:46:24]打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Web; 7using System.Web.SessionState; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.HtmlControls; 11using System.Data.OleDb; 12//该源码下载自www.51aspx.com(51aspx.com) 13 14namespace KaoQin 15{ 16 /// <summary> 17 /// adminEight 的摘要说明。 18 /// </summary> 19 public class adminEight : System.Web.UI.Page 20 { 21 protected System.Web.UI.WebControls.Label Label1; 22 protected System.Web.UI.WebControls.Label Label2; 23 protected System.Web.UI.WebControls.TextBox txtCode; 24 protected System.Web.UI.WebControls.Label Label3; 25 protected System.Web.UI.WebControls.Label Label4; 26 protected System.Web.UI.WebControls.TextBox txtPwd; 27 protected System.Web.UI.WebControls.Button Button1; 28 protected System.Web.UI.WebControls.Button Button2; 29 protected System.Web.UI.WebControls.TextBox txtName; 30 protected System.Web.UI.WebControls.DataGrid data; 31 protected System.Web.UI.WebControls.Label info; 32 protected System.Data.DataSet ds; 33 protected System.Data.OleDb.OleDbDataReader reader; 34 protected System.Data.OleDb.OleDbConnection con; 35 protected System.Data.OleDb.OleDbCommand com; 36 protected System.Web.UI.WebControls.Button Button3; 37 protected System.Data.OleDb.OleDbDataAdapter da; 38 39 private void Page_Load(object sender, System.EventArgs e) 40 { 41 // 在此处放置用户代码以初始化页面 42 if(System.Convert.ToString(Session["admin"]).Equals("")) 43 { 44 Response.Redirect("admin.aspx"); 45 } 46 else 47 { 48 string strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("message.mdb")+";User Id=admin;Password=;"; 49 con=new OleDbConnection(strcon); 50 if(!IsPostBack) 51 { 52 bind(); 53 } 54 } 55 } 56 57 Web 窗体设计器生成的代码 82 83 private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e) 84 { 85 data.CurrentPageIndex=e.NewPageIndex; 86 bind(); 87 } 88 89 private void Button1_Click(object sender, System.EventArgs e) 90 { 91 if(txtCode.Text.Trim().Equals("")) 92 { 93 info.Text="管理员编号不能为空!"; 94 } 95 else if(txtPwd.Text.Trim().Equals("")) 96 { 97 info.Text="管理员密码不能为空!"; 98 } 99 else if(txtPwd.Text.Length<6) 100 { 101 info.Text="管理员密码不能小于6位!"; 102 } 103 else if(txtName.Text.Trim().Equals("")) 104 { 105 info.Text="管理员姓名不能为空!"; 106 } 107 else 108 { 109 info.Text=""; 110 string sql2,sql3; 111 int count=0; 112 sql2="select adminId from admin where adminId='"+txtCode.Text.Trim()+"'"; 113 con.Open(); 114 com=new System.Data.OleDb.OleDbCommand(sql2,con); 115 reader=com.ExecuteReader(); 116 while(reader.Read()) 117 { 118 count++; 119 } 120 reader.Close(); 121 com.Dispose(); 122 con.Close(); 123 if(count==0) 124 { 125 sql3="insert into admin values('"+txtCode.Text.Trim()+"','"+txtPwd.Text.Trim()+"','"+txtName.Text.Trim()+"')"; 126 con.Open(); 127 com=new System.Data.OleDb.OleDbCommand(sql3,con); 128 com.ExecuteNonQuery(); 129 com.Dispose(); 130 con.Close(); 131 txtCode.Text=""; 132 txtPwd.Text=""; 133 txtName.Text=""; 134 bind(); 135 } 136 else 137 { 138 info.Text="你添加的管理员编号已存在!"; 139 } 140 con.Close(); 141 } 142 } 143 144 private void Button2_Click(object sender, System.EventArgs e) 145 { 146 txtCode.Text=""; 147 txtPwd.Text=""; 148 txtName.Text=""; 149 } 150 151 private void data_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 152 { 153 string id=(string)data.DataKeys[(int)e.Item.ItemIndex]; 154 if(id.Trim().Equals("admin")) 155 { 156 info.Text="系统管理员不能删除!"; 157 } 158 else 159 { 160 string sql4="delete from admin where adminId='"+id+"'"; 161 con.Open(); 162 com=new System.Data.OleDb.OleDbCommand(sql4,con); 163 com.ExecuteNonQuery(); 164 com.Dispose(); 165 con.Close(); 166 bind(); 167 } 168 } 169 170 public void bind() 171 { 172 con.Open(); 173 ds=new DataSet(); 174 string sql="select * from admin order by adminId desc"; 175 da=new System.Data.OleDb.OleDbDataAdapter(sql,con); 176 da.Fill(ds,"admin"); 177 da.Dispose(); 178 con.Close(); 179 data.DataSource=ds.Tables["admin"].DefaultView; 180 data.DataBind(); 181 } 182 183 private void Button3_Click(object sender, System.EventArgs e) 184 { 185 Response.Redirect("adminFive.aspx"); 186 } 187 } 188} 189
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Asp.net考勤系统源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146