Kolory w gridzie i automatyczne odświeżanie po zmianie konta
- zaimportowane dokumenty czerwoną czcionką, czekające na import czarną (status z DataImportu jako daty; wcześniej porównanie tekstu daty w formacie dd.mm.rrrr nigdy nie dawało czerwonego koloru) - lista odświeża się sama 0,5 s po ostatniej zmianie konta, więc przewijanie kont przytrzymanym klawiszem nie uruchamia serii zapytań - jedno odświeżenie grida po wczytaniu listy zamiast po każdym wierszu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
09dce6a34f
commit
8dc62f8986
1 file changed
+42
-4
+42
-4
@@ -204,6 +204,21 @@ Public Class MainFrm
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' odświeżenie listy po zmianie konta z opóźnieniem - przewijanie listy kont przytrzymanym klawiszem
|
||||
' albo wpisywanie numeru konta nie uruchamia zapytania po każdej zmianie, tylko raz po 0,5 s spokoju
|
||||
Private WithEvents TmKonto As New System.Windows.Forms.Timer With {.Interval = 500}
|
||||
Private WczytaneKonto As String = ""
|
||||
|
||||
Private Sub CbKonto_TextChanged(sender As Object, e As EventArgs) Handles CbKonto.TextChanged
|
||||
TmKonto.Stop()
|
||||
If SourceConnected AndAlso CbKonto.Text <> WczytaneKonto Then TmKonto.Start()
|
||||
End Sub
|
||||
|
||||
Private Sub TmKonto_Tick(sender As Object, e As EventArgs) Handles TmKonto.Tick
|
||||
TmKonto.Stop()
|
||||
If CbKonto.Text <> WczytaneKonto Then OdswiezDane()
|
||||
End Sub
|
||||
|
||||
Private Sub CbMiesiac_TextChanged(sender As Object, e As EventArgs) Handles CbMiesiac.TextChanged
|
||||
If SourceConnected Then
|
||||
Mies = CbMiesiac.Items.IndexOf(CbMiesiac.Text) + 1
|
||||
@@ -243,9 +258,23 @@ Public Class MainFrm
|
||||
OdswiezDane()
|
||||
End Sub
|
||||
|
||||
Private Sub DgvDokumenty_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DgvDokumenty.RowPostPaint
|
||||
If Not DgvDokumenty.Rows(e.RowIndex).Cells("colDataImportu").Value Is DBNull.Value Then
|
||||
If CStr(DgvDokumenty.Rows(e.RowIndex).Cells("colDataImportu").Value) > "1990-01-01" Then DgvDokumenty.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Red
|
||||
' Dokument niezaimportowany ma DataImportu = 1990-01-01 (DT_DataCentrali = 0) albo NULL
|
||||
Private Shared ReadOnly BrakImportu As Date = New Date(1990, 1, 1)
|
||||
|
||||
Private Function CzyZaimportowany(ByVal Wiersz As DataRowView) As Boolean
|
||||
Dim Data As Object = Wiersz("DataImportu")
|
||||
Return Not IsDBNull(Data) AndAlso CDate(Data) > BrakImportu
|
||||
End Function
|
||||
|
||||
' zaimportowane - czerwona czcionka, czekające na import - czarna
|
||||
Private Sub DgvDokumenty_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DgvDokumenty.CellFormatting
|
||||
If e.RowIndex < 0 OrElse e.RowIndex >= BsTbmy_ImpDM_Src.Count Then Return
|
||||
' wiersz z BindingSource, a nie z DgvDokumenty.Rows - nie rozwiązuje współdzielonych wierszy grida
|
||||
If CzyZaimportowany(CType(BsTbmy_ImpDM_Src(e.RowIndex), DataRowView)) Then
|
||||
e.CellStyle.ForeColor = Color.Red
|
||||
e.CellStyle.SelectionForeColor = Color.LightPink
|
||||
Else
|
||||
e.CellStyle.ForeColor = Color.Black
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -411,7 +440,9 @@ Public Class MainFrm
|
||||
|
||||
If Not SourceConnected Then Return
|
||||
|
||||
TmKonto.Stop()
|
||||
Konto = CbKonto.Text
|
||||
WczytaneKonto = Konto
|
||||
ImpFl = 2
|
||||
If RbBlack.Checked Then ImpFl = 0 Else If RbRed.Checked Then ImpFl = 1
|
||||
|
||||
@@ -425,7 +456,14 @@ Public Class MainFrm
|
||||
lbUwaga.Refresh()
|
||||
Application.DoEvents()
|
||||
pos = BsTbmy_ImpDM_Src.Position
|
||||
Tamy_ImpDM_Src.Fill(Me.DsMain.Tbmy_ImpDM_Src, SpFlag, ZakFlag, WewFlag, RM, Rok, Mies, Konto, ImpFl)
|
||||
' bez powiadamiania grida o każdym wczytanym wierszu - jedno odświeżenie po Fill
|
||||
BsTbmy_ImpDM_Src.RaiseListChangedEvents = False
|
||||
Try
|
||||
Tamy_ImpDM_Src.Fill(Me.DsMain.Tbmy_ImpDM_Src, SpFlag, ZakFlag, WewFlag, RM, Rok, Mies, Konto, ImpFl)
|
||||
Finally
|
||||
BsTbmy_ImpDM_Src.RaiseListChangedEvents = True
|
||||
BsTbmy_ImpDM_Src.ResetBindings(False)
|
||||
End Try
|
||||
If pos < BsTbmy_ImpDM_Src.Count Then BsTbmy_ImpDM_Src.Position = pos Else BsTbmy_ImpDM_Src.Position = BsTbmy_ImpDM_Src.Count - 1
|
||||
lbUwaga.Visible = False
|
||||
lbUwaga.Invalidate()
|
||||
|
||||
Reference in new issue
Block a user