コード例 #1
0
        public void update(ProductosModel producto)
        {
            SqlConnection sqlcon = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE producto SET "
                                     + "\"nombre\"='" + producto.nombre + "',"
                                     + "\"codigoInt\"='" + producto.codigoInt + "',"
                                     + "\"unmditem\"='" + producto.unmditem + "',"
                                     + "\"precioNeto\"=" + producto.precioNeto + ","
                                     + "\"precioVenta\"=" + producto.precioventa + ","
                                     + "\"exento\"='" + producto.exento + "'"
                                     + "WHERE \"id\" = " + producto.id + ";";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #2
0
        public void updateCiudad(Int32 codPais, String nomCiudad, Int32 codCiudad)
        {
            SqlConnection sqlcon = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE ciudades "
                                     + "SET \"codPais\"='" + codPais + "',"
                                     + "\"nomCiudad\"='" + nomCiudad + "'"
                                     + "WHERE \"codCiudad\" = " + codCiudad + ";";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #3
0
        public DataTable getContribuyenteXNombre(String nombre)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT \"rutRecep\",\"rznSocRecep\",\"giroRecep\" FROM cliente where \"rznSocRecep\" LIKE '%" + nombre + "%'";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #4
0
        public void update(UsuarioModel usuario)
        {
            SqlConnection sqlcon = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE usuario SET "
                                     + " email ='" + usuario.email + "',"
                                     + " nombre ='" + usuario.nombre + "',"
                                     + " usuario ='" + usuario.usuario + "',"
                                     + " password ='******'"
                                     + " WHERE \"id\" = " + usuario.id + ";";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #5
0
        public string validaUser(string usuario, string clave)
        {
            string        respuesta = "true";
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select * from usuario "
                                     + "where \"usuario\" = '" + usuario + "' and \"password\" = '" + clave + "'";
                OdbcDataReader reader = select.ExecuteReader();
                if (reader.HasRows == false)
                {
                    respuesta = "false";
                }
            }
            catch (Exception ex)
            {
                return("Error al conectar a la base de datos" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }


            return(respuesta);
        }
コード例 #6
0
        public void save(DocumentoModel documento)
        {
            foreach (Detalle det in documento.detalle)
            {
                MemoryStream stream = new MemoryStream();
                DataContractJsonSerializer detalle = new DataContractJsonSerializer(typeof(Detalle));
                detalle.WriteObject(stream, det);
                string jsonString = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();
                String json = jsonString.Replace("null", "\"\"");
                json = jsonString.Replace("{", "{\"FolioDoc\":" + documento.Folio + ", \"TipoDoc\":" + documento.TipoDTE + ",");

                try
                {
                    BaseDato       con      = new BaseDato();
                    OdbcConnection conexion = con.ConnectPostgres();
                    OdbcCommand    select   = new OdbcCommand();
                    select.Connection  = conexion;
                    select.CommandText = "INSERT INTO detalle SELECT * FROM json_populate_record(NULL::detalle,'" + json + "')";
                    OdbcDataReader reader = select.ExecuteReader();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error" + ex.Message);
                }
            }
        }
コード例 #7
0
 public void save(DocumentoModel documento)
 {
     foreach (ReferenciaDoc det in documento.Referencia)
     {
         MemoryStream stream = new MemoryStream();
         DataContractJsonSerializer referencia = new DataContractJsonSerializer(typeof(ReferenciaDoc));
         referencia.WriteObject(stream, det);
         string jsonString = Encoding.UTF8.GetString(stream.ToArray());
         stream.Close();
         String json  = jsonString.Replace("null", "\"\"");
         String json0 = json.Replace("{", "{\"FolioDoc\":" + documento.Folio + ", \"TipoDoc\":" + documento.TipoDTE + ",");
         if (det.TpoDocRef == "SET")
         {
             json0 = json0.Replace("\"TpoDocRef\":\"SET\"", "\"TpoDocRef\\r\\n\":\"1000\"");
         }
         if (det.TpoDocRef == "1000")
         {
             json0 = json0.Replace("\"TpoDocRef\":\"1000\"", "\"TpoDocRef\\r\\n\":\"1000\"");
         }
         try
         {
             BaseDato       con      = new BaseDato();
             OdbcConnection conexion = con.ConnectPostgres();
             OdbcCommand    select   = new OdbcCommand();
             select.Connection  = conexion;
             select.CommandText = "INSERT INTO referencia SELECT * FROM json_populate_record(NULL::referencia,'" + json0 + "')";
             OdbcDataReader reader = select.ExecuteReader();
         }
         catch (Exception ex)
         {
             throw new Exception("Error" + ex.Message);
         }
     }
 }
コード例 #8
0
        public void updatepais(Int32 codPais, String nomPais)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE paises "
                                     + "SET \"nomPais\"='" + nomPais + "'"
                                     + "WHERE \"codPais\" = " + codPais + ";";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #9
0
 public void save(ProductosModel producto)
 {
     try
     {
         BaseDato       con      = new BaseDato();
         OdbcConnection conexion = con.ConnectPostgres();
         OdbcCommand    select   = new OdbcCommand();
         select.Connection  = conexion;
         select.CommandText =
             "INSERT INTO producto("
             // +"id, "
             + "nombre, "
             + "\"codigoInt\", "
             + "\"precioNeto\", "
             + "\"precioVenta\","
             + "\"exento\""
             //+"codimpuesto "
             + ") VALUES ('"
             //+ producto.id +",'"//"id, "
             + producto.nombre + "','"              //"nombre, "
             + producto.codigoInt + "',"            //"\"codigoInt\", "
             + producto.precioNeto + ","            //"\"precioNeto\", "
             + producto.precioventa + ",'"          //"\"precioVenta\", "
             + producto.exento + "'"                //"\"precioVenta\", "
             // + "codimpuesto "
             + ");";
         OdbcDataReader reader = select.ExecuteReader();
     }
     catch (Exception ex)
     {
         throw new Exception("Error" + ex.Message);
     }
 }
コード例 #10
0
        public Int32 getUltimoFolioPedido()
        {
            Int32         ultimoFolio = 0;
            SqlConnection sqlcon      = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select MAX(\"Folio\") from documento where \"TipoDTE\" = '802'";
                OdbcDataReader reader = select.ExecuteReader();
                while (reader.Read())
                {
                    ultimoFolio = Convert.ToInt32(reader.GetValue(0));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
            finally
            {
                sqlcon.Close();
            }

            ultimoFolio = ultimoFolio + 1;
            return(ultimoFolio);

            //select min(folio) from folio where estado = 'DISPONIBLE'
            //cambiar a estado a ocupado
            // validar con try catch
        }
コード例 #11
0
        public void update(ContribuyenteModel contribuyenteModel)
        {
            SqlConnection sqlcon = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE cliente SET "
                                     + " \"rznSocRecep\" ='" + contribuyenteModel.rznSoc + "',"
                                     + " \"giroRecep\" ='" + contribuyenteModel.giro + "',"
                                     + " \"dirRecep\" ='" + contribuyenteModel.direccion + "',"
                                     + " \"codCmnaRecep\" =" + contribuyenteModel.codComuna + ","
                                     + " \"codCiudadRecep\" =" + contribuyenteModel.codCiudad + ","
                                     + " \"telefono\" ='" + contribuyenteModel.telefono + "'"
                                     + " WHERE \"rutRecep\" = '" + contribuyenteModel.rut + "';";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #12
0
        public Int32 getUltimoFolio(Int32 idCaf)
        {
            Int32         ultimoFolio = 0;
            SqlConnection sqlcon      = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select min(folio) from folio where estado = 'DISPONIBLE' and idcaf = " + idCaf + ";";
                OdbcDataReader reader = select.ExecuteReader();
                //no quedan folios no recorrer
                while (reader.Read())
                {
                    ultimoFolio = Convert.ToInt32(reader.GetValue(0));
                }
                // modificaEstado("OCUPADO", ultimoFolio,idCaf);
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
            finally
            {
                sqlcon.Close();
            }

            return(ultimoFolio);
            //select min(folio) from folio where estado = 'DISPONIBLE'
            //cambiar a estado a ocupado
            // validar con try catch
        }
コード例 #13
0
        public void save(FolioModel foliomodel)


        {
            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "INSERT INTO folio("
                                     + "folio, estado, idcaf, \"codSucSii\")"
                                     + " VALUES ("
                                     + foliomodel.folio + ",'"
                                     + "DISPONIBLE" + "',"
                                     + foliomodel.idcaf + ",'"
                                     + foliomodel.codSucSii + "'"
                                     + ");";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #14
0
        public DataTable getFolioXId(Int32 id)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM folio where idcaf = " + id + " order by folio ASC";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #15
0
        public DocumentoModel getDocumento(int tipo, int folio)
        {
            DocumentoModel documentoModel = new DocumentoModel();
            String         documento      = String.Empty;

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select row_to_json(documento) from documento where \"Folio\" = " + folio + " and \"TipoDTE\" = '" + tipo + "';";
                OdbcDataReader reader = select.ExecuteReader();
                while (reader.Read())
                {
                    documento = reader.GetString(reader.GetOrdinal("row_to_json"));
                }

                DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(DocumentoModel));
                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(documento));
                documentoModel            = (DocumentoModel)js.ReadObject(ms);
                documentoModel.detalle    = new Detalle().getDetalle(tipo, folio);
                documentoModel.Referencia = new ReferenciaDoc().getReferencia(tipo, folio);
                return(documentoModel);
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #16
0
        public DataTable getProdXCod(String codProd)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM producto where \"codigoInt\" = '" + codProd + "'";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #17
0
        public DataTable getAllDocDT()

        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT \"nombre\",\"TipoDTE\",\"Folio\",\"FchEmis\",\"RznSocRecep\",\"MntTotal\""
                                     + " FROM documento,tipodte "
                                     + " where  documento.\"TipoDTE\" = tipodte.tipo order by fchcreate DESC LIMIT 50";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #18
0
        public DataTable getComunasXCiudad(int codCiudad)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM comunas WHERE \"codCiudad\" = " + codCiudad;
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #19
0
        public List <Detalle> getDetalle(int tipoDoc, int folioDoc)
        {
            List <Detalle> detalles    = new List <Detalle>();
            Detalle        detalle     = new Detalle();
            String         detalleJson = String.Empty;

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select row_to_json(detalle) from detalle where \"FolioDoc\" = " + folioDoc + " and \"TipoDoc\" = " + tipoDoc + ";";
                OdbcDataReader reader = select.ExecuteReader();
                while (reader.Read())
                {
                    detalleJson = reader.GetString(reader.GetOrdinal("row_to_json"));
                    DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Detalle));
                    MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(detalleJson));
                    detalle = (Detalle)js.ReadObject(ms);
                    detalles.Add(detalle);
                }
                return(detalles);
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #20
0
        public void save(ClienteProductoModel cliProdModel)
        {
            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText =
                    "INSERT INTO clienteproducto("
                    + "\"idProducto\", \"rutCliente\", \"precioNeto\", \"precioVenta\")"
                    + " VALUES ("
                    + cliProdModel.idProducto + ",'"
                    + cliProdModel.rutCliente + "',"
                    + cliProdModel.precioNeto + ","
                    + cliProdModel.precioVenta + ");";

                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #21
0
        public List <ReferenciaDoc> getReferencia(int tipoDoc, int folioDoc)
        {
            List <ReferenciaDoc> referencias = new List <ReferenciaDoc>();
            ReferenciaDoc        referencia  = new ReferenciaDoc();
            String referenciaJson            = String.Empty;

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select row_to_json(referencia) from referencia where \"FolioDoc\" = " + folioDoc + " and \"TipoDoc\" = " + tipoDoc + " order by \"NroLinRef\" ASC;";
                OdbcDataReader reader = select.ExecuteReader();
                while (reader.Read())
                {
                    referenciaJson = reader.GetString(reader.GetOrdinal("row_to_json"));
                    String referenciaJson1        = referenciaJson.Replace("null", "\"\"");
                    String referenciaJson2        = referenciaJson1.Replace("\"TpoDocRef\\r\\n", "\"TpoDocRef");
                    DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(ReferenciaDoc));
                    MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(referenciaJson2));
                    referencia = (ReferenciaDoc)js.ReadObject(ms);
                    referencias.Add(referencia);
                }
                return(referencias);
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #22
0
        public string searchProdxCliente(Int32 codProd, string rutCliente)
        {
            string        respuesta = "true";
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select * from clienteproducto "
                                     + "where \"idProducto\" = " + codProd + " and \"rutCliente\" = '" + rutCliente + "'";
                OdbcDataReader reader = select.ExecuteReader();
                if (reader.HasRows == false)
                {
                    respuesta = "false";
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }


            return(respuesta);
        }
コード例 #23
0
        public string exists(int idUser)
        {
            string        respuesta = "True";
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select * from usuario "
                                     + "where id = " + idUser + "";
                OdbcDataReader reader = select.ExecuteReader();
                if (reader.HasRows == false)
                {
                    respuesta = "False";
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }


            return(respuesta);
        }
コード例 #24
0
        public void update(ClienteProductoModel cliProdModel)
        {
            SqlConnection sqlcon = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "UPDATE clienteproducto SET "
                                     + "\"precioNeto\"=" + cliProdModel.precioNeto + ","
                                     + "\"precioVenta\"=" + cliProdModel.precioVenta + " "
                                     + "WHERE \"rutCliente\" = '" + cliProdModel.rutCliente + "'"
                                     + "and \"idProducto\" = " + cliProdModel.idProducto + ";";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }
コード例 #25
0
        public DataTable getUsuarios()
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM usuario order by id DESC";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #26
0
        public DataTable getProdClientXCod(string rut, string codProd)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "select producto.\"id\",producto.nombre,producto.\"codigoInt\", "
                                     + "clienteproducto.\"precioNeto\",clienteproducto.\"precioVenta\", "
                                     + "producto.codimpuesto,producto.unmditem,producto.exento "
                                     + "from   clienteproducto,producto,cliente "
                                     + "where  clienteproducto.\"idProducto\" = producto.\"id\" "
                                     + "and    clienteproducto.\"rutCliente\" = cliente.\"rutRecep\" "
                                     + "and    clienteproducto.\"rutCliente\" = '" + rut + "'"
                                     + "and    producto.\"codigoInt\" = '" + codProd + "'";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
            return(datatable);
        }
コード例 #27
0
        public DataTable getCiudadXNombre(String nomCiudad)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM ciudades where \"nomCiudad\" Like '%" + nomCiudad + "%'";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #28
0
        public void save(DocumentoModel documento)
        {
            MemoryStream stream           = new MemoryStream();
            DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(DocumentoModel));

            ds.WriteObject(stream, documento);
            string jsonString = Encoding.UTF8.GetString(stream.ToArray());

            stream.Close();
            String json = jsonString.Replace("null", "\"\"");

            json = jsonString.Replace("{", "{\"fchcreate\":\"" + DateTime.Now.ToString() + "\",");
            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();
                OdbcCommand    select   = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "INSERT INTO documento SELECT * FROM json_populate_record(NULL::documento,'" + json + "')";
                OdbcDataReader reader = select.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
        }
コード例 #29
0
        public DataTable getContribuyente(String rut)
        {
            DataTable     datatable = new DataTable();
            SqlConnection sqlcon    = new SqlConnection();

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM cliente "
                                     + "INNER JOIN ciudades ON \"codCiudadRecep\" =\"codCiudad\" "
                                     + "INNER JOIN comunas ON \"codCmnaRecep\" = \"codComuna\" "
                                     + "where \"rutRecep\" = '" + rut + "'";
                OdbcDataReader reader = select.ExecuteReader();
                datatable.Load(reader);
            }
            catch (Exception ex)
            {
                datatable = null;
                throw new Exception("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }

            return(datatable);
        }
コード例 #30
0
        public int getUltimoFolioCaf(int idCaf, int tipoDte)
        {
            int ultimo = 0;

            try
            {
                BaseDato       con      = new BaseDato();
                OdbcConnection conexion = con.ConnectPostgres();

                OdbcCommand select = new OdbcCommand();
                select.Connection  = conexion;
                select.CommandText = "SELECT * FROM caf where id = " + idCaf + " and  \"tipoDte\" = '" + tipoDte + "';";
                OdbcDataReader reader = select.ExecuteReader();
                if (reader.RecordsAffected != 0)
                {
                    while (reader.Read())
                    {
                        ultimo = reader.GetInt32(reader.GetOrdinal("folioFinal"));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error" + ex.Message);
            }
            return(ultimo + 1);
        }