protected void retreiveDATA()
        {
            HomePageSetUpBE HomePage = new HomePageSetUpBE();
            HomePageSetUpBAL HomePageBAL = new HomePageSetUpBAL();
            DataTable dt = new DataTable();

            HomePage.HomePageId = Convert.ToInt32(hdnHomePageId.Value);

            if (HomePageBAL.GetDetailsbyHomePageId(HomePage, ref dt))
            {
                string[] TimeFrom = new string[2];
                string[] TimeTo = new string[2];
                txtPageValidDateFrom.Text = Convert.ToDateTime(dt.Rows[0]["PageValidDateFrom"]).ToShortDateString();
                txtPageValidDateTo.Text = Convert.ToDateTime(dt.Rows[0]["PageValidDateTo"]).ToShortDateString();
                
                TimeFrom =dt.Rows[0]["PageValidTimeFrom"].ToString().Split(':');
                DdlFromHrs.Text = (TimeFrom[0]).ToString();
                DdlFromMns.Text = (TimeFrom[1]).ToString();

                TimeTo = dt.Rows[0]["PageValidTimeTo"].ToString().Split(':');
                DdlToHrs.Text = (TimeTo[0]).ToString();
                DdlToMns.Text = (TimeTo[1]).ToString();
                txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(dt.Rows[0]["PageHtml"].ToString());
            
            }
            else
            {
            }
        }
        private void BindHomePageList()
        {

            HomePageSetUpBAL setupBAL = new HomePageSetUpBAL();
            DataTable dt = new DataTable();
            if (setupBAL.ShowHomePage(ref dt))
            {
                this.LvHomePageItems.DataSource = dt;
                LvHomePageItems.DataBind();
                
            }
            else
            {
                
            }


        }
        protected void btnDeleteYes_Click(object sender, EventArgs e)
        {
            HomePageSetUpBE HomePage = new HomePageSetUpBE();
            HomePageSetUpBAL HomePageBAL = new HomePageSetUpBAL();

            HomePage.HomePageId = Convert.ToInt32(hdnHomePageListId.Value);

            if (HomePageBAL.DeleteHomePage(HomePage))
            {
                LvHomePageItems.EditIndex = -1;
                BindHomePageList();
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Record successfully deleted.", true);
                BindHomePageList();
                recalcNoOfPages();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("UnSuccessful", false);
            
            }
            
        }
 protected void GetHtmlPage(HomePageSetUpBE HomePage)
 {
     DataTable dt = new DataTable();
     HomePageSetUpBAL HomePageBAL = new HomePageSetUpBAL();
     if (HomePageBAL.GetHtml(HomePage, ref dt))
     {
         divOutput.InnerHtml = HttpUtility.HtmlDecode(dt.Rows[0]["PageHtml"].ToString());
     }
     else
     {
     }
    
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            HomePageSetUpBE setupBE = new HomePageSetUpBE();
            HomePageSetUpBAL setupBAL = new HomePageSetUpBAL();

            setupBE.HomePageId = Convert.ToInt32(hdnHomePageId.Value);
            setupBE.PageValidDateFrom = Convert.ToDateTime(txtPageValidDateFrom.Text);
            setupBE.PageValidDateTo = Convert.ToDateTime(txtPageValidDateTo.Text);
            setupBE.PageValidTimeFrom = DdlFromHrs.SelectedValue + ":" + DdlFromMns.SelectedValue;
            setupBE.PageValidTimeTo = DdlToHrs.SelectedValue + ":" + DdlToMns.SelectedValue;
            setupBE.PageHtml = HttpUtility.HtmlDecode(txtHtmlEditorExtender_HomePage.Text);
            setupBE.LastModifiedBy = LoggedInUser.UserId;
            

            if (setupBAL.VerifyOverlapHomePage(setupBE, ref dt))
            {
                LoggedIn MasterPage = (LoggedIn)Page.Master;
                MasterPage.ShowMessage("Sorry You Cannot Update Event To Already Existing Dates", false);
                txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(txtHtmlEditorExtender_HomePage.Text);
               
               
            }

            else
            {
                LoggedIn MasterPage = (LoggedIn)Page.Master;
                MasterPage.ShowMessage("No Other events On the Same Date Proceed.", false);
                txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(txtHtmlEditorExtender_HomePage.Text);
              
                if (setupBAL.ModifyHomePage(setupBE))
                {

                    txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(txtHtmlEditorExtender_HomePage.Text);
                    
                    MasterPage.ShowMessage("Record Successfully Updated", true);
                   
                }
                else
                {
                    MasterPage.ShowMessage("UnSuccessful", true);
                    
                   
                }
            }

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            HomePageSetUpBE SetupBE = new HomePageSetUpBE();
            HomePageSetUpBAL SetupBAL = new HomePageSetUpBAL();
            DataTable dt = new DataTable();


            SetupBE.PageValidDateFrom = Convert.ToDateTime(txtPageValidDateFrom.Text);
            SetupBE.PageValidDateTo = Convert.ToDateTime(txtPageValidDateTo.Text);
            SetupBE.PageValidTimeFrom = DdlFromHrs.SelectedValue + ":" + DdlFromMns.SelectedValue;
            SetupBE.PageValidTimeTo = DdlToHrs.SelectedValue + ":" + DdlToMns.SelectedValue;
            SetupBE.PageHtml = HttpUtility.HtmlDecode(txtHtmlEditorExtender_HomePage.Text);
            SetupBE.LastModifiedBy = LoggedInUser.UserId;

            txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(HtmlEditorText);

            if (SetupBAL.VerifyOverlapHomePage(SetupBE, ref dt))
            {
               
                txtHtmlEditorExtender_HomePage.Text = HttpUtility.HtmlDecode(HtmlEditorText);
                LoggedIn MasterPage = (LoggedIn)Page.Master;
                MasterPage.ShowMessage("Sorry You Cannot Add Event On The Same Dates", false);
            }

            else
            {

                LoggedIn MasterPage = (LoggedIn)Page.Master;
                  MasterPage.ShowMessage("No Other events On the Same Date Proceed....", false);
              

                if (SetupBAL.AddHomePage(SetupBE))
                {
                  //  LoggedIn MasterPage = (LoggedIn)Page.Master;
                      MasterPage.ShowMessage("Record Succesfully Added", true);
                    
                    txtPageValidDateFrom.Text = "";
                    txtPageValidDateTo.Text = "";
                    DdlFromHrs.SelectedIndex = 0;
                    DdlFromMns.SelectedIndex = 0;
                    DdlToHrs.SelectedIndex = 0;
                    DdlToMns.SelectedIndex = 0;
                    txtHtmlEditorExtender_HomePage.Text = "";
                }
                else
                {
                     MasterPage.ShowMessage("Unsuccessful", false);
                    
                }
            }




        }