温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net考勤系统源码
当前文件:
kaoqin/adminFour.aspx.cs[8K,2009-6-12 11:46:24],打开代码结构图
kaoqin/adminFour.aspx.cs[8K,2009-6-12 11:46:24],打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
using System.Data.OleDb; 12
13
namespace KaoQin 14
{ 15
/// <summary> 16
/// adminFour 的摘要说明。 17
/// </summary> 18
public class adminFour : System.Web.UI.Page 19
{ 20
protected System.Web.UI.WebControls.DropDownList ddId; 21
protected System.Web.UI.WebControls.Label Label1; 22
protected System.Data.DataSet ds; 23
protected System.Web.UI.WebControls.DataGrid data; 24
protected System.Web.UI.WebControls.Button btnQuery; 25
protected System.Web.UI.WebControls.Label info; 26
protected System.Web.UI.WebControls.Label Label2; 27
protected System.Web.UI.WebControls.Label Label3; 28
protected System.Web.UI.WebControls.Label Label4; 29
protected System.Web.UI.WebControls.DropDownList ddYear; 30
protected System.Web.UI.WebControls.DropDownList ddMon; 31
protected System.Web.UI.WebControls.Label labCd; 32
protected System.Web.UI.WebControls.Label labZt; 33
protected System.Web.UI.WebControls.Label labBj; 34
protected System.Web.UI.WebControls.Label labSj; 35
protected System.Web.UI.WebControls.Label labKg; 36
protected System.Data.OleDb.OleDbDataReader reader; 37
protected System.Data.OleDb.OleDbConnection con; 38
protected System.Data.OleDb.OleDbCommand com; 39
protected System.Data.OleDb.OleDbDataAdapter da; 40
41
private void Page_Load(object sender, System.EventArgs e) 42
{ 43
// 在此处放置用户代码以初始化页面 44
if(System.Convert.ToString(Session["admin"]).Equals("")) 45
{ 46
Response.Redirect("admin.aspx"); 47
} 48
else 49
{ 50
string strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("message.mdb")+";User Id=admin;Password=;"; 51
con=new OleDbConnection(strcon); 52
ds=new DataSet(); 53
string sql1="select id from usermessage"; 54
if(!IsPostBack) 55
{ 56
con.Open(); 57
com=new OleDbCommand(sql1,con); 58
reader=com.ExecuteReader(); 59
while(reader.Read()) 60
{ 61
ddId.Items.Add(reader.GetString(0)); 62
} 63
reader.Close(); 64
com.Dispose(); 65
con.Close(); 66
} 67
} 68
} 69
70
Web 窗体设计器生成的代码 93
private void btnQuery_Click(object sender, System.EventArgs e) 94
{ 95
string strId,strYear,strMon,strSql; 96
strId=ddId.SelectedItem.Text.Trim().ToString(); 97
strYear=ddYear.SelectedItem.Text.Trim().ToString(); 98
strMon=ddMon.SelectedItem.Text.Trim().ToString(); 99
if(strId.Equals("")) 100
{ 101
info.Text="请选择员工编号!"; 102
} 103
else 104
{ 105
if(strYear.Equals("")) 106
{ 107
info.Text="请选择查询年份!"; 108
} 109
else 110
{ 111
if(strMon.Equals("")) 112
{ 113
info.Text="请选择查询月份!"; 114
} 115
else 116
{ 117
string strCd,strZt,strSj,strBj,strKg; 118
int cdCount=0,ztCount=0,sjCount=0,bjCount=0,kgCount=0; 119
strCd="select id from kaoqin where id='"+strId+"' and cd='迟到' and year='"+strYear+"' and mon='"+strMon+"'"; 120
strZt="select id from kaoqin where id='"+strId+"' and zt='早退' and year='"+strYear+"' and mon='"+strMon+"'"; 121
strSj="select id from kaoqin where id='"+strId+"' and sj='事假' and year='"+strYear+"' and mon='"+strMon+"'"; 122
strBj="select id from kaoqin where id='"+strId+"' and bj='病假' and year='"+strYear+"' and mon='"+strMon+"'"; 123
strKg="select id from kaoqin where id='"+strId+"' and kg='旷工' and year='"+strYear+"' and mon='"+strMon+"'"; 124
con.Open(); 125
com=new OleDbCommand(strCd,con); 126
reader=com.ExecuteReader(); 127
while(reader.Read()) 128
{ 129
cdCount++; 130
} 131
labCd.Text="迟到:"+cdCount.ToString()+"次"; 132
reader.Close(); 133
com.Dispose(); 134
con.Close(); 135
136
con.Open(); 137
com=new OleDbCommand(strZt,con); 138
reader=com.ExecuteReader(); 139
while(reader.Read()) 140
{ 141
ztCount++; 142
} 143
labZt.Text="早退:"+ztCount.ToString()+"次"; 144
reader.Close(); 145
com.Dispose(); 146
con.Close(); 147
148
con.Open(); 149
com=new OleDbCommand(strSj,con); 150
reader=com.ExecuteReader(); 151
while(reader.Read()) 152
{ 153
sjCount++; 154
} 155
labSj.Text="事假:"+sjCount.ToString()+"次"; 156
reader.Close(); 157
com.Dispose(); 158
con.Close(); 159
160
con.Open(); 161
com=new OleDbCommand(strBj,con); 162
reader=com.ExecuteReader(); 163
while(reader.Read()) 164
{ 165
bjCount++; 166
} 167
labBj.Text="病假:"+bjCount.ToString()+"次"; 168
reader.Close(); 169
com.Dispose(); 170
con.Close(); 171
172
con.Open(); 173
com=new OleDbCommand(strKg,con); 174
reader=com.ExecuteReader(); 175
while(reader.Read()) 176
{ 177
kgCount++; 178
} 179
labKg.Text="旷工:"+kgCount.ToString()+"次"; 180
reader.Close(); 181
com.Dispose(); 182
con.Close(); 183
184
strSql="select * from kaoqin where id='"+strId+"' and year='"+strYear+"' and mon='"+strMon+"'"; 185
con.Open(); 186
da=new OleDbDataAdapter(strSql,con); 187
da.Fill(ds,"kaoqin"); 188
data.DataSource=ds.Tables["kaoqin"].DefaultView; 189
data.DataBind(); 190
con.Close(); 191
} 192
} 193
} 194
} 195
196
private void data_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e) 197
{ 198
data.CurrentPageIndex=e.NewPageIndex; 199
data.DataSource=ds.Tables["kaoqin"].DefaultView; 200
data.DataBind(); 201
} 202
203
private void data_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 204
{ 205
string strId,strYear,strMon,strSql; 206
strId=ddId.SelectedItem.Text.Trim().ToString(); 207
strYear=ddYear.SelectedItem.Text.Trim().ToString(); 208
strMon=ddMon.SelectedItem.Text.Trim().ToString(); 209
string kqdate=(string)data.DataKeys[(int)e.Item.ItemIndex]; 210
string strDelSql="delete from kaoqin where id='"+strId+"' and kqdate='"+kqdate+"'"; 211
con.Open(); 212
com=new System.Data.OleDb.OleDbCommand(strDelSql,con); 213
com.ExecuteNonQuery(); 214
com.Dispose(); 215
con.Close(); 216
string strCd,strZt,strSj,strBj,strKg; 217
int cdCount=0,ztCount=0,sjCount=0,bjCount=0,kgCount=0; 218
strCd="select id from kaoqin where id='"+strId+"' and cd='迟到' and year='"+strYear+"' and mon='"+strMon+"'"; 219
strZt="select id from kaoqin where id='"+strId+"' and zt='早退' and year='"+strYear+"' and mon='"+strMon+"'"; 220
strSj="select id from kaoqin where id='"+strId+"' and sj='事假' and year='"+strYear+"' and mon='"+strMon+"'"; 221
strBj="select id from kaoqin where id='"+strId+"' and bj='病假' and year='"+strYear+"' and mon='"+strMon+"'"; 222
strKg="select id from kaoqin where id='"+strId+"' and kg='旷工' and year='"+strYear+"' and mon='"+strMon+"'"; 223
con.Open(); 224
com=new OleDbCommand(strCd,con); 225
reader=com.ExecuteReader(); 226
while(reader.Read()) 227
{ 228
cdCount++; 229
} 230
labCd.Text="迟到:"+cdCount.ToString()+"次"; 231
reader.Close(); 232
com.Dispose(); 233
con.Close(); 234
235
con.Open(); 236
com=new OleDbCommand(strZt,con); 237
reader=com.ExecuteReader(); 238
while(reader.Read()) 239
{ 240
ztCount++; 241
} 242
labZt.Text="早退:"+ztCount.ToString()+"次"; 243
reader.Close(); 244
com.Dispose(); 245
con.Close(); 246
247
con.Open(); 248
com=new OleDbCommand(strSj,con); 249
reader=com.ExecuteReader(); 250
while(reader.Read()) 251
{ 252
sjCount++; 253
} 254
labSj.Text="事假:"+sjCount.ToString()+"次"; 255
reader.Close(); 256
com.Dispose(); 257
con.Close(); 258
259
con.Open(); 260
com=new OleDbCommand(strBj,con); 261
reader=com.ExecuteReader(); 262
while(reader.Read()) 263
{ 264
bjCount++; 265
} 266
labBj.Text="病假:"+bjCount.ToString()+"次"; 267
reader.Close(); 268
com.Dispose(); 269
con.Close(); 270
271
con.Open(); 272
com=new OleDbCommand(strKg,con); 273
reader=com.ExecuteReader(); 274
while(reader.Read()) 275
{ 276
kgCount++; 277
} 278
labKg.Text="旷工:"+kgCount.ToString()+"次"; 279
reader.Close(); 280
com.Dispose(); 281
con.Close(); 282
283
strSql="select * from kaoqin where id='"+strId+"' and year='"+strYear+"' and mon='"+strMon+"'"; 284
con.Open(); 285
da=new OleDbDataAdapter(strSql,con); 286
da.Fill(ds,"kaoqin"); 287
data.DataSource=ds.Tables["kaoqin"].DefaultView; 288
data.DataBind(); 289
con.Close(); 290
} 291
} 292
} 293






}