Validar un datatable antes de Imprimir
Publicado por cjgallardo96 (1 intervención) el 17/07/2014 15:58:05
Saludos Expertos, intentare ser lo más explicito posible ( espero), resulta que deseo imprimir un registro que tiene una cabecera y detalle, el asunto es que esos datos los tengo atrapado en un DataSet . Después lo invoco en un Control "BotonImprimir" para que se muestre en un CrystalReportViewer , el asunto es que cuando modifico una fila(s) de la columna "Cant." del detalle y hago click en imprimir me carga o muestra la última modificación (valores de memoria) sin a ver sido grabadas. en tal caso la pgta de fondo es "Existe alguna forma simplificada de validar cualquier modificación de filas" e impedir que IMPRIMA hasta que no se haya grabado , salvo cuando los datos de memoria (datatable)están iguales que las filas de la DB
Acá un fragmento de mi código hecho Visual Basic 2008 y de ante manos muchas gracias por sus aportes y disculpen que soy novato.
Public Sub Procedimiento_de_impresion()
' Creaci'on de Tabla de Memoria para la Tabla Pedido Interno
Dim dt_Pedido_Interno_mmpp As New DataTable("Pedido_Interno_MMPP")
With dt_Pedido_Interno_mmpp.Columns
'***** Cabecera
.Add("Nro_Pedido")
.Add("FechaRegist")
.Add("Resp_Regist")
.Add("Resp_Trabaj")
.Add("Estado")
.Add("Obsevac_Gnral")
End With
' Para Materiales .:::
For i As Integer = 0 To dt_MP.Rows.Count - 1
Rw = dt_Pedido_Interno_mmpp.NewRow
' ***** Cabecera
Rw(0) = Lbl_NroPedido.Text
Rw(1) = Lbl_FechaRegistro.Text
Rw(2) = Lbl_Responsable.Text
Rw(3) = Cbo_RespEntrega.Text
Rw(4) = Lbl_Estado.Text
Rw(5) = Txt_ObsCreac.Text
' ***** Detalle
Rw(13) = dt_MP.Rows(i)(1) ' Id
Rw(14) = dt_MP.Rows(i)(2) ' Cod_Id
Rw(15) = dt_MP.Rows(i)(3) ' Codigo
Rw(16) = dt_MP.Rows(i)(4) ' Material
Rw(17) = dt_MP.Rows(i)(5) ' U.M.
Rw(18) = dt_MP.Rows(i)(6) ' Indicador
Rw(19) = dt_MP.Rows(i)(7) ' Nro. Lote
Rw(20) = dt_MP.Rows(i)(8) ' Stock
Rw(21) = dt_MP.Rows(i)(9) ' Cant
Rw(22) = dt_MP.Rows(i)(10) ' Precio
Rw(23) = dt_MP.Rows(i)(11) ' SubT(S/.)
Rw(24) = dt_MP.Rows(i)(12) ' Observaciones
dt_Pedido_Interno_mmpp.Rows.Add(Rw)
Next
' ******** Declaramos el Dataset
MiDataset.Reset()
MiDataset.Tables.Add(dt_Pedido_Interno_mmpp)
End Sub
Private Sub TS_VistaPrevia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TS_VistaPrevia.Click
' Para Materiales
ObjCE.str_UM = "Kg."
Dim Dx As DataTable = ObjCN.PIM_ListarDatosDetallePedidoInternoMMPPparaModificacion_CN(ObjCE)
For Each fila As DataGridViewRow In Dgv_Materiales.Rows
For i As Integer = 0 To Dx.Rows.Count - 1
If fila.Cells("Cant.").Value = Dx.Rows(i)(6) Then
Procedimiento_de_impresion() 'Llamado
RptDoc = New Reporte_PedidoProduccion
RptDoc.SetDataSource(MiDataset)
Dim frm As New FrmReportes
' --------------
RptDoc.Refresh() ' Actualizo el Registro antes de mostrarse ...
' --------------
frm.crv.ReportSource = RptDoc
frm.crv.RefreshReport()
frm.crv.Refresh()
frm.ShowDialog()
frm.Dispose()
Exit Sub
End If
If fila.Cells("Cant.").Value <> Dx.Rows(i)(6) Then
MessageBox.Show("Acaba de hacer una Modificación, Agradeceríamos" & vbCrLf & _
"que antes de Imprimir Grabe el Registro", Acceso.CompañiaSoftware, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
' Exit Sub
End If
Next
Exit Sub
Next
En Sub
P.D En el For solo valida la primera fila cuando no es igual pero al resto no... que estoy haciendo mal?
Atte.-
Carlos Javier del Águila Gallardo
Infinitas gracias
Acá un fragmento de mi código hecho Visual Basic 2008 y de ante manos muchas gracias por sus aportes y disculpen que soy novato.
Public Sub Procedimiento_de_impresion()
' Creaci'on de Tabla de Memoria para la Tabla Pedido Interno
Dim dt_Pedido_Interno_mmpp As New DataTable("Pedido_Interno_MMPP")
With dt_Pedido_Interno_mmpp.Columns
'***** Cabecera
.Add("Nro_Pedido")
.Add("FechaRegist")
.Add("Resp_Regist")
.Add("Resp_Trabaj")
.Add("Estado")
.Add("Obsevac_Gnral")
End With
' Para Materiales .:::
For i As Integer = 0 To dt_MP.Rows.Count - 1
Rw = dt_Pedido_Interno_mmpp.NewRow
' ***** Cabecera
Rw(0) = Lbl_NroPedido.Text
Rw(1) = Lbl_FechaRegistro.Text
Rw(2) = Lbl_Responsable.Text
Rw(3) = Cbo_RespEntrega.Text
Rw(4) = Lbl_Estado.Text
Rw(5) = Txt_ObsCreac.Text
' ***** Detalle
Rw(13) = dt_MP.Rows(i)(1) ' Id
Rw(14) = dt_MP.Rows(i)(2) ' Cod_Id
Rw(15) = dt_MP.Rows(i)(3) ' Codigo
Rw(16) = dt_MP.Rows(i)(4) ' Material
Rw(17) = dt_MP.Rows(i)(5) ' U.M.
Rw(18) = dt_MP.Rows(i)(6) ' Indicador
Rw(19) = dt_MP.Rows(i)(7) ' Nro. Lote
Rw(20) = dt_MP.Rows(i)(8) ' Stock
Rw(21) = dt_MP.Rows(i)(9) ' Cant
Rw(22) = dt_MP.Rows(i)(10) ' Precio
Rw(23) = dt_MP.Rows(i)(11) ' SubT(S/.)
Rw(24) = dt_MP.Rows(i)(12) ' Observaciones
dt_Pedido_Interno_mmpp.Rows.Add(Rw)
Next
' ******** Declaramos el Dataset
MiDataset.Reset()
MiDataset.Tables.Add(dt_Pedido_Interno_mmpp)
End Sub
Private Sub TS_VistaPrevia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TS_VistaPrevia.Click
' Para Materiales
ObjCE.str_UM = "Kg."
Dim Dx As DataTable = ObjCN.PIM_ListarDatosDetallePedidoInternoMMPPparaModificacion_CN(ObjCE)
For Each fila As DataGridViewRow In Dgv_Materiales.Rows
For i As Integer = 0 To Dx.Rows.Count - 1
If fila.Cells("Cant.").Value = Dx.Rows(i)(6) Then
Procedimiento_de_impresion() 'Llamado
RptDoc = New Reporte_PedidoProduccion
RptDoc.SetDataSource(MiDataset)
Dim frm As New FrmReportes
' --------------
RptDoc.Refresh() ' Actualizo el Registro antes de mostrarse ...
' --------------
frm.crv.ReportSource = RptDoc
frm.crv.RefreshReport()
frm.crv.Refresh()
frm.ShowDialog()
frm.Dispose()
Exit Sub
End If
If fila.Cells("Cant.").Value <> Dx.Rows(i)(6) Then
MessageBox.Show("Acaba de hacer una Modificación, Agradeceríamos" & vbCrLf & _
"que antes de Imprimir Grabe el Registro", Acceso.CompañiaSoftware, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
' Exit Sub
End If
Next
Exit Sub
Next
En Sub
P.D En el For solo valida la primera fila cuando no es igual pero al resto no... que estoy haciendo mal?
Atte.-
Carlos Javier del Águila Gallardo
Infinitas gracias
Valora esta pregunta


0