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;


public partial class Admin_airtoegen : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["AdminEMAILID"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            if (!IsPostBack)
            {
                GetOperators();
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    private void GetOperators()
    {
        SqlParameter[] param = new SqlParameter[]
        {
            new SqlParameter("@OperatorName",txtOpName.Text.Trim()),
            new SqlParameter("@Operatorid",0)
        };
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "sp_SHOWOPERATORS", param);
        
        GvOperators.DataSource = ds;
        GvOperators.DataBind();
        GvOperators.Visible = true;
    }
   
    //private void deleteenquiry()
    //{
    //    try
    //    {
    //        foreach (GridViewRow gvdr in this. GridView1.Rows)
    //        {
    //            if (((CheckBox)gvdr.FindControl("delete_chkbox")).Checked == true)
    //            {
    //                //int fundtransfer_id;
    //                Label FUND_TRANSFER_ID = (Label)gvdr.FindControl("FUND_TRANSFER_ID");

    //                SqlParameter[] param_del = new SqlParameter[]
    //                {
    //                    new SqlParameter("@status",SqlDbType.Int,4),
    //                    new SqlParameter("@FUND_TRANSFER_ID",FUND_TRANSFER_ID.Text)
    //                };

    //                param_del[0].Direction = ParameterDirection.Output;

    //                SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_delete_airtoegen_enquiry", param_del);

    //                id_statusparam = Convert.ToString(param_del[0].Value);

    //                if (id_statusparam == "1")
    //                {
    //                    Label3.Text = "Record Deleted Successfully";
    //                    Label3.ForeColor = Color.Blue;
    //                }
    //                else if (id_statusparam == "2")
    //                {

    //                }
    //                else
    //                {
    //                    Label3.Text = "Record not deleted";
    //                    Label3.ForeColor = Color.Red;
    //                }
    //                //dgactivate_subs_id.DataSource = objDs;
    //                //dgactivate_subs_id.DataBind();
    //            }
    //        }
    //        get_transfer_details_air_to_egen();
    //    }
    //    catch (Exception ex)
    //    {
    //        throw ex;
    //    }
    //}

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            GetOperators();
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    //protected void btnEdit_Command(object sender, CommandEventArgs e)
    //{
    //    LinkButton btn = (LinkButton)sender;
    //    GridViewRow rowitem = (GridViewRow)btn.Parent.Parent;
    //    Label lbl_Operator;
    //    lbl_Operator = (Label)rowitem.FindControl("lblopid");
    //    Response.Redirect("addoperators.aspx?operatorid=" + lbl_Operator.Text + "");
    //}

    protected void GvOperators_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int opID = 0;
        int.TryParse(e.CommandArgument as string, out opID);

        if (e.CommandName.Equals("EditOperator"))
        {
            Response.Redirect("addoperators.aspx?operatorid=" + Convert.ToString(opID) + "");
        }
    }
}
