Пример #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public k_geoz getObjectk_geoz(System.Int32 myID)
        {
            k_geoz  myk_geoz = new k_geoz();
            CnxBase myBase   = new CnxBase();
            string  reqSQL   = "SELECT gid,id_hoja,id_celda,fila,columna,geoz,geom FROM k_geoz WHERE (gid=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myk_geoz.gid      = Convert.ToInt32(myReader[0]);
                    myk_geoz.id_hoja  = Convert.ToInt64(myReader[1]);
                    myk_geoz.id_celda = myReader[2].ToString();
                    myk_geoz.fila     = myReader[3].ToString();
                    myk_geoz.columna  = Convert.ToInt32(myReader[4]);
                    myk_geoz.geoz     = myReader[5].ToString();
                    myk_geoz.the_geom = myReader[6].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myk_geoz);
        }
Пример #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(k_geoz myk_geoz)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE k_geoz SET gid=" + myk_geoz.gid + ",id_hoja=" + myk_geoz.id_hoja + ",id_celda='" + myk_geoz.id_celda + "',fila='" + myk_geoz.fila + "',columna=" + myk_geoz.columna + ",geoz='" + myk_geoz.geoz + "',geom='" + myk_geoz.the_geom + "' WHERE (gid=" + myk_geoz.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));
            }
        }
Пример #3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(k_geoz myk_geoz)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO k_geoz (gid,id_hoja,id_celda,fila,columna,geoz,geom) VALUES (" + myk_geoz.gid + "," + myk_geoz.id_hoja + ",'" + myk_geoz.id_celda + "','" + myk_geoz.fila + "'," + myk_geoz.columna + ",'" + myk_geoz.geoz + "','" + myk_geoz.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));
            }
        }