/// <summary> /// Metodo que llena el grid principal de los reportes generados /// </summary> private void LlenarGrid() { try { TransferenciaMateriales_Negocio Neg = new TransferenciaMateriales_Negocio(); List <TransferenciaMateriales> Lista = Neg.ObtenerTransferenciaMateriales(Comun.Conexion); this.dgvTransferencia.AutoGenerateColumns = false; this.dgvTransferencia.DataSource = Lista; } catch (Exception ex) { throw ex; } }
/// <summary> /// Este metodo llena el grid principal de los reportes de acuerdo a el filtro de busqueda /// muestra los resultados que son iguales. /// </summary> /// <param name="fechaBuscar"> Es el valor de la fecha que se eligio en la interfaz</param> private void LlenarGridBusqueda(DateTime fechaBuscar) { try { DateTime fecha = DateTime.MinValue; fecha = fecha.AddDays((double)fechaBuscar.Day - 1); fecha = fecha.AddMonths(fechaBuscar.Month - 1); fecha = fecha.AddYears(fechaBuscar.Year - 1); TransferenciaMateriales_Negocio a = new TransferenciaMateriales_Negocio(); List <TransferenciaMateriales> Lista = a.ObtenerTransferenciaMaterialesBusqueda(Comun.Conexion, fecha); this.dgvTransferencia.AutoGenerateColumns = false; this.dgvTransferencia.DataSource = Lista; } catch (Exception ex) { throw ex; } }
/// <summary> /// Llena los combos de los empleados para transferencia de sus materiales /// </summary> private void LlenarCombos() { try { TransferenciaMateriales Datos = new TransferenciaMateriales { Conexion = Comun.Conexion, Opcion = 1 }; TransferenciaMateriales_Negocio SN = new TransferenciaMateriales_Negocio(); this.cmbEOrigen.DataSource = SN.LlenarComboEmpleado(Datos); this.cmbEOrigen.DisplayMember = "Empleado"; this.cmbEOrigen.ValueMember = "IDEmpleado"; //otro combo this.cmbEDestino.DataSource = SN.LlenarComboEmpleado(Datos); this.cmbEDestino.DisplayMember = "Empleado"; this.cmbEDestino.ValueMember = "IDEmpleado"; } catch (Exception ex) { throw ex; } }
private void btnGuardar_Click(object sender, EventArgs e) { try { this.txtMensajeError.Visible = false; List <Error> Errores = this.ValidarDatos(); if (Errores.Count == 0) { this.Visible = false; TransferenciaMateriales Datos = this.ObtenerDatos(); TransferenciaMateriales_Negocio Neg = new TransferenciaMateriales_Negocio(); int IDTransferencia = Neg.GenerarTransferencia(Comun.Conexion, Datos.IDEmpleado, Datos.IDEmpleadoDestino, Datos.Observaciones, Comun.IDUsuario); if (IDTransferencia > 0) { //Generar el reporte frmVerReporteTransferenciaMateriales VerReporte = new frmVerReporteTransferenciaMateriales(IDTransferencia); VerReporte.ShowDialog(); VerReporte.Dispose(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Ocurrió un error al generar el reporte.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Visible = true; } else { this.MostrarMensajeError(Errores); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNuevaTransferenciaMateriales ~ btnGuardar_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GenerarReporteTransferenciaMateriales() { try { reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); reportViewer1.ZoomMode = ZoomMode.Percent; reportViewer1.ZoomPercent = 100; reportViewer1.LocalReport.DataSources.Clear(); TransferenciaMateriales_Negocio Neg = new TransferenciaMateriales_Negocio(); TransferenciaMaterialesGeneral DatosReporte = Neg.ObtenerDetalleReporteTransferenciaMateriales(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 TRANSFERENCIA DE MATERIALES"); 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("EmpleadoO", DatosReporte.EmpleadoO); Parametros[6] = new ReportParameter("EmpleadoD", DatosReporte.EmpleadoD); this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.TransferenciaMateriales.rdlc"; reportViewer1.LocalReport.SetParameters(Parametros); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("TransferenciaMateriales", DatosReporte.Detalle)); this.reportViewer1.RefreshReport(); } catch (Exception ex) { throw ex; } }