using framework_business; using framework_library; using System; using System.Collections; using System.Data; using System.Linq; using System.Reflection; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; using System.Web.UI.HtmlControls; using System.Text; using System.Drawing; using System.IO; using System.Configuration; public partial class controls_module_surfacecomms : UserControl, ISurfaceControlBase { #region methods /// /// ReloadControl /// /// public void ReloadControl(oSurfaceFieldData controlFieldData, bool alternateView = false, bool readOnly = false) { try { SurfaceId = controlFieldData.surfaceId; SurfaceItemId = controlFieldData.surfaceItemId; foreach (oSurfaceField field in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", controlFieldData.surfaceFieldID.ToString())) { SurfaceFieldId = field.recId; lblCommTitle.Text = field.surfaceFieldDisplay; } if (alternateView) RecordLimit = 3; BindComms(); } catch (Exception ex) { exception.HandleException("comms:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save Control Data /// /// public void SaveControlData(ref oSurfaceFieldData _surfaceFieldData) { } /// /// Populate surface comm /// private void PopulateSurfaceComm() { try { foreach (ovCampaignHistory history in xData.GetTypedByCriteriaSpecific("recId", typeof(ovCampaignHistory), "recId", CommId.ToString())) { lblTitle.Text = history.campaignTitle; lblDateSent.Text = history.dateSent.ToString("dd/MM/yyyy HH:mm:ss tt"); lblMessage.Text = history.campaignBody; lblMsgType.Text = history.messageType.ToString(); lblRecipientDetail.Text = history.mobile; lblStatus.Text = history.statusDisplay; lblType.Text = history.campaignType.ToString(); } } catch (Exception ex) { exception.HandleException("comms:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// BindComms /// private void BindComms() { DataTable dtCampaignHistory = xData.GetTypedByCriteriaSpecificTable("recId",typeof(ovCampaignHistory),"surfaceItemId",SurfaceItemId.ToString(),"lastSent DESC"); rptCampaignHistory.DataSource = dtCampaignHistory; rptCampaignHistory.DataBind(); } #endregion #region events /// /// Page Init /// /// /// protected void Page_Init(object sender, EventArgs e) { } /// /// Page Load /// /// /// protected void Page_Load(object sender, EventArgs e) { //BindComms(); } protected void btnCancelSurfaceComm_Click(object sender, EventArgs e) { try { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mySurfaceCommModalClose", "$('#" + pnlModal.ClientID + "').closest('div').find('.modSurfaceComm').modal('toggle');", true); } catch (Exception ex) { exception.HandleException("comms:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// view item /// /// /// protected void lnkView_Click(object sender, EventArgs e) { try { if (sender.GetType() == typeof(LinkButton)) { LinkButton lnkButton = (LinkButton)sender; CommId = int.Parse(((LinkButton)sender).CommandArgument); PopulateSurfaceComm(); //CVH 2017-05-05 Open surface group again. If it defaults to collapsed, it collapses when clicking add and then modal doesn't show until you manually expand the group again. string script = ""; if (SurfaceGroupId != "") script = "$('#" + SurfaceGroupId + "').collapse('show'); $('#" + pnlModal.ClientID + "').closest('div').find('.modSurfaceComm').modal();"; else script = "$('#" + pnlModal.ClientID + "').closest('div').find('.modSurfaceComm').modal();"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mySurfaceCommModal", script, true); //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mySurfaceCommModal", "$('.modSurfaceComm').modal();", true); } } catch (Exception ex) { exception.HandleException("comms:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } #endregion #region properties /// /// MPL getter and setter /// private DataTable SurfaceComms { get { if (ViewState["surfaceComms"] != null) { return (DataTable)ViewState["surfaceComms"]; } else { return null; } } set { ViewState["surfaceComms"] = value; } } private int SurfaceItemId { get { if (ViewState["commSurfaceItemId"] != null) return (int)ViewState["commSurfaceItemId"]; else return 0; } set { ViewState["commSurfaceItemId"] = value; } } private int SurfaceFieldId { get { if (ViewState["commSurfaceFieldId"] != null) return Convert.ToInt32(ViewState["commSurfaceFieldId"]); else return 0; } set { ViewState["commSurfaceFieldId"] = value; } } private int SurfaceId { get { if (ViewState["commSurfaceId"] != null) return Convert.ToInt32(ViewState["commSurfaceId"]); else return 0; } set { ViewState["commSurfaceId"] = value; } } private int CommId { get { if (ViewState["commId"] != null) return (int)ViewState["commId"]; else return 0; } set { ViewState["commId"] = value; } } private int RecordLimit { get { if (ViewState["recordLimit"] == null) return 0; else return (int)ViewState["recordLimit"]; } set { ViewState["recordLimit"] = value; } } public string SurfaceGroupId { get { if (ViewState["surfaceGroupId"] != null) return ViewState["surfaceGroupId"].ToString(); else return null; } set { ViewState["surfaceGroupId"] = value; } } #endregion }