private void btnGuardar_Click(object sender, EventArgs e) { try { this.txtMensajeError.Visible = false; List <Error> Errores = this.ValidarDatos(); if (Errores.Count == 0) { ReporteTrabajosRealizados Datos = this.ObtenerDatos(); Reporte_NegocioTrabajosRealizados Neg = new Reporte_NegocioTrabajosRealizados(); int IDReporte = Neg.GenerarReporteTrabajosRealizados(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Comun.IDUsuario); if (IDReporte > 0) { frmVerReporteTrabajosRealizados VerReporte = new frmVerReporteTrabajosRealizados(IDReporte); VerReporte.ShowDialog(); VerReporte.Dispose(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Ocurrió un error al generar el reporte.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { this.MostrarMensajeError(Errores); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNuevoReporteTrabajosRealizados ~ btnGuardar_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private ReporteTrabajosRealizados ObtenerDatosReporte() { try { ReporteTrabajosRealizados DatosAux = new ReporteTrabajosRealizados(); Int32 RowData = this.dgvReportesTrabajosRealizados.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (RowData > -1) { int ID = 0; DataGridViewRow FilaDatos = this.dgvReportesTrabajosRealizados.Rows[RowData]; int.TryParse(FilaDatos.Cells["IDReporte"].Value.ToString(), out ID); DatosAux.IDReporte = ID; DateTime FechaInicio = DateTime.MinValue; DateTime FechaFin = DateTime.MinValue; DateTime.TryParse(FilaDatos.Cells["FechaInicio"].Value.ToString(), out FechaInicio); DateTime.TryParse(FilaDatos.Cells["FechaFin"].Value.ToString(), out FechaFin); } return(DatosAux); } catch (Exception ex) { throw ex; } }
private ReporteTrabajosRealizados ObtenerDatos() { try { ReporteTrabajosRealizados DatosAux = new ReporteTrabajosRealizados(); DatosAux.FechaInicio = dtpFechaInicio.Value; DatosAux.FechaFin = dtpFechaFin.Value; return(DatosAux); } catch (Exception ex) { throw ex; } }
public ReporteTrabajosRealizados ObtenerDetalleReporteTrabajosRealizados(string Conexion, int IDReporte) { try { ReporteTrabajosRealizados Resultado = new ReporteTrabajosRealizados(); DataSet Ds = SqlHelper.ExecuteDataset(Conexion, "Reportes.spCSLDB_get_ReporteTrabajosRealizadosXID", IDReporte); if (Ds != null) { if (Ds.Tables.Count == 2) { DataTableReader Dr = Ds.Tables[0].CreateDataReader(); while (Dr.Read()) { Resultado.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("FechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaInicio")) : DateTime.MinValue; Resultado.FechaFin = !Dr.IsDBNull(Dr.GetOrdinal("FechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaFin")) : DateTime.MinValue; break; } Dr.Close(); List <ReporteTrabajosRealizadosDetalle> Lista = new List <ReporteTrabajosRealizadosDetalle>(); ReporteTrabajosRealizadosDetalle Item; DataTableReader Dr2 = Ds.Tables[1].CreateDataReader(); while (Dr2.Read()) { Item = new ReporteTrabajosRealizadosDetalle(); Item.IDSucursal = !Dr2.IsDBNull(Dr2.GetOrdinal("IDSucursal")) ? Dr2.GetString(Dr2.GetOrdinal("IDSucursal")) : string.Empty; Item.Sucursal = !Dr2.IsDBNull(Dr2.GetOrdinal("Sucursal")) ? Dr2.GetString(Dr2.GetOrdinal("Sucursal")) : string.Empty; Item.IDEmpleado = !Dr2.IsDBNull(Dr2.GetOrdinal("IDEmpleado")) ? Dr2.GetString(Dr2.GetOrdinal("IDEmpleado")) : string.Empty; Item.NombreEmpleado = !Dr2.IsDBNull(Dr2.GetOrdinal("NombreEmpleado")) ? Dr2.GetString(Dr2.GetOrdinal("NombreEmpleado")) : string.Empty; Item.IDServicio = !Dr2.IsDBNull(Dr2.GetOrdinal("IDServicio")) ? Dr2.GetString(Dr2.GetOrdinal("IDServicio")) : string.Empty; Item.NombreServicio = !Dr2.IsDBNull(Dr2.GetOrdinal("NombreServicio")) ? Dr2.GetString(Dr2.GetOrdinal("NombreServicio")) : string.Empty; Item.CantidadServicios = !Dr2.IsDBNull(Dr2.GetOrdinal("CantidadServicios")) ? Dr2.GetInt32(Dr2.GetOrdinal("CantidadServicios")) : 0; Lista.Add(Item); } Dr2.Close(); Resultado.Detalle = Lista; Resultado.Completo = true; } } return(Resultado); } catch (Exception ex) { throw ex; } }
private void btnImpresion_Click_1(object sender, EventArgs e) { try { if (this.dgvReportesTrabajosRealizados.SelectedRows.Count == 1) { ReporteTrabajosRealizados Datos = this.ObtenerDatosReporte(); frmVerReporteTrabajosRealizados VerReporte = new frmVerReporteTrabajosRealizados(Datos.IDReporte); VerReporte.ShowDialog(); VerReporte.Dispose(); } else { MessageBox.Show("Seleccione una fila.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmReporteTrabajosRealizados ~ btnImpresion_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <ReporteTrabajosRealizados> ObtenerReporteTrabajosRealizados(string Conexion) { try { List <ReporteTrabajosRealizados> Lista = new List <ReporteTrabajosRealizados>(); ReporteTrabajosRealizados Item; SqlDataReader Dr = SqlHelper.ExecuteReader(Conexion, "Reportes.spCSLDB_get_ReportesTrabajosRealizados"); while (Dr.Read()) { Item = new ReporteTrabajosRealizados(); Item.IDReporte = !Dr.IsDBNull(Dr.GetOrdinal("IDReporte")) ? Dr.GetInt32(Dr.GetOrdinal("IDReporte")) : 0; Item.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("FechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaInicio")) : DateTime.MinValue; Item.FechaFin = !Dr.IsDBNull(Dr.GetOrdinal("FechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaFin")) : DateTime.MinValue; Lista.Add(Item); } Dr.Close(); return(Lista); } catch (Exception ex) { throw ex; } }
private void GenerarReporteTrabajosRealizados() { try { reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); reportViewer1.ZoomMode = ZoomMode.Percent; reportViewer1.ZoomPercent = 100; reportViewer1.LocalReport.DataSources.Clear(); Reporte_NegocioTrabajosRealizados Neg = new Reporte_NegocioTrabajosRealizados(); ReporteTrabajosRealizados DatosReporte = Neg.ObtenerDetalleReporteTrabajosRealizados(Comun.Conexion, IDReporte); reportViewer1.LocalReport.EnableExternalImages = true; ReportParameter[] Parametros = new ReportParameter[7]; Parametros[0] = new ReportParameter("Empresa", Comun.NombreComercial); Parametros[1] = new ReportParameter("Eslogan", Comun.Eslogan); Parametros[2] = new ReportParameter("Direccion", Comun.Direccion); Parametros[3] = new ReportParameter("TituloReporte", "REPORTE DE TRABAJOS REALIZADOS"); if (File.Exists(@"Resources\Documents\" + Comun.UrlLogo.ToLower())) { string Aux = new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo.ToLower())).AbsoluteUri; Parametros[4] = new ReportParameter("UrlLogo", new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo.ToLower())).AbsoluteUri); } else { Parametros[4] = new ReportParameter("UrlLogo", new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\Default.jpg")).AbsoluteUri); } Parametros[5] = new ReportParameter("FechaInicio", DatosReporte.FechaInicio.ToShortDateString()); Parametros[6] = new ReportParameter("FechaFin", DatosReporte.FechaFin.ToShortDateString()); this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.TrabajosRealizados.rdlc"; reportViewer1.LocalReport.SetParameters(Parametros); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("TrabajosRealizados", DatosReporte.Detalle)); this.reportViewer1.RefreshReport(); } catch (Exception ex) { throw ex; } }