/// <summary> /// Handles the Update event of the grdMailboxes control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void dtgMailboxes_Update(object sender, DataGridCommandEventArgs e) { var emailAddress = (TextBox)e.Item.FindControl("txtEmailAddress"); var pickUser = (PickSingleUser)e.Item.FindControl("IssueAssignedUser"); var pickType = (PickType)e.Item.FindControl("IssueType"); var id = Convert.ToInt32(grdMailboxes.DataKeys[e.Item.ItemIndex]); if (emailAddress.Text.Trim() == "") { throw new ArgumentNullException("Email Address empty"); } var mailbox = ProjectMailboxManager.GetById(id); if (mailbox != null) { mailbox.Mailbox = emailAddress.Text; mailbox.IssueTypeId = pickType.SelectedValue; mailbox.AssignToUserName = pickUser.SelectedValue; ProjectMailboxManager.SaveOrUpdate(mailbox); } grdMailboxes.EditItemIndex = -1; BindMailboxes(); }
/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void btnAdd_Click(object sender, EventArgs e) { var mailbox = new ProjectMailbox { AssignToDisplayName = string.Empty, AssignToId = Guid.Empty, AssignToUserName = IssueAssignedUser.SelectedValue, IssueTypeId = IssueAssignedType.SelectedValue, Mailbox = txtMailbox.Text, ProjectId = ProjectId }; if (ProjectMailboxManager.SaveOrUpdate(mailbox)) { BindMailboxes(); } }