Esempio n. 1
0
        public s_sector getObjects_sector_comuna(string comuna)
        {
            s_sector mys_sector = new s_sector();
            CnxBase  myBase     = new CnxBase();
            string   reqSQL     = "SELECT id_sector,id_areas,descripcion FROM s_sector WHERE (descripcion='" + comuna + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mys_sector.id_sector   = Convert.ToInt32(myReader[0]);
                    mys_sector.id_areas    = myReader[1].ToString();
                    mys_sector.descripcion = myReader[2].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(mys_sector);
        }
Esempio n. 2
0
        public s_sector getObjects_sector_area(int id_area)
        {
            s_sector mys_sector = new s_sector();
            CnxBase  myBase     = new CnxBase();
            string   reqSQL     = string.Format("SELECT id_sector,id_areas,descripcion FROM s_sector WHERE trim(both ',' from substring(id_areas, '.?{0}.?'))='{0}'", id_area);

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mys_sector.id_sector   = Convert.ToInt32(myReader[0]);
                    mys_sector.id_areas    = myReader[1].ToString();
                    mys_sector.descripcion = myReader[2].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(mys_sector);
        }
Esempio n. 3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void adds_sector(s_sector mys_sector)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO s_sector (id_areas,descripcion) VALUES ('" + mys_sector.id_areas + "','" + mys_sector.descripcion + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void modifys_sector(s_sector mys_sector)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE s_sector SET id_sector=" + mys_sector.id_sector + ",id_areas='" + mys_sector.id_areas + "',descripcion='" + mys_sector.descripcion + "' WHERE (id_sector=" + mys_sector.id_sector + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
        }