/// <summary> /// Handles the ItemCommand event of the grdResolutions 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 grdResolutions_ItemCommand(object sender, DataGridCommandEventArgs e) { Resolution m; var itemIndex = e.Item.ItemIndex; switch (e.CommandName) { case "up": //move row up if (itemIndex == 0) { return; } m = ResolutionManager.GetById(Convert.ToInt32(e.CommandArgument)); m.SortOrder -= 1; ResolutionManager.SaveOrUpdate(m); break; case "down": //move row down if (itemIndex == grdResolutions.Items.Count - 1) { return; } m = ResolutionManager.GetById(Convert.ToInt32(e.CommandArgument)); m.SortOrder += 1; ResolutionManager.SaveOrUpdate(m); break; } BindResolutions(); }
/// <summary> /// Handles the Update event of the grdResolutions 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 grdResolutions_Update(object sender, DataGridCommandEventArgs e) { var txtResolutionName = (TextBox)e.Item.FindControl("txtResolutionName"); var pickimg = (PickImage)e.Item.FindControl("lstEditImages"); if (txtResolutionName.Text.Trim() == "") { throw new ArgumentNullException("Resolution name is empty."); } var m = ResolutionManager.GetById(Convert.ToInt32(grdResolutions.DataKeys[e.Item.ItemIndex])); m.Name = txtResolutionName.Text.Trim(); m.ImageUrl = pickimg.SelectedValue; ResolutionManager.SaveOrUpdate(m); grdResolutions.EditItemIndex = -1; BindResolutions(); }
/// <summary> /// Adds the milestone. /// </summary> /// <param name="s">The s.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddResolution(Object s, EventArgs e) { var newName = txtName.Text.Trim(); if (newName == String.Empty) { return; } var newResolution = new Resolution { ProjectId = ProjectId, Name = newName, ImageUrl = lstImages.SelectedValue }; if (ResolutionManager.SaveOrUpdate(newResolution)) { txtName.Text = ""; BindResolutions(); lstImages.SelectedValue = String.Empty; } else { ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("SaveResolutionError")); } }