Ejemplo n.º 1
0
 public void AddBusinessPartner(BusinessPartner partner, AppConnData oAppConnData)
 {
     try
     {
         facade = new BizFacade(BusinessClass.BizBusinessPartner);
         facade.AddBusinessPartner(partner, oAppConnData);
     }
     catch (Exception ex)
     {
         DataAccessFault detalleError = new DataAccessFault();
         foreach (string valores in ex.Data.Keys)
         {
             switch (valores)
             {
                 case "1": detalleError.ErrorID = ex.Data[valores].ToString();
                     break;
                 case "2": detalleError.ErrorSAP = ex.Data[valores].ToString();
                     break;
                 case "3": detalleError.Description = ex.Data[valores].ToString();
                     break;
                 default: detalleError.ErrorID = ex.Data[valores].ToString();
                     break;
             }
         }
         throw new FaultException<DataAccessFault>(detalleError, "Error al Procesar la solicitud");
     }
 }
Ejemplo n.º 2
0
 public void AddBusinessPartner(BusinessPartner partner, AppConnData oAppConnData)
 {
     bizBusinessPartner.Add(partner, oAppConnData);
 }
Ejemplo n.º 3
0
 public void UpdateBusinessPartner(BusinessPartner partner, AppConnData oAppConnData)
 {
     bizBusinessPartner.Update(partner, oAppConnData);
 }
        public void Add(BusinessPartner partner, SAPConnection sapConn)
        {
            BusinessPartners bp; //= new BusinessPartners();
            bp = (BusinessPartners)sapConn.company.GetBusinessObject(BoObjectTypes.oBusinessPartners);

            #region Basic Data
            bp.CardCode = partner.cardCode;

            switch (partner.cardType)
            {
                case CardType.Customer:
                    bp.CardType = BoCardTypes.cCustomer;
                    break;
                case CardType.Supplier:
                    bp.CardType = BoCardTypes.cSupplier;
                    break;
                case CardType.Lead:
                    bp.CardType = BoCardTypes.cLid;
                    break;
                default:
                    break;
            }

            bp.CardName = partner.cardName;

            if (!string.IsNullOrEmpty(partner.cardFName))
                bp.CardForeignName = partner.cardFName;

            bp.GroupCode = partner.groupCode;
            bp.FederalTaxID = partner.licTradNum;
            bp.Currency = partner.currency;
            #endregion

            #region General tab
            bp.Phone1 = partner.phone1;

            if (!string.IsNullOrEmpty(partner.phone2))
                bp.Phone2 = partner.phone2;
            if (!string.IsNullOrEmpty(partner.cellular))
                bp.Cellular = partner.cellular;
            if (!string.IsNullOrEmpty(partner.fax))
                bp.Fax = partner.fax;
            if (!string.IsNullOrEmpty(partner.e_Mail))
                bp.EmailAddress = partner.e_Mail;
            if (!string.IsNullOrEmpty(partner.password))
                bp.Password = partner.password;
            if (partner.slpCode != 0)
                bp.SalesPersonCode = partner.slpCode;
            if (partner.territory != null)
                bp.Territory = (int)partner.territory;

            /*
             * DI-Api not expose agent Code field
            if (!string.IsNullOrEmpty(partner.agentCode))
                bp.a = partner.phone2;
             * 
            */

            #endregion

            #region Payment temrs tab
            if (partner.groupNum != null)
                bp.PayTermsGrpCode = (int)partner.groupNum;
            if (partner.intrstRate != null)
                bp.IntrestRatePercent = (double)partner.intrstRate;
            if (partner.listNum != null)
                bp.PriceListNum = (int)partner.listNum;
            if (partner.discount != null)
                bp.DiscountPercent = (double)partner.discount;
            if (partner.creditLine != null)
                bp.CreditLimit = (double)partner.creditLine;
            if (partner.debitLine != null)
                bp.MaxCommitment = (double)partner.debitLine;
            if (!string.IsNullOrEmpty(partner.dunTerm))
                bp.DunningTerm = partner.dunTerm;
            #endregion

            #region Accounting tab
            #region general subtab
            if (!string.IsNullOrEmpty(partner.debPayAcct))
                bp.DebitorAccount = partner.debPayAcct;

            if (partner.blockDunn)
                bp.BlockDunning = BoYesNoEnum.tYES;
            else
                bp.BlockDunning = BoYesNoEnum.tNO;

            #endregion
            #region tax subtab
            if (partner.wtLiable)
            {
                bp.SubjectToWithholdingTax = BoYesNoEnum.tYES;
            }
            #endregion
            #endregion

            #region Propierties tab
            bp.set_Properties(1, partner.qryGroup1 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(2, partner.qryGroup2 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(3, partner.qryGroup3 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(4, partner.qryGroup4 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(5, partner.qryGroup5 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(6, partner.qryGroup6 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(7, partner.qryGroup7 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(8, partner.qryGroup8 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(9, partner.qryGroup9 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(10, partner.qryGroup10 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(11, partner.qryGroup11 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(12, partner.qryGroup12 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(13, partner.qryGroup13 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(14, partner.qryGroup14 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(15, partner.qryGroup15 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(16, partner.qryGroup16 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(17, partner.qryGroup17 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(18, partner.qryGroup18 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(19, partner.qryGroup19 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(20, partner.qryGroup20 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(21, partner.qryGroup21 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(22, partner.qryGroup22 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(23, partner.qryGroup23 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(24, partner.qryGroup24 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(25, partner.qryGroup25 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(26, partner.qryGroup26 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(27, partner.qryGroup27 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(28, partner.qryGroup28 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(29, partner.qryGroup29 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(30, partner.qryGroup30 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(31, partner.qryGroup31 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(32, partner.qryGroup32 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(33, partner.qryGroup33 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(34, partner.qryGroup34 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(35, partner.qryGroup35 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(36, partner.qryGroup36 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(37, partner.qryGroup37 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(38, partner.qryGroup38 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(39, partner.qryGroup39 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(40, partner.qryGroup40 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(41, partner.qryGroup41 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(42, partner.qryGroup42 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(43, partner.qryGroup43 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(44, partner.qryGroup44 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(45, partner.qryGroup45 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(46, partner.qryGroup46 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(47, partner.qryGroup47 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(48, partner.qryGroup48 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(49, partner.qryGroup49 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(50, partner.qryGroup50 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(51, partner.qryGroup51 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(52, partner.qryGroup52 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(53, partner.qryGroup53 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(54, partner.qryGroup54 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(55, partner.qryGroup55 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(56, partner.qryGroup56 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(57, partner.qryGroup57 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(58, partner.qryGroup58 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(59, partner.qryGroup59 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(60, partner.qryGroup60 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(61, partner.qryGroup61 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(62, partner.qryGroup62 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(63, partner.qryGroup63 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            bp.set_Properties(64, partner.qryGroup64 ? BoYesNoEnum.tYES : BoYesNoEnum.tNO);
            #endregion

            #region Remarks tab
            if (!string.IsNullOrEmpty(partner.freeText))
                bp.FreeText = partner.freeText;
            #endregion

            #region UDF's
            if (partner.userDefinedFields != null)
                foreach (UserDefinedField item in partner.userDefinedFields)
                {
                    if (!string.IsNullOrEmpty(item.value))
                        switch (item.type)
                        {
                            case UdfType.Alphanumeric:
                                bp.UserFields.Fields.Item(item.name).Value = item.value;
                                break;
                            case UdfType.Integer:
                                bp.UserFields.Fields.Item(item.name).Value = int.Parse(item.value);
                                break;
                            case UdfType.Double:
                                bp.UserFields.Fields.Item(item.name).Value = double.Parse(item.value);
                                break;
                            case UdfType.Datetime:
                                bp.UserFields.Fields.Item(item.name).Value = DateTime.Parse(item.value);
                                break;
                            case UdfType.Price:
                                bp.UserFields.Fields.Item(item.name).Value = double.Parse(item.value);
                                break;
                            case UdfType.Text:
                                bp.UserFields.Fields.Item(item.name).Value = item.value;
                                break;
                            default:
                                break;
                        }
                }
            #endregion

            if (bp.Add() != 0)
                throw new SAPException(sapConn.company.GetLastErrorCode(), sapConn.company.GetLastErrorDescription());
        }
        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;
        }
        public bool Add(BusinessPartner partner, 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);

                string licenseServer =  Cryptography.Decrypt(HexSerialization.HexToString(ConfigurationManager.AppSettings["licenseServer"]));
                string dbServer = Cryptography.Decrypt(HexSerialization.HexToString(ConfigurationManager.AppSettings["dbServer"]));
                string dbUser = Cryptography.Decrypt(HexSerialization.HexToString(ConfigurationManager.AppSettings["dbUser"]));
                string dbUserPassword = Cryptography.Decrypt(HexSerialization.HexToString(ConfigurationManager.AppSettings["dbUserPassword"]));
                string serverType = ConfigurationManager.AppSettings["serverType"];

                DataConnection = new SAPConnectionData(oAppConnData.dataBaseName, licenseServer, dbServer, oAppConnData.sapUser, oAppConnData.sapUserPassword, dbUser, dbUserPassword, serverType);
                //DataConnection.Conn = DataConnection.Conn.company;

                if (DataConnection.ConnectCompany(oAppConnData.dataBaseName, oAppConnData.sapUser, oAppConnData.sapUserPassword))
                {
                    DataConnection.BeginTran();
                    BusinessPartnerAccess = new BusinessPartnerData(oAppConnData.adoConnString);
                    BusinessPartnerAccess.Add(partner, DataConnection.Conn);
                    DataConnection.EndTranAndRelease(BoWfTransOpt.wf_Commit);

                    return true;
                }
            }
            #region Catch
            catch (SAPException ex)
            {
                DataConnection.EndTranAndRelease(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                BizUtilities.ProcessSapException(ex, "Gestión de Pagos");
                return false;
            }
            catch (COMException ex)
            {
                DataConnection.EndTranAndRelease(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                Exception outEx;
                if (ExceptionPolicy.HandleException(ex, "Politica_Excepcion_Com", out outEx))
                {
                    outEx.Data.Add("1", "3");
                    outEx.Data.Add("2", "NA");
                    outEx.Data.Add("3", outEx.Message + " Descripción: " + ex.Message);
                    throw outEx;
                }
                else
                {
                    throw;
                }
                //return false;
            }
            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)
            {
                ex.Data.Add("1", ex.ErrorId);
                ex.Data.Add("2", "NA");
                ex.Data.Add("3", ex.Message);
                throw ex;
            }
            catch (Exception ex)
            {
                DataConnection.EndTranAndRelease(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                Exception outEx;
                if (ex.Data["1"] == null)
                {
                    if (ExceptionPolicy.HandleException(ex, "Politica_ExcepcionGenerica", out outEx))
                    {
                        outEx.Data.Add("1", "3");
                        outEx.Data.Add("2", "NA");
                        outEx.Data.Add("3", outEx.Message + " Descripción: " + ex.Message);
                        throw outEx;

                    }
                }
                else
                {
                    throw ex;
                    //return 0;
                }
                return false;
            }
            #endregion
            return false;
        }