public List <Cliente> ConsultaClientes() { if (!ValidaAutenticacao()) { throw new Exception("Credenciais de acesso inválidas"); } Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); //BSO.AbreEmpresaTrabalho(0, "DEMO", "primavera", "123"); BSO = ERP.AbrirERP(); string sql = "SELECT cliente,nome, NumContrib FROM Clientes"; List <Cliente> result = new List <Cliente>(); Interop.StdBE900.StdBELista objLista; objLista = BSO.Consulta(sql); while (!objLista.NoFim()) { Cliente objCliente = new Cliente(); objCliente.cliente = objLista.Valor("Cliente").ToString(); objCliente.nome = objLista.Valor("Nome").ToString(); objCliente.nif = objLista.Valor("NumContrib").ToString(); result.Add(objCliente); objLista.Seguinte(); } return(result); }
public static Interop.ErpBS900.ErpBS AbrirERP() { string empresa = string.Empty; string username = string.Empty; string password = string.Empty; // ---------------------------------------------------- // Cargar desde el fichero de configuración Web.config: // ---------------------------------------------------- //empresa = System.Web.Configuration.WebConfigurationManager.AppSettings["ERPCompany"]; //username = System.Web.Configuration.WebConfigurationManager.AppSettings["ERPUsername"]; //password = System.Web.Configuration.WebConfigurationManager.AppSettings["ERPPassword"]; // Datos hardcore: empresa = "DEMOES"; username = "******"; password = ""; // Instancia/inicializa los motores PRIMAVERA: Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); // Abre la empresa: BSO.AbreEmpresaTrabalho(0, empresa, username, password); return(BSO); }
public string AtualizarClientes(Cliente cliente) { Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); BSO.AbreEmpresaTrabalho(0, "DEMO", "primavera", "123"); Interop.GcpBE900.GcpBECliente objCliente; objCliente = BSO.Comercial.Clientes.Edita(cliente.cliente); if (objCliente == null) { objCliente = new Interop.GcpBE900.GcpBECliente(); objCliente.set_Cliente(cliente.cliente); objCliente.set_Moeda(BSO.Contexto.MoedaBase); } objCliente.set_Nome(cliente.nome); objCliente.set_Morada(cliente.morada1); objCliente.set_Morada(cliente.morada2); objCliente.set_NumContribuinte(cliente.nif); objCliente.set_Localidade(cliente.localidade); objCliente.set_CodigoPostal(cliente.codPostal); BSO.Comercial.Clientes.Actualiza(objCliente); return(objCliente.get_Cliente()); }
// Pasamos el contexto a la DLL externa: public void setERPContext(Interop.ErpBS900.ErpBS erpBSO, Interop.StdPlatBS900.StdBSInterfPub erpPlat) { // Los motores (engine): BSO = erpBSO; // La Plataforma: Plataforma = erpPlat; }
public string ExisteClienteNIF(string NIF) { Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); BSO.AbreEmpresaTrabalho(0, "DEMO", "primavera", "123"); string cliente = BSO.Comercial.Clientes.ExisteContribuinte(NIF); return(cliente); }
// Pasamos el contexto a la DLL externa: public void setERPContext(Interop.ErpBS900.ErpBS erpBSO, Interop.StdPlatBS900.StdBSInterfPub erpPlat) { // Los motores (engine): BSO = erpBSO; // La Plataforma: Plataforma = erpPlat; // Creamos una conexión a la base de datos a través del ConnectionString: SQLConnection = new SqlConnection(Plataforma.BaseDados.DaConnectionStringNET("PRI" + BSO.Contexto.CodEmp, BSO.Contexto.Instancia)); SQLConnection.Open(); }
public ConsultaNIF ExisteClienteNIF_Ex(string NIF) { Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); BSO.AbreEmpresaTrabalho(0, "DEMOES", "Administrator", ""); ConsultaNIF resultado = new ConsultaNIF(); string cliente = BSO.Comercial.Clientes.ExisteContribuinte(NIF); if (cliente != "") { resultado.existe = true; resultado.codigo = cliente; resultado.nome = BSO.Comercial.Clientes.DaNome(cliente); } else { resultado.existe = false; } return(resultado); }
public EncomendaResultado CriarEncomenda(Encomenda enc) { EncomendaResultado resultado = new EncomendaResultado(); try { Interop.ErpBS900.ErpBS BSO = new Interop.ErpBS900.ErpBS(); //BSO.AbreEmpresaTrabalho(0, "DEMO", "primavera", "123"); BSO = ERP.AbrirERP(); Interop.GcpBE900.GcpBEDocumentoVenda objDocVenda = new Interop.GcpBE900.GcpBEDocumentoVenda(); objDocVenda.set_Tipodoc(enc.tipodoc); objDocVenda.set_Serie(BSO.Comercial.Series.DaSerieDefeito("V", enc.tipodoc)); objDocVenda.set_TipoEntidade("C"); objDocVenda.set_Entidade(enc.cliente); BSO.Comercial.Vendas.PreencheDadosRelacionados(objDocVenda); foreach (LinhaEncomenda linha in enc.linhas) { BSO.Comercial.Vendas.AdicionaLinha(objDocVenda, linha.artigo, linha.quantidade, PrecoUnitario: linha.precoUnitario); } BSO.Comercial.Vendas.Actualiza(objDocVenda); string strRefDoc = objDocVenda.get_Tipodoc() + objDocVenda.get_NumDoc() + "/" + objDocVenda.get_Serie(); resultado.erro = false; resultado.referencia = strRefDoc; } catch (Exception ex) { resultado.erro = true; resultado.descricaoErro = ex.Message; } return(resultado); }