public static List <CashConversionModule> getCC(string criteria, int branchID)
        {
            var dbUtil   = new DatabaseManager();
            var brHeader = new List <CashConversionModule>();

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = "spCashConversionGetTran";
                    cmd.CommandTimeout = 180;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@strCriteria", criteria);
                    cmd.Parameters.AddWithValue("@intBranchID", branchID);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var brhdr = new CashConversionModule
                            {
                                ID = ReferenceEquals(reader["ID"], DBNull.Value) ? 0 : Convert.ToInt32(reader["ID"]),
                                intIDMasLocation    = ReferenceEquals(reader["intIDMasLocation"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasLocation"]),
                                intIDSalMCFinancing = ReferenceEquals(reader["intIDSalMCFinancing"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDSalMCFinancing"]),
                                strAccountCode      = ReferenceEquals(reader["strAccountCode"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strAccountCode"]),
                                datAccountDate      = ReferenceEquals(reader["datAccountDate"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datAccountDate"]),
                                datFirstDueDate     = ReferenceEquals(reader["datFirstDueDate"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datFirstDueDate"]),
                                datConvertedDate    = ReferenceEquals(reader["datConvertedDate"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datConvertedDate"]),
                                strCustomerName     = ReferenceEquals(reader["strCustomerName"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strCustomerName"]),
                                decFactorRate       = ReferenceEquals(reader["decFactorRate"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["decFactorRate"]),
                                decRateFromLCP      = ReferenceEquals(reader["decRateFromLCP"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["decRateFromLCP"]),
                                decRateFromMonthLCP = ReferenceEquals(reader["decRateFromMonthLCP"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["decRateFromMonthLCP"]),
                                amtLCP                = ReferenceEquals(reader["amtLCP"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtLCP"]),
                                amtCashPrice          = ReferenceEquals(reader["amtCashPrice"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtCashPrice"]),
                                intMonthLapse         = ReferenceEquals(reader["intMonthLapse"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["intMonthLapse"]),
                                amtTotalPay           = ReferenceEquals(reader["amtTotalPay"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtTotalPay"]),
                                amtDP                 = ReferenceEquals(reader["amtDP"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtDP"]),
                                amtRebate             = ReferenceEquals(reader["amtRebate"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtRebate"]),
                                amtMAmort             = ReferenceEquals(reader["amtMAmort"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtMAmort"]),
                                amtTotalPayWithRebate = ReferenceEquals(reader["amtTotalPayWithRebate"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["amtTotalPayWithRebate"]),
                            };

                            brHeader.Add(brhdr);
                        }

                        return(brHeader);
                    }
                }
            }
        }
        public static string Manage(NameValueCollection querystring)
        {
            int     integerParse;
            decimal decimalParse;
            //bool boolParser;

            UserProfile userProfile = WebCommon.GetUserProfile();

            var cashconv = new CashConversionModule
            {
                ID = int.TryParse(querystring.Get("CCID"), out integerParse) ? integerParse : 0,
                intIDMasLocation    = int.TryParse(querystring.Get("BranchID"), out integerParse) ? integerParse : 0,
                datAccountDate      = querystring.Get("AcctDate"),
                datFirstDueDate     = querystring.Get("FirstDueDate"),
                datConvertedDate    = querystring.Get("ConversionDate"),
                intIDSalMCFinancing = int.TryParse(querystring.Get("SalesID"), out integerParse) ? integerParse : 0,
                strAccountCode      = querystring.Get("AccountCode"),
                decRateFromLCP      = decimal.TryParse(querystring.Get("InterestRate"), out decimalParse) ? decimalParse : 0,
                decRateFromMonthLCP = decimal.TryParse(querystring.Get("InterestRateMonth"), out decimalParse) ? decimalParse : 0,
                decFactorRate       = decimal.TryParse(querystring.Get("FactorRate"), out decimalParse) ? decimalParse : 0,
                amtLCP                = decimal.TryParse(querystring.Get("LCP"), out decimalParse) ? decimalParse : 0,
                amtDP                 = decimal.TryParse(querystring.Get("DownPayment"), out decimalParse) ? decimalParse : 0,
                amtCashPrice          = decimal.TryParse(querystring.Get("CashPrice"), out decimalParse) ? decimalParse : 0,
                intMonthLapse         = decimal.TryParse(querystring.Get("MonthLapse"), out decimalParse) ? decimalParse : 0,
                amtTotalPay           = decimal.TryParse(querystring.Get("TotalPayNetRebate"), out decimalParse) ? decimalParse : 0,
                amtTotalPayWithRebate = decimal.TryParse(querystring.Get("TotalPayWithRebate"), out decimalParse) ? decimalParse : 0,
                amtRebate             = decimal.TryParse(querystring.Get("Rebate"), out decimalParse) ? decimalParse : 0,
            };



            string isInsert = querystring.Get("TransType");
            string param    = WebCommon.ToXML(cashconv);

            return(CashConversionModuleDAL.Manage(param, isInsert));
        }