Beispiel #1
0
        private DBTaxRate GetTaxRateFromReader(IDataReader dataReader)
        {
            DBTaxRate taxRate = new DBTaxRate();

            taxRate.TaxRateID       = NopSqlDataHelper.GetInt(dataReader, "TaxRateID");
            taxRate.TaxCategoryID   = NopSqlDataHelper.GetInt(dataReader, "TaxCategoryID");
            taxRate.CountryID       = NopSqlDataHelper.GetInt(dataReader, "CountryID");
            taxRate.StateProvinceID = NopSqlDataHelper.GetInt(dataReader, "StateProvinceID");
            taxRate.Zip             = NopSqlDataHelper.GetString(dataReader, "Zip");
            taxRate.Percentage      = NopSqlDataHelper.GetDecimal(dataReader, "Percentage");
            return(taxRate);
        }
        private DBTaxRate GetTaxRateFromReader(IDataReader dataReader)
        {
            var item = new DBTaxRate();

            item.TaxRateId       = NopSqlDataHelper.GetInt(dataReader, "TaxRateID");
            item.TaxCategoryId   = NopSqlDataHelper.GetInt(dataReader, "TaxCategoryID");
            item.CountryId       = NopSqlDataHelper.GetInt(dataReader, "CountryID");
            item.StateProvinceId = NopSqlDataHelper.GetInt(dataReader, "StateProvinceID");
            item.Zip             = NopSqlDataHelper.GetString(dataReader, "Zip");
            item.Percentage      = NopSqlDataHelper.GetDecimal(dataReader, "Percentage");
            return(item);
        }
        private static TaxRate DBMapping(DBTaxRate dbItem)
        {
            if (dbItem == null)
                return null;

            TaxRate item = new TaxRate();
            item.TaxRateID = dbItem.TaxRateID;
            item.TaxCategoryID = dbItem.TaxCategoryID;
            item.CountryID = dbItem.CountryID;
            item.StateProvinceID = dbItem.StateProvinceID;
            item.Zip = dbItem.Zip;
            item.Percentage = dbItem.Percentage;

            return item;
        }
Beispiel #4
0
        /// <summary>
        /// Gets all tax rates
        /// </summary>
        /// <returns>Tax rate collection</returns>
        public override DBTaxRateCollection GetAllTaxRates()
        {
            DBTaxRateCollection taxRateCollection = new DBTaxRateCollection();
            Database            db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand           dbCommand = db.GetStoredProcCommand("Nop_TaxRateLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBTaxRate taxRate = GetTaxRateFromReader(dataReader);
                    taxRateCollection.Add(taxRate);
                }
            }
            return(taxRateCollection);
        }
        /// <summary>
        /// Inserts a tax rate
        /// </summary>
        /// <param name="taxCategoryId">The tax category identifier</param>
        /// <param name="countryId">The country identifier</param>
        /// <param name="stateProvinceId">The state/province identifier</param>
        /// <param name="zip">The zip</param>
        /// <param name="percentage">The percentage</param>
        /// <returns>Tax rate</returns>
        public override DBTaxRate InsertTaxRate(int taxCategoryId, int countryId,
                                                int stateProvinceId, string zip, decimal percentage)
        {
            DBTaxRate item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TaxRateInsert");

            db.AddOutParameter(dbCommand, "TaxRateID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "TaxCategoryID", DbType.Int32, taxCategoryId);
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId);
            db.AddInParameter(dbCommand, "StateProvinceID", DbType.Int32, stateProvinceId);
            db.AddInParameter(dbCommand, "Zip", DbType.String, zip);
            db.AddInParameter(dbCommand, "Percentage", DbType.Decimal, percentage);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int taxRateId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TaxRateID"));
                item = GetTaxRateById(taxRateId);
            }
            return(item);
        }
Beispiel #6
0
        /// <summary>
        /// Updates the tax rate
        /// </summary>
        /// <param name="TaxRateID">The tax rate identifier</param>
        /// <param name="TaxCategoryID">The tax category identifier</param>
        /// <param name="CountryID">The country identifier</param>
        /// <param name="StateProvinceID">The state/province identifier</param>
        /// <param name="Zip">The zip</param>
        /// <param name="Percentage">The percentage</param>
        /// <returns>Tax rate</returns>
        public override DBTaxRate UpdateTaxRate(int TaxRateID, int TaxCategoryID, int CountryID,
                                                int StateProvinceID, string Zip, decimal Percentage)
        {
            DBTaxRate taxRate   = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TaxRateUpdate");

            db.AddInParameter(dbCommand, "TaxRateID", DbType.Int32, TaxRateID);
            db.AddInParameter(dbCommand, "TaxCategoryID", DbType.Int32, TaxCategoryID);
            db.AddInParameter(dbCommand, "CountryID", DbType.Int32, CountryID);
            db.AddInParameter(dbCommand, "StateProvinceID", DbType.Int32, StateProvinceID);
            db.AddInParameter(dbCommand, "Zip", DbType.String, Zip);
            db.AddInParameter(dbCommand, "Percentage", DbType.Decimal, Percentage);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                taxRate = GetTaxRateByID(TaxRateID);
            }

            return(taxRate);
        }
        /// <summary>
        /// Gets a tax rate
        /// </summary>
        /// <param name="taxRateId">Tax rate identifier</param>
        /// <returns>Tax rate</returns>
        public override DBTaxRate GetTaxRateById(int taxRateId)
        {
            DBTaxRate item = null;

            if (taxRateId == 0)
            {
                return(item);
            }
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_TaxRateLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "TaxRateID", DbType.Int32, taxRateId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetTaxRateFromReader(dataReader);
                }
            }
            return(item);
        }