Exemplo n.º 1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public f_ferias getObjectf_ferias(System.String myID)
        {
            f_ferias myf_ferias = new f_ferias();
            CnxBase  myBase     = new CnxBase();
            string   reqSQL     = "SELECT gid,id,comuna,nombre,desde,hasta,dia_1,dia_2,the_geom FROM f_ferias WHERE (the_geom='" + myID + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myf_ferias.gid      = Convert.ToInt32(myReader[0]);
                    myf_ferias.id       = Convert.ToInt32(myReader[1]);
                    myf_ferias.comuna   = myReader[2].ToString();
                    myf_ferias.nombre   = myReader[3].ToString();
                    myf_ferias.desde    = myReader[4].ToString();
                    myf_ferias.hasta    = myReader[5].ToString();
                    myf_ferias.dia_1    = myReader[6].ToString();
                    myf_ferias.dia_2    = myReader[7].ToString();
                    myf_ferias.the_geom = myReader[8].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(myf_ferias);
        }
Exemplo n.º 2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(f_ferias myf_ferias)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE f_ferias SET gid=" + myf_ferias.gid + ",id=" + myf_ferias.id + ",comuna='" + myf_ferias.comuna + "',nombre='" + myf_ferias.nombre + "',desde='" + myf_ferias.desde + "',hasta='" + myf_ferias.hasta + "',dia_1='" + myf_ferias.dia_1 + "',dia_2='" + myf_ferias.dia_2 + "',the_geom='" + myf_ferias.the_geom + "' WHERE (the_geom=" + myf_ferias.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));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(f_ferias myf_ferias)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO f_ferias (gid,id,comuna,nombre,desde,hasta,dia_1,dia_2,the_geom) VALUES (" + myf_ferias.gid + "," + myf_ferias.id + ",'" + myf_ferias.comuna + "','" + myf_ferias.nombre + "','" + myf_ferias.desde + "','" + myf_ferias.hasta + "','" + myf_ferias.dia_1 + "','" + myf_ferias.dia_2 + "','" + myf_ferias.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));
            }
        }