public void CampaignInsert(Campaign objCampaign)
        {
            try
            {
                objEmailCampDataContext = new EmailCampDataContext();

                var Insert = (from cde in objEmailCampDataContext.spCampaign_AllActions(objCampaign.PK_CampaignID, objCampaign.FK_UserID, objCampaign.CampaignName, objCampaign.Title, objCampaign.SchduleDateTime, objCampaign.CampTimezone, objCampaign.Utctime, objCampaign.FromName, objCampaign.Emailid, objCampaign.CreatedBy, objCampaign.CreatedOn, objCampaign.UpdatedBy, objCampaign.UpdatedOn, objCampaign.CampaignStatus, objCampaign.mailcontent, null, null, null, "i")
                              select cde).ToList();

                Insert = null;
                objCampaign = null;
                objEmailCampDataContext = null;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void CampaignDelete(int Campaignid)
        {
            try
            {
                objEmailCampDataContext = new EmailCampDataContext();

                var Delete = (from cde in objEmailCampDataContext.spCampaign_AllActions(Campaignid, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "d")
                              select cde).ToList();

                Delete = null;
                objCampaign = null;
                objEmailCampDataContext = null;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public List<Campaign> CampaignBindDashboard(int CompanyID)
        {
            objEmailCampDataContext = new EmailCampDataContext();
            lstCampaign = new List<Campaign>();

            var Select = (from cde in objEmailCampDataContext.spCampaign_AllActions(null, CompanyID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "p")
                          select cde).ToList();

            if (Select.Count > 0)
            {
                lstCampaign = new List<Campaign>();
                foreach (var item in Select)
                {
                    objCampaign = new Campaign();
                    objCampaign.CampaignName = Convert.ToString(item.CampaignName);
                    objCampaign.PK_CampaignID = item.PK_CampaignID;
                    lstCampaign.Add(objCampaign);
                }
            }
            objEmailCampDataContext = null;
            objCampaign = null;
            return lstCampaign;
        }
        public void RetrieveCampaign()
        {
            try
            {
                objCampaign = new Campaign();
                objBL_CreateCampaign = new BL_CreateCampaign();
                lstCampaign = objBL_CreateCampaign.SelectCampaignListbasedonid(Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["CampId"]).ToString()));

                if (lstCampaign.Count > 0)
                {
                    txtCampaignName.Value = lstCampaign[0].CampaignName;
                    txtTitle.Value = lstCampaign[0].Title;

                    if(lstCampaign[0].FromName != null)
                        FromName.Value = lstCampaign[0].FromName;
                    if (lstCampaign[0].Emailid != null)
                        EmailID.Value = lstCampaign[0].Emailid;
                }
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CampaignEdit.aspx:RetrieveCampaign() - " + ex.Message);
            }
        }
        private void RetrieveCampaigndetails()
        {
            try
            {
                objCampaign = new Campaign();
                objBL_CreateCampaign = new BL_CreateCampaign();
                lstCampaign = objBL_CreateCampaign.SelectCampaignListbasedonid(Convert.ToInt32(Session["CampgnID"].ToString()));

                if (lstCampaign.Count > 0)
                {
                    txtCampaignName.Value = lstCampaign[0].CampaignName;
                    txtTitle.Value = lstCampaign[0].Title;

                    if (lstCampaign[0].FromName != null)
                        FromName.Value = lstCampaign[0].FromName;
                    if (lstCampaign[0].FromName != null)
                        EmailID.Value = lstCampaign[0].Emailid;
                }
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateCampign.aspx:RetrieveCampaigndetails() - " + ex.Message);
            }
        }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 27-3-2015
        /// Comments :: Inserting all values of campaign form.
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                objCampaign = new Campaign();
                objCampaign.FK_UserID = Convert.ToInt32(Session["UserID"].ToString());
                objCampaign.CampaignName = txtCampaignName.Value.ToString().Trim();
                objCampaign.Title = txtTitle.Value.ToString().Trim();

                string dttime = dtScheduledatetime.Value;
                string[] dateString = dttime.Split('/');
                DateTime enter_date = Convert.ToDateTime(dateString[1] + "/" + dateString[0] + "/" + dateString[2]);
                DateTime utcTime = enter_date.ToUniversalTime();
                objCampaign.Utctime = utcTime;

                objCampaign.SchduleDateTime = enter_date;
                objCampaign.FromName = FromName.Value.ToString();
                objCampaign.Emailid = EmailID.Value.ToString();
                objCampaign.CampTimezone = ddlTimeZone.SelectedValue;
                objCampaign.CampaignStatus = false;
                //if (Editstatus == 1)
                //{
                //    objCampaign.UpdatedBy = Convert.ToInt32(Session["UserID"].ToString());
                //    objCampaign.UpdatedOn = DateTime.Now;
                //    objBL_CreateCampaign.AccessInsertCampign(objCampaign);
                //}
                //else
                //{
                //    objCampaign.CreatedBy = Convert.ToInt32(Session["UserID"].ToString());
                objCampaign.CreatedOn = DateTime.Now;
                objBL_CreateCampaign.AccessInsertCampign(objCampaign);
                //}

                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Clearuserinput1();", true);
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateCampign.aspx:btnSubmit_Click() - " + ex.Message);
            }
        }
 public void AccessUpdateCampign(Campaign objCampaign1)
 {
     objDL_CreateCampaign.CampaignUpdate(objCampaign1);
 }
 public void AccessInsertCampign(Campaign objCampaign1)
 {
     objDL_CreateCampaign.CampaignInsert(objCampaign1);
 }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 20-5-2015
        /// Comments :: Inserting all values of campaign form.
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                objCampaign = new Campaign();
                lstCampaign = new List<Campaign>();
                objCampaign.FK_UserID = Convert.ToInt32(Session["UserID"].ToString());
                objCampaign.CampaignName = txtCampaignName.Value.ToString().Trim();
                objCampaign.Title = txtTitle.Value.ToString().Trim();

                //string dttime = dtScheduledatetime.Value;
                //string[] dateString = dttime.Split('/');
                //DateTime enter_date = Convert.ToDateTime(dateString[1] + "/" + dateString[0] + "/" + dateString[2]);
                //DateTime utcTime = enter_date.ToUniversalTime();
                //objCampaign.Utctime = utcTime;

                //objCampaign.SchduleDateTime = enter_date;
                objCampaign.FromName = FromName.Value.ToString();
                objCampaign.Emailid = EmailID.Value.ToString();

                //objCampaign.CampTimezone = ddlTimeZone.SelectedValue;
                objCampaign.CampaignStatus = false;
                //if (Editstatus == 1)
                //{
                //    objCampaign.UpdatedBy = Convert.ToInt32(Session["UserID"].ToString());
                //    objCampaign.UpdatedOn = DateTime.Now;
                //    objBL_CreateCampaign.AccessInsertCampign(objCampaign);
                //}
                //else
                //{
                //    objCampaign.CreatedBy = Convert.ToInt32(Session["UserID"].ToString());
                if (Request.QueryString["CampId"] != null)
                {
                    objCampaign.PK_CampaignID = Convert.ToInt32(Request.QueryString["CampId"].ToString());
                    objCampaign.UpdatedBy = Convert.ToInt32(Session["UserID"].ToString());
                    objCampaign.UpdatedOn = DateTime.Now;
                    lstCampaign = objBL_CreateCampaign.SelectCampaignListbasedonid(Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["CampId"]).ToString()));

                    if (lstCampaign.Count > 0)
                    {
                        //if(lstCampaign[0].FK_UserID != null)
                            objCampaign.FK_UserID = lstCampaign[0].FK_UserID;
                        if (lstCampaign[0].SchduleDateTime != null)
                            objCampaign.SchduleDateTime = lstCampaign[0].SchduleDateTime;
                        if (lstCampaign[0].CampTimezone != null)
                            objCampaign.CampTimezone = lstCampaign[0].CampTimezone;
                        if (lstCampaign[0].Utctime != null)
                            objCampaign.Utctime = lstCampaign[0].Utctime;
                        if (lstCampaign[0].CampaignStatus != null)
                            objCampaign.CampaignStatus = lstCampaign[0].CampaignStatus;

                        if (lstCampaign[0].CreatedOn != null)
                            objCampaign.CreatedOn = lstCampaign[0].CreatedOn;
                        if (lstCampaign[0].CreatedBy != null)
                            objCampaign.CreatedBy = lstCampaign[0].CreatedBy;
                    }
                    objBL_CreateCampaign.AccessUpdateCampign(objCampaign);
                }
                else
                {
                    objCampaign.CreatedOn = DateTime.Now;
                    objCampaign.CreatedBy = Convert.ToInt32(Session["UserID"].ToString());
                    objBL_CreateCampaign.AccessInsertCampign(objCampaign);
                }

                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Clearuserinput1();", true);
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CampaignEdit.aspx:btnSubmit_Click() - " + ex.Message);
            }
        }
        public DataSet CampaignSelectforgridBasedonFilter(string uertype, int companyid, string CampName, string Title, Nullable<DateTime> CreatedOn, string all, string fromname)
        {
            objEmailCampDataContext = new EmailCampDataContext();
            lstCampaign = new List<Campaign>();

            var Select = (from cde in objEmailCampDataContext.spCampaign_AllActions(null, companyid, CampName, Title, null, null, null, fromname, all, null, CreatedOn, null, null, null, null, null, null, null, uertype)
                          select cde).ToList();

            if (Select.Count > 0)
            {
                lstCampaign = new List<Campaign>();
                foreach (var item in Select)
                {
                    objCampaign = new Campaign();
                    objCampaign.CampaignName = Convert.ToString(item.CampaignName);
                    objCampaign.CampTimezone = Convert.ToString(item.CampTimezone);
                    objCampaign.CreatedBy = item.CreatedBy;
                    objCampaign.CreatedOn = item.CreatedOn;
                    objCampaign.UpdatedBy = item.UpdatedBy;
                    objCampaign.UpdatedOn = item.UpdatedOn;
                    objCampaign.Emailid = item.Emailid;
                    objCampaign.FK_UserID = item.FK_UserID;
                    objCampaign.FromName = item.FromName;
                    objCampaign.PK_CampaignID = item.PK_CampaignID;
                    objCampaign.SchduleDateTime = item.SchduleDateTime;
                    objCampaign.Title = item.Title;
                    objCampaign.Utctime = item.utctime;
                    objCampaign.CampaignStatus = item.CampaignStatus;
                    objCampaign.mailcontent = item.mailcontent;

                    lstCampaign.Add(objCampaign);
                }
            }

            objEmailCampDataContext = null;
            objCampaign = null;
            DataSet converted = new DataSet();

            if (lstCampaign.Count > 0)
            {
                converted.Tables.Add(ListToDataSet.newTable(lstCampaign));
                return converted;
            }
            else
            {
                converted.Tables.Add(ListToDataSet.newTableColumnAlone(lstCampaign));
                return converted;
            }
        }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 30-3-2015
        /// Comments :: Select all records for Campaign details based on campaignid.
        /// </summary>
        public List<Campaign> CampaignSelectbasedonid(int Campaignid)
        {
            objEmailCampDataContext = new EmailCampDataContext();
            lstCampaign = new List<Campaign>();

            var Select = (from cde in objEmailCampDataContext.spCampaign_AllActions(Campaignid, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "s")
                          select cde).ToList();

            if (Select.Count > 0)
            {
                lstCampaign = new List<Campaign>();
                foreach (var item in Select)
                {
                    objCampaign = new Campaign();
                    objCampaign.CampaignName = Convert.ToString(item.CampaignName);
                    objCampaign.CampTimezone = Convert.ToString(item.CampTimezone);
                    objCampaign.CreatedBy = item.CreatedBy;
                    objCampaign.CreatedOn = item.CreatedOn;
                    objCampaign.UpdatedBy = item.UpdatedBy;
                    objCampaign.UpdatedOn = item.UpdatedOn;
                    objCampaign.Emailid = item.Emailid;
                    objCampaign.FK_UserID = item.FK_UserID;
                    objCampaign.CampaignStatus = item.CampaignStatus;
                    objCampaign.CampTimezone = item.CampTimezone;
                    objCampaign.FromName = item.FromName;
                    objCampaign.PK_CampaignID = item.PK_CampaignID;
                    objCampaign.SchduleDateTime = item.SchduleDateTime;
                    objCampaign.Title = item.Title;
                    objCampaign.Utctime = item.utctime;
                    objCampaign.mailcontent = item.mailcontent;

                    lstCampaign.Add(objCampaign);
                }
            }
            objEmailCampDataContext = null;
            objCampaign = null;
            return lstCampaign;
        }