Exemple #1
0
        public static List<Merchant> Merchants(string merchantType)
        {
            List<Merchant> merchants = new List<Merchant>();
            string cmdText = "select * from tblMerchant";
            switch (merchantType)
            {
                case "Local Merchants *":
                    cmdText += " where LocalMerchant = true";
                    break;
                case "National Merchants *":
                    cmdText += " where LocalMerchant = false";
                    break;
            }
            cmdText += " order by MerchantName";
            using (OleDbConnection myConnection = new OleDbConnection(
                ConfigurationManager.ConnectionStrings["BeanCounterDB"].ToString()))
            {
                using (OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection))
                {
                    myConnection.Open();
                    using (OleDbDataReader myDataReader = myCommand.ExecuteReader())
                    {
                        while (myDataReader.Read())
                        {

                            Merchant merchant = new Merchant(
                                myDataReader["MerchantName"].ToString(),
                                myDataReader["CategoryName"].ToString(),
                                Convert.ToBoolean(myDataReader["AutoCategorize"].ToString()),
                                Convert.ToBoolean(myDataReader["LocalMerchant"].ToString()),
                                Convert.ToInt32(myDataReader["MerchantID"].ToString()));
                            merchants.Add(merchant);
                        }
                    }
                }
            }
            return merchants;
        }
Exemple #2
0
 public static List<Merchant> NationalMerchants()
 {
     List<Merchant> merchants = new List<Merchant>();
     string cmdText = "SELECT MerchantName, CategoryName FROM tblMerchant where LocalMerchant = false and AutoCategorize = true order by MerchantName";
     using (OleDbConnection myConnection = new OleDbConnection(
         ConfigurationManager.ConnectionStrings["BeanCounterDB"].ToString()))
     {
         using (OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection))
         {
             myConnection.Open();
             using (OleDbDataReader myDataReader = myCommand.ExecuteReader())
             {
                 while (myDataReader.Read())
                 {
                     //if (merchant.Contains(myDataReader["MerchantName"].ToString()))
                     //{
                     //    categoryName = myDataReader["CategoryName"].ToString();
                     //    break;
                     //}
                     Merchant merchant = new Merchant();
                     merchant.MerchantName = myDataReader["MerchantName"].ToString();
                     merchant.CategoryName = myDataReader["CategoryName"].ToString();
                     merchants.Add(merchant);
                 }
             }
         }
     }
     return merchants;
 }