private void BtnEliminar_Click_1(object sender, EventArgs e)
        {
            if (txtCodigo.Text == string.Empty)
            {
                MensajeError("Seleccione un registro");
            }
            else
            {
                try
                {
                    DialogResult Opcion;
                    Opcion = MessageBox.Show("Estas seguro de eliminar este Funcionario", "Sistema de Reservas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                    if (Opcion == DialogResult.OK)
                    {
                        string Rpta = "";
                        Rpta = NCargos.Eliminar(Convert.ToInt32(txtCodigo.Text));

                        if (Rpta.Equals("OK"))
                        {
                            this.MensajeOk("Se Eliminó Correctamente el registro");
                        }
                        else
                        {
                            this.MensajeError("No se pueden eliminar resitros que tengan referencias" + Rpta);
                        }
                        this.Mostrar();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }
 private void cargarCargos()
 {
     cbCargo.DataSource    = NCargos.Mostrar();
     cbCargo.ValueMember   = "CodigoC";
     cbCargo.DisplayMember = "Cargo";
 }
 private void Buscar()
 {
     this.dgvRegistros.DataSource = NCargos.Buscar(this.txtBuscarCargo.Text, this.cbBuscarEstado.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total de registros: " + Convert.ToString(dgvRegistros.Rows.Count);
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";
                if (this.txtcargo.Text == string.Empty || this.txtDescripcion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtDescripcion, "Ingrese el nombre");
                    errorIcono.SetError(txtcargo, "Ingrese el apellido");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        Rpta = NCargos.Insertar(
                            this.txtcargo.Text,
                            Convert.ToDateTime(DateTime.Now.ToShortTimeString()),
                            "ACTIVO",
                            this.txtDescripcion.Text
                            );
                    }
                    else
                    {
                        Rpta = NCargos.Editar(Convert.ToInt32(txtCodigo.Text),
                                              this.txtcargo.Text,
                                              this.cbEstado.Text,
                                              this.txtDescripcion.Text
                                              );
                    }

                    if (Rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se insertó de forma correcta el registro");
                            errorIcono.Clear();
                            txtCodigo.Visible = true;
                            label10.Visible   = true;
                        }
                        else
                        {
                            this.MensajeOk("Se actualizó de forma correcta el registro");
                            errorIcono.Clear();
                        }
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    dgvRegistros.Enabled = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
 private void Mostrar()
 {
     this.dgvRegistros.DataSource = NCargos.Mostrar();
     this.OcultarColumnas();
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dgvRegistros.Rows.Count);
 }