Example #1
0
 //COMBOBOX CMBPRESENTACION
 private void ListaPresentacion()
 {
     cmbPresentacion.DataSource    = NegocioPresentacion.Mostrar();
     cmbPresentacion.ValueMember   = "IdPresentacion";
     cmbPresentacion.DisplayMember = "Presentacion";
     cmbPresentacion.SelectedValue = 0;
     AutocompletarPresentacion();
 }
Example #2
0
        // CARGA DE ITEMS AUTOCOMPLETE EN FUENTE - PRESENTACION
        private AutoCompleteStringCollection ItemsPresentacion()
        {
            DataTable listaItems = NegocioPresentacion.Buscar(cmbPresentacion.Text);
            AutoCompleteStringCollection cadenaPresentacion = new AutoCompleteStringCollection();

            foreach (DataRow row in listaItems.Rows)
            {
                cadenaPresentacion.Add(Convert.ToString(row["Presentacion"]));
            }
            return(cadenaPresentacion);
        }
Example #3
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            //IdPresentacion = Convert.ToInt32(txtIdPresentacion.Text);
            Presentacion = txtPresentacion.Text;
            Descripcion  = txtDescripcion.Text;
            string agregarActualizar = "";

            if (Presentacion == string.Empty)
            {
                errorIcono.SetError(txtPresentacion, "Ingrese el nombre de la presentación.");
                txtPresentacion.SelectAll();
            }
            else
            {
                try
                {
                    switch (ctrlSeleccionado)
                    {
                    case 0:    //INSERTAR
                        agregarActualizar = NegocioPresentacion.Insertar(Presentacion.Trim().ToUpper(),
                                                                         Descripcion.Trim());
                        NotificacionOk("Presentación guardada", "Guardando");     // Aqui antes iba el método mensajeOk pero lo reemplacé por
                        //un icono de notificación
                        HabilitarBotones();
                        Limpiar();
                        txtPresentacion.SelectAll();
                        break;

                    case 1:    //EDITAR
                        agregarActualizar = NegocioPresentacion.Editar(IdPresentacion,
                                                                       Presentacion.Trim().ToUpper(), Descripcion.Trim());
                        txtPresentacion.Enabled = false;
                        txtDescripcion.ReadOnly = true;
                        btnEditar.Visible       = true;
                        btnInsertar.Visible     = false;
                        NotificacionOk("Presentación modificada", "Modificando");     // Aqui antes iba el método mensajeOk pero lo reemplacé por
                        //un icono de notificación
                        break;

                    default:
                        MessageBox.Show(agregarActualizar);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
                //Mostrar();
            }
        }
Example #4
0
 //MOSTRAR
 public void Mostrar()
 {
     dgvListado.DataSource = NegocioPresentacion.Mostrar();
     NombreColumnas();
     if (dgvListado.RowCount == 0)
     {
         chkEliminarVarios.Enabled       = false;
         btnEliminar.Enabled             = false;
         dgvListado.ColumnHeadersVisible = false;
     }
     else
     {
         chkEliminarVarios.Enabled       = true;
         dgvListado.ColumnHeadersVisible = true;
     }
     if (!chkEliminarVarios.Checked)
     {
         OcultarColumnas();
     }
 }
Example #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            string       idPresentacion = "";
            string       respuesta      = "";
            DialogResult Opcion;

            try
            {
                //SELECCION DE VARIOS REGISTROS
                if (chkEliminarVarios.Checked)
                {
                    Opcion = MessageBox.Show(
                        "¿Realmente desea eliminar los registros seleccionados?",
                        "Eliminando registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (Opcion == DialogResult.Yes)
                    {
                        foreach (DataGridViewRow row in dgvListado.Rows)
                        {
                            if (Convert.ToBoolean(row.Cells[0].Value))
                            {
                                idPresentacion = Convert.ToString(row.Cells[1].Value);
                                respuesta      = NegocioPresentacion.Eliminar(Convert.ToInt32(idPresentacion));
                            }
                        }
                        if (respuesta.Equals("OK"))
                        {
                            NotificacionOk("Registros eliminados", "Eliminando");
                        }
                        else
                        {
                            NotificacionError("Los registros no se eliminaron.", "Error");
                        }
                    }
                }
                else
                {
                    //SELECCION DE UN REGISTRO
                    Opcion = MessageBox.Show(
                        "¿Realmente desea eliminar el registro seleccionado?",
                        "Eliminando registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (Opcion == DialogResult.Yes)
                    {
                        idPresentacion = Convert.ToString(dgvListado.CurrentRow.Cells[1].Value);
                        respuesta      = NegocioPresentacion.Eliminar(Convert.ToInt32(idPresentacion));
                        if (respuesta.Equals("OK"))
                        {
                            NotificacionOk("Registro eliminado", "Eliminando");
                        }
                        else
                        {
                            NotificacionError("El registro no se eliminó.", "Error");
                            MessageBox.Show(respuesta);
                        }
                    }
                }
                chkEliminarVarios.Checked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
            Mostrar();
            ctrlSeleccionado = 0;
        }
Example #6
0
 //METODO BUSCAR
 private void Buscar()
 {
     dgvListado.DataSource = NegocioPresentacion.Buscar(txtBuscar.Text);
     OcultarColumnas();
 }