コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ConnectionString = Session["Connectionstring"].ToString();
                Master.ParentModulelbl.Text = "MAILINGS";
                AccountSettingsClass objAccCls;
                // to get the login name for this session
                //LoginName LoginName = (LoginName)Master.FindControl("LoginName1");
                //UserName = LoginName.Page.User.Identity.Name;
                #region UnComment when integrate with the billing
                //Billing objBilling=new Billing();

                ////save the No of email limits for the client in hidden field
                ////the first parameter gives the user name from the login name
                //NoOfEmailLimitsForClient.Value =
                //    objBilling.SelectEmailCount(((LoginName)Master.FindControl("LoginName1")).Page.User.Identity.Name, BillingConnectionString).ToString();
                #endregion
                txtCurDate.Text = DateTime.Now.ToShortDateString();
                ScriptManager1.SetFocus(txtCampaignName);
                lblMainMsg.Text = string.Empty;
                if (!IsPostBack)
                {
                    ListMaster objListMaster = new ListMaster(ConnectionString);
                    dtListNames = objListMaster.SelectAllSuppressLists(ConnectionString, "CreatedDate", "Desc");

                    if (Session["AccCls"] != null)
                    {
                        objAccCls = (AccountSettingsClass)Session["AccCls"];
                        if (objAccCls.IsCustomizedAMMForms)
                        {
                            RadComboBoxItem Hwitem = new RadComboBoxItem("Wconnect", "&nbsp;<a href='[!RPLINK:2!]'>Wconnect</a>&nbsp;");
                            RadComboBoxItem Hgitem = new RadComboBoxItem("GoWidener", "&nbsp;<a href='[!RPLINK:3!]'>GoWidener</a>&nbsp;");

                            RadComboBoxItem Twitem = new RadComboBoxItem("Wconnect", "[!RPLINK:2!]");
                            RadComboBoxItem Tgitem = new RadComboBoxItem("GoWidener", "[!RPLINK:3!]");

                            rcbLinks.Items.Add(Hwitem);
                            rcbLinks.Items.Add(Hgitem);
                            RadLinks.Items.Add(Twitem);
                            RadLinks.Items.Add(Tgitem);
                        }
                    }
                    //Code Added by Pushpesh Suman for From Name and Address Issue
                    string Username = User.Identity.Name;
                    if (Username.ToString().ToLower().Equals("admin"))// || Username.ToString().ToLower().Equals("4virtu"))
                    {
                        LinkButton1.Enabled = false;
                        lbtnScheduleCampaign.Enabled = false;
                    }
                    objMembershipUser = Membership.GetUser(Username);
                    objProfileBase = ProfileBase.Create(Username, true);
                    txtFromName.Text = (objProfileBase.GetPropertyValue("FromName").ToString() != string.Empty) ? objProfileBase.GetPropertyValue("FromName").ToString() : Username;
                    txtReplytoAddress.Text = (objProfileBase.GetPropertyValue("ReplyEmail").ToString() != string.Empty) ? objProfileBase.GetPropertyValue("ReplyEmail").ToString() : string.Empty;
                    string fromAddresses = string.Empty;
                    if (User.IsInRole("user"))
                    {
                        objUserProfileBase = ProfileBase.Create(objProfileBase.GetPropertyValue("ParentUserName").ToString(), true);
                        fromAddresses = objUserProfileBase.GetPropertyValue("FromDomain").ToString().Replace(" ", string.Empty);
                    }
                    else
                    {
                        fromAddresses = (objProfileBase.GetPropertyValue("FromDomain").ToString() != string.Empty) ? objProfileBase.GetPropertyValue("FromDomain").ToString().Replace(" ", string.Empty) : Username;
                    }
                    if (fromAddresses.ToString().Trim() != string.Empty && fromAddresses.Contains(','))
                    {
                        ddlFromAddress.DataSource = fromAddresses.Split(',');
                        ddlFromAddress.DataBind();
                    }
                    else if (fromAddresses.ToString().Trim() != string.Empty && !fromAddresses.Contains(','))
                        ddlFromAddress.Items.Add(fromAddresses);

                    //string FromAdd = objProfileBase.GetPropertyValue("FromDomain").ToString();
                    //if (FromAdd.ToString().Trim() != string.Empty)
                    //{
                    //    txtFromAddress.Text = FromAdd.ToString().Trim();
                    //}
                    //else
                    //{
                    //    objUserProfileBase = ProfileBase.Create(objProfileBase.GetPropertyValue("ParentUserName").ToString(), true);
                    //    FromAdd = objUserProfileBase.GetPropertyValue("FromDomain").ToString();
                    //    txtFromAddress.Text = FromAdd.ToString().Trim();
                    //}

                    if (!User.IsInRole("user"))
                    {
                        CompanyName = objProfileBase.GetPropertyValue("CompanyName").ToString();
                        domainNames = objProfileBase.GetPropertyValue("FromDomain").ToString();
                        Address = objProfileBase.GetPropertyValue("Address").ToString();
                        state = objProfileBase.GetPropertyValue("State").ToString();
                        postalcode = objProfileBase.GetPropertyValue("PostalCode").ToString();
                        country = objProfileBase.GetPropertyValue("Country").ToString();
                        hdUserAddress.Value = "<span style='font-size :small'>Our mailing address is:<br />" + CompanyName + "," + Address + "," + state + "," + postalcode + "," + country + "</span>";
                    }
                    else
                    {
                        string ConnectionString1 = System.Configuration.ConfigurationManager.ConnectionStrings["sqlConstr"].ConnectionString;
                        UserInfos objUserInfos = UserInfo.SelectByField("UserId", objMembershipUser.ProviderUserKey.ToString(), ConnectionString1);
                        if (objUserInfos.Count > 0)
                        {
                            //CompanyName = objProfileBase.GetPropertyValue("CompanyName").ToString();
                            objUserProfileBase = ProfileBase.Create(objProfileBase.GetPropertyValue("ParentUserName").ToString(), true);
                            CompanyName = objUserProfileBase.GetPropertyValue("CompanyName").ToString().Replace(" ", string.Empty);
                            Address = objUserInfos[0].Address1;
                            domainNames = objUserInfos[0].EmailAddress;
                            country = objUserInfos[0].Country;
                            state = objUserInfos[0].State;
                            postalcode = objUserInfos[0].PostalCode;
                            hdUserAddress.Value = "<span style='font-size :small'>Our mailing address is:<br />" + CompanyName + "," + Address + "," + state + "," + postalcode + "," + country + "</span>";
                        }
                    }
                    RadComboBoxItem MailingaddHTML = new RadComboBoxItem("Mailing Address", hdUserAddress.Value);
                    rcbLinks.Items.Add(MailingaddHTML);

                    RadComboBoxItem MailingaddText = new RadComboBoxItem("Mailing Address", hdUserAddress.Value);
                    RadLinks.Items.Add(MailingaddText);

                    ViewState["CCSelectedAll"] = null;
                    ViewState["CCSelectedLists"] = null;

                    ViewState["SeedSelectedAll"] = null;
                    ViewState["SeedSelectedLists"] = null;
                    ViewState["SeedSelectAllLists"] = null;

                    ViewState["CCSelectedDomains"] = null;
                    ViewState["CCDomainSelectedAll"] = null;

                    ViewState["SupressLists"] = null;
                    ViewState["dtDomain"] = null;
                    lbtnHtml.Visible = true;
                    lbtnText.Visible = true;
                    divtextHtml.Style.Add("display", "none");
                    bindCampNames();
                    ////Up to here
                    if (Request.QueryString["id"] != null)
                    {
                        //set main title for the page.
                        lblMainTitle.Text = "Edit Mailing";
                        hiddenCampaignID.Value = Request.QueryString["id"].ToString();
                        bindCampaignDetails(hiddenCampaignID.Value);
                    }
                    else
                    {
                        //set main title for the page.
                        lblMainTitle.Text = "New Mailing";
                        DivUnsubtext.InnerHtml = "If you no longer wish to receive these emails, simply click on the following link: \n" + DDLinktext.SelectedValue;
                        txtUnsubscribe.Text = "If you no longer wish to receive these emails, simply click on the following link:";
                        lblunsubinfo.Text = "If you no longer wish to receive these emails, simply click on the following link:";
                        lblunsublinktext.Text = DDLinktext.SelectedItem.Text.ToString();
                    }

                    //for subjectpf dropdown fill data
                    ddlSubjectpf.Items.Add(new ListItem("--Select--", "--Select--"));
                    ddlSubjectpf.Items.Add(new ListItem("First Name", "[!FirstName!]"));
                    ddlSubjectpf.Items.Add(new ListItem("Last Name", "[!LastName!]"));
                    ddlSubjectpf.Items.Add(new ListItem("Email Address", "[!EmailAddress!]"));

                    DataTable dt = ManageFieldsBase.SelectCustomFields(ConnectionString);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["PersonalizedField"].ToString() == "True")
                        {
                            if (dt.Rows[i]["FieldType"].ToString() == "Text Box" || dt.Rows[i]["FieldType"].ToString() == "Date" || dt.Rows[i]["FieldType"].ToString() == "Check Box")
                            {
                                ddlSubjectpf.Items.Add(new ListItem(dt.Rows[i]["FieldName"].ToString(), "[!" + dt.Rows[i]["FieldName"].ToString() + "!]"));
                            }

                        }
                    }

                }
                this.Form.DefaultFocus = txtCampaignName.ClientID;
                if (rdoSendLater.Checked == true)
                {
                    LinkButton1.Visible = true;
                    lbtnScheduleCampaign.Visible = false;
                }
                else
                {
                    LinkButton1.Visible = false;
                    lbtnScheduleCampaign.Visible = true;
                }

            }
            catch (Exception ex)
            {
                lblMainMsg.Text = "Error: " + ex.Message;
            }
        }
コード例 #2
0
 protected void bindSuppressdList()
 {
     //if (ViewState["SupressLists"] != null)
     //{
     ListMaster objListMaster = new ListMaster(ConnectionString);
     dtLists = objListMaster.SelectAllSuppressLists(ConnectionString, "CreatedDate", "Desc");
     //}
     if (dtLists.Rows.Count > 0)
     {
         chkSuppressListNames.DataSource = dtLists;
         chkSuppressListNames.DataTextField = "ListContacts";
         chkSuppressListNames.DataValueField = "ListMasterID";
         chkSuppressListNames.DataBind();
     }
 }