示例#1
0
        public bool updateStore(StoreCatalogModel store)
        {
            string        query = "UPDATE storeCatalog SET  name = @name, state = @state, town = @town, addressSt = @address, phone = @phone WHERE id = @id";
            SqlConnection conn  = new SqlConnection(cadena);
            SqlCommand    cmd   = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value          = store.id;
                cmd.Parameters.Add("@name", System.Data.SqlDbType.VarChar).Value    = store.name;
                cmd.Parameters.Add("@state", System.Data.SqlDbType.VarChar).Value   = store.state;
                cmd.Parameters.Add("@town", System.Data.SqlDbType.VarChar).Value    = store.town;
                cmd.Parameters.Add("@address", System.Data.SqlDbType.VarChar).Value = store.address;
                cmd.Parameters.Add("@phone", System.Data.SqlDbType.VarChar).Value   = store.phone;

                int register = cmd.ExecuteNonQuery();

                return(register == 1);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
示例#2
0
        public StoreCatalogModel returnStore(int id)
        {
            string            query = "SELECT * FROM storeCatalog WHERE id = @id";
            SqlConnection     conn  = new SqlConnection(cadena);
            SqlCommand        cmd   = new SqlCommand(query, conn);
            StoreCatalogModel store = new StoreCatalogModel();

            try
            {
                conn.Open();
                cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value = id;
                SqlDataReader dr = cmd.ExecuteReader();


                if (dr.Read())
                {
                    store.id      = dr.GetInt32(0);
                    store.name    = dr.GetString(1);
                    store.state   = dr.GetString(2);
                    store.town    = dr.GetString(3);
                    store.address = dr.GetString(4);
                    store.phone   = dr.GetString(5);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conn.Close();
            }
            return(store);
        }
示例#3
0
        public bool createStore(StoreCatalogModel store)
        {
            string        query = "INSERT INTO storeCatalog VALUES(@name,@state,@town,@address,@phone)";
            SqlConnection conn  = new SqlConnection(cadena);
            SqlCommand    cmd   = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@name", System.Data.SqlDbType.VarChar).Value    = store.name;
                cmd.Parameters.Add("@state", System.Data.SqlDbType.VarChar).Value   = store.state;
                cmd.Parameters.Add("@town", System.Data.SqlDbType.VarChar).Value    = store.town;
                cmd.Parameters.Add("@address", System.Data.SqlDbType.VarChar).Value = store.address;
                cmd.Parameters.Add("@phone", System.Data.SqlDbType.VarChar).Value   = store.phone;


                int register = cmd.ExecuteNonQuery();
                return(register == 1);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }