温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net2.0值班管理系统源码
当前文件:
DutySystem/DutyDepartmentMain.aspx.cs[2K,2009-6-12 11:41:29],打开代码结构图
DutySystem/DutyDepartmentMain.aspx.cs[2K,2009-6-12 11:41:29],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
12
public partial class DutyDepartmentMain : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
if (!this.IsPostBack) 17
{ 18
bindDepartment(); 19
} 20
} 21
22
private void bindDepartment() 23
{ 24
if (DepartmentDao.dsDepartment() == null || (DepartmentDao.dsDepartment()).Tables[0].Rows.Count == 0) 25
{ 26
this.Label1.Visible = true; 27
this.GridView1.Visible = false; 28
} 29
else 30
{ 31
this.GridView1.Visible = true; 32
this.GridView1.DataSource = DepartmentDao.dsDepartment(); 33
this.GridView1.DataBind(); 34
} 35
} 36
protected void Button1_Click(object sender, EventArgs e) 37
{ 38
if (string.IsNullOrEmpty(this.TextBox1.Text)) 39
{ 40
this.Label2.Text = "名称不能留空!"; 41
} 42
else if (string.IsNullOrEmpty(this.TextBox2.Text)) 43
{ 44
this.Label2.Text = "编号不能留空!"; 45
} 46
else 47
{ 48
DepartmentPo dp = new DepartmentPo(); 49
dp.DepartName = this.TextBox1.Text; 50
dp.DepartId = this.TextBox2.Text; 51
DepartmentDao.insertDepartment(dp); 52
this.Label2.Text = ""; 53
this.TextBox1.Text = ""; 54
this.TextBox2.Text = ""; 55
bindDepartment(); 56
} 57
58
} 59
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) 60
{ 61
this.GridView1.EditIndex = e.NewEditIndex; 62
bindDepartment(); 63
64
} 65
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) 66
{ 67
this.GridView1.EditIndex = -1; 68
bindDepartment(); 69
} 70
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) 71
{ 72
string name = ((TextBox)(this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text; 73
string id = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text; 74
75
int keyId = Int32.Parse(this.GridView1.DataKeys[e.RowIndex].Value.ToString()); 76
DepartmentPo dp = new DepartmentPo(); 77
dp.DepartId = id; 78
dp.DepartName = name; 79
DepartmentDao.updateDepartment(dp,keyId); 80
this.GridView1.EditIndex = -1; 81
bindDepartment(); 82
83
} 84
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 85
{ 86
//删除 87
int keyId = Int32.Parse(this.GridView1.DataKeys[e.RowIndex].Value.ToString()); 88
DepartmentDao.deleteDepart(keyId); 89
bindDepartment(); 90
} 91
} 92






}
}