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.Text;
using System.Drawing;
using System.Net;
using System.Net.Mail;

public partial class Panel_Billpayment : System.Web.UI.Page
{
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["LOGINID"] == null && Session["USERNAME"] == null)
            {
                Response.Redirect("../login.aspx");
            }
            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 rbntoperater_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            SqlParameter[] getoperatorstatus = new SqlParameter[]
            {
                new SqlParameter("@WLID",Session["WhitelabelId"].ToString()),
                new SqlParameter("@operator",rbntoperater.SelectedItem.Text),
                new SqlParameter("@ServiceType","Bill Payment")
            };
            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",rbntoperater.SelectedItem.Text),
                    new SqlParameter("@ServiceType","Bill Payment")
                };
                ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_GetServiceVendor", GetCurrentVendor);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Session["operator"] = rbntoperater.SelectedItem.Text.ToUpper().Trim();
                    Session["serviceprovider"] = ds.Tables[0].Rows[0]["ServiceProvider"].ToString();
                    Session["operatorValue"] = rbntoperater.SelectedValue.Trim();
                    Response.Redirect("BillPaymentMode.aspx");
                }
                else
                {
                    lblerror.Text = ds.Tables[0].Rows[0]["Remark"].ToString();
                    lblerror.ForeColor = Color.Red;
                }
            }
        }
        catch (Exception ex)
        { throw (ex); }     
    }

    protected void lnkbtnElectricity_Click(object sender, EventArgs e)
    {
        string vendor = GetElectricityVendor();
        if (vendor == "APIBOX")
        {
            Response.Redirect("electricitynew.aspx");
        }
        else if (vendor == "SoftZone")
        {
            Response.Redirect("electricity.aspx");
        }
        else
        {
            Response.Redirect("electricity.aspx");
        }
    }
    public string GetElectricityVendor()
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
            new SqlParameter("@Service","Electricity")
        };
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Get_VendorList", warlock);
        if (ds.Tables[0].Rows.Count > 0)
        {
            return Convert.ToString(ds.Tables[0].Rows[0][0]);
        }
        else
            return "";
    }
}
