コード例 #1
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            try
            {
                dgvFallas.DataSource = null;

                // Mostrar los datos del reporte
                DateTime inicio = dtpInicio.Value;
                DateTime fin    = dtpFin.Value;

                FallaCartucho falla = null;
                int           est   = -1;
                if (cboFalla.SelectedIndex > 0)
                {
                    falla = (FallaCartucho)cboFalla.SelectedItem;
                }
                if (cboEstado.SelectedIndex > 0)
                {
                    est = cboEstado.SelectedIndex - 1;
                }
                string numeroCartucho = txtCartucho.Text;

                Cartucho c = new Cartucho();
                c.Numero = numeroCartucho;

                _mantenimiento.verificarCartuchoFallas(ref c);

                dgvFallas.DataSource = _mantenimiento.ObtieneDatosFallasCartuchos(inicio, fin, falla, est, c);


                foreach (DataGridViewColumn columna in dgvFallas.Columns)
                {
                    if (columna.ValueType == typeof(decimal))
                    {
                        columna.DefaultCellStyle.Format = "N2";
                    }

                    if (columna.ValueType == typeof(DateTime))
                    {
                        columna.DefaultCellStyle.Format = "dd'/'MM'/'yyyy hh:mm:ss tt";
                    }
                }

                // Habilitar los botones de exportar a excel y graficar el reporte si el mismo tiene datos

                if (dgvFallas.RowCount > 0)
                {
                    btnExportar.Enabled = true;
                }
                else
                {
                    btnExportar.Enabled = false;
                }
            }
            catch (Excepcion ex)
            {
                ex.mostrarMensaje();
            }
        }