public List<Country> GetCountryList(AppConnData oAppConnData)
        {
            try
            {
                if (!BizUtilities.ValidateServiceConnection(oAppConnData))
                    throw new BusinessException(15, "Nombre de Usuario o ContraseƱa incorrecta para el Servicio");

                oAppConnData = BizUtilities.GetDataConnection(oAppConnData);

                UtilitieAccess = new UtilitiesData(oAppConnData.adoConnString);
                List<Country> countries = UtilitieAccess.GetCountryList();

                return countries;
            }
            catch (DbException ex)
            {
                Exception outEx;
                if (ExceptionPolicy.HandleException(ex, "Politica_SQLServer", out outEx))
                {
                    outEx.Data.Add("1", "14");
                    outEx.Data.Add("2", "NA");
                    //outEx.Data.Add("3", outEx.Message);
                    outEx.Data.Add("3", outEx.Message + " DescripciĆ³n: " + ex.Message);
                    throw outEx;
                }
                else
                {
                    throw ex;
                }
            }
            catch (BusinessException ex)
            {
                BizUtilities.ProcessBusinessException(ex);
            }
            catch (Exception ex)
            {
                Exception outEx;
                if (ExceptionPolicy.HandleException(ex, "Politica_ExcepcionGenerica", out outEx))
                {
                    outEx.Data.Add("1", "3");
                    outEx.Data.Add("2", "NA");
                    outEx.Data.Add("3", outEx.Message);
                    throw outEx;
                }
                else
                {
                    throw ex;
                }
            }
            return null;
        }
        public BusinessPartner GetSingle(string cardCode)
        {
            UtilitiesData utilities = new UtilitiesData(this.connStr);
            BusinessPartner partner = new BusinessPartner();
            StringBuilder oSQL = new StringBuilder();
            List<UserDefinedField> ocrdUdfs = utilities.GetUserDefinedFieldList("OCRD");

            #region Query
            oSQL.Append("SELECT ");
            oSQL.Append("CardCode   ,CardType  ,CardName  ,CardFName ,GroupCode ,LicTradNum,Currency ");
            oSQL.Append(",Phone1    ,Phone2    ,Cellular  ,Fax       ,E_Mail    ,Password  ,SlpCode   ,AgentCode ,CntctPrsn ,Address   ,Territory ");
            oSQL.Append(",GroupNum  ,IntrstRate,ListNum   ,Discount  ,CreditLine,DebtLine  ,DunTerm   ,DebPayAcct,BlockDunn ,WTLiable ");
            oSQL.Append(",QryGroup1 ,QryGroup2 ,QryGroup3 ,QryGroup4 ,QryGroup5 ,QryGroup6 ,QryGroup7 ,QryGroup8 ,QryGroup9 ,QryGroup10 ");
            oSQL.Append(",QryGroup11,QryGroup12,QryGroup13,QryGroup14,QryGroup15,QryGroup16,QryGroup17,QryGroup18,QryGroup19,QryGroup20 ");
            oSQL.Append(",QryGroup21,QryGroup22,QryGroup23,QryGroup24,QryGroup25,QryGroup26,QryGroup27,QryGroup28,QryGroup29,QryGroup30 ");
            oSQL.Append(",QryGroup31,QryGroup32,QryGroup33,QryGroup34,QryGroup35,QryGroup36,QryGroup37,QryGroup38,QryGroup39,QryGroup40 ");
            oSQL.Append(",QryGroup41,QryGroup42,QryGroup43,QryGroup44,QryGroup45,QryGroup46,QryGroup47,QryGroup48,QryGroup49,QryGroup50 ");
            oSQL.Append(",QryGroup51,QryGroup52,QryGroup53,QryGroup54,QryGroup55,QryGroup56,QryGroup57,QryGroup58,QryGroup59,QryGroup60 ");
            oSQL.Append(",QryGroup61,QryGroup62,QryGroup63,QryGroup64,Free_Text ");
            oSQL.Append(",ISNULL(Balance, 0) Balance, ISNULL(DNotesBal, 0) DNotesBal, ISNULL(OrdersBal, 0) OrdersBal");

            foreach (UserDefinedField item in ocrdUdfs)
            {
                oSQL.Append(string.Format(", U_{0} ", item.name));
            }

            oSQL.Append("FROM OCRD with (nolock) ");
            oSQL.Append("WHERE cardCode = @CardCode ");

            DbCommand myCommand = this.dataBase.GetSqlStringCommand(oSQL.ToString());

            this.dataBase.AddInParameter(myCommand, "CardCode", DbType.String, cardCode);
            #endregion

            using (this.reader = this.dataBase.ExecuteReader(myCommand))
            {
                while (this.reader.Read())
                {
                    #region Basic Data
                    partner.cardCode = this.reader.IsDBNull(0) ? "" : this.reader.GetValue(0).ToString();
                    partner.cardType = this.reader.GetValue(1).ToString() == "C" ? CardType.Customer : (this.reader.GetValue(1).ToString() == "S" ? CardType.Supplier : CardType.Lead);
                    partner.cardName = this.reader.IsDBNull(2) ? "" : this.reader.GetValue(2).ToString();
                    partner.cardFName = this.reader.IsDBNull(3) ? "" : this.reader.GetValue(3).ToString();
                    partner.groupCode = int.Parse(this.reader.GetValue(4).ToString());
                    partner.licTradNum = this.reader.IsDBNull(5) ? "" : this.reader.GetValue(5).ToString();
                    partner.currency = this.reader.IsDBNull(6) ? "" : this.reader.GetValue(6).ToString();
                    partner.dNotesBal = this.reader.IsDBNull(94) ? 0 : double.Parse(this.reader.GetValue(94).ToString());
                    partner.ordersBal = this.reader.IsDBNull(95) ? 0 : double.Parse(this.reader.GetValue(95).ToString());
                    #endregion

                    #region General tab
                    partner.phone1 = this.reader.IsDBNull(7) ? "" : this.reader.GetValue(7).ToString();
                    partner.phone2 = this.reader.IsDBNull(8) ? "" : this.reader.GetValue(8).ToString();
                    partner.cellular = this.reader.IsDBNull(9) ? "" : this.reader.GetValue(9).ToString();
                    partner.fax = this.reader.IsDBNull(10) ? "" : this.reader.GetValue(10).ToString();
                    partner.e_Mail = this.reader.IsDBNull(11) ? "" : this.reader.GetValue(11).ToString();
                    partner.password = this.reader.IsDBNull(12) ? "" : this.reader.GetValue(12).ToString();
                    partner.slpCode = int.Parse(this.reader.GetValue(13).ToString());
                    partner.agentCode = this.reader.IsDBNull(14) ? "" : this.reader.GetValue(14).ToString();
                    partner.cntctPrsn = this.reader.IsDBNull(15) ? "" : this.reader.GetValue(15).ToString();
                    partner.address = this.reader.IsDBNull(16) ? "" : this.reader.GetValue(16).ToString();
                    partner.territory = this.reader.IsDBNull(17) ? 0 : (int)this.reader.GetValue(17);
                    #endregion

                    #region Payment temrs tab
                    partner.groupNum = this.reader.IsDBNull(18) ? 0 : int.Parse(this.reader.GetValue(18).ToString());
                    partner.intrstRate = this.reader.IsDBNull(19) ? 0 : double.Parse(this.reader.GetValue(19).ToString());
                    partner.listNum = this.reader.IsDBNull(20) ? 0 : int.Parse(this.reader.GetValue(20).ToString());
                    partner.discount = this.reader.IsDBNull(21) ? 0 : double.Parse(this.reader.GetValue(21).ToString());
                    partner.creditLine = this.reader.IsDBNull(22) ? 0 : double.Parse(this.reader.GetValue(22).ToString());
                    partner.debitLine = this.reader.IsDBNull(23) ? 0 : double.Parse(this.reader.GetValue(23).ToString());
                    partner.dunTerm = this.reader.IsDBNull(24) ? "" : this.reader.GetValue(24).ToString();
                    partner.balance = this.reader.IsDBNull(93) ? 0 : double.Parse(this.reader.GetValue(93).ToString());
                    #endregion

                    #region Accounting tab
                    #region general subtab
                    partner.debPayAcct = this.reader.IsDBNull(25) ? "" : this.reader.GetValue(25).ToString();
                    partner.blockDunn = this.reader.IsDBNull(26) ? false : (this.reader.GetValue(26).ToString() == "Y" ? true : false);
                    #endregion

                    #region tax subtab
                    partner.wtLiable = this.reader.IsDBNull(27) ? false : (this.reader.GetValue(27).ToString() == "Y" ? true : false);
                    #endregion
                    #endregion

                    #region Propierties tab
                    partner.qryGroup1 = this.reader.IsDBNull(28) ? false : (this.reader.GetValue(28).ToString() == "Y" ? true : false);
                    partner.qryGroup2 = this.reader.IsDBNull(29) ? false : (this.reader.GetValue(29).ToString() == "Y" ? true : false);
                    partner.qryGroup3 = this.reader.IsDBNull(30) ? false : (this.reader.GetValue(30).ToString() == "Y" ? true : false);
                    partner.qryGroup4 = this.reader.IsDBNull(31) ? false : (this.reader.GetValue(31).ToString() == "Y" ? true : false);
                    partner.qryGroup5 = this.reader.IsDBNull(32) ? false : (this.reader.GetValue(32).ToString() == "Y" ? true : false);
                    partner.qryGroup6 = this.reader.IsDBNull(33) ? false : (this.reader.GetValue(33).ToString() == "Y" ? true : false);
                    partner.qryGroup7 = this.reader.IsDBNull(34) ? false : (this.reader.GetValue(34).ToString() == "Y" ? true : false);
                    partner.qryGroup8 = this.reader.IsDBNull(35) ? false : (this.reader.GetValue(35).ToString() == "Y" ? true : false);
                    partner.qryGroup9 = this.reader.IsDBNull(36) ? false : (this.reader.GetValue(36).ToString() == "Y" ? true : false);
                    partner.qryGroup10 = this.reader.IsDBNull(37) ? false : (this.reader.GetValue(37).ToString() == "Y" ? true : false);
                    partner.qryGroup11 = this.reader.IsDBNull(38) ? false : (this.reader.GetValue(38).ToString() == "Y" ? true : false);
                    partner.qryGroup12 = this.reader.IsDBNull(39) ? false : (this.reader.GetValue(39).ToString() == "Y" ? true : false);
                    partner.qryGroup13 = this.reader.IsDBNull(40) ? false : (this.reader.GetValue(40).ToString() == "Y" ? true : false);
                    partner.qryGroup14 = this.reader.IsDBNull(41) ? false : (this.reader.GetValue(41).ToString() == "Y" ? true : false);
                    partner.qryGroup15 = this.reader.IsDBNull(42) ? false : (this.reader.GetValue(42).ToString() == "Y" ? true : false);
                    partner.qryGroup16 = this.reader.IsDBNull(43) ? false : (this.reader.GetValue(43).ToString() == "Y" ? true : false);
                    partner.qryGroup17 = this.reader.IsDBNull(44) ? false : (this.reader.GetValue(44).ToString() == "Y" ? true : false);
                    partner.qryGroup18 = this.reader.IsDBNull(45) ? false : (this.reader.GetValue(45).ToString() == "Y" ? true : false);
                    partner.qryGroup19 = this.reader.IsDBNull(46) ? false : (this.reader.GetValue(46).ToString() == "Y" ? true : false);
                    partner.qryGroup20 = this.reader.IsDBNull(47) ? false : (this.reader.GetValue(47).ToString() == "Y" ? true : false);
                    partner.qryGroup21 = this.reader.IsDBNull(48) ? false : (this.reader.GetValue(48).ToString() == "Y" ? true : false);
                    partner.qryGroup22 = this.reader.IsDBNull(49) ? false : (this.reader.GetValue(49).ToString() == "Y" ? true : false);
                    partner.qryGroup23 = this.reader.IsDBNull(50) ? false : (this.reader.GetValue(50).ToString() == "Y" ? true : false);
                    partner.qryGroup24 = this.reader.IsDBNull(51) ? false : (this.reader.GetValue(51).ToString() == "Y" ? true : false);
                    partner.qryGroup25 = this.reader.IsDBNull(52) ? false : (this.reader.GetValue(52).ToString() == "Y" ? true : false);
                    partner.qryGroup26 = this.reader.IsDBNull(53) ? false : (this.reader.GetValue(53).ToString() == "Y" ? true : false);
                    partner.qryGroup27 = this.reader.IsDBNull(54) ? false : (this.reader.GetValue(54).ToString() == "Y" ? true : false);
                    partner.qryGroup28 = this.reader.IsDBNull(55) ? false : (this.reader.GetValue(55).ToString() == "Y" ? true : false);
                    partner.qryGroup29 = this.reader.IsDBNull(56) ? false : (this.reader.GetValue(56).ToString() == "Y" ? true : false);
                    partner.qryGroup30 = this.reader.IsDBNull(57) ? false : (this.reader.GetValue(57).ToString() == "Y" ? true : false);
                    partner.qryGroup31 = this.reader.IsDBNull(58) ? false : (this.reader.GetValue(58).ToString() == "Y" ? true : false);
                    partner.qryGroup32 = this.reader.IsDBNull(59) ? false : (this.reader.GetValue(59).ToString() == "Y" ? true : false);
                    partner.qryGroup33 = this.reader.IsDBNull(60) ? false : (this.reader.GetValue(60).ToString() == "Y" ? true : false);
                    partner.qryGroup34 = this.reader.IsDBNull(61) ? false : (this.reader.GetValue(61).ToString() == "Y" ? true : false);
                    partner.qryGroup35 = this.reader.IsDBNull(62) ? false : (this.reader.GetValue(62).ToString() == "Y" ? true : false);
                    partner.qryGroup36 = this.reader.IsDBNull(63) ? false : (this.reader.GetValue(63).ToString() == "Y" ? true : false);
                    partner.qryGroup37 = this.reader.IsDBNull(64) ? false : (this.reader.GetValue(64).ToString() == "Y" ? true : false);
                    partner.qryGroup38 = this.reader.IsDBNull(65) ? false : (this.reader.GetValue(65).ToString() == "Y" ? true : false);
                    partner.qryGroup39 = this.reader.IsDBNull(66) ? false : (this.reader.GetValue(66).ToString() == "Y" ? true : false);
                    partner.qryGroup40 = this.reader.IsDBNull(67) ? false : (this.reader.GetValue(67).ToString() == "Y" ? true : false);
                    partner.qryGroup41 = this.reader.IsDBNull(68) ? false : (this.reader.GetValue(68).ToString() == "Y" ? true : false);
                    partner.qryGroup42 = this.reader.IsDBNull(69) ? false : (this.reader.GetValue(69).ToString() == "Y" ? true : false);
                    partner.qryGroup43 = this.reader.IsDBNull(70) ? false : (this.reader.GetValue(70).ToString() == "Y" ? true : false);
                    partner.qryGroup44 = this.reader.IsDBNull(71) ? false : (this.reader.GetValue(71).ToString() == "Y" ? true : false);
                    partner.qryGroup45 = this.reader.IsDBNull(72) ? false : (this.reader.GetValue(72).ToString() == "Y" ? true : false);
                    partner.qryGroup46 = this.reader.IsDBNull(73) ? false : (this.reader.GetValue(73).ToString() == "Y" ? true : false);
                    partner.qryGroup47 = this.reader.IsDBNull(74) ? false : (this.reader.GetValue(74).ToString() == "Y" ? true : false);
                    partner.qryGroup48 = this.reader.IsDBNull(75) ? false : (this.reader.GetValue(75).ToString() == "Y" ? true : false);
                    partner.qryGroup49 = this.reader.IsDBNull(76) ? false : (this.reader.GetValue(76).ToString() == "Y" ? true : false);
                    partner.qryGroup50 = this.reader.IsDBNull(77) ? false : (this.reader.GetValue(77).ToString() == "Y" ? true : false);
                    partner.qryGroup51 = this.reader.IsDBNull(78) ? false : (this.reader.GetValue(78).ToString() == "Y" ? true : false);
                    partner.qryGroup52 = this.reader.IsDBNull(79) ? false : (this.reader.GetValue(79).ToString() == "Y" ? true : false);
                    partner.qryGroup53 = this.reader.IsDBNull(80) ? false : (this.reader.GetValue(80).ToString() == "Y" ? true : false);
                    partner.qryGroup54 = this.reader.IsDBNull(81) ? false : (this.reader.GetValue(81).ToString() == "Y" ? true : false);
                    partner.qryGroup55 = this.reader.IsDBNull(82) ? false : (this.reader.GetValue(82).ToString() == "Y" ? true : false);
                    partner.qryGroup56 = this.reader.IsDBNull(83) ? false : (this.reader.GetValue(83).ToString() == "Y" ? true : false);
                    partner.qryGroup57 = this.reader.IsDBNull(84) ? false : (this.reader.GetValue(84).ToString() == "Y" ? true : false);
                    partner.qryGroup58 = this.reader.IsDBNull(85) ? false : (this.reader.GetValue(85).ToString() == "Y" ? true : false);
                    partner.qryGroup59 = this.reader.IsDBNull(86) ? false : (this.reader.GetValue(86).ToString() == "Y" ? true : false);
                    partner.qryGroup60 = this.reader.IsDBNull(87) ? false : (this.reader.GetValue(87).ToString() == "Y" ? true : false);
                    partner.qryGroup61 = this.reader.IsDBNull(88) ? false : (this.reader.GetValue(88).ToString() == "Y" ? true : false);
                    partner.qryGroup62 = this.reader.IsDBNull(89) ? false : (this.reader.GetValue(89).ToString() == "Y" ? true : false);
                    partner.qryGroup63 = this.reader.IsDBNull(90) ? false : (this.reader.GetValue(90).ToString() == "Y" ? true : false);
                    partner.qryGroup64 = this.reader.IsDBNull(91) ? false : (this.reader.GetValue(91).ToString() == "Y" ? true : false);
                    #endregion

                    #region Remarks tab
                    partner.freeText = this.reader.IsDBNull(92) ? "" : this.reader.GetValue(92).ToString();
                    #endregion

                    #region UDF's
                    int currentField = 96;
                    foreach (UserDefinedField item in ocrdUdfs)
                    {
                        item.value = this.reader.IsDBNull(currentField) ? "" : this.reader.GetValue(currentField).ToString();
                        partner.userDefinedFields.Add(item);

                        currentField++;
                    }
                    #endregion
                }
            }
            return partner;
        }