Exemple #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Esta seguro que desea ELIMINAR el registro?", "¿Eliminar?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                lblEstado.Text      = "<<<ELIMINANDO>>>";
                lblEstado.ForeColor = Color.FromArgb(255, 255, 255);

                ciudad pCiudad = new ciudad();
                pCiudad.id     = int.Parse(txtId.Text.Trim());
                pCiudad.nomCiu = txtNombre.Text.Trim();
                int delResul = ciudadDal.delCiudad(pCiudad);
                if (delResul > 0)
                {
                    MessageBox.Show("¡Registro ELIMINADO con exito!", "¡Eliminando!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    rNew();
                }
                else
                {
                    MessageBox.Show("¡Registro no fue encontrado!", "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                rNew();
            }
        }
Exemple #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            ciudad pCiudad = new ciudad();

            pCiudad.id     = int.Parse(txtId.Text.Trim());
            pCiudad.nomCiu = txtNombre.Text.Trim();
            int updResul = ciudadDal.updCiudad(pCiudad);

            if (updResul > 0)
            {
                MessageBox.Show("Ciudad Modificado con exito!!", "Modificando", MessageBoxButtons.OK, MessageBoxIcon.Information);
                rNew();
            }
            else
            {
                int resultado = ciudadDal.addCiudad(pCiudad);
                if (resultado > 0)
                {
                    MessageBox.Show("Ciudad Guardada con exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    rNew();
                }
                else
                {
                    MessageBox.Show("No se pudo guardad la Ciudad", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemple #3
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);
        }
Exemple #4
0
        public static int addCiudad(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 = "insertCiudad";

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

                    retorno = cmd.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.ToString(), "ERROR AL INSERTAR EL REGISTRO CIUDAD");
                }
                finally
                {
                    conexion.Close();
                }
            }
            return(retorno);
        }
Exemple #5
0
        private void dgvCiudad_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            ciudad modCiu = new ciudad();

            modCiu              = ciudadDal.ObtenerCiudad((int)dgvCiudad.CurrentRow.Cells["ID"].Value);
            lblEstado.Text      = "<<<Consultando>>>";
            lblEstado.ForeColor = Color.FromArgb(65, 105, 225);
            txtId.Text          = modCiu.id.ToString();
            txtNombre.Text      = modCiu.nomCiu.ToString();
            ctrlInicio(true);
            txtNombre.Enabled = false;
        }
Exemple #6
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);
        }
Exemple #7
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);
        }