/// <summary> /// Handles the OnUpdateCommand event of the rgMaterials control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void rgMaterials_OnUpdateCommand(object sender, GridCommandEventArgs e) { var item = e.Item as GridEditableItem; var id = Guid.Parse(item.GetDataKeyValue("ID").ToString()); var material = MaterialList.FirstOrDefault(a => a.ID == id); var newValue = material.Value; switch ((MaterialType)material.Type) { case MaterialType.Url: newValue = ((TextBox)item.FindControl("txtValue")).Text; foreach (var siteActionTemplate in SiteActionTemplateList) { siteActionTemplate.MessageCaption = siteActionTemplate.MessageCaption.Replace(material.Value, newValue); siteActionTemplate.MessageBody = siteActionTemplate.MessageBody.Replace(material.Value, newValue); } break; case MaterialType.File: var dcbFile = ((DictionaryOnDemandComboBox)item.FindControl("dcbFile")); if (dcbFile.SelectedId != Guid.Empty) { newValue = dcbFile.SelectedId.ToString(); } break; case MaterialType.Form: var dcbForm = ((DictionaryOnDemandComboBox)item.FindControl("dcbForm")); if (dcbForm.SelectedId != Guid.Empty) { newValue = dcbForm.SelectedId.ToString(); } break; } material.Value = newValue; }
protected void rgMaterials_OnEditCommand(object sender, GridCommandEventArgs e) { var editedItem = e.Item as GridEditableItem; var id = Guid.Parse(editedItem.GetDataKeyValue("ID").ToString()); var material = MaterialList.FirstOrDefault(a => a.ID == id); if (material.Type == (int)MaterialType.ActionTemplate) { var rolesList = new List <WorkflowTemplateWizardRole>(); var gridRoles = ((RadGrid)MultiPage.FindPageViewByID("GeneralInformation").Controls[0].FindControl("rgContactRoles")); foreach (GridDataItem item in gridRoles.Items) { rolesList.Add(new WorkflowTemplateWizardRole { OldContactRoleID = item.GetDataKeyValue("ContactRoleID").ToString().ToGuid(), OldEmail = item.GetDataKeyValue("RoleInTemplate").ToString(), ContactRoleID = ((DictionaryOnDemandComboBox)item.FindControl("dcbContactRole")).SelectedId, Email = ((TextBox)item.FindControl("txtFromEmail")).Text, DisplayName = ((TextBox)item.FindControl("txtFromName")).Text }); } var siteActionTemplate = SiteActionTemplateList.FirstOrDefault(a => a.ID == id); if (siteActionTemplate.FromContactRoleID.HasValue) { var role = rolesList.FirstOrDefault(a => a.OldContactRoleID == siteActionTemplate.FromContactRoleID); if (role != null) { if (role.ContactRoleID != Guid.Empty) { siteActionTemplate.FromContactRoleID = role.ContactRoleID; } else { siteActionTemplate.FromContactRoleID = null; siteActionTemplate.FromEmail = role.Email; if (!string.IsNullOrEmpty(role.DisplayName)) { siteActionTemplate.FromName = role.DisplayName; } else { siteActionTemplate.FromName = null; } } } } else { var role = rolesList.FirstOrDefault(a => a.OldEmail == siteActionTemplate.FromEmail); if (role != null) { if (role.ContactRoleID != Guid.Empty) { siteActionTemplate.FromContactRoleID = role.ContactRoleID; } else { siteActionTemplate.FromEmail = role.Email; if (!string.IsNullOrEmpty(role.DisplayName)) { siteActionTemplate.FromName = role.DisplayName; } else { siteActionTemplate.FromName = null; } } } } foreach (var siteActionTemplateRecipient in siteActionTemplate.tbl_SiteActionTemplateRecipient) { if (siteActionTemplateRecipient.ContactRoleID.HasValue) { var role = rolesList.FirstOrDefault(a => a.OldContactRoleID == siteActionTemplateRecipient.ContactRoleID); if (role != null) { if (role.ContactRoleID != Guid.Empty) { siteActionTemplateRecipient.ContactRoleID = role.ContactRoleID; } else { siteActionTemplateRecipient.ContactRoleID = null; siteActionTemplateRecipient.Email = role.Email; if (!string.IsNullOrEmpty(role.DisplayName)) { siteActionTemplateRecipient.DisplayName = role.DisplayName; } } } } else { var role = rolesList.FirstOrDefault(a => a.OldEmail == siteActionTemplateRecipient.Email); if (role != null) { if (role.ContactRoleID != Guid.Empty) { siteActionTemplateRecipient.ContactRoleID = role.ContactRoleID; } else { siteActionTemplateRecipient.ContactRoleID = null; siteActionTemplateRecipient.Email = role.Email; if (!string.IsNullOrEmpty(role.DisplayName)) { siteActionTemplateRecipient.DisplayName = role.DisplayName; } } } } } if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_ShowSiteActionTemplateRadWindow")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_ShowSiteActionTemplateRadWindow", "ShowSiteActionTemplate('" + id + "');", true); } e.Canceled = true; e.Item.Edit = false; } }