using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;

public partial class Admin_egenmessage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["AdminEMAILID"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            if (!IsPostBack)
            {
                getmessage();
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {        
        try
        {
            SqlParameter[] eGenmessage = new SqlParameter[]
            {
                new SqlParameter ("@AddContent",txt_Content.Text),
                new SqlParameter("@msgHeading", txt_MessageHeading.Text)
               
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "proc_insert_Addcontent", eGenmessage);
            lblerror.Text = "Notice Update Successfully";
            lblerror.ForeColor = Color.Blue;
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }        
    }
    public void getmessage()
    {
        try
        {
            SqlParameter[] eGenmessage = new SqlParameter[]
            {          
            };
            SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "proc_get_content", eGenmessage);
            if (dr.Read())
            {
                txt_Content.Text = Convert.ToString(dr["AddContent"]);
                txt_MessageHeading.Text = Convert.ToString(dr["msgHeading"]);
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }
    
}
    