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;
using System.IO;
using System.Text;
using System.Net.Mail;
using System.Net.Sockets;
using System.Xml;
using System.Xml.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections.Specialized;

public partial class MobileRecharge : System.Web.UI.Page
{    
    #region Declare private variable
    private string _loginID;
    #endregion   
    DataSet ds = new DataSet();
    public string LoginID
    {
        get
        {
            return _loginID;
        }
        set
        {
            _loginID = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["LOGINID"])) && string.IsNullOrEmpty(Convert.ToString(Session["USERNAME"])))
            {
                Response.Redirect("../login.aspx");
            }
            else
            {
                LoginID = Convert.ToString(Session["LOGINID"]);
            }
            lblerror.Text = Request.QueryString["error"];
            if (lblerror.Text == "Successfully completed.")
            {
                lblerror.ForeColor = Color.Blue;
            }
            else
            {
                lblerror.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    
    protected void rbntDivOperaterMobileRecharge_SelectedIndexChanged(object sender, EventArgs e)
    {       
        try
        {
            SqlParameter[] getoperatorstatus = new SqlParameter[]
            {
                new SqlParameter("@WLID",Session["WhitelabelId"].ToString()),
                new SqlParameter("@operator",rbntDivOperaterMobileRecharge.SelectedItem.Text),
                new SqlParameter("@ServiceType","MOBILE")
            };
            ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_Getoperatorstatus", getoperatorstatus);
            if (ds.Tables[0].Rows[0]["Flag"].ToString().Equals("1"))
            {
                SqlParameter[] GetCurrentVendor = new SqlParameter[]
                {
                    new SqlParameter("@operator",rbntDivOperaterMobileRecharge.SelectedItem.Text),
                    new SqlParameter("@ServiceType","MobileRecharge")
                };
                ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_GetServiceVendor", GetCurrentVendor);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Session["operator"] = rbntDivOperaterMobileRecharge.SelectedItem.Text.ToUpper().Trim();
                    Session["serviceprovider"] = ds.Tables[0].Rows[0]["ServiceProvider"].ToString();
                    Session["operatorValue"] = rbntDivOperaterMobileRecharge.SelectedValue.Trim();
                    Response.Redirect("MobileRechargeb.aspx");                   
                }
            }
            else
            {
                lblerror.Text = "Currently this service is not available.";
                lblerror.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }    
    
}
