Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                var c = new DMunicipio();
                c.Id_Municipio = Convert.ToInt32(textBox1.Text);

                if (NMunicipio.Eliminar(c))
                {
                    MessageBox.Show("Se elimino correctamente", "Aviso");
                    id_municipio();
                    listarmunicipios();
                    listarZonas();
                    limpiar();
                    button1.Enabled = true;
                    button2.Enabled = false;
                    button3.Enabled = false;
                    button4.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Error", "Aviso");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         var c = new DMunicipio();
         c.Id_Municipio = Convert.ToInt32(textBox1.Text);
         c.Nombre       = textBox2.Text.ToUpper();
         c.Id_zona      = Convert.ToInt32(comboBox1.SelectedValue);
         if (NMunicipio.Actualizar(c))
         {
             MessageBox.Show("Se actualizo correctamente", "Aviso");
             id_municipio();
             listarmunicipios();
             listarZonas();
             limpiar();
             button1.Enabled = true;
             button2.Enabled = false;
             button3.Enabled = false;
             button4.Enabled = false;
         }
         else
         {
             MessageBox.Show("Error", "Aviso");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox2.Text != "")
                {
                    var c = new DMunicipio();
                    c.Id_Municipio = Convert.ToInt32(textBox1.Text);
                    c.Nombre       = textBox2.Text;
                    c.Id_zona      = Convert.ToInt32(zona);
                    if (NMunicipio.Agregar(c))
                    {
                        MessageBox.Show("Datos guardados correctamente", "Aviso");
                        id_municipio();
                        listarmunicipios();
                        listarZonas();
                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("Error", "Aviso");
                    }
                }

                else
                {
                    MessageBox.Show("Error", "Aviso");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void FormRepPorMunicipio_Load(object sender, EventArgs e)
        {
            DataTable datos = new DataTable();

            datos = NMunicipio.ListaMunicipios();
            comboBox1.DataSource    = datos;
            comboBox1.DisplayMember = "Municipio";
            comboBox1.ValueMember   = "Id_Municipio";
        }
Ejemplo n.º 5
0
 private void id_municipio()
 {
     try
     {
         var val = new DMunicipio();
         val.Id_Municipio = NMunicipio.Id() + 1;
         textBox1.Text    = val.Id_Municipio.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 6
0
        private void btnGuardar_Click_1(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtNombre.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtNombre, "Ingrese un Nombre");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NMunicipio.Insertar(this.txtNombre.Text, this.txtDes.Text, Convert.ToInt32(this.cbIdDepartamento.SelectedValue));
                    }
                    else
                    {
                        rpta = NMunicipio.Editar(Convert.ToInt32(this.txtIdMunipio.Text),
                                                 this.txtNombre.Text, this.txtDes.Text, Convert.ToInt32(this.cbIdDepartamento.SelectedValue));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }
                    this.Mostrar();
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 7
0
 private void ListaMunicipio()
 {
     try
     {
         DataTable datos = new DataTable();
         datos = NMunicipio.ListaMunicipios();
         comboBox2.DataSource    = datos;
         comboBox2.DisplayMember = "Municipio";
         comboBox2.ValueMember   = "Id_Municipio";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 8
0
 private void listarmunicipios()
 {
     try
     {
         DataTable datos = new DataTable();
         datos = NMunicipio.ListaMunicipios();
         dataGridView1.DataSource = datos;
         dataGridView1.Refresh();
         this.dataGridView1.Columns["Id_Zona"].Visible = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 9
0
        private void btnElimnar_Click_1(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "SEGURIDAD DEL SISTEMA", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (Opcion == DialogResult.OK)
                {
                    string Codigo;
                    string Rpta = "";

                    foreach (DataGridViewRow row in dataListado.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Codigo = Convert.ToString(row.Cells[1].Value);
                            Rpta   = NMunicipio.Eliminar(Convert.ToInt32(Codigo));

                            if (Rpta.Equals("OK"))
                            {
                                this.MensajeOk("Se Eliminó Correctamente el registro");
                            }
                            else
                            {
                                this.MensajeError(Rpta);
                            }
                        }
                    }
                    this.Mostrar();
                    this.Limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 10
0
 private void BuscarNombre()
 {
     this.dataListado.DataSource = NMunicipio.BuscarNombre(this.txtBuscar.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Ejemplo n.º 11
0
 private void Mostrar()
 {
     this.dataListado.DataSource = NMunicipio.Mostrar();
     this.OcultarColumnas();
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count);
 }