public IEnumerable <Revenue> GetRunDate()
        {
            //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
            var connectionString = MPRContext.GetDataConnection();

            var revenues = new List <Revenue>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_mpr_getDistinctrevenueRundate", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;


                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var revenue = new Revenue();

                    if (reader["RunDate"] != DBNull.Value)
                    {
                        revenue.RunDate = DateTime.Parse(reader["RunDate"].ToString());
                    }

                    revenues.Add(revenue);
                }

                con.Close();
            }

            return(revenues);
        }
        public List <PLIncomeReportAdjustment> GetCodebyUser(string username)
        {
            var connectionString = MPRContext.GetDataConnection();

            var mprbalancesheetadjustments = new List <PLIncomeReportAdjustment>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_getplcurrentuser", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "username",
                    Value         = username,
                });


                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var mprbalancesheetadjustment = new PLIncomeReportAdjustment();

                    if (reader["Code"] != DBNull.Value)
                    {
                        mprbalancesheetadjustment.Code = reader["Code"].ToString();
                    }

                    mprbalancesheetadjustments.Add(mprbalancesheetadjustment);
                }

                con.Close();
            }

            return(mprbalancesheetadjustments);
        }
        public List <PLIncomeReportAdjustment> GetPLIncomeReportAdjustmentBySearch(string searchType, string searchValue, int number)
        {
            var connectionString = MPRContext.GetDataConnection();

            var plIncomeAdjs = new List <PLIncomeReportAdjustment>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_mpr_pl_income_report_adjustment", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchType",
                    Value         = searchType,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchValue",
                    Value         = searchValue,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "Number",
                    Value         = number,
                });

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var plIncomeAdj = new PLIncomeReportAdjustment();

                    if (reader["id"] != DBNull.Value)
                    {
                        plIncomeAdj.Id = int.Parse(reader["id"].ToString());
                    }

                    if (reader["GLCode"] != DBNull.Value)
                    {
                        plIncomeAdj.GLCode = reader["GLCode"].ToString();
                    }

                    if (reader["Narrative"] != DBNull.Value)
                    {
                        plIncomeAdj.Narrative = reader["Narrative"].ToString();
                    }

                    if (reader["TeamCode"] != DBNull.Value)
                    {
                        plIncomeAdj.TeamCode = reader["TeamCode"].ToString();
                    }

                    if (reader["AccountOfficerCode"] != DBNull.Value)
                    {
                        plIncomeAdj.AccountOfficerCode = reader["AccountOfficerCode"].ToString();
                    }

                    if (reader["Caption"] != DBNull.Value)
                    {
                        plIncomeAdj.Caption = reader["Caption"].ToString();
                    }

                    if (reader["BranchCode"] != DBNull.Value)
                    {
                        plIncomeAdj.BranchCode = reader["BranchCode"].ToString();
                    }

                    if (reader["RelatedAccount"] != DBNull.Value)
                    {
                        plIncomeAdj.RelatedAccount = reader["RelatedAccount"].ToString();
                    }

                    if (reader["Amount"] != DBNull.Value)
                    {
                        plIncomeAdj.Amount = decimal.Parse(reader["Amount"].ToString());
                    }

                    if (reader["CompanyCode"] != DBNull.Value)
                    {
                        plIncomeAdj.CompanyCode = reader["CompanyCode"].ToString();
                    }

                    if (reader["RunDate"] != DBNull.Value)
                    {
                        plIncomeAdj.RunDate = DateTime.Parse(reader["RunDate"].ToString());
                    }

                    plIncomeAdjs.Add(plIncomeAdj);
                }

                con.Close();
            }

            return(plIncomeAdjs);
        }
Пример #4
0
        public List <BalanceSheetBudgetOfficer> GetBalanceSheetBySearch(string searchValue)
        {
            //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
            var connectionString = MPRContext.GetDataConnection();

            var balSheets = new List <BalanceSheetBudgetOfficer>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_mpr_balancesheetbudgetOfficer", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchValue",
                    Value         = searchValue,
                });

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var balSheet = new BalanceSheetBudgetOfficer();

                    if (reader["BalancesheetBudgetOffId"] != DBNull.Value)
                    {
                        balSheet.BudgetId = int.Parse(reader["BalancesheetBudgetOffId"].ToString());
                    }

                    if (reader["CompanyCode"] != DBNull.Value)
                    {
                        balSheet.CompanyCode = reader["CompanyCode"].ToString();
                    }

                    if (reader["AccountOfficerCode"] != DBNull.Value)
                    {
                        balSheet.MisCode = reader["AccountOfficerCode"].ToString();
                    }

                    if (reader["Year"] != DBNull.Value)
                    {
                        balSheet.Year = reader["Year"].ToString();
                    }

                    if (reader["CaptionName"] != DBNull.Value)
                    {
                        balSheet.CaptionName = reader["CaptionName"].ToString();
                    }

                    if (reader["Mth1"] != DBNull.Value)
                    {
                        balSheet.Mth1 = decimal.Parse(reader["Mth1"].ToString());
                    }

                    if (reader["Mth2"] != DBNull.Value)
                    {
                        balSheet.Mth2 = decimal.Parse(reader["Mth2"].ToString());
                    }

                    if (reader["Mth3"] != DBNull.Value)
                    {
                        balSheet.Mth3 = decimal.Parse(reader["Mth3"].ToString());
                    }

                    if (reader["Mth4"] != DBNull.Value)
                    {
                        balSheet.Mth4 = decimal.Parse(reader["Mth4"].ToString());
                    }

                    if (reader["Mth5"] != DBNull.Value)
                    {
                        balSheet.Mth5 = decimal.Parse(reader["Mth5"].ToString());
                    }

                    if (reader["Mth6"] != DBNull.Value)
                    {
                        balSheet.Mth6 = decimal.Parse(reader["Mth6"].ToString());
                    }

                    if (reader["Mth7"] != DBNull.Value)
                    {
                        balSheet.Mth7 = decimal.Parse(reader["Mth7"].ToString());
                    }

                    if (reader["Mth8"] != DBNull.Value)
                    {
                        balSheet.Mth8 = decimal.Parse(reader["Mth8"].ToString());
                    }

                    if (reader["Mth9"] != DBNull.Value)
                    {
                        balSheet.Mth9 = decimal.Parse(reader["Mth9"].ToString());
                    }

                    if (reader["Mth10"] != DBNull.Value)
                    {
                        balSheet.Mth10 = decimal.Parse(reader["Mth10"].ToString());
                    }

                    if (reader["Mth11"] != DBNull.Value)
                    {
                        balSheet.Mth11 = decimal.Parse(reader["Mth11"].ToString());
                    }

                    if (reader["Mth12"] != DBNull.Value)
                    {
                        balSheet.Mth12 = decimal.Parse(reader["Mth12"].ToString());
                    }

                    balSheets.Add(balSheet);
                }

                con.Close();
            }

            return(balSheets);
        }
        public List <Revenue> GetAllRevenueBySearch(string searchType, string searchValue, int number, DateTime fromDate, DateTime toDate)
        {
            //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
            var connectionString = MPRContext.GetDataConnection();

            var revenues = new List <Revenue>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_mpr_revenueAll", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchType",
                    Value         = searchType,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchValue",
                    Value         = searchValue,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "Number",
                    Value         = number,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "FromDate",
                    Value         = fromDate,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "ToDate",
                    Value         = toDate,
                });

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var revenue = new Revenue();

                    if (reader["RevenueId"] != DBNull.Value)
                    {
                        revenue.RevenueId = int.Parse(reader["RevenueId"].ToString());
                    }

                    if (reader["TransId"] != DBNull.Value)
                    {
                        revenue.TransId = reader["TransId"].ToString();
                    }

                    if (reader["TransDate"] != DBNull.Value)
                    {
                        revenue.TransDate = DateTime.Parse(reader["TransDate"].ToString());
                    }

                    if (reader["GLCode"] != DBNull.Value)
                    {
                        revenue.GLCode = reader["GLCode"].ToString();
                    }

                    if (reader["Narrative"] != DBNull.Value)
                    {
                        revenue.Narrative = reader["Narrative"].ToString();
                    }

                    if (reader["TeamCode"] != DBNull.Value)
                    {
                        revenue.TeamCode = reader["TeamCode"].ToString();
                    }

                    if (reader["AccountOfficerCode"] != DBNull.Value)
                    {
                        revenue.AccountOfficerCode = reader["AccountOfficerCode"].ToString();
                    }

                    if (reader["Caption"] != DBNull.Value)
                    {
                        revenue.Caption = reader["Caption"].ToString();
                    }

                    if (reader["BranchCode"] != DBNull.Value)
                    {
                        revenue.BranchCode = reader["BranchCode"].ToString();
                    }

                    if (reader["RelatedAccount"] != DBNull.Value)
                    {
                        revenue.RelatedAccount = reader["RelatedAccount"].ToString();
                    }

                    if (reader["Amount_LCY"] != DBNull.Value)
                    {
                        revenue.Amount_LCY = decimal.Parse(reader["Amount_LCY"].ToString());
                    }

                    if (reader["AccountTitle"] != DBNull.Value)
                    {
                        revenue.AccountTitle = reader["AccountTitle"].ToString();
                    }

                    if (reader["Indicator"] != DBNull.Value)
                    {
                        revenue.Indicator = reader["Indicator"].ToString();
                    }

                    if (reader["CompanyCode"] != DBNull.Value)
                    {
                        revenue.CompanyCode = reader["CompanyCode"].ToString();
                    }

                    if (reader["RunDate"] != DBNull.Value)
                    {
                        revenue.RunDate = DateTime.Parse(reader["RunDate"].ToString());
                    }

                    revenues.Add(revenue);
                }

                con.Close();
            }

            return(revenues);
        }
        public List <MPRBalanceSheetAdjustment> GetBalanceSheetAdjustmentByCode(string code, string userName)
        {
            var connectionString = MPRContext.GetDataConnection();

            var balSheetAdjs = new List <MPRBalanceSheetAdjustment>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_getmprbalancesheetadjustmentbyCode", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "code",
                    Value         = code,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "username",
                    Value         = userName,
                });


                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var balSheetAdj = new MPRBalanceSheetAdjustment();

                    if (reader["BalancesheetAdjustmentId"] != DBNull.Value)
                    {
                        balSheetAdj.BalancesheetAdjustmentId = int.Parse(reader["BalancesheetAdjustmentId"].ToString());
                    }

                    if (reader["AccountNo"] != DBNull.Value)
                    {
                        balSheetAdj.AccountNo = reader["AccountNo"].ToString();
                    }

                    if (reader["AccountName"] != DBNull.Value)
                    {
                        balSheetAdj.AccountName = reader["AccountName"].ToString();
                    }

                    if (reader["TeamCode"] != DBNull.Value)
                    {
                        balSheetAdj.TeamCode = reader["TeamCode"].ToString();
                    }

                    if (reader["AccountOfficerCode"] != DBNull.Value)
                    {
                        balSheetAdj.AccountOfficerCode = reader["AccountOfficerCode"].ToString();
                    }

                    if (reader["ProductCode"] != DBNull.Value)
                    {
                        balSheetAdj.ProductCode = reader["ProductCode"].ToString();
                    }

                    if (reader["Category"] != DBNull.Value)
                    {
                        balSheetAdj.Category = reader["Category"].ToString();
                    }

                    if (reader["CurrencyType"] != DBNull.Value)
                    {
                        balSheetAdj.CurrencyType = reader["CurrencyType"].ToString();
                    }

                    if (reader["ActualBal"] != DBNull.Value)
                    {
                        balSheetAdj.ActualBal = double.Parse(reader["ActualBal"].ToString());
                    }

                    if (reader["AverageBal"] != DBNull.Value)
                    {
                        balSheetAdj.AverageBal = double.Parse(reader["AverageBal"].ToString());
                    }

                    if (reader["Interest"] != DBNull.Value)
                    {
                        balSheetAdj.Interest = decimal.Parse(reader["Interest"].ToString());
                    }

                    if (reader["CompanyCode"] != DBNull.Value)
                    {
                        balSheetAdj.CompanyCode = reader["CompanyCode"].ToString();
                    }

                    if (reader["Code"] != DBNull.Value)
                    {
                        balSheetAdj.Code = reader["Code"].ToString();
                    }

                    if (reader["RunDate"] != DBNull.Value)
                    {
                        balSheetAdj.Rundate = DateTime.Parse(reader["RunDate"].ToString());
                    }

                    balSheetAdjs.Add(balSheetAdj);
                }

                con.Close();
            }

            return(balSheetAdjs);
        }
Пример #7
0
        //public List<MPRBalanceSheet> GetBalanceSheetBySearch(string searchType, string searchValue, int number)
        //{
        //   string clientcode = ConfigurationManager.AppSettings["ClientCode"].ToString();
        //    if (clientcode == "CMB")
        //        return GetBalanceSheetBySearch_A(searchType, searchValue, number);
        //    else
        //      return  GetBalanceSheetBySearch_B(searchType, searchValue, number);
        //}

        //public List<MPRBalanceSheet> GetBalanceSheetBySearch_A(string searchType, string searchValue, int number)
        //{
        //    //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
        //    var connectionString = MPRContext.GetDataConnection();

        //    var balSheets = new List<MPRBalanceSheet>();
        //    using (var con = new SqlConnection(connectionString))
        //    {
        //        var cmd = new SqlCommand("spp_mpr_balancesheet", con);
        //        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        //        cmd.CommandTimeout = 0;
        //        cmd.Parameters.Add(new SqlParameter
        //        {
        //            ParameterName = "SearchType",
        //            Value = searchType,
        //        });

        //        cmd.Parameters.Add(new SqlParameter
        //        {
        //            ParameterName = "SearchValue",
        //            Value = searchValue,
        //        });

        //        cmd.Parameters.Add(new SqlParameter
        //        {
        //            ParameterName = "Number",
        //            Value = number,
        //        });

        //        con.Open();

        //        SqlDataReader reader = cmd.ExecuteReader();

        //        while (reader.Read())
        //        {
        //            var balSheet = new MPRBalanceSheet();

        //            if (reader["BalancesheetId"] != DBNull.Value)
        //                balSheet.BalanceSheetId = int.Parse(reader["BalancesheetId"].ToString());

        //            if (reader["AccountNo"] != DBNull.Value)
        //                balSheet.AccountNo = reader["AccountNo"].ToString();

        //            if (reader["AccountName"] != DBNull.Value)
        //                balSheet.AccountName = reader["AccountName"].ToString();

        //            if (reader["TeamCode"] != DBNull.Value)
        //                balSheet.TeamCode = reader["TeamCode"].ToString();

        //            if (reader["AccountOfficerCode"] != DBNull.Value)
        //                balSheet.AccountOfficerCode = reader["AccountOfficerCode"].ToString();

        //            if (reader["CaptionName"] != DBNull.Value)
        //                balSheet.CaptionName = reader["CaptionName"].ToString();

        //            if (reader["BranchCode"] != DBNull.Value)
        //                balSheet.BranchCode = reader["BranchCode"].ToString();

        //            if (reader["ProductCode"] != DBNull.Value)
        //                balSheet.ProductCode = reader["ProductCode"].ToString();

        //            if (reader["Category"] != DBNull.Value)
        //                balSheet.Category = reader["Category"].ToString();

        //            if (reader["CurrencyType"] != DBNull.Value)
        //                balSheet.CurrencyType = reader["CurrencyType"].ToString();

        //            if (reader["Currency"] != DBNull.Value)
        //                balSheet.Currency = reader["Currency"].ToString();

        //            if (reader["ActualBal"] != DBNull.Value)
        //                balSheet.ActualBal = double.Parse(reader["ActualBal"].ToString());

        //            if (reader["AverageBal"] != DBNull.Value)
        //                balSheet.AverageBal = double.Parse(reader["AverageBal"].ToString());

        //            if (reader["Interest"] != DBNull.Value)
        //                balSheet.Interest = double.Parse(reader["Interest"].ToString());

        //            if (reader["EffIntRate"] != DBNull.Value)
        //                //balSheet.EffIntRate = double.Parse(reader["EffIntRate"].ToString());
        //                balSheet.EffIntRate = double.Parse(reader["EffIntRate"].ToString());

        //            if (reader["Pool"] != DBNull.Value)
        //                balSheet.Pool = double.Parse(reader["Pool"].ToString());

        //            if (reader["PoolRate"] != DBNull.Value)
        //                balSheet.PoolRate = double.Parse(reader["PoolRate"].ToString());

        //            if (reader["ContractRate"] != DBNull.Value)
        //                balSheet.ContractRate = double.Parse(reader["ContractRate"].ToString());

        //            if (reader["VolumeGL"] != DBNull.Value)
        //                balSheet.VolumeGL = reader["VolumeGL"].ToString();

        //            if (reader["InterestGL"] != DBNull.Value)
        //                balSheet.InterestGL = reader["InterestGL"].ToString();

        //            if (reader["EntryStatus"] != DBNull.Value)
        //                balSheet.EntryStatus = reader["EntryStatus"].ToString();

        //            if (reader["MaxRate"] != DBNull.Value)
        //                balSheet.MaxRate = double.Parse(reader["MaxRate"].ToString());

        //            if (reader["PenalCharge"] != DBNull.Value)
        //                balSheet.PenalCharge = decimal.Parse(reader["PenalCharge"].ToString());

        //            if (reader["PenalRate"] != DBNull.Value)
        //                balSheet.PenalRate = double.Parse(reader["PenalRate"].ToString());

        //            if (reader["AcctStatus"] != DBNull.Value)
        //                balSheet.AcctStatus = reader["AcctStatus"].ToString();

        //            if (reader["CreditRating"] != DBNull.Value)
        //                balSheet.CreditRating = reader["CreditRating"].ToString();

        //            if (reader["CompanyCode"] != DBNull.Value)
        //                balSheet.CompanyCode = reader["CompanyCode"].ToString();

        //            if (reader["RunDate"] != DBNull.Value)
        //                balSheet.Rundate = DateTime.Parse(reader["RunDate"].ToString());

        //            balSheets.Add(balSheet);
        //        }

        //        con.Close();
        //    }
        //    return balSheets;
        //}


        //public List<MPRBalanceSheet> GetBalanceSheetBySearch_B(string searchType, string searchValue, int number)
        //    {
        //        //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
        //        var connectionString = MPRContext.GetDataConnection();

        //        var balSheets = new List<MPRBalanceSheet>();
        //        using (var con = new SqlConnection(connectionString))
        //        {
        //            var cmd = new SqlCommand("spp_mpr_balancesheet", con);
        //            cmd.CommandType = System.Data.CommandType.StoredProcedure;
        //            cmd.CommandTimeout = 0;
        //            cmd.Parameters.Add(new SqlParameter
        //            {
        //                ParameterName = "SearchType",
        //                Value = searchType,
        //            });

        //            cmd.Parameters.Add(new SqlParameter
        //            {
        //                ParameterName = "SearchValue",
        //                Value = searchValue,
        //            });

        //            cmd.Parameters.Add(new SqlParameter
        //            {
        //                ParameterName = "Number",
        //                Value = number,
        //            });

        //            con.Open();

        //            SqlDataReader reader = cmd.ExecuteReader();

        //            while (reader.Read())
        //            {
        //            var balSheet = new MPRBalanceSheet();

        //            if (reader["BalancesheetId"] != DBNull.Value)
        //                balSheet.BalanceSheetId = int.Parse(reader["BalancesheetId"].ToString());

        //            if (reader["AccountNo"] != DBNull.Value)
        //                balSheet.AccountNo = reader["AccountNo"].ToString();

        //            if (reader["AccountName"] != DBNull.Value)
        //                balSheet.AccountName = reader["AccountName"].ToString();

        //            if (reader["TeamCode"] != DBNull.Value)
        //                balSheet.TeamCode = reader["TeamCode"].ToString();

        //            if (reader["AccountOfficerCode"] != DBNull.Value)
        //                balSheet.AccountOfficerCode = reader["AccountOfficerCode"].ToString();

        //            if (reader["CaptionName"] != DBNull.Value)
        //                balSheet.CaptionName = reader["CaptionName"].ToString();

        //            if (reader["BranchCode"] != DBNull.Value)
        //                balSheet.BranchCode = reader["BranchCode"].ToString();

        //            if (reader["ProductCode"] != DBNull.Value)
        //                balSheet.ProductCode = reader["ProductCode"].ToString();

        //            if (reader["Category"] != DBNull.Value)
        //                balSheet.Category = reader["Category"].ToString();

        //            if (reader["CurrencyType"] != DBNull.Value)
        //                balSheet.CurrencyType = reader["CurrencyType"].ToString();

        //            if (reader["Currency"] != DBNull.Value)
        //                balSheet.Currency = reader["Currency"].ToString();

        //            if (reader["ActualBal"] != DBNull.Value)
        //                balSheet.ActualBal = double.Parse(reader["ActualBal"].ToString());

        //            if (reader["AverageBal"] != DBNull.Value)
        //                balSheet.AverageBal = double.Parse(reader["AverageBal"].ToString());

        //            if (reader["Interest"] != DBNull.Value)
        //                balSheet.Interest = double.Parse(reader["Interest"].ToString());

        //            if (reader["EffIntRate"] != DBNull.Value)
        //                balSheet.EffIntRate = double.Parse(reader["EffIntRate"].ToString());

        //            if (reader["Pool"] != DBNull.Value)
        //                balSheet.Pool = double.Parse(reader["Pool"].ToString());

        //            if (reader["PoolRate"] != DBNull.Value)
        //                balSheet.PoolRate = double.Parse(reader["PoolRate"].ToString());

        //            if (reader["ContractRate"] != DBNull.Value)
        //                balSheet.ContractRate = double.Parse(reader["ContractRate"].ToString());

        //            if (reader["VolumeGL"] != DBNull.Value)
        //                balSheet.VolumeGL = reader["VolumeGL"].ToString();

        //            if (reader["InterestGL"] != DBNull.Value)
        //                balSheet.InterestGL = reader["InterestGL"].ToString();

        //            if (reader["EntryStatus"] != DBNull.Value)
        //                balSheet.EntryStatus = reader["EntryStatus"].ToString();

        //            if (reader["MaxRate"] != DBNull.Value)
        //                balSheet.MaxRate = double.Parse(reader["MaxRate"].ToString());

        //            if (reader["PenalCharge"] != DBNull.Value)
        //                balSheet.PenalCharge = decimal.Parse(reader["PenalCharge"].ToString());

        //            if (reader["PenalRate"] != DBNull.Value)
        //                balSheet.PenalRate = double.Parse(reader["PenalRate"].ToString());

        //            if (reader["AcctStatus"] != DBNull.Value)
        //                balSheet.AcctStatus = reader["AcctStatus"].ToString();

        //            if (reader["CreditRating"] != DBNull.Value)
        //                balSheet.CreditRating = reader["CreditRating"].ToString();

        //            if (reader["CompanyCode"] != DBNull.Value)
        //                balSheet.CompanyCode = reader["CompanyCode"].ToString();

        //            if (reader["RunDate"] != DBNull.Value)
        //                balSheet.Rundate = DateTime.Parse(reader["RunDate"].ToString());

        //            balSheets.Add(balSheet);
        //        }

        //        con.Close();
        //        }
        //        return balSheets;
        //    }


        public List <MPRBalanceSheet> GetBalanceSheetBySearch(string searchType, string searchValue, int number)
        {
            //var connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
            var connectionString = MPRContext.GetDataConnection();

            var balSheets = new List <MPRBalanceSheet>();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("spp_mpr_balancesheet", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchType",
                    Value         = searchType,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "SearchValue",
                    Value         = searchValue,
                });

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "Number",
                    Value         = number,
                });

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var balSheet = new MPRBalanceSheet();

                    if (reader["BalancesheetId"] != DBNull.Value)
                    {
                        balSheet.BalanceSheetId = int.Parse(reader["BalancesheetId"].ToString());
                    }

                    if (reader["AccountNo"] != DBNull.Value)
                    {
                        balSheet.AccountNo = reader["AccountNo"].ToString();
                    }

                    if (reader["AccountName"] != DBNull.Value)
                    {
                        balSheet.AccountName = reader["AccountName"].ToString();
                    }

                    if (reader["TeamCode"] != DBNull.Value)
                    {
                        balSheet.TeamCode = reader["TeamCode"].ToString();
                    }

                    if (reader["AccountOfficerCode"] != DBNull.Value)
                    {
                        balSheet.AccountOfficerCode = reader["AccountOfficerCode"].ToString();
                    }

                    if (reader["CaptionName"] != DBNull.Value)
                    {
                        balSheet.CaptionName = reader["CaptionName"].ToString();
                    }

                    if (reader["BranchCode"] != DBNull.Value)
                    {
                        balSheet.BranchCode = reader["BranchCode"].ToString();
                    }

                    if (reader["ProductCode"] != DBNull.Value)
                    {
                        balSheet.ProductCode = reader["ProductCode"].ToString();
                    }

                    if (reader["Category"] != DBNull.Value)
                    {
                        balSheet.Category = reader["Category"].ToString();
                    }

                    if (reader["CurrencyType"] != DBNull.Value)
                    {
                        balSheet.CurrencyType = reader["CurrencyType"].ToString();
                    }

                    if (reader["Currency"] != DBNull.Value)
                    {
                        balSheet.Currency = reader["Currency"].ToString();
                    }

                    if (reader["ActualBal"] != DBNull.Value)
                    {
                        //balSheet.ActualBal = decimal.Parse(reader["ActualBal"].ToString
                        balSheet.ActualBal = double.Parse(reader["ActualBal"].ToString());
                    }

                    if (reader["AverageBal"] != DBNull.Value)
                    {
                        //balSheet.AverageBal = decimal.Parse(reader["AverageBal"].ToString());
                        balSheet.AverageBal = double.Parse(reader["AverageBal"].ToString());
                    }

                    if (reader["Interest"] != DBNull.Value)
                    {
                        //balSheet.Interest = decimal.Parse(reader["Interest"].ToString());
                        balSheet.Interest = double.Parse(reader["Interest"].ToString());
                    }

                    if (reader["EffIntRate"] != DBNull.Value)
                    {
                        //balSheet.EffIntRate = decimal.Parse(reader["EffIntRate"].ToString());
                        balSheet.EffIntRate = double.Parse(reader["EffIntRate"].ToString());
                    }


                    if (reader["Pool"] != DBNull.Value)
                    {
                        //balSheet.Pool = decimal.Parse(reader["Pool"].ToString());
                        balSheet.Pool = double.Parse(reader["Pool"].ToString());
                    }

                    if (reader["PoolRate"] != DBNull.Value)
                    {
                        balSheet.PoolRate = double.Parse(reader["PoolRate"].ToString());
                    }

                    if (reader["ContractRate"] != DBNull.Value)
                    {
                        balSheet.ContractRate = double.Parse(reader["ContractRate"].ToString());
                    }

                    if (reader["VolumeGL"] != DBNull.Value)
                    {
                        balSheet.VolumeGL = reader["VolumeGL"].ToString();
                    }

                    if (reader["InterestGL"] != DBNull.Value)
                    {
                        balSheet.InterestGL = reader["InterestGL"].ToString();
                    }

                    if (reader["EntryStatus"] != DBNull.Value)
                    {
                        balSheet.EntryStatus = reader["EntryStatus"].ToString();
                    }

                    if (reader["MaxRate"] != DBNull.Value)
                    {
                        balSheet.MaxRate = double.Parse(reader["MaxRate"].ToString());
                    }

                    if (reader["PenalCharge"] != DBNull.Value)
                    {
                        balSheet.PenalCharge = decimal.Parse(reader["PenalCharge"].ToString());
                    }

                    if (reader["PenalRate"] != DBNull.Value)
                    {
                        balSheet.PenalRate = double.Parse(reader["PenalRate"].ToString());
                    }

                    if (reader["AcctStatus"] != DBNull.Value)
                    {
                        balSheet.AcctStatus = reader["AcctStatus"].ToString();
                    }

                    if (reader["CreditRating"] != DBNull.Value)
                    {
                        balSheet.CreditRating = reader["CreditRating"].ToString();
                    }

                    if (reader["CompanyCode"] != DBNull.Value)
                    {
                        balSheet.CompanyCode = reader["CompanyCode"].ToString();
                    }

                    if (reader["RunDate"] != DBNull.Value)
                    {
                        balSheet.Rundate = DateTime.Parse(reader["RunDate"].ToString());
                    }

                    balSheets.Add(balSheet);
                }

                con.Close();
            }

            return(balSheets);
        }