예제 #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public s_central getObjects_central(System.Int32 myID)
        {
            s_central mys_central = new s_central();
            CnxBase   myBase      = new CnxBase();
            string    reqSQL      = "SELECT id_central,nombre,telefono FROM s_central WHERE (id_central=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mys_central.id_central = Convert.ToInt32(myReader[0]);
                    mys_central.nombre     = myReader[1].ToString();
                    mys_central.telefono   = myReader[2].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(mys_central);
        }
예제 #2
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void adds_central(s_central mys_central)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO s_central (id_central,nombre,telefono) VALUES (" + mys_central.id_central + ",'" + mys_central.nombre + "','" + mys_central.telefono + "')";

            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));
            }
        }
예제 #3
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void modifys_central(s_central mys_central)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE s_central SET id_central=" + mys_central.id_central + ",nombre='" + mys_central.nombre + "',telefono='" + mys_central.telefono + "' WHERE (id_central=" + mys_central.id_central + ")";

            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));
            }
        }