コード例 #1
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();
            }
        }
コード例 #2
0
        public void save(ContribuyenteModel cm)
        {
            SqlConnection sqlcon = new SqlConnection();

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

                OdbcCommand select = new OdbcCommand();

                select.Connection  = conexion;
                select.CommandText = "INSERT INTO cliente("
                                     + "\"rutRecep\","
                                     + "\"rznSocRecep\","
                                     + "\"giroRecep\","
                                     + "\"dirRecep\","
                                     + "\"codCmnaRecep\","
                                     + "\"codCiudadRecep\","
                                     + "\"telefono\""
                                     + ") VALUES ('"
                                     + cm.rut + "','"
                                     + cm.rznSoc + "','"
                                     + cm.giro + "','"
                                     + cm.direccion + "',"
                                     + cm.codComuna + ","
                                     + cm.codCiudad + ",'"
                                     + cm.telefono + "');";

                OdbcDataReader reader = select.ExecuteReader();
            }

            catch (Exception ex)
            {
                Console.WriteLine("Error" + ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }