Beispiel #1
0
        public static string findOne(string id)
        {
            string          nomTitel = "";
            MySqlConnection conexion = Conectando.conectando();

            try
            {
                MySqlCommand _comando = new MySqlCommand(string.Format(
                                                             "SELECT nomTiTel FROM tipotel where id=" + id), conexion);
                MySqlDataReader _reader = _comando.ExecuteReader();
                while (_reader.Read())
                {
                    nomTitel = _reader.GetString(0);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO TIPOTEL");
            }
            finally
            {
                conexion.Close();
            }
            return(nomTitel);
        }
Beispiel #2
0
        public static Tipos obtenerReg(int pId)
        {
            Tipos           pObjet   = new Tipos();
            MySqlConnection conexion = Conectando.conectando();

            try
            {
                MySqlCommand _comando = new MySqlCommand(string.Format(
                                                             "SELECT id, parentezco FROM parentezco where id={0}", pId), conexion);
                MySqlDataReader _reader = _comando.ExecuteReader();
                while (_reader.Read())
                {
                    pObjet.id  = _reader.GetInt32(0);
                    pObjet.nom = _reader.GetString(1);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), "ERROR AL BUSCAR EL REGISTRO PARIENTES");
            }
            finally
            {
                conexion.Close();
            }
            return(pObjet);
        }
Beispiel #3
0
        public static int addTitel(Tipos pTitel)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "inTiTel";

                    cmd.Parameters.AddWithValue("pTiTel", pTitel.nom);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO TIPOTEL");
                }
                finally
                {
                    conexion.Close();
                }
            }
            return(retorno);
        }
Beispiel #4
0
        public static Tipos ObtenerTel(int pId)
        {
            Tipos           pTel     = new Tipos();
            MySqlConnection conexion = Conectando.conectando();

            try
            {
                MySqlCommand _comando = new MySqlCommand(string.Format(
                                                             "SELECT id, nomTiTel FROM tipotel where id={0}", pId), conexion);
                MySqlDataReader _reader = _comando.ExecuteReader();
                while (_reader.Read())
                {
                    pTel.id  = _reader.GetInt32(0);
                    pTel.nom = _reader.GetString(1);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO TIPOTEL");
            }
            finally
            {
                conexion.Close();
            }
            return(pTel);
        }
Beispiel #5
0
        public static int update(Tipos pObjet)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "updzona";

                    cmd.Parameters.AddWithValue("pId", pObjet.id);
                    cmd.Parameters.AddWithValue("pNomZona", pObjet.nom);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "ERROR AL ACTUALIZAR EL REGISTRO ZONA");
                }
                finally
                {
                    conexion.Close();
                }
            }

            return(retorno);
        }
Beispiel #6
0
        public static int addSector(sector pSector)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "insertSector";

                    cmd.Parameters.AddWithValue("pIdCiu", pSector.idCiu);
                    cmd.Parameters.AddWithValue("pNomSec", pSector.nomSector);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO");
                }
                finally
                {
                    conexion.Close();
                }
            }
            return(retorno);
        }
Beispiel #7
0
        public static int updNumSig3(int pNextNum, string peCampo)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "updEnum3";

                    cmd.Parameters.AddWithValue("pCampo", peCampo);
                    cmd.Parameters.AddWithValue("pValor", pNextNum);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
                finally
                {
                    conexion.Close();
                }
            }

            return(retorno);
        }
Beispiel #8
0
        public static int updCiudad(ciudad pCiudad)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "updateCiudad";

                    cmd.Parameters.AddWithValue("pId", pCiudad.id);
                    cmd.Parameters.AddWithValue("pNomC", pCiudad.nomCiu);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
                finally
                {
                    conexion.Close();
                }
            }

            return(retorno);
        }
Beispiel #9
0
        public static int insertar(Tipos pObjet)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "inparent";

                    cmd.Parameters.AddWithValue("pNom", pObjet.nom);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO PARIENTES");
                }
                finally
                {
                    conexion.Close();
                }
            }
            return(retorno);
        }
Beispiel #10
0
        public static int updSector(sector pSector)
        {
            int             retorno  = 0;
            MySqlConnection conexion = Conectando.conectando();

            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = conexion;
                    cmd.CommandText = "updateSector";

                    cmd.Parameters.AddWithValue("pId", pSector.id);
                    cmd.Parameters.AddWithValue("pIdCiu", pSector.idCiu);
                    cmd.Parameters.AddWithValue("pNomSec", pSector.nomSector);

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "Error en actualizar el registro");
                }
                finally
                {
                    conexion.Close();
                }
            }

            return(retorno);
        }
