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_ManageSmsService : System.Web.UI.Page
{
    string ServiceType;
    int Service = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["AdminEMAILID"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            if (!IsPostBack)
            {
                SMS_Service();
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            ServiceType = ddlservice.SelectedItem.Text;
            
            SqlParameter[] SMSService = new SqlParameter[]
            {
                new SqlParameter("@Service",ServiceType)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "ChangeSmsService", SMSService);
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('SMS Service change successfully');"), true);
            ddlservice.SelectedIndex = 0;
            SMS_Service();
        }
        catch(Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There are some technical problem');"), true);
            throw (ex);
        }
    }

    public void SMS_Service()
    {
        try
        {
            SqlParameter[] SMS = new SqlParameter[]
            {
            };
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "GetStatusSmsServiceByAdmin", SMS);
            if (ds.Tables[0].Rows.Count > 0)
            {
                Service = Convert.ToInt32(ds.Tables[0].Rows[0]["SMSService"]);
            }
            else
            {
                Service = 1;
            }
            if (Service == 1)
            {
                lblService.Text = "Egen Services";
                lblService.Font.Bold = true;
                lblService.ForeColor = Color.Blue;
            }
            else
            {
                lblService.Text = "Jharkhand";
                lblService.Font.Bold = true;
                lblService.ForeColor = Color.Blue;
            }

        }
        catch(Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There are some technical problem');"), true);
            throw(ex);
        }
    }
}
