Exemplo n.º 1
0
        private static List <OrderStatusId> get(string query, Dictionary <string, object> parameters)
        {
            OrderStatusId        item = null;
            Connection           cs   = new Connection();
            List <OrderStatusId> list = new List <OrderStatusId>();

            MySqlDataReader reader = cs.Select(query, parameters);

            while (reader.Read())
            {
                item = new OrderStatusId();

                if (!reader.IsDBNull(reader.GetOrdinal("id")))
                {
                    item.id = reader.GetInt32(reader.GetOrdinal("id"));
                }

                if (!(reader["name"] == DBNull.Value))
                {
                    item.name = reader["name"].ToString().Trim();
                }

                if (!(reader["description"] == DBNull.Value))
                {
                    item.description = reader["description"].ToString().Trim();
                }

                list.Add(item);
            }

            cs.CloseConnection();
            return(list);
        }
Exemplo n.º 2
0
        public static int Add(OrderStatusId m)
        {
            int    t     = 0;
            string query = @"INSERT INTO orderStatusId (name, description) " +
                           "VALUES (@name, @description);";
            Connection cs = new Connection();
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("name", m.name);
            param.Add("description", m.description);

            try
            {
                t = cs.Insert(query, param);
                //si insertion reussit
            }
            catch (MySqlException e) { }
            cs.CloseConnection();
            //si insertion echoue
            return(t);
        }