Ejemplo n.º 1
0
        public List<CCombo> get_Combos(string state_str, string order_str)
        {
            List<CCombo> combos = new List<CCombo>();
            SqlConnection sqlCn = null;

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

                string cmd_str = "Select * from [Combo]";
                if (state_str != null && state_str != "")
                    cmd_str += " where " + state_str;

                if (order_str != null && order_str != "")
                    cmd_str += " " + order_str;
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var combo = new CCombo();

                        combo.id = (int)dr["id"];
                        combo.originPrice = (double)dr["originPrice"];
                        combo.priceType = dr["priceType"].ToString();
                        combo.price = ToDouble(dr["price"]);
                        combo.freePrice = ToDouble(dr["freePrice"]);
                        combo.expenseUpTo = ToDouble(dr["expenseUpTo"]);
                        combo.menuIds = dr["menuIds"].ToString();
                        combo.freeMenuIds = dr["freeMenuIds"].ToString();

                        combos.Add(combo);
                    }
                }

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

            return combos;
        }
Ejemplo n.º 2
0
        public CCombo get_Combo(string key, object key_val)
        {
            CCombo combo = null;
            SqlConnection sqlCn = null;

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

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

                        combo.id = (int)dr["id"];
                        combo.originPrice = (double)dr["originPrice"];
                        combo.priceType = dr["priceType"].ToString();
                        combo.price = ToDouble(dr["price"]);
                        combo.freePrice = ToDouble(dr["freePrice"]);
                        combo.expenseUpTo = ToDouble(dr["expenseUpTo"]);
                        combo.menuIds = dr["menuIds"].ToString();
                        combo.freeMenuIds = dr["freeMenuIds"].ToString();
                    }
                }

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

            return combo;
        }