Beispiel #11
0
        public static ciudad ObtenerCiudad(int pId)
        {
            ciudad pCiudad = new ciudad();

            MySqlConnection conexion = Conectando.conectando();
            MySqlCommand    _comando = new MySqlCommand(string.Format(
                                                            "SELECT idCiudad, nomCiudad FROM ciudad where idciudad={0}", pId), conexion);
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                pCiudad.id     = _reader.GetInt32(0);
                pCiudad.nomCiu = _reader.GetString(1);
            }
            conexion.Close();
            return(pCiudad);
        }
Beispiel #12
0
        public static DataTable fillCbox(string pTable, string pCampo1, string pWhere)
        {
            DataTable    dt       = new DataTable();
            string       sql      = "SELECT * FROM " + pTable + " WHERE " + pCampo1 + "=" + pWhere + "";
            MySqlCommand _comando = new MySqlCommand(sql, Conectando.conectando());

            try
            {
                MySqlDataAdapter _adap = new MySqlDataAdapter(_comando);
                _adap.Fill(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error en ejecutar el comando");
            }
            return(dt);
        }
Beispiel #13
0
        public static sector ObtenerSec(int pId)
        {
            sector pSector = new sector();

            MySqlConnection conexion = Conectando.conectando();
            MySqlCommand    _comando = new MySqlCommand(string.Format(
                                                            "SELECT idsector, idciudad, nomsector FROM sector where idsector={0}", pId), conexion);
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                pSector.id        = _reader.GetInt32(0);
                pSector.idCiu     = _reader.GetInt32(1);
                pSector.nomSector = _reader.GetString(2);
            }
            conexion.Close();
            return(pSector);
        }
Beispiel #14
0
        public static int buscar(string pCampo)//pCampo se refiere al campo a buscar
        {
            int             numNext  = 0;
            MySqlConnection conexion = Conectando.conectando();
            string          pString  = "SELECT " + pCampo + " FROM enum WHERE id='1'";
            MySqlCommand    _comando = new MySqlCommand(string.Format(pString), conexion);

            try
            {
                MySqlDataReader _reader = _comando.ExecuteReader();
                while (_reader.Read())
                {
                    numNext = _reader.GetInt32(0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error en la Numeración Buscada!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            conexion.Close();
            return(numNext + 1);
        }
Beispiel #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     Conectando.conectando();
     MessageBox.Show("Conectado");
 }
Beispiel #16
0
        public static List <sector> buscar(string filtroCiudad)
        {
            List <sector> _lista   = new List <sector>();
            MySqlCommand  _comando = new MySqlCommand(string.Format(
                                                          "SELECT idsector, nomsector FROM sector where idciudad=" + filtroCiudad), Conectando.conectando());

            try
            {
                MySqlDataReader _reader = _comando.ExecuteReader();
                while (_reader.Read())
                {
                    sector pSector = new sector();
                    pSector.id = _reader.GetInt32(0);
                    //pSector.idCiu = _reader.GetInt32(1);
                    pSector.nomSector = _reader.GetString(1);

                    _lista.Add(pSector);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL BUSCAR REGISTRO");
            }


            return(_lista);
        }
Beispiel #17
0
        public static List <Tipos> buscar()
        {
            List <Tipos> _lista   = new List <Tipos>();
            MySqlCommand _comando = new MySqlCommand(string.Format(
                                                         "SELECT id, nomTiTel FROM tipotel"), Conectando.conectando());

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Tipos tipotel = new Tipos();
                tipotel.id  = _reader.GetInt32(0);
                tipotel.nom = _reader.GetString(1);

                _lista.Add(tipotel);
            }

            return(_lista);
        }
Beispiel #18
0
        public static List <ciudad> buscar()
        {
            List <ciudad> _lista   = new List <ciudad>();
            MySqlCommand  _comando = new MySqlCommand(string.Format(
                                                          "SELECT idCiudad, nomCiudad FROM ciudad"), Conectando.conectando());

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                ciudad pCiudad = new ciudad();
                pCiudad.id     = _reader.GetInt32(0);
                pCiudad.nomCiu = _reader.GetString(1);

                _lista.Add(pCiudad);
            }

            return(_lista);
        }