Пример #1
0
        /// <summary>
        /// Inserts the jurisdiction record.
        /// </summary>
        /// <param name="jurisdiction">A jurisdiction dto.</param>
        /// <returns></returns>
        public static int InsertJurisdiction(JurisdictionDto jurisdiction)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("Jurisdiction");
            cmd.Parameters  = new DataParameters();
            DataParameter jurisdictionId = new DataParameter("JurisdictionId", jurisdiction.JurisdictionId);

            jurisdictionId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(jurisdictionId);
            cmd.Parameters.Add(new DataParameter("DisplayName", jurisdiction.DisplayName));
            cmd.Parameters.Add(new DataParameter("StateProvinceCode", jurisdiction.StateProvinceCode));
            cmd.Parameters.Add(new DataParameter("CountryCode", jurisdiction.CountryCode));
            cmd.Parameters.Add(new DataParameter("JurisdictionType", jurisdiction.JurisdictionType));
            cmd.Parameters.Add(new DataParameter("ZipPostalCodeStart", jurisdiction.ZipPostalCodeStart));
            cmd.Parameters.Add(new DataParameter("ZipPostalCodeEnd", jurisdiction.ZipPostalCodeEnd));
            cmd.Parameters.Add(new DataParameter("City", jurisdiction.City));
            cmd.Parameters.Add(new DataParameter("District", jurisdiction.District));
            cmd.Parameters.Add(new DataParameter("County", jurisdiction.County));
            cmd.Parameters.Add(new DataParameter("GeoCode", jurisdiction.GeoCode));
            cmd.Parameters.Add(new DataParameter("ApplicationId", jurisdiction.ApplicationId));
            cmd.Parameters.Add(new DataParameter("Code", jurisdiction.Code));

            DataResult result = DataService.ExecuteNonExec(cmd);

            // return JurisdictionId
            return(int.Parse(jurisdictionId.Value.ToString()));
        }
Пример #2
0
        /// <summary>
        /// Deletes the tax value record.
        /// </summary>
        /// <param name="taxValueId">The tax value id.</param>
        /// <returns></returns>
        public static int DeleteTaxValue(int taxValueId)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateDeleteStoredProcedureName("TaxValue");
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("TaxValueId", taxValueId));
            return(Int32.Parse(DataService.ExecuteNonExec(cmd).Scalar.ToString()));
        }
Пример #3
0
        /// <summary>
        /// Deletes the jurisdiction group record.
        /// </summary>
        /// <param name="jurisdictionGroupId">The jurisdiction group id.</param>
        /// <returns></returns>
        public static int DeleteJurisdictionGroup(int jurisdictionGroupId)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateDeleteStoredProcedureName("JurisdictionGroup");
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("JurisdictionGroupId", jurisdictionGroupId));
            return(Int32.Parse(DataService.ExecuteNonExec(cmd).Scalar.ToString()));
        }
Пример #4
0
        /// <summary>
        /// Inserts the jurisdiction relation record.
        /// </summary>
        /// <param name="jurisdictionRelation">A jurisdiction relation dto.</param>
        public static void InsertJurisdictionRelation(JurisdictionRelationDto jurisdictionRelation)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("JurisdictionRelation");
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("JurisdictionId", jurisdictionRelation.JurisdictionId));
            cmd.Parameters.Add(new DataParameter("JurisdictionGroupId", jurisdictionRelation.JurisdictionGroupId));
            DataService.ExecuteNonExec(cmd);
        }
Пример #5
0
        /// <summary>
        /// Gets the tax value id.
        /// </summary>
        /// <param name="taxValue">A tax value dto.</param>
        /// <returns>The tax value id.</returns>
        public static int GetTaxValueId(TaxValueDto taxValue)
        {
            // for use as a FK value
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT TaxValueId FROM TaxValue WHERE TaxCategory='{0}' and SiteId='{1}'",
                                            taxValue.TaxCategory,
                                            taxValue.SiteId);
            return(int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString()));
        }
Пример #6
0
        /// <summary>
        /// Gets the jurisdiction id.
        /// </summary>
        /// <param name="jurisdiction">A jurisdiction dto.</param>
        /// <returns>The jurisdiction id.</returns>
        public static int GetJurisdictionId(JurisdictionDto jurisdiction)
        {
            // for use as a FK value
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT JurisdictionId FROM Jurisdiction WHERE JurisdictionType='{0}' and Code='{1}'",
                                            jurisdiction.JurisdictionType,
                                            jurisdiction.Code);
            return(int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString()));
        }
Пример #7
0
        /// <summary>
        /// Gets the tax id.
        /// </summary>
        /// <param name="tax">A tax dto.</param>
        /// <returns>The tax id.</returns>
        public static int GetTaxId(TaxDto tax)
        {
            // for use as a FK value
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT TaxId FROM Tax WHERE Name='{0}' and ApplicationId='{1}'",
                                            tax.Name,
                                            tax.ApplicationId);
            return(int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString()));
        }
