Exemplo n.º 1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public p_supermercado getObjectp_supermercado(System.Int32 myID)
        {
            p_supermercado myp_supermercado = new p_supermercado();
            CnxBase        myBase           = new CnxBase();
            string         reqSQL           = "SELECT gid,id,sgc1,sgc2,the_geom FROM p_supermercado WHERE (gid=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myp_supermercado.gid      = Convert.ToInt32(myReader[0]);
                    myp_supermercado.id       = Convert.ToInt32(myReader[1]);
                    myp_supermercado.sgc1     = Convert.ToInt64(myReader[2]);
                    myp_supermercado.sgc2     = myReader[3].ToString();
                    myp_supermercado.the_geom = myReader[4].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myp_supermercado);
        }
Exemplo n.º 2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(p_supermercado myp_supermercado)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE p_supermercado SET gid=" + myp_supermercado.gid + ",id=" + myp_supermercado.id + ",sgc1=" + myp_supermercado.sgc1 + ",sgc2='" + myp_supermercado.sgc2 + "',the_geom='" + myp_supermercado.the_geom + "' WHERE (gid=" + myp_supermercado.gid + ")";

            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));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(p_supermercado myp_supermercado)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO p_supermercado (gid,id,sgc1,sgc2,the_geom) VALUES (" + myp_supermercado.gid + "," + myp_supermercado.id + "," + myp_supermercado.sgc1 + ",'" + myp_supermercado.sgc2 + "','" + myp_supermercado.the_geom + "')";

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