Esempio n. 1
0
        protected static FR_L3TX_STfDCaRR_1119_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3TX_STfDCaRR_1119 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3TX_STfDCaRR_1119_Array();

            var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList();

            var defaultCountryISOCode = cls_Get_DefaultCountryISOCode_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result;

            var defaultCountry = CL1_CMN.ORM_CMN_Country.Query.Search(Connection, Transaction,
                                                                      new ORM_CMN_Country.Query
            {
                Country_ISOCode_Alpha2 = defaultCountryISOCode.Country_639_1_ISOCode,
                Tenant_RefID           = securityTicket.TenantID,
                IsDeleted = false
            }).SingleOrDefault();

            var param = new P_L3TX_GTfCICaT_1359();
            param.CountryISOCode = defaultCountryISOCode.Country_639_1_ISOCode;
            var taxes = cls_Get_Taxes_for_CountryISOCode_and_TenantID.Invoke(Connection, Transaction, param, securityTicket).Result;

            var result = new List <L3TX_STfDCaRR_1119>();
            foreach (var taxRate in Parameter.TaxRates)
            {
                var tax = taxes.Where(i => i.TaxRate == taxRate).SingleOrDefault();

                if (tax == default(L3TX_GTfCICaT_1359))
                {
                    var saveTaxParam = new P_L3TX_STX_1119();
                    saveTaxParam.ACC_TAX_TaxeID       = Guid.Empty;
                    saveTaxParam.EconomicRegion_RefID = Guid.Empty;
                    saveTaxParam.Country_RefID        = defaultCountry.CMN_CountryID;
                    saveTaxParam.TaxRate = taxRate;
                    saveTaxParam.TaxName = new Dict(ORM_ACC_TAX_Tax.TableName);
                    foreach (var language in DBLanguages)
                    {
                        saveTaxParam.TaxName.AddEntry(language.CMN_LanguageID, taxRate.ToString());
                    }

                    var saveTaxResult = cls_Save_Tax.Invoke(Connection, Transaction, saveTaxParam, securityTicket).Result;

                    result.Add(new L3TX_STfDCaRR_1119()
                    {
                        TaxID   = saveTaxResult,
                        TaxRate = taxRate
                    });
                }
                else
                {
                    result.Add(new L3TX_STfDCaRR_1119()
                    {
                        TaxID   = tax.ACC_TAX_TaxeID,
                        TaxRate = tax.TaxRate
                    });
                }
            }

            returnValue.Result = result.ToArray();
            return(returnValue);

            #endregion UserCode
        }
Esempio n. 2
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L3TX_STfDCaRR_1119_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L3TX_STfDCaRR_1119 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Esempio n. 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L3TX_STfDCaRR_1119_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3TX_STfDCaRR_1119 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L3TX_STfDCaRR_1119_Array functionReturn = new FR_L3TX_STfDCaRR_1119_Array();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Save_Taxes_for_DefaultCountry_and_ReturnResult", ex);
            }
            return(functionReturn);
        }
Esempio n. 4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L3TX_STfDCaRR_1119_Array Invoke(string ConnectionString, P_L3TX_STfDCaRR_1119 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }