Exemplo n.º 1
0
        public List<CCardPopSale> get_CardPopSales(string state_str)
        {
            List<CCardPopSale> cardPopSales = new List<CCardPopSale>();
            SqlConnection sqlCn = null;
            string cmd_str = "";

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                cmd_str = "Select * from [CardPopSale]";
                if (state_str != null && state_str != "")
                    cmd_str += "where (" + state_str + ")";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var cardPopSale = new CCardPopSale();

                        cardPopSale.id = (int)dr["id"];
                        cardPopSale.mimMoney = ToInt(dr["mimMoney"]);
                        cardPopSale.saleMoney = ToInt(dr["saleMoney"]);

                        cardPopSales.Add(cardPopSale);
                    }
                }

            }
            catch (System.Exception e)
            {
                IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str);
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return cardPopSales;
        }
Exemplo n.º 2
0
        public CCardPopSale get_CardPopSale(string cmd_str)
        {
            CCardPopSale cardPopSale = null;
            SqlConnection sqlCn = null;

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                //string cmd_str = "Select * from [Orders] where " + key + "='" + key_val.ToString() + "'";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        cardPopSale = new CCardPopSale();

                        cardPopSale.id = (int)dr["id"];
                        cardPopSale.mimMoney = ToInt(dr["mimMoney"]);
                        cardPopSale.saleMoney = ToInt(dr["saleMoney"]);
                    }
                }

            }
            catch (System.Exception e)
            {
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return cardPopSale;
        }