コード例 #1
0
        public z_locutores Login(string user, string password)
        {
            z_locutores myz_locutores = null;
            CnxBase     myBase        = new CnxBase();
            string      reqSQL        = "SELECT id_locutor,login,password,admin FROM z_locutores WHERE (login='******' and password='******')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myz_locutores            = new z_locutores();
                    myz_locutores.id_locutor = Convert.ToInt32(myReader[0]);
                    myz_locutores.login      = myReader[1].ToString();
                    myz_locutores.password   = myReader[2].ToString();
                    myz_locutores.admin      = Convert.ToBoolean(myReader[3]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(myz_locutores);
        }
コード例 #2
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public z_locutores getObjectz_locutores(System.Int32 myID)
        {
            z_locutores myz_locutores = new z_locutores();
            CnxBase     myBase        = new CnxBase();
            string      reqSQL        = "SELECT id_locutor,login,password,admin,id_tipo_locutor, id_op_vol FROM z_locutores WHERE (id_locutor=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myz_locutores.id_locutor      = Convert.ToInt32(myReader[0]);
                    myz_locutores.login           = myReader[1].ToString();
                    myz_locutores.password        = myReader[2].ToString();
                    myz_locutores.admin           = Convert.ToBoolean(myReader[3]);
                    myz_locutores.id_tipo_locutor = Convert.ToInt32(myReader[4]);
                    myz_locutores.id_op_vol       = Convert.ToInt32(myReader[5]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(myz_locutores);
        }
コード例 #3
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void modifyz_locutores(z_locutores myz_locutores)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE z_locutores SET id_locutor=" + myz_locutores.id_locutor + ",login='******',password='******',admin=" + myz_locutores.admin + ", id_tipo_locutor=" + myz_locutores.id_tipo_locutor + ", id_op_vol=" + myz_locutores.id_op_vol + " WHERE (id_locutor=" + myz_locutores.id_locutor + ")";

            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));
            }
        }
コード例 #4
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void addz_locutores(z_locutores myz_locutores)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO z_locutores (login,password,admin, id_tipo_locutor, id_op_vol) VALUES ('" + myz_locutores.login + "','" + myz_locutores.password + "'," + myz_locutores.admin + "," + myz_locutores.id_tipo_locutor + "," + myz_locutores.id_op_vol + ")";

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