温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:BugNet0.7.881.0汉化免安装版源码
当前文件路径:BugNet/BugNET_WAP/Bugs/BugDetail.aspx.cs

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 FredCK.FCKeditorV2; 12
using BugNET.BusinessLogicLayer; 13
using BugNET.UserInterfaceLayer; 14
using BugNET.UserControls; 15
using System.Threading; 16
17
namespace BugNET 18
...{ 19
/**//// <summary> 20
/// Bug Detail Page 21
/// </summary> 22
public partial class BugDetail : BasePage 23
...{ 24
Private Variables#region Private Variables 25
protected Bug editBug; 26
protected int NextBug = -1; 27
protected int PreviousBug = -1; 28
#endregion 29
30
Private Events#region Private Events 31
/**//// <summary> 32
/// Page Load Event 33
/// </summary> 34
/// <param name="sender"></param> 35
/// <param name="e"></param> 36
protected void Page_Load(object sender, System.EventArgs e) 37
...{ 38
if (!Page.IsPostBack) 39
...{ 40
BindData(); 41
} 42
43
// The ExpandIssuePaths method is called to handle 44
// the SiteMapResolve event. 45
SiteMap.SiteMapResolve += 46
new SiteMapResolveEventHandler(this.ExpandIssuePaths); 47
48
49
ctlBugTabs.BugId = BugId; 50
ctlBugTabs.ProjectId = ProjectId; 51
Page.Title = string.Concat("[",editBug.FullId,"] ",editBug.Summary); 52
53
//need to rebind the fields because of atlas 54
ctlCustomFields.DataSource = CustomField.GetCustomFieldsByBugId(BugId); 55
ctlCustomFields.DataBind(); 56
57
58
} 59
60
/**//// <summary> 61
/// Handles the Unload event of the Page control. 62
/// </summary> 63
/// <param name="sender">The source of the event.</param> 64
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> 65
protected void Page_Unload(object sender, System.EventArgs e) 66
...{ 67
//remove the event handler 68
SiteMap.SiteMapResolve -= 69
new SiteMapResolveEventHandler(this.ExpandIssuePaths); 70
} 71
72
/**//// <summary> 73
/// Expands the issue paths. 74
/// </summary> 75
/// <param name="sender">The sender.</param> 76
/// <param name="e">The <see cref="System.Web.SiteMapResolveEventArgs"/> instance containing the event data.</param> 77
/// <returns></returns> 78
private SiteMapNode ExpandIssuePaths(Object sender, SiteMapResolveEventArgs e) 79
...{ 80
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true); 81
SiteMapNode tempNode = currentNode; 82
83
// The current node, and its parents, can be modified to include 84
// dynamic querystring information relevant to the currently 85
// executing request. 86
if (BugId != 0) 87
...{ 88
string title = (editBug.Summary.Length >= 30) ? editBug.Summary.Substring(0, 30) + " ..." : editBug.Summary; 89
tempNode.Title =string.Format("{0}: {1}",editBug.FullId.ToUpper(),title); 90
tempNode.Url = tempNode.Url + "?bid=" + BugId.ToString(); 91
} 92
93
if ((null != (tempNode = tempNode.ParentNode))) 94
...{ 95
if (Context.Session["ReferrerUrl"] == null || !Context.Session["ReferrerUrl"].ToString().Contains("BugList.aspx")) 96
...{ 97
tempNode.Url = string.Format("~/Bugs/BugList.aspx?pid={0}", ProjectId); 98
} 99
else 100
...{ 101
tempNode.Url = Context.Session["ReferrerUrl"].ToString(); 102
} 103
} 104
105
return currentNode; 106
} 107
108
/**//// <summary> 109
/// Binds the data to the form 110
/// </summary> 111
private void BindData() 112
...{ 113
cpDueDate.ValueToCompare = DateTime.Now.ToShortDateString(); 114
115
//set the refferrer url if we came from the bug list, otherwise hide the navigation links. 116
if (Request.UrlReferrer != null && !Request.UrlReferrer.ToString().Contains("BugDetail.aspx") && !Request.UrlReferrer.ToString().Contains("AddSuccess.aspx")) 117
...{ 118
Session["ReferrerUrl"] = Request.UrlReferrer.ToString(); 119
} 120
else 121
...{ 122
Session["ReferrerUrl"] = string.Format("/Bugs/BugList.aspx?pid={0}",ProjectId); 123
} 124
125
//Bind Drop Down Lists 126
BindDropDowns(); 127
128
Type.SelectedValue = editBug.TypeId; 129
Resolution.SelectedValue = editBug.ResolutionId; 130
ddlStatus.SelectedValue = editBug.StatusId.ToString(); 131
Priority.SelectedValue = editBug.PriorityId; 132
lblDescription.Text = editBug.Description; 133
FCKDescription.Value = editBug.Description; 134
lblLastUpdateUser.Text = editBug.LastUpdateUserName; 135
lblReporter.Text = editBug.ReporterDisplayName; 136
lblSummary.Text = editBug.Summary; 137
txtSummary.Text = editBug.Summary; 138
lblOpenedDate.Text = editBug.DateCreated.ToString("g"); 139
lblLastModified.Text = editBug.LastUpdate.ToString("g"); 140
lblBugNumber.Text = editBug.FullId; 141
Comps.SelectedValue = editBug.ComponentId; 142
Version.SelectedValue = editBug.VersionId; 143
ReAssign.SelectedValue = editBug.AssignedDisplayName; 144
lblLoggedTime.Text = editBug.TimeLogged.ToString(); 145
txtEstimation.Text = editBug.Estimation == 0 ? string.Empty : editBug.Estimation.ToString(); 146
147
DueDate.Text = editBug.DueDate == DateTime.MinValue ? String.Empty : editBug.DueDate.ToShortDateString(); 148
FixedInVersion.SelectedValue = editBug.FixedInVersionId; 149
chkPrivate.Checked = editBug.Visibility == 0 ? false : true; 150
151
//disable resolution dropdownlist if bug is close or resolved 152
if(int.Parse(ddlStatus.SelectedValue) != (int)Globals.StatusType.Resolved || int.Parse(ddlStatus.SelectedValue) != (int)Globals.StatusType.Closed) 153
...{ 154
Resolution.Enabled=false; 155
} 156
157
158
} 159
160
/**//// <summary> 161
/// Handles the IndexChanged event of the ddlStatus control. 162
/// </summary> 163
/// <param name="sender">The source of the event.</param> 164
/// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> 165
protected void ddlStatus_IndexChanged(object sender, EventArgs e) 166
...{ 167
if (ddlStatus.SelectedValue == "4" || ddlStatus.SelectedValue == "5") 168
...{ 169
rfvResolution.Enabled = true; 170
Resolution.Enabled = true; 171
} 172
else 173
...{ 174
rfvResolution.Enabled = false; 175
Resolution.Enabled = false; 176
} 177
} 178
179
/**//// <summary> 180
/// Allows editing of the issue summary 181
/// </summary> 182
/// <param name="sender"></param> 183
/// <param name="e"></param> 184
protected void EditSummary_Click(object sender, ImageClickEventArgs e) 185
...{ 186
switch (((ImageButton)sender).CommandName) 187
...{ 188
case "Edit": 189
break; 190
case "Cancel": 191
break; 192
case "Save": 193
editBug.Summary = Server.HtmlEncode(txtSummary.Text.Trim()); 194
editBug.Save(); 195
Response.Redirect(Request.UrlReferrer.ToString(), true); 196
break; 197
198
} 199
EditSummary.Visible = !EditSummary.Visible; 200
txtSummary.Visible = !txtSummary.Visible; 201
lblSummary.Visible = !lblSummary.Visible; 202
SaveSummary.Visible = !SaveSummary.Visible; 203
CancelEditSummary.Visible = !CancelEditSummary.Visible; 204
205
} 206
207
/**//// <summary> 208
/// Allows editing of the issue description 209
/// </summary> 210
/// <param name="sender"></param> 211
/// <param name="e"></param> 212
protected void EditDescription_Click(object sender, ImageClickEventArgs e) 213
...{ 214
switch (((ImageButton)sender).CommandName) 215
...{ 216
case "Edit": 217
break; 218
case "Cancel": 219
break; 220
case "Save": 221
editBug.Description = FCKDescription.Value.Trim(); 222
editBug.Save(); 223
Response.Redirect(Request.UrlReferrer.ToString(), true); 224
break; 225
} 226
227
EditDescription.Visible = !EditDescription.Visible; 228
SaveDescription.Visible = !SaveDescription.Visible; 229
CancelEditDescription.Visible = !CancelEditDescription.Visible; 230
FCKDescription.Visible = !FCKDescription.Visible; 231
lblDescription.Visible = !lblDescription.Visible; 232
233
} 234
235
/**//// <summary> 236
/// Handles the Click event of the lnkUpdate control. 237
/// </summary> 238
/// <param name="sender">The source of the event.</param> 239
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> 240
protected void lnkUpdate_Click(object sender, EventArgs e) 241
...{ 242
if (Page.IsValid) 243
...{ 244
editBug = Bug.GetBugById(BugId); 245
246
//update Values 247
editBug.Summary = Server.HtmlEncode(txtSummary.Text.Trim()); 248
editBug.Description = FCKDescription.Value.Trim(); 249
editBug.ResolutionId = Resolution.SelectedValue; 250
editBug.StatusId = int.Parse(ddlStatus.SelectedValue); 251
editBug.PriorityId = Priority.SelectedValue; 252
editBug.TypeId = Type.SelectedValue; 253
editBug.ComponentId = Comps.SelectedValue; 254
editBug.VersionId = Version.SelectedValue; 255
editBug.LastUpdateUserName = User.Identity.Name; 256
double estimation; 257
double.TryParse(txtEstimation.Text.Trim(), out estimation); 258
editBug.Estimation = estimation; 259
if (DueDate.Text.Length > 0) 260
...{ 261
try 262
...{ 263
editBug.DueDate = Convert.ToDateTime(DueDate.Text); 264
} 265
catch 266
...{ 267
//TODO:Report this back to the user. 268
} 269
} 270
editBug.Visibility = chkPrivate.Checked == true ? 1 : 0; 271
editBug.AssignedDisplayName = ReAssign.SelectedValue; 272
273
if (FixedInVersion.SelectedValue != -1) 274
editBug.FixedInVersionId = FixedInVersion.SelectedValue; 275
276
editBug.Save(); 277
278
if (!CustomField.SaveCustomFieldValues(editBug.Id, ctlCustomFields.Values)) 279
...{ 280
//TODO:Log this error 281
//lblError.Text = "Could not save issue custom fields"; 282
//return false; 283
} 284
285
if (((Control)sender).ID == "imgSaveReturn" || ((Control)sender).ID == "lnkSaveReturn") 286
...{ 287
ReturnToPreviousPage(); 288
} 289
else 290
...{ 291
Response.Redirect(String.Format("~/Bugs/BugDetail.aspx?bid={0}", BugId)); 292
} 293
294
} 295
} 296
297




