DataTable dtOkrecords(string strPortFolio)
    {

        DataTable dtOkRecords;

        try
        {
            myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
            paramsMcm.Add(new myDH.InputParameter("recon_handle", Convert.ToString(GetFromSession("OkHandler"))));
            paramsMcm.Add(new myDH.InputParameter("portfolio", strPortFolio));
            paramsMcm.Add(new myDH.InputParameter("portfolio_nm", "NULL"));
            paramsMcm.Add(new myDH.InputParameter("status", "O"));            
            dtOkRecords = mcmDH.ExecuteStoredProcReturnDS("RCN_EXCEPTION_DETAILS_FI", ref paramsMcm).Tables[0];
            return dtOkRecords;
        }
        catch (Exception ex)
        {
            log.Error("Exception occured-BindGridExceptionSum():", ex);
            throw;
        }
        //return null;
    }
    DataTable dtOkrecords(string strPortFolio)
    {

        DataTable dtOkRecords;

        try
        {
            myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
            paramsMcm.Add(new myDH.InputParameter("recon_handle", Convert.ToString(GetFromSession("OkHandler"))));
            paramsMcm.Add(new myDH.InputParameter("portfolio", strPortFolio));
            paramsMcm.Add(new myDH.InputParameter("status", "O"));
            // paramsMcm.Add(new myDH.InputParameter("trade_list_id", intTradeListID));
            // paramsMcm.Add(new myDH.InputParameter("brkr", strBroker));
            dtOkRecords = mcmDH.ExecuteStoredProcReturnDS("FLSH_DTC_RCN_ECEPTION_DETAILS", ref paramsMcm).Tables[0];
            return dtOkRecords;
        }
        catch (Exception ex)
        {
            log.Error("Exception occured-BindGridExceptionSum():", ex);
            throw;
        }
        return null;
    }
    /// <summary>
    /// calling the stored proc-MCM_STAGE..RCN_EXCEPTION_DETAILS_FI
    /// retrieve the type of exceptions for the portfolio 
    /// Table used : MCM_STAGE..FLSH_DTC_DIFF_RPT
    /// Bind the exception with the Gridview-GridExceptionSum
    /// </summary>
    DataSet BindGridExceptionSum(string strPortFolio, string strPN)
    {

        DataSet dsException;

        try
        {
            myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
            paramsMcm.Add(new myDH.InputParameter("recon_handle", Convert.ToString(GetFromSession("ExHandler"))));
            paramsMcm.Add(new myDH.InputParameter("portfolio", strPortFolio));
            if(strPN !="")
                paramsMcm.Add(new myDH.InputParameter("portfolio_nm", strPN));
            else
                paramsMcm.Add(new myDH.InputParameter("portfolio_nm", "NULL"));
            paramsMcm.Add(new myDH.InputParameter("status", "E"));            
            dsException = mcmDH.ExecuteStoredProcReturnDS("RCN_EXCEPTION_DETAILS_FI", ref paramsMcm);
            return dsException;
        }
        catch (Exception ex)
        {
            log.Error("Exception occured-BindGridExceptionSum():", ex);
            throw;
        }
        //return null;
    }
 /// <summary>
 /// calling the stored procedure MCM_STAGE..FLSH_DTC_RCN_RPT_RESULT
 /// binding the data according to the page index changed in the Gridview-GridViewReconSum
 /// </summary>
 void BinddtExceptionReportSub(int intPageNo, string strHandlerKey)
 {
     DataTable dtExceptionSub = new DataTable();
     try
     {
         myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
         paramsMcm.Add(new myDH.InputParameter("recon_handle", strHandlerKey));//Convert.ToString(GetFromSession("Handler")
         paramsMcm.Add(new myDH.InputParameter("page_no", intPageNo));
         dtExceptionSub = mcmDH.ExecuteStoredProcReturnDS("FLSH_DTC_RCN_RPT_RESULT", ref paramsMcm).Tables[0];
         if (dtExceptionSub.Rows.Count > 0)
         {
             GridViewReconSum.VirtualItemCount = Convert.ToInt16(dtExceptionSub.Rows[0]["distinct_rows"]);
             GridViewReconSum.DataSource = dtExceptionSub;
             GridViewReconSum.CurrentPageIndex = intPageNo - 1;
             GridViewReconSum.DataBind();
         }
     }
     catch (Exception ex)
     {
         log.Info("Exception occured-dtExceptionReportSub():", ex);
         throw;
     }
 }
    /// <summary>
    /// calling the stored procedure MCM_STAGE..insert_Portia_mtf
    /// Returns the no of records inserted in the table MCM_STAGE..FLSH_DTC_PORTIA_MTF
    /// </summary>
    public string insertPortiaMTF(DataTable dt)
    {
        string strOut = string.Empty;
        int rowcount = 0;
        int rowfalse = 0;
        int paramDelete = 1;
        foreach (DataRow dr in dt.Rows)
        {
            myDH.ParameterCollection param = new myDH.ParameterCollection();
            param.Add(new myDH.InputParameter("paramDelete", paramDelete));
            param.Add(new myDH.InputParameter("recon_handle", dr["recon_handle"].ToString()));
            param.Add(new myDH.InputParameter("id", Convert.ToInt32(dr["id"])));
            param.Add(new myDH.InputParameter("tran_#", Convert.ToInt32(dr["tran_#"])));
            if (dr["trade_list_id"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("trade_list_id", Convert.ToInt32(dr["trade_list_id"])));
            //else
            //    param.Add(new InputParameter("trade_list_id", DBNull.Value));
            if (dr["portfolio_nm"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("portfolio_nm", dr["portfolio_nm"].ToString()));
            //else
            //    param.Add(new InputParameter("portfolio_nm", DBNull.Value));
            if (dr["portfolio"].ToString() != "")
                param.Add(new myDH.InputParameter("portfolio", dr["portfolio"].ToString()));
            //else
            //    param.Add(new InputParameter("portfolio", DBNull.Value));
            if (dr["security_nm"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("security_nm", dr["security_nm"].ToString()));
            //else
            //param.Add(new InputParameter("security_nm", DBNull.Value));
            if (dr["cusip"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("cusip", dr["cusip"].ToString()));
            //else
            //param.Add(new InputParameter("cusip", DBNull.Value));
            param.Add(new myDH.InputParameter("lot_#", Convert.ToInt32(dr["lot_#"])));
            param.Add(new myDH.InputParameter("tran_type_id", Convert.ToInt32(dr["tran_type_int"])));
            param.Add(new myDH.InputParameter("tran_type", dr["tran_type"].ToString()));
            param.Add(new myDH.InputParameter("trade_date", dr["trade_date"].ToString()));
            param.Add(new myDH.InputParameter("settle_date", dr["settle_date"].ToString()));
            param.Add(new myDH.InputParameter("broker", dr["broker"].ToString()));
            param.Add(new myDH.InputParameter("broker_number", dr["broker_number"].ToString()));
            param.Add(new myDH.InputParameter("quantity", Convert.ToDecimal(dr["quantity"])));
            param.Add(new myDH.InputParameter("price", Convert.ToDecimal(dr["price"])));
            param.Add(new myDH.InputParameter("commission", Convert.ToDecimal(dr["commission"])));
            param.Add(new myDH.InputParameter("sec_fee", Convert.ToDecimal(dr["sec_fee"])));
            param.Add(new myDH.InputParameter("total_amount", Convert.ToDecimal(dr["total_amount"])));
            param.Add(new myDH.InputParameter("entry_status", dr["entry_status"].ToString()));
            if (dr["raw_id"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("raw_id", Convert.ToInt32(dr["raw_id"])));
            //else
            //param.Add(new InputParameter("raw_id", DBNull.Value));
            if (dr["post_date"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("post_date", dr["post_date"].ToString()));
            //else
            //param.Add(new InputParameter("post_date", DBNull.Value));
            if (dr["settlement_country"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("settlement_country", dr["settlement_country"].ToString()));
            //else
            //param.Add(new InputParameter("settlement_country", DBNull.Value));
            if (dr["currency_id"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("currency_id", dr["currency_id"].ToString()));
            //else
            //param.Add(new InputParameter("currency_id", DBNull.Value));
            if (dr["price_symbol"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("price_symbol", dr["price_symbol"].ToString()));
            // else
            // param.Add(new InputParameter("price_symbol", DBNull.Value));
            if (dr["interest"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("interest", Convert.ToDecimal(dr["interest"])));
            //else
            //param.Add(new InputParameter("interest", DBNull.Value));
            if (dr["principal_amount"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("principal_amount", Convert.ToDecimal(dr["principal_amount"])));
            // else
            //param.Add(new InputParameter("principal_amount", DBNull.Value));
            if (dr["sec_type"].ToString().Trim() != "")
                param.Add(new myDH.InputParameter("sec_type", dr["sec_type"].ToString()));
            //else
            //param.Add(new InputParameter("sec_type", DBNull.Value));

            try
            {
                strOut = Convert.ToString(mcmDH.ExecuteStoredProcReturnScalar("dbo.insert_Portia_mtf", ref param));
                param = null;
            }

            catch (Exception ex)
            {
                param = null;
                strOut = "ERROR";
            }
            if (paramDelete == 1)
                paramDelete = 0;
            if (strOut == "0")
            {
                rowcount += 1;
            }
            else
            {
                rowfalse += 1;
            }

            param = null;
        }
        theDH.Dispose();
        log.Info("Not inserted-FLSH_DTC_PORTIA_MTF Rowcount:" + rowfalse.ToString());
        log.Info("Inserted-FLSH_DTC_PORTIA_MTF Rowcount:" + rowcount.ToString());
        return Convert.ToString(rowcount + "," + rowfalse);

    }
    /// <summary>
    /// calling the stored procedure PORTIA_APO..mcm_dtc_recon_New for Equity trades
    /// calling the stored procedure PORTIA_APO..mcm_dtc_recon_FI_New for FI trades
    /// Returns the datatable of inserted records from the table PORTIA_APO..mcm_dtc_flash_work
    /// </summary>
    private DataTable GetPortiamtfraw(string strHandler, string strTradeDate, string strTradeType, string strTypeVal)
    {
        DataTable dtPortia = new DataTable();
        try
        {
            myDH.ParameterCollection parms = new myDH.ParameterCollection();
            parms.Add(new myDH.InputParameter("recon_handle", strHandler));
            parms.Add(new myDH.InputParameter("trade_date", strTradeDate));
            parms.Add(new myDH.InputParameter("trade_Type", strTradeType));
            if (strTypeVal == "1")//Equity trades
                dtPortia = theDH.ExecuteStoredProcReturnDS("mcm_dtc_recon_New", ref parms).Tables[0];
            else//FI trades
            //dtPortia = theDH.ExecuteStoredProcReturnDS("mcm_dtc_recon_FI_New", ref parms).Tables[0];
            {

            }
            log.Info(":Retrieved From PORTIA_APO..mcm_dtc_flash_work:" + Convert.ToString(dtPortia.Rows.Count));
            return dtPortia;
        }
        catch (Exception ex)
        {
            log.Info("Exception occured GetPortiamtfraw()", ex);
            throw;

        }
        //return dtPortia;
    }
    //#region UserDefined Function
    ///// <summary>
    ///// calling the stored proc-MCM_STAGE..FLSH_DTC_RCN_ECEPTION_RESULT
    ///// retrieve the type of exceptions for the portfolio 
    ///// Table used : MCM_STAGE..FLSH_DTC_DIFF_RPT
    ///// Bind the exception with the Gridview-GridExceptionSum
    ///// </summary>
    //DataSet BindGridExceptionSum(string strPortFolio)
    //{

    //    DataSet dsException;

    //    try
    //    {
    //        myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
    //        paramsMcm.Add(new myDH.InputParameter("recon_handle", Convert.ToString(GetFromSession("ExHandler"))));
    //        paramsMcm.Add(new myDH.InputParameter("portfolio", strPortFolio));
    //        paramsMcm.Add(new myDH.InputParameter("status", "E"));           
    //       // paramsMcm.Add(new myDH.InputParameter("trade_list_id", intTradeListID));
    //       // paramsMcm.Add(new myDH.InputParameter("brkr", strBroker));
    //        dsException = mcmDH.ExecuteStoredProcReturnDS("FLSH_DTC_RCN_ECEPTION_DETAILS", ref paramsMcm);
    //        return dsException;
    //    }
    //    catch (Exception ex)
    //    {
    //        log.Error("Exception occured-BindGridExceptionSum():", ex);
    //        throw;
    //    }
    //    return null;
    //}

    #region UserDefined Function
    /// <summary> By Ruchi
    /// calling the stored proc-MCM_STAGE..FLSH_DTC_RCN_ECEPTION_RESULT
    /// retrieve the type of exceptions for the portfolio 
    /// Table used : MCM_STAGE..FLSH_DTC_DIFF_RPT
    /// Bind the exception with the Gridview-GridExceptionSum
    /// </summary>
    DataSet BindGridExceptionSum(string strPortFolio, DateTime dtSettleDate)
    {

        DataSet dsException;

        try
        {
            myDH.ParameterCollection paramsMcm = new myDH.ParameterCollection();
            paramsMcm.Add(new myDH.InputParameter("recon_handle", Convert.ToString(GetFromSession("ExHandler"))));
            paramsMcm.Add(new myDH.InputParameter("portfolio", strPortFolio));
            paramsMcm.Add(new myDH.InputParameter("status", "E"));
            //Added by Ruchi
            paramsMcm.Add(new myDH.InputParameter("settle_date", dtSettleDate));
            // paramsMcm.Add(new myDH.InputParameter("trade_list_id", intTradeListID));
            // paramsMcm.Add(new myDH.InputParameter("brkr", strBroker));
            dsException = mcmDH.ExecuteStoredProcReturnDS("FLSH_DTC_RCN_ECEPTION_DETAILS", ref paramsMcm);
            return dsException;
        }
        catch (Exception ex)
        {
            log.Error("Exception occured-BindGridExceptionSum():", ex);
            throw;
        }
        return null;
    }