protected void lnk_genHTHRpt_OnClick(object sender, EventArgs e)
    {
        lbl_error.Text = "";
        string         yrmo     = ddlYrmo.SelectedItem.Text;
        string         plancode = "P5/P5";
        IPBA           dobj     = new IPBA();
        CreateExcelRpt xlobj    = new CreateExcelRpt();
        DataSet        ds       = new DataSet();

        ds.Clear();
        string filename = yrmo.Substring(0, 4) + "_" + yrmo + "_HMODETSTD_P5";

        string[]   sheetnames = { filename };
        string[][] titles     = { new string[] { "" } };
        string[][] colsFormat = { new string[] { "string", "string", "string", "string", "string", "string", "currency" } };
        int[][]    colsWidth  = { new int[] { 60, 40, 65, 130, 35, 60, 65 } };

        try
        {
            ds = dobj.GetHTHAnthemRpt(yrmo, plancode);
            xlobj.ExcelXMLRpt(ds, filename, sheetnames, titles, colsFormat, colsWidth, String.Empty);
        }
        catch (Exception ex)
        {
            lbl_error.Text = "Error in generating HTH International Report for Anthem module for YRMO - " + yrmo + "<br />" + ex.Message;
        }
    }
    protected void lnk_genAdjRptAll_OnClick(object sender, EventArgs e)
    {
        lbl_error.Text = "";
        string yrmo = ddlYrmo.SelectedItem.Text;
        string plancode = ddlPlancd.SelectedItem.Value;
        string filename, footernotes;

        string[]       sheetnames;
        string[][]     titles, colsFormat;
        int[][]        colsWidth;
        IPBA           dobj    = new IPBA();
        CreateExcelRpt xlobj   = new CreateExcelRpt();
        DataSet        ds      = new DataSet(); ds.Clear();
        DataSet        dsFinal = new DataSet(); dsFinal.Clear();

        try
        {
            footernotes = "Exceeded maximum months adjustment that system can be applied. Additional adjustments need to be manually processed.";
            filename    = yrmo + "_IPBA_ADJ_All";
            titles      = new string[ddlPlancd.Items.Count - 1][];
            sheetnames  = new string[ddlPlancd.Items.Count - 1];
            colsFormat  = new string[ddlPlancd.Items.Count - 1][];
            colsWidth   = new int[ddlPlancd.Items.Count - 1][];

            for (int i = 1; i < (ddlPlancd.Items.Count); i++)
            {
                plancode = ddlPlancd.Items[i].Value;

                if (plancode.Equals("P5"))
                {
                    plancode = "P5/P5";
                }

                if (plancode.Contains("P5"))
                {
                    titles[i - 1] = new string[] { "HTH Billing Adjustment Report: " + ddlPlancd.Items[i].Text, "Year-Month: " + yrmo }
                }
                ;
                else
                {
                    titles[i - 1] = new string[] { "Local HMO Billing Adjustment Report: " + ddlPlancd.Items[i].Text, "Year-Month: " + yrmo }
                };

                sheetnames[i - 1] = "Adjustments_" + plancode.Substring(0, 2);
                colsFormat[i - 1] = new string[] { "number", "string", "string", "string", "string", "number", "string", "number", "currency", "string" };
                colsWidth[i - 1]  = new int[] { 30, 60, 30, 60, 100, 40, 180, 40, 65, 30 };

                ds = dobj.GetAdjustmentRpt(yrmo, plancode);
                ds.Tables[0].TableName = "Table_" + plancode.Substring(0, 2);
                dsFinal.Tables.Add(ds.Tables[0].Copy());
                dsFinal.Tables[i - 1].TableName = "TableF_" + plancode.Substring(0, 2);
                ds.Clear();
            }
            xlobj.ExcelXMLRpt(dsFinal, filename, sheetnames, titles, colsFormat, colsWidth, footernotes);
        }
        catch (Exception ex)
        {
            lbl_error.Text = "Error in generating HTH/HMO Billing Adjustment Report for YRMO - " + yrmo + "<br />" + ex.Message;
        }
    }
    protected void lnk_genSumRptAll_OnClick(object sender, EventArgs e)
    {
        lbl_error.Text = "";
        string yrmo     = ddlYrmo.SelectedItem.Text;
        string plancode = ddlPlancd.SelectedItem.Value;
        string filename;

        string[]       sheetnames;
        string[][]     titles, colsFormat;
        int[][]        colsWidth;
        IPBA           dobj    = new IPBA();
        CreateExcelRpt xlobj   = new CreateExcelRpt();
        DataSet        ds      = new DataSet(); ds.Clear();
        DataSet        dsFinal = new DataSet(); dsFinal.Clear();

        try
        {
            filename   = yrmo + "_IPBA_SUM_All";
            titles     = new string[ddlPlancd.Items.Count - 1][];
            sheetnames = new string[ddlPlancd.Items.Count - 1];
            colsFormat = new string[ddlPlancd.Items.Count - 1][];
            colsWidth  = new int[ddlPlancd.Items.Count - 1][];

            for (int i = 1; i < (ddlPlancd.Items.Count); i++)
            {
                plancode = ddlPlancd.Items[i].Value;

                if (plancode.Equals("P5"))
                {
                    plancode = "P5/P5";
                }

                if (plancode.Contains("P5"))
                {
                    titles[i - 1] = new string[] { "HTH Billing Summary Report: " + ddlPlancd.Items[i].Text, "Year-Month: " + yrmo }
                }
                ;
                else
                {
                    titles[i - 1] = new string[] { "Local HMO Billing Summary Report: " + ddlPlancd.Items[i].Text, "Year-Month: " + yrmo }
                };

                sheetnames[i - 1] = "Summary_" + plancode.Substring(0, 2);
                colsFormat[i - 1] = new string[] { "number", "string", "string", "number_comma", "currency", "currency" };
                colsWidth[i - 1]  = new int[] { 40, 110, 80, 35, 75, 75 };

                ds = dobj.GetSummaryRpt(yrmo, plancode);
                ds.Tables[0].TableName = "Table_" + plancode.Substring(0, 2);
                dsFinal.Tables.Add(ds.Tables[0].Copy());
                dsFinal.Tables[i - 1].TableName = "TableF_" + plancode.Substring(0, 2);
                ds.Clear();
            }

            xlobj.ExcelXMLRpt(dsFinal, filename, sheetnames, titles, colsFormat, colsWidth, String.Empty);
        }
        catch (Exception ex)
        {
            lbl_error.Text = "Error in generating HTH/HMO Billing Summary Report for YRMO - " + yrmo + "<br />" + ex.Message;
        }
    }
    protected void lnk_genDetRpt_OnClick(object sender, EventArgs e)
    {
        lbl_error.Text = "";
        string yrmo     = ddlYrmo.SelectedItem.Text;
        string plancode = ddlPlancd.SelectedItem.Value;
        string filename;

        string[]       sheetnames;
        string[][]     titles, colsFormat;
        int[][]        colsWidth;
        IPBA           dobj    = new IPBA();
        CreateExcelRpt xlobj   = new CreateExcelRpt();
        DataSet        dsFinal = new DataSet(); dsFinal.Clear();

        try
        {
            filename   = yrmo + "_IPBA_DET_" + plancode;
            titles     = new string[1][];
            sheetnames = new string[1];
            colsFormat = new string[1][];
            colsWidth  = new int[1][];

            if (plancode.Equals("P5"))
            {
                plancode = "P5/P5";
            }

            if (plancode.Contains("P5"))
            {
                titles[0] = new string[] { "HTH Billing Detail Report: " + ddlPlancd.SelectedItem.Text, "Year-Month: " + yrmo }
            }
            ;
            else
            {
                titles[0] = new string[] { "Local HMO Billing Detail Report: " + ddlPlancd.SelectedItem.Text, "Year-Month: " + yrmo }
            };

            sheetnames[0] = "Detail";
            colsFormat[0] = new string[] { "string", "string", "string", "string", "string", "string", "currency" };
            colsWidth[0]  = new int[] { 90, 35, 60, 125, 35, 55, 65 };

            dsFinal = dobj.GetDetailRpt(yrmo, plancode);
            xlobj.ExcelXMLRpt(dsFinal, filename, sheetnames, titles, colsFormat, colsWidth, String.Empty);
        }
        catch (Exception ex)
        {
            lbl_error.Text = "Error in generating HTH/HMO Billing Detail Report for YRMO - " + yrmo + "<br />" + ex.Message;
        }
    }
    private void SortGridView(string sortExpression, string direction, string source)
    {
        DataTable dt;
        DataView  dv;
        string    yrmo     = ddlYrmo.SelectedItem.Text;
        string    plancode = ddlPlancd.SelectedItem.Value;

        if (plancode.Equals("P5"))
        {
            plancode = "P5/P5";
        }
        IPBA dobj = new IPBA();

        switch (source)
        {
        case "Summary":
            dt                 = dobj.GetSummaryRpt(yrmo, plancode).Tables[0];
            dv                 = new DataView(dt);
            dv.Sort            = sortExpression + direction;
            grdvSum.DataSource = dv;
            grdvSum.DataBind();
            break;

        case "Detail":
            dt                 = dobj.GetDetailRpt(yrmo, plancode).Tables[0];
            dv                 = new DataView(dt);
            dv.Sort            = sortExpression + direction;
            grdvDet.DataSource = dv;
            grdvDet.DataBind();
            break;

        case "Adjustment":
            dt                 = dobj.GetAdjustmentRpt(yrmo, plancode).Tables[0];
            dv                 = new DataView(dt);
            dv.Sort            = sortExpression + direction;
            grdvAdj.DataSource = dv;
            grdvAdj.DataBind();
            break;

        case "HTH":
            dt                 = dobj.GetHTHAnthemRpt(yrmo, "P5").Tables[0];
            dv                 = new DataView(dt);
            dv.Sort            = sortExpression + direction;
            grdvHTH.DataSource = dv;
            grdvHTH.DataBind();
            break;
        }
    }
    protected void bindResult(string _src)
    {
        DataSet ds = new DataSet();

        ds.Clear();
        string yrmo     = ddlYrmo.SelectedItem.Text;
        string plancode = ddlPlancd.SelectedItem.Value;

        if (plancode.Equals("P5"))
        {
            plancode = "P5/P5";
        }
        IPBA dobj = new IPBA();

        switch (_src)
        {
        case "Summary":
            ds = dobj.GetSummaryRpt(yrmo, plancode);
            grdvSum.DataSource = ds;
            grdvSum.DataBind();
            ds.Clear();
            break;

        case "Detail":
            ds = dobj.GetDetailRpt(yrmo, plancode);
            grdvDet.DataSource = ds;
            grdvDet.DataBind();
            ds.Clear();
            break;

        case "Adjustment":
            ds = dobj.GetAdjustmentRpt(yrmo, plancode);
            grdvAdj.DataSource = ds;
            grdvAdj.DataBind();
            ds.Clear();
            break;

        case "HTH":
            ds = dobj.GetHTHAnthemRpt(yrmo, "P5");
            grdvHTH.DataSource = ds;
            grdvHTH.DataBind();
            ds.Clear();
            break;
        }
    }