protected void lbtnSaveNewCamp_Click(object sender, EventArgs e)
        {
            try
            {
                lbMsg.Text = string.Empty;
                Campaign Campaign = new Campaign(ConnectionString);
                Campaign.CampaignsName = txtCampName.Text;
                Campaign.CampaignsDesc = txtCampDescription.Text;
                Campaign.Active = true;

                DataTable dtCheck = CampaignBase.SelectByField("CampaignsName", txtCampName.Text.ToString(), ConnectionString);
                if (dtCheck.Rows.Count > 0)
                {
                    throw new Exception(string.Format("Campaign: {0},  already exists. Please enter other name.", txtCampName.Text));
                }
                Campaign.CreatedDate = System.DateTime.Now;
                Campaign.ModifiedDate = System.DateTime.Now;
                lblMainMsg.ForeColor = Color.Green;
                lblMainMsg.Text = string.Format(Campaign.Insert() == true ? "Campaign {0} Created Successfully." : "Mailing {0} Created Failed.", txtCampName.Text);
                bindCampNames();
            }
            catch (Exception ex)
            {
                CreateCampPopup.Show();
                lbMsg.Text = "Error: " + ex.Message;
            }
        }
示例#2
0
 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;
     }
 }