Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        // 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;
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        // 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();
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }