public void bindPopup(int CampID)
        {
            try
            {
                if (CampID > 0)
                {
                    CampaignPrimaryKey pk = new CampaignPrimaryKey(CampID);
                    Campaign Campaign = Campaign.SelectOne(pk, ConnectionString);
                    txtEditCampName.Text = Campaign.CampaignsName;
                    txtEditCampDescription.Text = Campaign.CampaignsDesc;
                }
                else
                {
                    txtEditCampName.Text = string.Empty;
                    txtEditCampDescription.Text = string.Empty;
                }
            }
            catch
            {

            }
        }
        protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
        {
            try
            {

                #region Ex1
                //CrystalDecisions.Shared.ExportFormatType formateType = ExportFormatType.PortableDocFormat;
                //if (dpExport.SelectedValue == "PDF")
                //{
                //    formateType = ExportFormatType.PortableDocFormat;
                //}
                //else if (dpExport.SelectedValue == "Excel")
                //{
                //    formateType = ExportFormatType.Excel;
                //}
                //else if (dpExport.SelectedValue == "Word")
                //{
                //    formateType = ExportFormatType.WordForWindows;
                //}
                //else if (dpExport.SelectedValue == "RichText")
                //{
                //    formateType = ExportFormatType.RichText;
                //}
                //else if (dpExport.SelectedValue == "CrystalReport")
                //{
                //    formateType = ExportFormatType.CrystalReport;
                //}
                //if (ContactRptname == "Contacts Targeted")
                //{
                //    SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString());
                //    TargetedRpt.SetParameterValue("@ListID", Request.QueryString["ListIds"].ToString());
                //    TargetedRpt.SetParameterValue("@CampaignID", Request.QueryString["CampId"].ToString());
                //    TargetedRpt.ExportToHttpResponse(formateType, Response, true, "ContactsTargeted");
                //}
                //else if (ContactRptname == "Advanced")
                //{
                //    SetDatabase(AdvancedRpt, Request.QueryString["ListIds"].ToString());
                //    AdvancedRpt.SetParameterValue("@ListIds", Request.QueryString["ListIds"].ToString());
                //    AdvancedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    AdvancedRpt.ExportToHttpResponse(formateType, Response, true, "Advanced");
                //}
                //else if (ContactRptname == "Successful Delivered")
                //{
                //    SetDatabase(SuccessDRpt, string.Empty);
                //    SuccessDRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    SuccessDRpt.ExportToHttpResponse(formateType, Response, true, "SuccessfulDeliveredContacts");
                //}
                //else if (ContactRptname == "Clicked")
                //{
                //    SetDatabase(ClickedRpt, string.Empty);
                //    ClickedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    ClickedRpt.ExportToHttpResponse(formateType, Response, true, "ClickedContacts");
                //}

                //else if (ContactRptname == "Forwards")
                //{
                //    SetDatabase(ForwardRpt, string.Empty);
                //    ForwardRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    ForwardRpt.ExportToHttpResponse(formateType, Response, true, "ForwardContacts");
                //}
                //else if (ContactRptname == "Opened")
                //{
                //    SetDatabase(OpenMailRpt, string.Empty);
                //    OpenMailRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    OpenMailRpt.ExportToHttpResponse(formateType, Response, true, "OpenedContacts");
                //}
                //else if (ContactRptname == "Unopened")
                //{
                //    SetDatabase(UnopenRpt, string.Empty);
                //    UnopenRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    UnopenRpt.ExportToHttpResponse(formateType, Response, true, "UnopenedContacts");
                //}
                //else if (ContactRptname == "Unsubscribed")
                //{
                //    SetDatabase(UnsubRpt, string.Empty);
                //    UnsubRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    UnsubRpt.ExportToHttpResponse(formateType, Response, true, "UnsubscribedContacts");
                //}
                //else if (ContactRptname == "Bounced")
                //{
                //    SetDatabase(BouncedRpt, string.Empty);
                //    BouncedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    BouncedRpt.ExportToHttpResponse(formateType, Response, true, "BounceContacts");
                //}
                #endregion

                #region Ex2
                //SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString());
                //if (dpExport.SelectedValue == "PDF")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/pdf";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".pdf");
                //    Response.End();
                //    //TargetedRpt.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, true, Page.Title);
                //}
                //else if (dpExport.SelectedValue == "Excel")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.Excel);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/vnd.xls";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".xls");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "Word")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.WordForWindows);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/vnd.doc";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".doc");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "RichText")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.RichText);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/rtf";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rtf");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "CrystalReport")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.CrystalReport);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/rpt";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rpt");
                //    Response.End();
                //}

                #endregion
                string CampName = string.Empty;
                string campId = HttpContext.Current.Request.QueryString["CampId"] != null ? HttpContext.Current.Request.QueryString["CampId"].ToString() : string.Empty;
                string mailingId = HttpContext.Current.Request.QueryString["MailingID"] != null ? HttpContext.Current.Request.QueryString["MailingID"].ToString() : string.Empty;
                //Get the MailingName Using MailingId
                if (mailingId != string.Empty)
                {
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId));
                    CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                    CampName = objCampMaster.CampaignName.ToString().Trim();
                }
                else
                {
                    CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(campId));
                    Campaign Campaign = Campaign.SelectOne(pk, ConnectionString);
                    CampName = Campaign.CampaignsName;
                }
                string listIds = HttpContext.Current.Request.QueryString["ListIds"] != null ? HttpContext.Current.Request.QueryString["ListIds"].ToString() : string.Empty;
                //string CampName = HttpContext.Current.Request.QueryString["CampName"] != null ? HttpContext.Current.Request.QueryString["CampName"].ToString() : string.Empty;
                string TabName = string.Empty;
                DataTable table = new DataTable();
                int TotalBounceCount, SoftBounceCount, HardBounceCount = -1;
                int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1, TotalUnsubCount = -1;
                Export Export = new Export("Web");
                #region download using Dll
                if (ContactRptname == "Contacts Targeted")
                {
                    TabName = "ContactsTargeted";
                    ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                    if (listIds != string.Empty && mailingId != string.Empty)
                        table = objListContactMaster.getContactsWithCampaignID(listIds, mailingId);
                    else
                        table = objListContactMaster.getContactsWithAssignCampaignID(campId);
                }
                else if (ContactRptname == "Successful Delivered")
                {
                    TabName = "SuccessfulDelivered";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectSuccDeliveredByAssignCampIdwithDistinct(ConnectionString, Convert.ToInt32(campId));
                    else
                        table = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, Convert.ToInt32(mailingId));

                }
                else if (ContactRptname == "Bounced")
                {
                    TabName = "Bounced";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectRecipientsBounceRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                    else
                        table = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, Convert.ToInt32(mailingId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                }
                else if (ContactRptname == "Opened")
                {
                    TabName = "Opened"; int TotalOpenCounts = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.EmailOpendByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalOpenCounts);
                    else
                        table = ContactMaster.EmailOpendByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Unopened")
                {
                    TabName = "Unopened";
                    if (campId != string.Empty)
                        table = ContactMaster.EmailUnopendRecByAssignCampId(ConnectionString, campId);
                    else
                        table = ContactMaster.EmailUnopendByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Clicked")
                {
                    TabName = "Clicked"; int TotalClickCounts = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.EmailClickedRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalClickCounts);
                    else
                        table = ContactMaster.EmailClickedRecByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Forwards")
                {
                    TabName = "Forwards"; int TotalForwardCount = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.SelectForwardRecipientsByAssignId(ConnectionString, Convert.ToInt32(campId), out TotalForwardCount);
                    else
                        table = ContactMaster.SelectForwardRecipients(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Unsubscribed")
                {
                    TabName = "Unsubscribed";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectUnsubscribeRecipientsByAssignedCampId(ConnectionString, Convert.ToInt32(campId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount, out TotalUnsubCount);
                    else
                        table = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, Convert.ToInt32(mailingId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount);
                }
                else if (ContactRptname == "Advanced")
                {
                    TabName = "Advanced";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectRecipientsDomainCountsByAssign(ConnectionString, Convert.ToInt32(campId), "TargetedDomain", string.Empty);
                    else
                        table = ContactMaster.SelectRecipientsDomainCounts(ConnectionString, listIds, Convert.ToInt32(mailingId), "TargetedDomain", string.Empty);
                    table.Columns["TargetedDomain"].ColumnName = "Domains";
                    table.Columns["Unsubs"].ColumnName = "Unsubscribe";
                }
                if (dpExport.SelectedValue.Equals("CSV"))
                    Export.ExportDetails(table, Export.ExportFormat.CSV, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".csv");
                else if (dpExport.SelectedValue.Equals("Excel"))
                    Export.ExportDetails(table, Export.ExportFormat.Excel, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".xls");
                else if (dpExport.SelectedValue.Equals("Text"))
                {
                    Export.ExportDetails(table, Export.ExportFormat.Text, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".txt");
                }
                else
                    ExportToPDF(table, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".pdf");
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 protected void lBtnSave_Click(object sender, EventArgs e)
 {
     try
     {
         lbMsg.Text = string.Empty;
         Campaign = new Campaign(ConnectionString);
         Campaign.CampaignsName = txtCampName.Text;
         Campaign.CampaignsDesc = txtCampDescription.Text;
         Campaign.Active = true;
         Campaign.TotalCount = 0;
         DataTable dtCheck = CampaignBase.SelectByField("CampaignsName", txtCampName.Text.ToString(), ConnectionString);
         if (dtCheck.Rows.Count > 0)
         {
             if (dtCheck.Rows[0]["Active"].ToString() == "True")
             {
                 lbMsg.ForeColor = Color.Red;
                 lbMsg.Text = string.Format("Campaign: {0},  already exists. Please enter other name.", txtCampName.Text);
                 CreateCampPE.Show();
             }
             else
             {
                 CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(dtCheck.Rows[0]["ID"].ToString()));
                 CampaignBase campaignMail = CampaignBase.SelectOne(pk, ConnectionString);
                 campaignMail.CampaignsDesc = string.Empty;
                 campaignMail.CreatedDate = DateTime.Now;
                 campaignMail.ModifiedDate = DateTime.Now;
                 campaignMail.Active = true;
                 lblMainMsg.Text = string.Format(campaignMail.Update() == true ? "Campaign {0} Created Successfully." : "Campaign {0} Created Failed.", txtCampName.Text);
                 bindGrid(string.Empty, RGridCampMails.CurrentPageIndex);
             }
         }
         else
         {
             Campaign.CreatedDate = System.DateTime.Now;
             Campaign.ModifiedDate = System.DateTime.Now;
             lblMainMsg.Text = string.Format(Campaign.Insert() == true ? "Campaign {0} Created Successfully." : "Campaign {0} Created Failed.", txtCampName.Text);
             bindGrid(string.Empty, RGridCampMails.CurrentPageIndex);
         }
     }
     catch (Exception ex)
     {
         CreateCampPE.Show();
         lbMsg.ForeColor = Color.Red;
         lbMsg.Text = "Error: " + ex.Message;
     }
 }
        protected void lbtnYes_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder strbDeletedContacts = new StringBuilder();
                rememberCampaignsSelection("PgrdaddchkSelectRecs", "lblDCampaignId", RGridCampMails, "Pgrdaddselectall");
                if (ViewState["SelectedContacts"] != null)
                {
                    //adding selected contatIds to stringbuilder
                    for (int i = 0; i < CampaignsSelected.Count; i++)
                    {
                        strbDeletedContacts.Append(CampaignsSelected[i] + ", ");
                    }
                    strbDeletedContacts.Remove(strbDeletedContacts.Length - 2, 1);
                    string[] CampIds = strbDeletedContacts.ToString().Split(',');
                    for (int i = 0; i < CampIds.Length; i++)
                    {
                        //Get Related Mailings then Change AssignedCampaignId is zero.
                        CampaignMailings objCampMail = CampaignMailing.SelectByField("CampaignsId", Convert.ToInt32(CampIds[i].ToString()), ConnectionString);
                        for (int j = 0; j < objCampMail.Count; j++)
                        {
                            long campMasterId = Convert.ToInt64(objCampMail[j].CampaignId.ToString());
                            CampaignMasterPrimaryKey campMasterPk = new CampaignMasterPrimaryKey(campMasterId);
                            CampaignMaster campMaster = CampaignMaster.SelectOne(campMasterPk, ConnectionString);
                            if (rbtnKeepMails.Checked)
                                campMaster.AssignedCampaignID = 0;
                            else
                            {
                                campMaster.AssignedCampaignID = 0;
                                campMaster.Active = false;
                            }
                            campMaster.Update();
                        }
                        //Delete All Recoreds in CampaignMailing Table Related to Mailings
                        bool delStatus = CampaignMailing.DeleteByField("CampaignsID", Convert.ToInt32(CampIds[i].ToString()), ConnectionString);

                        CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt32(CampIds[i].ToString()));
                        CampaignBase campaignMail = CampaignBase.SelectOne(pk, ConnectionString);
                        campaignMail.Active = false;
                        bool status = campaignMail.Update();
                    }
                    MDelModalPopupExtender.Hide();
                    GridPrevSortExpression = string.Empty;
                    bindGrid("sort", 0);
                    ViewState["SelectedContacts"] = null;
                    lblMainMsg.Visible = true;
                    lblMainMsg.Text = "Successfully Deleted Campaign(s) with ids: " + strbDeletedContacts.ToString();
                    lblMainMsg.Style.Add("color", "Green");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 //lbtnEditMultipleYes_Click
 protected void lbtnEditMultipleYes_Click(object sender, EventArgs e)
 {
     if (RGridCampMails.MasterTableView.Items.Count > 0)
     {
         //Get contact Selection
         rememberCampaignsSelection("PgrdaddchkSelectRecs", "lblDCampaignId", RGridCampMails, "Pgrdaddselectall");
         if (ViewState["SelectedContacts"] != null)
         {
             StringBuilder strbEditContacts = new StringBuilder();
             //adding selected contatIds to stringbuilder
             for (int i = 0; i < CampaignsSelected.Count; i++)
             {
                 strbEditContacts.Append(CampaignsSelected[i] + ", ");
                 Campaign campaign = new Campaign(ConnectionString);
                 campaign.ID = Convert.ToInt64(CampaignsSelected[i]);
                 campaign.CampaignsDesc = txtMultiCampaignDesc.Text;
                 CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(CampaignsSelected[i]));
                 CampaignBase campaignnew = CampaignBase.SelectOne(pk, ConnectionString);
                 campaign.CreatedDate = campaignnew.CreatedDate;
                 campaign.ModifiedDate = System.DateTime.Now;
                 campaign.Active = true;
                 CampaignBase objCampaignBase = new CampaignBase(ConnectionString);
                 objCampaignBase.SelectedEditUpdateCampaign(campaign);
             }
             strbEditContacts.Remove(strbEditContacts.Length - 2, 1);
             ViewState["SelectedContacts"] = null;
             hdrchkselected.Clear();
             if (txtCampNameSearch.Text != string.Empty || txtCampDesSearch.Text != string.Empty || txtCreatedDate.Text != string.Empty)
             {
                 SearchCriteria(0, string.Empty);
             }
             else
             {
                 bindGrid(string.Empty, 0);
             }
             lblMainMsg.Text = "Successfully Edit Campaign(s) with ids: " + strbEditContacts.ToString();
             hdnMeditselect.Value = "false";
         }
     }
 }
        // Edit
        protected void lbSaveCamp_Click(object sender, EventArgs e)
        {
            try
            {
                string campName = txtEditCampName.Text.ToString();
                DataTable dtCheck = CampaignBase.SelectByField("CampaignsName", txtEditCampName.Text.ToString(), ConnectionString);
                Campaign objCampaign = new Campaign(ConnectionString);
                objCampaign.CampaignsName = txtEditCampName.Text;
                objCampaign.CampaignsDesc = txtEditCampDescription.Text;
                if (Convert.ToInt64(hiddenEditID.Value) > 0)
                {
                    objCampaign.ID = Convert.ToInt64(hiddenEditID.Value);
                    if (dtCheck.Rows.Count > 0 && Convert.ToInt64(dtCheck.Rows[0]["ID"]) != Convert.ToInt64(hiddenEditID.Value))
                    {
                        lbMsgForEdit.Text = "Campaign:" + txtEditCampName.Text + ",  already exists. Please enter other name.";
                        MpextDivEdit.Show();
                    }
                    else
                    {
                        CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(hdId.Value.ToString()));
                        Campaign CampNew = Campaign.SelectOne(pk, ConnectionString);
                        Campaign = new Campaign(ConnectionString);
                        Campaign.ID = Convert.ToInt64(hdId.Value.ToString());
                        Campaign.CampaignsName = txtEditCampName.Text.ToString().Trim();
                        Campaign.CampaignsDesc = txtEditCampDescription.Text.ToString().Trim();
                        Campaign.CreatedDate = CampNew.CreatedDate;
                        Campaign.ModifiedDate = DateTime.Now;
                        Campaign.Active = true;
                        if (Campaign.Update() == true)
                        {

                            lblMainMsg.Text = string.Format("Campaign: {0} Updated Successfully.", Server.HtmlEncode(txtEditCampName.Text));
                            bindGrid(string.Empty, RGridCampMails.CurrentPageIndex);
                        }
                        else
                        {
                            lblMainMsg.Text = string.Format("Campaign: {0} Updation Failed.", Server.HtmlEncode(txtEditCampName.Text));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified 
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="CampaignsPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class Campaigns</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			6/25/2012 02:05:58 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static Campaign SelectOneWithCampaignMailingUsingCampaignMailId(CampaignPrimaryKey pk,string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool ExecutionState = false;
            Campaign obj=null;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }

            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_Campaigns_SelectOneWithCampaignMailingUsingCampaignMailId", ref ExecutionState);
            if (dr.Read())
            {
                obj = new Campaign(ConnectionString);
                PopulateObjectFromReader(obj,dr);

                dr.NextResult();

                //Get the child records.
                obj.CampaignMailings = CampaignMailing.PopulateObjectsFromReader(dr, ConnectionString);
            }
            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
Example #8
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="CampaignPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			6/25/2012 02:05:58 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(CampaignPrimaryKey pk)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            oDatabaseHelper.ExecuteScalar("sp_Campaigns_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
        protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string CampName = string.Empty;
                string campId = HttpContext.Current.Request.QueryString["CampId"] != null ? HttpContext.Current.Request.QueryString["CampId"].ToString() : string.Empty;
                string mailingId = HttpContext.Current.Request.QueryString["MailingID"] != null ? HttpContext.Current.Request.QueryString["MailingID"].ToString() : string.Empty;

                //Get the MailingName Using MailingId
                if (mailingId != string.Empty)
                {
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId));
                    CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                    CampName = objCampMaster.CampaignName.ToString().Trim();
                }
                else
                {
                    CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(campId));
                    Campaign Campaign = Campaign.SelectOne(pk, ConnectionString);
                    CampName = Campaign.CampaignsName;
                }

                //string CampName = HttpContext.Current.Request.QueryString["CampName"] != null ? HttpContext.Current.Request.QueryString["CampName"].ToString() : string.Empty;
                string TabName = string.Empty;
                DataTable table = new DataTable();
                Export Export = new Export("Web");
                #region download using Dll
                if (ContactRptname == "Wheelock")
                {
                    TabName = "Wheelock";
                    if (campId != string.Empty)
                        table = ContactMaster.getWheelockClickCountsByAssignCampId(ConnectionString, campId);
                    else
                        table = ContactMaster.getWheelockClickCounts(ConnectionString, mailingId);
                }

                else if (ContactRptname == "Widener")
                {
                    TabName = "Widener";
                    if (campId != string.Empty)
                        table = ContactMaster.getWidenerClickCountsByAssignCampId(ConnectionString, campId);
                    else
                        table = ContactMaster.getWidenerClickCounts(ConnectionString, mailingId);
                }
                if (dpExport.SelectedValue.Equals("CSV"))
                    Export.ExportDetails(table, Export.ExportFormat.CSV, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".csv");
                else if (dpExport.SelectedValue.Equals("Excel"))
                    Export.ExportDetails(table, Export.ExportFormat.Excel, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".xls");
                else if (dpExport.SelectedValue.Equals("Text"))
                {
                    Export.ExportDetails(table, Export.ExportFormat.Text, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".txt");
                }
                else
                    ExportToPDF(table, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".pdf");
                #endregion
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }