public void ScheduleMailDetailsInsert(ScheduleMailDetails objScheduleMailDetails)
        {
            try
            {
                objEmailCampDataContext = new EmailCampDataContext();

                var Insert = (from cde in objEmailCampDataContext.spScheduleMailDetails_AllActions(objScheduleMailDetails.PK_ScheduleID, objScheduleMailDetails.FK_ContactID, objScheduleMailDetails.Scheduledatetime, objScheduleMailDetails.FK_Scheduleby, objScheduleMailDetails.QueueStatus, objScheduleMailDetails.CreatedBy, objScheduleMailDetails.CreatedOn, objScheduleMailDetails.UpdatedBy, objScheduleMailDetails.UpdatedOn, objScheduleMailDetails.FK_CampaignID, "i")
                              select cde).ToList();

                Insert = null;
                objScheduleMailDetails = null;
                objEmailCampDataContext = null;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void ScheduleMailDetailsDelete(int ScheduleMailDetailsid)
        {
            try
            {
                objEmailCampDataContext = new EmailCampDataContext();

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

                Delete = null;
                objScheduleMailDetails = null;
                objEmailCampDataContext = null;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 30-3-2015
        /// Comments :: Select all records for ScheduleMailDetails details based on ScheduleMailDetailsid.
        /// </summary>
        public List<ScheduleMailDetails> ScheduleMailDetailsSelectbasedonid(int ScheduleMailDetailsid)
        {
            objEmailCampDataContext = new EmailCampDataContext();
            lstScheduleMailDetails = new List<ScheduleMailDetails>();

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

            if (Select.Count > 0)
            {
                lstScheduleMailDetails = new List<ScheduleMailDetails>();
                foreach (var item in Select)
                {
                    objScheduleMailDetails = new ScheduleMailDetails();
                    objScheduleMailDetails.PK_ScheduleID = item.PK_ScheduleID;

                    if (item.FK_CampaignID != null)
                        objScheduleMailDetails.FK_CampaignID = Convert.ToInt32(item.FK_CampaignID);
                    objScheduleMailDetails.Scheduledatetime = item.scheduledatetime;
                    if (item.FK_Scheduleby != null)
                        objScheduleMailDetails.FK_Scheduleby = Convert.ToInt32(item.FK_Scheduleby);
                    objScheduleMailDetails.QueueStatus = item.QueueStatus;
                    if (item.FK_ContactID != null)
                        objScheduleMailDetails.FK_ContactID = Convert.ToInt32(item.FK_ContactID);

                    objScheduleMailDetails.CreatedBy = item.CreatedBy;
                    objScheduleMailDetails.CreatedOn = item.CreatedOn;
                    objScheduleMailDetails.UpdatedBy = item.UpdatedBy;
                    objScheduleMailDetails.UpdatedOn = item.UpdatedOn;

                    lstScheduleMailDetails.Add(objScheduleMailDetails);
                }
            }
            objEmailCampDataContext = null;
            objScheduleMailDetails = null;
            return lstScheduleMailDetails;
        }
        protected void btngridsubmit_Click(object sender, EventArgs e)
        {
            Boolean AllowMail = ValidateAllowedMails();

            if (AllowMail == false)
                return;
            string CampTimezone = ddlTimeZone.SelectedValue;
            string dttime = dtScheduledatetime.Value;
            string[] dateString = dttime.Split('/');
            DateTime enter_date = Convert.ToDateTime
            (dateString[1] + "/" + dateString[0] + "/" + dateString[2]);
            DateTime indtime;
            DateTime utcTime = enter_date.ToUniversalTime();

            if (ddlTimeZone.SelectedIndex > 0)
            {
                indtime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Convert.ToDateTime(enter_date.ToString()), ddlTimeZone.SelectedValue, TimeZoneInfo.Local.Id);
                utcTime = new DateTime();
                utcTime = indtime.ToUniversalTime();
                objCampaign.Utctime = utcTime;
            }
            //else
            //    objCampaign.Utctime = utcTime;

            //objCampaign.SchduleDateTime = enter_date;
            string body = txta9.Value;

            if (body != "" && gvAddContacts.Rows.Count > 0)
            {
                objBL_Common = new BL_Common();

                objBL_Common.AccessUpdateAllCampaign("EC_Campaign", "Utctime = '" + utcTime + "', CampTimezone = '" + ddlTimeZone.SelectedValue + "', mailcontent = '" + body + "', CampaignStatus = " + 0 + ", SchduleDateTime = '" + enter_date + "' ", "PK_CampaignID =" + Convert.ToInt32(Session["CampgnID"].ToString()) + "");

                for (int i = 0; i < gvAddContacts.Rows.Count; i++)
                {
                    string tomailid = gvAddContacts.Rows[i].Cells[5].Text.ToString();
                    int contactid = 0;
                    Label lblEmpID = (Label)gvAddContacts.Rows[i].Cells[0].FindControl("lblThirdPartyId");

                    if (gvAddContacts.Rows[i].Cells[0].Text.ToString() != null)
                        contactid = Convert.ToInt32(lblEmpID.Text.ToString());
                    CampaignQueueInsert(false, contactid);
                }
                //objBL_Common = new BL_Common();
                //objBL_Common.AccessUpdateAllCampaign("EC_Campaign", "CampaignStatus = " + 0 + "", "PK_CampaignID =" + Convert.ToInt32(Session["CampgnID"].ToString()) + "");
                objBL_ScheduleMailDetails = new BL_ScheduleMailDetails();
                objScheduleMailDetails = new ScheduleMailDetails();
                Label lblEmpID1 = (Label)gvAddContacts.Rows[0].Cells[0].FindControl("lblThirdPartyId");
                objScheduleMailDetails.FK_ContactID = Convert.ToInt32(lblEmpID1.Text.ToString());
                objScheduleMailDetails.Scheduledatetime = utcTime;
                objScheduleMailDetails.FK_Scheduleby = Convert.ToInt32(Session["UserID"].ToString());
                objScheduleMailDetails.QueueStatus = false;
                objScheduleMailDetails.CreatedBy = Convert.ToInt32(Session["UserID"].ToString());
                objScheduleMailDetails.CreatedOn = DateTime.Now;
                objScheduleMailDetails.FK_CampaignID = Convert.ToInt32(Session["CampgnID"].ToString());
                objBL_ScheduleMailDetails.AccessInsertScheduleMailDetails(objScheduleMailDetails);
                objScheduleMailDetails = null;
                objBL_ScheduleMailDetails = null;
                Session["SelectContactID"] = null;
                Session.Remove("SelectContactID");
                Session["CampgnID"] = null;
                Session.Remove("CampgnID");
                //ClientScript.RegisterStartupScript(Page.GetType(), "mykey26", "alert('Your schedule mail content text message or Choose Recipients to send a mail!');", true);
                Response.Redirect("MailScheduleSuccess.aspx", false);
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "mykey25", "alert('Enter your mail content text message or Choose time zone and Recipients to send a mail!');", true);
            }
        }
 public void AccessUpdateScheduleMailDetails(ScheduleMailDetails objScheduleMailDetails1)
 {
     objDL_ScheduleMailDetails.ScheduleMailDetailsUpdate(objScheduleMailDetails1);
 }
 public void AccessInsertScheduleMailDetails(ScheduleMailDetails objScheduleMailDetails1)
 {
     objDL_ScheduleMailDetails.ScheduleMailDetailsInsert(objScheduleMailDetails1);
 }