Пример #8
0
        /// <summary>
        /// Gets the tax language id.
        /// </summary>
        /// <param name="taxLanguage">A tax language dto.</param>
        /// <returns>The tax language id.</returns>
        public static int GetTaxLanguageId(TaxLanguageDto taxLanguage)
        {
            // for use as a FK value
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT TaxLanguageId FROM TaxLanguage WHERE Displayname='{0}' and LanguageCode='{1}' and TaxId='{2}'",
                                            taxLanguage.DisplayName,
                                            taxLanguage.LanguageCode,
                                            taxLanguage.TaxId);
            return(int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString()));
        }
Пример #9
0
        /// <summary>
        /// Inserts the tax language record.
        /// </summary>
        /// <param name="taxLanguage">A tax language dto.</param>
        /// <returns></returns>
        public static int InsertTaxLanguage(TaxLanguageDto taxLanguage)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("TaxLanguage");
            cmd.Parameters  = new DataParameters();
            DataParameter taxLanguageId = new DataParameter("TaxLanguageId", taxLanguage.TaxLanguageId);

            taxLanguageId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(taxLanguageId);
            cmd.Parameters.Add(new DataParameter("DisplayName", taxLanguage.DisplayName));
            cmd.Parameters.Add(new DataParameter("LanguageCode", taxLanguage.LanguageCode));
            cmd.Parameters.Add(new DataParameter("TaxId", taxLanguage.TaxId));

            DataResult result = DataService.ExecuteNonExec(cmd);

            // return TaxLanguageId
            return(int.Parse(taxLanguageId.Value.ToString()));
        }
Пример #10
0
        /// <summary>
        /// Inserts the jurisdiction group record.
        /// </summary>
        /// <param name="jurisdictionGroup">A jurisdiction group dto.</param>
        /// <returns></returns>
        public static int InsertJurisdictionGroup(JurisdictionGroupDto jurisdictionGroup)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("JurisdictionGroup");
            cmd.Parameters  = new DataParameters();
            DataParameter jurisdictionGroupId = new DataParameter("JurisdictionGroupId", jurisdictionGroup.JurisdictionGroupId);

            jurisdictionGroupId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(jurisdictionGroupId);
            cmd.Parameters.Add(new DataParameter("ApplicationId", jurisdictionGroup.ApplicationId));
            cmd.Parameters.Add(new DataParameter("DisplayName", jurisdictionGroup.DisplayName));
            cmd.Parameters.Add(new DataParameter("JurisdictionType", jurisdictionGroup.JurisdictionType));
            cmd.Parameters.Add(new DataParameter("Code", jurisdictionGroup.Code));

            DataResult result = DataService.ExecuteNonExec(cmd);

            // return JurisdictionGroupId
            return(int.Parse(jurisdictionGroupId.Value.ToString()));
        }
Пример #11
0
        /// <summary>
        /// Inserts the tax record.
        /// </summary>
        /// <param name="tax">A tax dto.</param>
        /// <returns></returns>
        public static int InsertTax(TaxDto tax)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("Tax");
            cmd.Parameters  = new DataParameters();
            DataParameter taxId = new DataParameter("TaxId", tax.TaxId);

            taxId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(taxId);
            cmd.Parameters.Add(new DataParameter("TaxType", tax.TaxType));
            cmd.Parameters.Add(new DataParameter("Name", tax.Name));
            cmd.Parameters.Add(new DataParameter("SortOrder", tax.SortOrder));
            cmd.Parameters.Add(new DataParameter("ApplicationId", tax.ApplicationId));

            DataResult result = DataService.ExecuteNonExec(cmd);

            // return TaxId
            return(int.Parse(taxId.Value.ToString()));
        }
Пример #12
0
        /// <summary>
        /// Inserts the tax value record.
        /// </summary>
        /// <param name="taxValue">A tax value dto.</param>
        /// <returns></returns>
        public static int InsertTaxValue(TaxValueDto taxValue)
        {
            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandText = TaxImporterDataHelper.CreateInsertStoredProcedureName("TaxValue");
            cmd.Parameters  = new DataParameters();
            DataParameter taxValueId = new DataParameter("TaxValueId", taxValue.TaxValueId);

            taxValueId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(taxValueId);
            cmd.Parameters.Add(new DataParameter("Percentage", taxValue.Percentage));
            cmd.Parameters.Add(new DataParameter("TaxId", taxValue.TaxId));
            cmd.Parameters.Add(new DataParameter("TaxCategory", taxValue.TaxCategory));
            cmd.Parameters.Add(new DataParameter("JurisdictionGroupId", taxValue.JurisdictionGroupId));
            cmd.Parameters.Add(new DataParameter("SiteId", taxValue.SiteId));
            cmd.Parameters.Add(new DataParameter("AffectiveDate", taxValue.AffectiveDate));

            DataResult result = DataService.ExecuteNonExec(cmd);

            // return TaxValueId
            return(int.Parse(taxValueId.Value.ToString()));
        }
