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 DataCard : System.Web.UI.Page
{
    string varoperator;
    DataSet ds = new DataSet();
    private string _loginID;
    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");
            }
            LoginID = Convert.ToString(Session["LOGINID"]);
            lblerror.Text = Request.QueryString["error"];
            if (lblerror.Text == "Transaction has process successfully")
            {
                lblerror.ForeColor = Color.Blue;
            }
            else
            {
                lblerror.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }

    protected void rbtnlist_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            SqlParameter[] getoperatorstatus = new SqlParameter[]
            {
                new SqlParameter("@WLID",Session["WhitelabelId"].ToString()),
                new SqlParameter("@operator",rbtnlist.SelectedItem.Text),
                new SqlParameter("@ServiceType","Data Card")
            };
            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",rbtnlist.SelectedItem.Text),
                    new SqlParameter("@ServiceType","Data Card")
                };
                ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_GetServiceVendor", GetCurrentVendor);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Session["operator"] = rbtnlist.SelectedItem.Text.ToUpper().Trim();
                    Session["serviceprovider"] = ds.Tables[0].Rows[0]["ServiceProvider"].ToString();
                    Session["operatorValue"] = rbtnlist.SelectedValue.Trim();
                    Response.Redirect("DataCardb.aspx");
                }
            }
            else
            {
                lblerror.Text = "Currently this service is not available.";
                lblerror.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }

}

