温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net2.0值班管理系统源码
当前文件:
DutySystem/DutyListMain.aspx.cs[4K,2009-6-12 11:41:29],打开代码结构图
DutySystem/DutyListMain.aspx.cs[4K,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 DutyListMain : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
17
if (!this.IsPostBack) 18
{ 19
bindDepartDrop(); 20
bindUserDrop(); 21
22
bindDutyData(); 23
24
} 25
} 26
27
private void bindDutyData() 28
{ 29
if (DutyDao.dsDuty() == null || (DutyDao.dsDuty()).Tables[0].Rows.Count == 0) 30
{ 31
this.Label1.Visible = true; 32
this.GridView1.Visible = false; 33
} 34
else 35
{ 36
this.Label1.Visible = false; 37
this.GridView1.Visible = true; 38
this.GridView1.DataSource = DutyDao.dsDuty(); 39
this.GridView1.DataBind(); 40
} 41
} 42
43
private void bindDepartDrop() 44
{ 45
DataTable dt = DepartmentDao.dsDepartment().Tables[0]; 46
this.DropDownList1.DataSource = dt; 47
this.DropDownList1.DataTextField = dt.Columns[1].ToString(); 48
this.DropDownList1.DataValueField = dt.Columns[0].ToString(); 49
this.DropDownList1.DataBind(); 50
this.DropDownList1.Items.Insert(0, new ListItem("请选择", "0")); 51
} 52
53
private void bindUserDrop() 54
{ 55
56
} 57
protected void Button1_Click(object sender, EventArgs e) 58
{ 59
if(!this.Calendar1.Visible) 60
this.Calendar1.Visible = true; 61
else 62
this.Calendar1.Visible = false; 63
} 64
protected void Calendar1_SelectionChanged(object sender, EventArgs e) 65
{ 66
this.TextBox1.Text = this.Calendar1.SelectedDate.ToShortDateString(); 67
this.Calendar1.Visible = false; 68
} 69
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 70
{ 71
if (this.DropDownList1.SelectedIndex != 0) 72
{ 73
this.DropDownList2.Items.Clear(); 74
this.DropDownList2.DataSource = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0]; 75
this.DropDownList2.DataTextField = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0].Columns[1].ToString(); 76
this.DropDownList2.DataValueField = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0].Columns[0].ToString(); 77
this.DropDownList2.DataBind(); 78
} 79
80
} 81
protected void Button4_Click(object sender, EventArgs e) 82
{ 83
if (!this.Calendar2.Visible) 84
this.Calendar2.Visible = true; 85
else 86
this.Calendar2.Visible = false; 87
} 88
protected void Calendar2_SelectionChanged(object sender, EventArgs e) 89
{ 90
this.TextBox3.Text = this.Calendar2.SelectedDate.ToShortDateString(); 91
this.Calendar2.Visible = false; 92
} 93
protected void Button2_Click(object sender, EventArgs e) 94
{ 95
if (this.DropDownList1.SelectedIndex == 0) 96
{ 97
this.Label2.Text = "请选择部门!"; 98
99
} 100
else if (this.DropDownList2.SelectedIndex == -1) 101
{ 102
this.Label2.Text = "请选择人员!"; 103
} 104
else if (string.IsNullOrEmpty(this.TextBox1.Text)) 105
{ 106
this.Label2.Text = "请选择开始时间!"; 107
} 108
else if (string.IsNullOrEmpty(this.TextBox3.Text)) 109
{ 110
this.Label2.Text = "请选择结束时间!"; 111
} 112
else if ((DateTime.Parse(this.TextBox1.Text)).CompareTo(DateTime.Parse(this.TextBox3.Text)) == 1) 113
{ 114
this.Label2.Text = "开始时间不应大于结束时间"; 115
} 116
else 117
{ 118
int departId = int.Parse(this.DropDownList1.SelectedValue.ToString()); 119
int userId = int.Parse(this.DropDownList2.SelectedValue.ToString()); 120
121
DateTime begin = DateTime.Parse(this.TextBox1.Text); 122
DateTime end = DateTime.Parse(this.TextBox3.Text); 123
124
string comment = this.TextBox2.Text; 125
126
DutyPO dp = new DutyPO(); 127
dp.DepartId = departId; 128
dp.StaffId = userId; 129
dp.DutyDateBegin = begin; 130
dp.DutyDateEnd = end; 131
dp.DutyComment = comment; 132
DutyDao.insertDuty(dp); 133
bindDutyData(); 134
this.Label2.Text = ""; 135
} 136
137
} 138
} 139






}
}