Пример #13
0
        //public static int UpdateJurisdictionRelation(int jurisdictionId, int jurisdictionGroupId)
        //{
        //    DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();
        //    cmd.CommandText = TaxImporterDataHelper.CreateUpdateStoredProcedureName("JurisdictionRelation");
        //    cmd.Parameters = new DataParameters();
        //    cmd.Parameters.Add(new DataParameter("JurisdictionId", jurisdictionId));
        //    cmd.Parameters.Add(new DataParameter("JurisdictionGroupId", jurisdictionGroupId));
        //    return Int32.Parse(DataService.ExecuteNonExec(cmd).Scalar.ToString());
        //}
        #endregion

        /// <summary>
        /// Checks whether the specified jurisdiction relation exists.
        /// </summary>
        /// <param name="jurisdictionRelation">A jurisdiction relation dto.</param>
        /// <returns></returns>
        public static bool Exists(JurisdictionRelationDto jurisdictionRelation)
        {
            // Check for uniqueness by: JurisdictionId, JurisdictionGroupId

            int count;

            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT COUNT(*) FROM JurisdictionRelation WHERE JurisdictionId='{0}' and JurisdictionGroupId='{1}'",
                                            jurisdictionRelation.JurisdictionId,
                                            jurisdictionRelation.JurisdictionGroupId);
            count = int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString());

            if (count >= 1) // count should never be greater than one.
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #14
0
        //public static int UpdateTaxValue(int taxValueId, TaxValueDto taxValue)
        //{
        //    DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();
        //    cmd.CommandText = TaxImporterDataHelper.CreateUpdateStoredProcedureName("TaxValue");
        //    cmd.Parameters = new DataParameters();
        //    cmd.Parameters.Add(new DataParameter("TaxValueId", taxValueId));
        //    cmd.Parameters.Add(new DataParameter("Percentage", taxValue.Percentage));
        //    cmd.Parameters.Add(new DataParameter("TaxId", taxValue.TaxId));
        //    cmd.Parameters.Add(new DataParameter("TaxCategory", taxValue.TaxCategory));
        //    cmd.Parameters.Add(new DataParameter("JurisdictionGroupId", taxValue.JurisdictionGroupId));
        //    cmd.Parameters.Add(new DataParameter("SiteId", taxValue.SiteId));
        //    cmd.Parameters.Add(new DataParameter("AffectiveDate", taxValue.AffectiveDate));
        //    return Int32.Parse(DataService.ExecuteNonExec(cmd).Scalar.ToString());
        //}
        #endregion

        /// <summary>
        /// Checks if the specified tax value exists.
        /// </summary>
        /// <param name="taxValue">A tax value dto.</param>
        /// <returns></returns>
        public static bool Exists(TaxValueDto taxValue)
        {
            // Check for uniqueness by: TaxCategory, SiteId

            int count;

            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT COUNT(*) FROM TaxValue WHERE TaxCategory='{0}' and SiteId='{1}'",
                                            taxValue.TaxCategory,
                                            taxValue.SiteId);
            count = int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString());

            if (count >= 1) // count should never be greater than one.
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #15
0
        //public static int UpdateTax(int taxId, TaxDto tax)
        //{
        //    DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();
        //    cmd.CommandText = TaxImporterDataHelper.CreateUpdateStoredProcedureName("Tax");
        //    cmd.Parameters = new DataParameters();
        //    cmd.Parameters.Add(new DataParameter("TaxId", taxId));
        //    cmd.Parameters.Add(new DataParameter("TaxType", tax.TaxType));
        //    cmd.Parameters.Add(new DataParameter("Name", tax.Name));
        //    cmd.Parameters.Add(new DataParameter("SortOrder", tax.SortOrder));
        //    cmd.Parameters.Add(new DataParameter("ApplicationId", tax.ApplicationId));
        //    return Int32.Parse(DataService.ExecuteNonExec(cmd).Scalar.ToString());
        //}
        #endregion

        /// <summary>
        /// Checks if the specified tax exists.
        /// </summary>
        /// <param name="tax">A tax dto.</param>
        /// <returns></returns>
        public static bool Exists(TaxDto tax)
        {
            // See Unique Index: IX_Tax(Unique, Non-Clustered)
            // Uses: Name, ApplicationId

            int count;

            DataCommand cmd = TaxImporterDataHelper.CreateDataCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = string.Format("SELECT COUNT(*) FROM Tax WHERE Name='{0}' and ApplicationId='{1}'",
                                            tax.Name,
                                            tax.ApplicationId);
            count = int.Parse(DataService.ExecuteScalar(cmd).Scalar.ToString());

            if (count >= 1) // count should never be greater than one.
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }