温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:项目管理系统(多用户)源码
当前文件:
ProjectManager/userControl/ucManageProject.ascx.cs[6K,2009-6-12 11:52:29],打开代码结构图
ProjectManager/userControl/ucManageProject.ascx.cs[6K,2009-6-12 11:52: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
using projmanager; 12
using System.Data.Common; 13
//该源码下载自www.51aspx.com(51aspx.com) 14
15
public partial class userControl_ucManageProject : System.Web.UI.UserControl 16
{ 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!IsPostBack) 20
{ 21
bool flag1 = (bool)Session["IsDepartmentManager"]; 22
bool flag2 = (bool)Session["IsAdmin"]; 23
if (flag1 == false && flag2 == false) 24
{ 25
Response.Redirect("login.aspx"); 26
return; 27
} 28
dataBind(); 29
} 30
} 31
private void dataBind() 32
{ 33
string departmentid = Session["DepartmentID"].ToString(); 34
string sql = "select *," + 35
" isnull((select employeename from [employee] e where e.employeeid=p.projectmanagerid),null)as projectmanagername" + 36
" from project p where departmentid=" + departmentid; 37
Utilities.BindingDataGridView(this.GridViewProject, DataAccess.ExecuteDataTable(sql), new string[] { "projectid" }); 38
} 39
40
protected void GridViewProject_RowUpdated(object sender, GridViewUpdatedEventArgs e) 41
{ 42
43
} 44
protected void GridViewProject_RowUpdating(object sender, GridViewUpdateEventArgs e) 45
{ 46
this.GridViewProject.EditIndex = -1; 47
DropDownList ddl = (DropDownList)this.GridViewProject.Rows[e.RowIndex].FindControl("ddlProjmanagerName"); 48
string projmanagerid = ddl.SelectedValue; 49
string projname = ((TextBox)this.GridViewProject.Rows[e.RowIndex].FindControl("tbProjName")).Text; 50
string projno = ((TextBox)this.GridViewProject.Rows[e.RowIndex].FindControl("tbProjNo")).Text; 51
52
string preditFinishDate = ((TextBox)this.GridViewProject.Rows[e.RowIndex].FindControl("tbPreditFinishDate")).Text; 53
string description = ((TextBox)this.GridViewProject.Rows[e.RowIndex].FindControl("tbDescription")).Text; 54
55
string projectid = this.GridViewProject.DataKeys[e.RowIndex].Value.ToString(); 56
string sql = "update project set projectname='" + projname + "',projectno='" + projno + "'," + 57
" projectmanagerid=" + projmanagerid + ",predictfinishdate='" + preditFinishDate + "'," + 58
" description='" + description + "' where projectid=" + projectid; 59
60
if (DataAccess.ExecuteNonQuery(sql) == 1) 61
{ 62
this.lbMsg.Text = "项目更新成功"; 63
dataBind(); 64
} 65
else 66
{ 67
this.lbMsg.Text = "项目失败成功"; 68
} 69
70
71
72
} 73
protected void GridViewProject_RowEditing(object sender, GridViewEditEventArgs e) 74
{ 75
string projectid = this.GridViewProject.DataKeys[e.NewEditIndex].Value.ToString(); 76
77
string sql1 = "select isactive from project where projectid=" + projectid; 78
bool flag = (bool)DataAccess.ExecuteScalar(sql1); 79
if (flag==false) 80
{ 81
this.lbMsg.Text = "项目处于非活动期,不能修改"; 82
this.GridViewProject.EditIndex = -1; 83
return; 84
} 85
86
this.GridViewProject.EditIndex = e.NewEditIndex; 87
dataBind(); 88
89
DropDownList ddl = (DropDownList)this.GridViewProject.Rows[e.NewEditIndex].FindControl("ddlProjmanagerName"); 90
string sql = "select employeename,employeeid from employee e where e.departmentid=" + Session["DepartmentID"].ToString(); 91
92
DataTable dt = DataAccess.ExecuteDataTable(sql); 93
Utilities.BindingDropDownList(ddl, dt, "employeename", "employeeid"); 94
} 95
protected void GridViewProject_PageIndexChanging(object sender, GridViewPageEventArgs e) 96
{ 97
this.GridViewProject.PageIndex = e.NewPageIndex; 98
dataBind(); 99
} 100
protected void GridViewProject_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) 101
{ 102
this.GridViewProject.EditIndex = -1; 103
dataBind(); 104
105
} 106
protected void GridViewProject_RowCommand(object sender, GridViewCommandEventArgs e) 107
{ 108
if (e.CommandName == "setunactive") 109
{ 110
string projectid = e.CommandArgument.ToString(); 111
string sql = "update project set isactive=0 where projectid=" + projectid; 112
if (DataAccess.ExecuteNonQuery(sql) == 1) 113
{ 114
this.lbMsg.Text = "项目成功设置成非活动"; 115
dataBind(); 116
} 117
else 118
{ 119
this.lbMsg.Text = "项目设置失败"; 120
} 121
} 122
if (e.CommandName == "delete") 123
{ 124
string projectid = e.CommandArgument.ToString(); 125
string sql = "delete from project where projectid=" + projectid; 126
if (DataAccess.ExecuteNonQuery(sql) == 1) 127
{ 128
this.lbMsg.Text = "项目删除成功"; 129
dataBind(); 130
} 131
else 132
{ 133
this.lbMsg.Text = "项目删除失败"; 134
} 135
} 136
} 137
protected void GridViewProject_RowDataBound(object sender, GridViewRowEventArgs e) 138
{ 139
if (e.Row.RowType == DataControlRowType.DataRow) 140
{ 141
string projectid = ((DataRowView)e.Row.DataItem).Row.ItemArray[0].ToString(); 142
string sql = "select isactive from project where projectid=" + projectid; 143
bool flag = (bool)DataAccess.ExecuteScalar(sql); 144
if (flag == false) 145
{ 146
Button btn = (Button)e.Row.FindControl("btnSetUnActive"); 147
btn.Enabled = false; 148
btn.Attributes.Remove("onclientclick"); 149
} 150
} 151
} 152
protected void GridViewProject_RowDeleting(object sender, GridViewDeleteEventArgs e) 153
{ 154
155
} 156
} 157






}
}