using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Data.OracleClient;

public partial class POS_ClaimsPOS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadStatus();
            loadEvents();
            loadSamaClaimTypes();
            rdPOS_CheckedChanged(sender, e);
            loadSamaStatuses();
            //loadClaims(Helper.gridSize(), 1);
        }
        lblError.Text = "";
    }


    /// <summary>
    /// IJR
    /// 18-Feb-2012
    /// Load Sama claim types
    /// </summary>
    private void loadSamaClaimTypes()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "lookup_getter.GET_SAMA_CLAIM_TYPES";

        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlClaimType2.DataSource = ds;
        ddlClaimType2.DataBind();
        ddlClaimType2.Items.Insert(0, "------ All ------");
        oracon.Close();
    }

    private void loadStatus()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "poslookup_getter.get_claim_status";

        oracom.Parameters.Add("p_claim_id", OracleType.Cursor).Direction = ParameterDirection.Output;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlClaimType.DataSource = ds;
        ddlClaimType.DataBind();


        ddlClaimType.Items.Insert(0, "------ All ------");
        oracon.Close();
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddClaim.aspx?p=2");
    }

    protected void btnAdd1_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddMClaim1.aspx");
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        txtClaimID.Text = txtClaimID.Text.Trim();
        txtClientNo.Text = txtClientNo.Text.Trim();
        txtTermID.Text = txtTermID.Text.Trim();
        txtRetailerID.Text = txtRetailerID.Text.Trim();
        txtCardPOS.Text = txtCardPOS.Text.Trim();

        //IJR - 28-1-2012 , Add the original claim ID to search Criteria
        txtOrgClaimID.Text = txtOrgClaimID.Text.Trim();

        if (("".Equals(dtTranDateFrom.date.Trim()) && dtTranDateTo.date.Trim().Length > 3) || ("".Equals(dtTranDateTo.date.Trim()) && dtTranDateFrom.date.Trim().Length > 3))
        {
            lblError.Text = "Please Enter both (From and To) Date";
            return;
        }

        if (ddlClaimType.SelectedValue.ToString() == "301" && ddlSamaStatuses.SelectedValue.ToString() == "1")
        {
            loadClaims(Helper.gridSize(), 1);
        }
        else
            if (txtTermID.Text.Length == 0 && txtCardPOS.Text.Length == 0
                && txtClaimID.Text.Length == 0 // && dtClaimDate.date.Length == 0
                && txtOrgClaimID.Text.Length == 0 && (dtTranDateFrom.date.Length != 6 && dtTranDateTo.date.Length != 6))
                lblError.Text = "please enter at least one of the marked fields";
            else
                loadClaims(Helper.gridSize(), 1);
    }

    protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadClaims(Helper.gridSize(), int.Parse(ddlPages.SelectedValue));
    }

    private void loadClaims(int pageSize, int pageNumber)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "claim_process.get_atmposclaim_info";

        oracom.Parameters.Add("c_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_card_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_rrn", OracleType.VarChar).Direction = ParameterDirection.Input;

        //IRFAN_MOD SAIB_CR 170202 starts
       // oracom.Parameters.Add("c_tran_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_date_from", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_date_To", OracleType.VarChar).Direction = ParameterDirection.Input;
     //   oracom.Parameters.Add("p_claim_Date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_on_off_Us_Flag", OracleType.VarChar).Direction = ParameterDirection.Input;
        // Ends

        //
        oracom.Parameters.Add("c_product", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_client_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_retailer_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_term_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("c_claim_status", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        //oracom.Parameters.Add("p_onus", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_onus", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_mer_ch", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_getclaim_atmpos", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        //IJR - 28-1-2012 , Add the original claim ID to search Criteria
        oracom.Parameters.Add("p_org_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        //IJR - 28-1-2012 , Add the Event ID to search Criteria
        oracom.Parameters.Add("p_EventId", OracleType.VarChar).Direction = ParameterDirection.Input;
        //IJR - 30-1-2012 , edd claim action status to search Criteria
        oracom.Parameters.Add("p_claim_action_status", OracleType.VarChar).Direction = ParameterDirection.Input;

        //if (rdATM.Checked)
        //    oracom.Parameters["c_card_number"].Value = txtCardNumber.Text;
        //else
        //    oracom.Parameters["c_card_number"].Value = txtCardPOS.Text;




        oracom.Parameters["c_claim_id"].Value = txtClaimID.Text;
        oracom.Parameters["c_rrn"].Value = txtReference.Text;

        //IRFAN_MOD SAIB_CR 170202 starts
      //  oracom.Parameters["p_claim_date"].Value = dtClaimDate.date;
        oracom.Parameters["p_claim_date_from"].Value = dtTranDateFrom.date;
        oracom.Parameters["p_claim_date_To"].Value = dtTranDateTo.date;

        if (rdClaimOnUS.Checked == true)
            oracom.Parameters["p_on_off_Us_Flag"].Value = "on-us";
        else if (rdClaimOffUs.Checked == true)
            oracom.Parameters["p_on_off_Us_Flag"].Value = "off-us";
        else
            oracom.Parameters["p_on_off_Us_Flag"].Value = "";
        // ENDS
        oracom.Parameters["c_client_number"].Value = txtClientNo.Text;
        oracom.Parameters["c_retailer_id"].Value = txtRetailerID.Text;
        oracom.Parameters["c_term_id"].Value = txtTermID.Text;
        oracom.Parameters["p_atm_num"].Value = txtATMNo.Text;


        if (txtCardPOS.Text.Length > 0)
            oracom.Parameters["c_card_number"].Value = txtCardPOS.Text;
        else
            oracom.Parameters["c_card_number"].Value = OracleString.Null;


        //if (rdATM.Checked)
        //{
        //    oracom.Parameters["c_product"].Value = "1";

        //    oracom.Parameters["p_mer_ch"].Value = OracleNumber.Null;

        //    if (rdOnUs.Checked)
        //        oracom.Parameters["p_onus"].Value = "1";
        //    else
        //        oracom.Parameters["p_onus"].Value = "0";
        //}
        //else
        //{
        oracom.Parameters["c_product"].Value = "2";
        //oracom.Parameters["p_onus"].Value = OracleNumber.Null;

        if (rdCH.Checked)
            oracom.Parameters["p_mer_ch"].Value = "0";
        else
            oracom.Parameters["p_mer_ch"].Value = "1";

        //}

        if (ddlClaimType.SelectedIndex > 0)
            oracom.Parameters["c_claim_status"].Value = ddlClaimType.SelectedValue;
        else
            oracom.Parameters["c_claim_status"].Value = OracleString.Null;

        if (txtOrgClaimID.Text.Length > 0)
            oracom.Parameters["p_org_claim_id"].Value = txtOrgClaimID.Text;
        else
            oracom.Parameters["p_org_claim_id"].Value = OracleString.Null;
        // oracom.Parameters["p_org_claim_id"].Value = txtOrgClaimID.Text;
        //IJR - 28-1-2012 , Add the Event ID to search Criteria
        if (ddlEvents.SelectedIndex > 0)
            oracom.Parameters["p_EventId"].Value = ddlEvents.SelectedValue;
        else
            oracom.Parameters["p_EventId"].Value = OracleString.Null;

        ////IJR - 30-1-2012 , edd claim action status to search Criteria
        if (ddlSamaStatuses.Enabled == false)
            oracom.Parameters["p_claim_action_status"].Value = OracleString.Null;
        else
            if (ddlSamaStatuses.SelectedIndex > 0)
                oracom.Parameters["p_claim_action_status"].Value = ddlSamaStatuses.SelectedValue;
            else
                oracom.Parameters["p_claim_action_status"].Value = OracleString.Null;

        if (rdOnUs.Enabled)
            if (rdOnUs.Checked)
                oracom.Parameters["p_onus"].Value = "C";
            else
                oracom.Parameters["p_onus"].Value = "S";
        else
            oracom.Parameters["p_onus"].Value = "C";

        //Start --> 18-2-2012 IJR: Add new parameter to define the ATM Type (CW or DEP)
        // and add the sama from/to date and the sma claim type
        oracom.Parameters.Add("p_atmType", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters["p_atmType"].Value = OracleString.Null;

        oracom.Parameters.Add("p_sama_from_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_sama_to_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_sama_claim_type", OracleType.VarChar).Direction = ParameterDirection.Input;

        if (dtSamaFromDate.date.Length > 0)
            oracom.Parameters["p_sama_from_date"].Value = dtSamaFromDate.date;
        else
            oracom.Parameters["p_sama_from_date"].Value = OracleString.Null;

        if (dtSameToDate.date.Length > 0)
            oracom.Parameters["p_sama_to_date"].Value = dtSameToDate.date;
        else
            oracom.Parameters["p_sama_to_date"].Value = OracleString.Null;


        if (ddlClaimType2.SelectedIndex > 0)
            oracom.Parameters["p_sama_claim_type"].Value = ddlClaimType2.SelectedValue;
        else
            oracom.Parameters["p_sama_claim_type"].Value = OracleString.Null;

        //END --> 18-2-2012 IJR: Add new parameter to define the ATM Type (CW or DEP)
        // and add the sama from/to date and the sma claim type


        oracom.Parameters["p_page_size"].Value = pageSize;
        oracom.Parameters["p_page_num"].Value = pageNumber;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["c_current_uid"].Value = Session["uid"].ToString();

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
        oracon.Close();

        GridView1.DataSource = ds;
        GridView1.DataBind();

        if (pageNumber == 1)
        {
            ddlPages.Items.Clear();
            for (int i = 1; i <= nop; i++)
            {
                ddlPages.Items.Add(i.ToString());
            }
        }

        //if (pageNumber == 1)
        //{
        //    ddlPages.Items.Clear();
        //    for (int i = 1; i <= nop; i++)
        //    {
        //        ddlPages.Items.Add(i.ToString());
        //    }
        //}
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("i"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            //if (authenticateUser(rowID))
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                           "window.open('InvestigateClaim.aspx?clID=" + rowID + "','Redirect')", true);
           // Response.Redirect("InvestigateClaim.aspx?clID=" + rowID);
            //else
            //  lblError.Text = "You are not authorized to investigate this claim";
        }
        else if (e.CommandName.Equals("d"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            bool saved = Delete(rowID, ref error);
            if (saved)
            {
                lblError.Text = "Claim Inactivated Successful";
            }
            else
            {
                lblError.Text = error;
            }
        }
        else if (e.CommandName.Equals("r"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            bool saved = Reset(rowID, ref error);
            if (saved)
            {
                lblError.Text = "Claim Reset Successful";
            }
            else
            {
                lblError.Text = error;
            }
        }
        loadClaims(Helper.gridSize(), 1);
    }

    private bool Delete(string index, ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "claim_process.inactive_claim_info";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = index;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    private bool Reset(string index, ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "claim_process.resetclm_to_orgclmstatus";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = index;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    protected void rdATM_CheckedChanged(object sender, EventArgs e)
    {
        rowATM.Visible = true;
        rowATM2.Visible = true;
        rowPOS.Visible = false;
        rowPOS2.Visible = false;
        rowPOS3.Visible = false;
      //  btnAdd1.Visible = false;
    }

    protected void rdPOS_CheckedChanged(object sender, EventArgs e)
    {
        rowATM.Visible = false;
        rowATM2.Visible = false;
        rowPOS.Visible = true;
        rowPOS2.Visible = true;
        rowPOS3.Visible = true;
       // btnAdd1.Visible = true;
    }

    private bool authenticateUser(string claimID)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "CLAIM_SECURITY.get_auth_user_claim";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_user_id", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_out_auth_user", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = claimID;
        oracom.Parameters["p_user_id"].Value = Session["uid"].ToString();

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_out_auth_user"].Value.ToString();
        if (a == "1")
            return true;
        else
            return false;
    }

    /// <summary>
    /// IJR 
    /// 28-Jan-2012
    /// Add The load events functions to get the events related to POS (2)
    /// </summary>
    private void loadEvents()
    {
        ddlEvents.Items.Clear();
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.get_events";

        oracom.Parameters.Add("p_product", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_recon_events", OracleType.Cursor).Direction = ParameterDirection.Output;

        oracom.Parameters["p_product"].Value = 2;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlEvents.DataSource = ds;
        ddlEvents.DataBind();

        oracon.Close();
        ddlEvents.Items.Insert(0, "------ Events ------");
    }

    /// <summary>
    /// IJR
    /// 30-Jan-2012
    /// Load Sama Statuses
    /// </summary>
    private void loadSamaStatuses()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "poslookup_getter.get_claim_samastatus";

        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlSamaStatuses.DataSource = ds;
        ddlSamaStatuses.DataBind();


        ddlSamaStatuses.Items.Insert(0, "------ All ------");
        oracon.Close();
    }

    protected void ddlClaimType_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlClaimType.SelectedValue == "301")
        {
            ddlSamaStatuses.Enabled = true;
            rdOnUs.Enabled = true;
            rdOther.Enabled = true;
        }
        else
        {
            ddlSamaStatuses.Enabled = false;
            rdOnUs.Enabled = false;
            rdOther.Enabled = false;
        }
    }
    protected void btnGenReport_Click(object sender, EventArgs e)
    {
        txtClaimID.Text = txtClaimID.Text.Trim();
        txtClientNo.Text = txtClientNo.Text.Trim();
        txtTermID.Text = txtTermID.Text.Trim();
        txtRetailerID.Text = txtRetailerID.Text.Trim();
        txtCardPOS.Text = txtCardPOS.Text.Trim();
        txtOrgClaimID.Text = txtOrgClaimID.Text.Trim();

        if (ddlClaimType.SelectedValue.ToString() == "301" && ddlSamaStatuses.SelectedValue.ToString() == "1")
        {
            loadClaimsReport();
        }
        else
            if (txtTermID.Text.Length == 0 && txtCardPOS.Text.Length == 0
                && txtClaimID.Text.Length == 0// && dtClaimDate.date.Length == 0
                && txtOrgClaimID.Text.Length == 0)
                lblError.Text = "please enter at least one of the marked fields";
            else
                loadClaimsReport();
    }


    private void loadClaimsReport()
    {
        
        int p_page_size = 0;
        int p_page_num = 0;
        int p_mer_ch = 0;
        string c_current_uid = "";
        string c_product = "";
        string c_claim_id = "";
        string c_card_number = "";
        string c_rrn = "";
        string c_claim_date = "";
        string c_client_number = "";
        string c_retailer_id = "";
        string c_term_id = "";
        string c_claim_status = "";
        string p_atm_num = "";
        string p_onus = "";
        string p_lang = "";
        string p_atmType = "";
        string p_sama_from_date = "";
        string p_sama_to_date = "";
        string p_sama_claim_type = "";
        string p_org_claim_id = "";
        string p_EventId = "";
        string p_claim_action_status = "";

        c_claim_id = txtClaimID.Text;
        c_rrn = txtReference.Text;
       // c_claim_date = dtClaimDate.date;
        c_client_number = txtClientNo.Text;
        c_retailer_id = txtRetailerID.Text;
        c_term_id = txtTermID.Text;
        p_atm_num = txtATMNo.Text;
        if (txtCardPOS.Text.Length > 0)
            c_card_number = txtCardPOS.Text;
        else
            c_card_number = null;

        c_product = "2";

        if (rdCH.Checked)
            p_mer_ch = 0;
        else
            p_mer_ch = 1;

        if (ddlClaimType.SelectedIndex > 0)
            c_claim_status = ddlClaimType.SelectedValue;
        else
            c_claim_status = null;
        if (txtOrgClaimID.Text.Length > 0)
            p_org_claim_id = txtOrgClaimID.Text;
        else
            p_org_claim_id = null;
        if (ddlEvents.SelectedIndex > 0)
            p_EventId = ddlEvents.SelectedValue;
        else
            p_EventId = null;
        if (ddlSamaStatuses.Enabled == false)
            p_claim_action_status = null;
        else
            if (ddlSamaStatuses.SelectedIndex > 0)
                p_claim_action_status = ddlSamaStatuses.SelectedValue;
            else
                p_claim_action_status = null;
        if (rdOnUs.Enabled)
            if (rdOnUs.Checked)
                p_onus = "C";
            else
                p_onus = "S";
        else
            p_onus = "C";
        p_atmType = null;
        if (dtSamaFromDate.date.Length > 0)
            p_sama_from_date = dtSamaFromDate.date;
        else
            p_sama_from_date = null;
        if (dtSameToDate.date.Length > 0)
            p_sama_to_date = dtSameToDate.date;
        else
            p_sama_to_date = null;
        if (ddlClaimType2.SelectedIndex > 0)
            p_sama_claim_type = ddlClaimType2.SelectedValue;
        else
            p_sama_claim_type = null;
        p_page_size = 0;
        p_page_num = 0;
        p_lang = "EN";
        c_current_uid = Session["uid"].ToString();


        string UrlString = "rpt=507&c_current_uid=" + c_current_uid
                            + "&c_claim_id=" + c_claim_id
                            + "&c_card_number=" + c_card_number
                            + "&c_rrn=" + c_rrn
                            + "&c_claim_date=" + c_claim_date
                            + "&c_product=" + c_product
                            + "&c_client_number=" + c_client_number
                            + "&c_retailer_id=" + c_retailer_id
                            + "&c_term_id=" + c_term_id
                            + "&c_claim_status=" + c_claim_status
                            + "&p_atm_num=" + p_atm_num
                            + "&p_onus=" + p_onus
                            + "&p_mer_ch=" + p_mer_ch
                            + "&p_org_claim_id=" + p_org_claim_id
                            + "&p_EventId=" + p_EventId
                            + "&p_claim_action_status=" + p_claim_action_status
                            + "&p_atmType=" + p_atmType
                            + "&p_sama_from_date=" + p_sama_from_date
                            + "&p_sama_to_date=" + p_sama_to_date
                            + "&p_sama_claim_type=" + p_sama_claim_type
                            + "&p_page_size=" + p_page_size
                            + "&p_page_num=" + p_page_num
                            + "&p_lang=" + p_lang;

        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
            "window.open('../Reports/Default.aspx?" + UrlString + "','Report')", true);
    }
}
