Ejemplo n.º 1
0
        public static Address GetById(AddressPrimaryKey pk)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool           ExecutionState  = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key, nvc[key]);
            }
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("Address_GetById", ref ExecutionState);

            if (dr.Read())
            {
                Address obj = new Address();
                PopulateObjectFromReader(obj, dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return(obj);
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static bool Delete(AddressPrimaryKey pk)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool           ExecutionState  = false;

            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key, nvc[key]);
            }
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            oDatabaseHelper.ExecuteScalar("Address_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return(ExecutionState);
        }