private Documents GetSapDocument(ICompany company, Type docType = null) { docType = docType != null ? docType : _curDocType; if (docType == _quotationType) { return((Documents)company.GetBusinessObject(BoObjectTypes.oQuotations)); } if (docType == _orderType) { return((Documents)company.GetBusinessObject(BoObjectTypes.oOrders)); } if (docType == _invoiceType) { return((Documents)company.GetBusinessObject(BoObjectTypes.oInvoices)); } if (docType == _deliveryNoteType) { return((Documents)company.GetBusinessObject(BoObjectTypes.oDeliveryNotes)); } if (docType == _creditNoteType) { return((Documents)company.GetBusinessObject(BoObjectTypes.oCreditNotes)); } return(null); }
public static bool InitializeCompany() { // Create a new company object oCompany = new SAPbobsCOM.Company(); if (oCompany.Connected) { oCompany.Disconnect(); } // SQL Server oCompany.Server = ""; // server version oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2017; // usuario de la base de datos oCompany.DbUserName = ""; // password de la base de datos oCompany.DbPassword = ""; // base de datos de la compania oCompany.CompanyDB = ""; // usuario de SAP B1 oCompany.UserName = ""; // password de SAP B1 oCompany.Password = ""; // conexion segur oCompany.UseTrusted = false; // license server oCompany.LicenseServer = ""; // conexion a la compania int lRetCode = oCompany.Connect(); // si errCode es diferente de 0 pudo haber algún error if (lRetCode != 0) { var a = Program.GetLastError("Company: " + oCompany.Server + ", DB: " + oCompany.CompanyDB); } var isConnected = oCompany.Connected; return(isConnected); }