Public Class frmBrgDetails Public datum As New DateTime Public buergschaft As cBuergschaft Private BRG As New cBrgDb Private isnew As Boolean = False Private Sub frmBrgDetails_Load(sender As Object, e As EventArgs) Handles Me.Load lblDetails.Text = "Details für " & datum buergschaft = BRG.getBrgbyDate(datum) If Not buergschaft Is Nothing Then isnew = True initDetails() Else buergschaft = New cBuergschaft End If 'cbxTagessaldo If Not Now.ToShortDateString = datum.ToShortDateString Then cbxTagessaldo.Checked = False cbxTagessaldo.Enabled = False Else cbxTagessaldo.Checked = True cbxTagessaldo.Enabled = True End If End Sub Private Sub initDetails() txtAtTag_atlas.Text = buergschaft.brg_at_tag_atlas txtAtTag_zolaris.Text = buergschaft.brg_at_tag_zolaris txtAtWoche_atlas.Text = buergschaft.brg_at_woche_atlas txtAtWoche_zolaris.Text = buergschaft.brg_at_woche_zolaris txtDeTag.Text = buergschaft.brg_de_tag_atlas txtDeWoche.Text = buergschaft.brg_de_woche_atlas txtDe2Tag.Text = buergschaft.brg_de2_tag_atlas txtDe2Woche.Text = buergschaft.brg_de2_woche_atlas If txtAtTag_atlas.Text <> "" Then txtAtTag_atlas.Text = String.Format("{0:C}", CDbl(txtAtTag_atlas.Text)) If txtAtTag_zolaris.Text <> "" Then txtAtTag_zolaris.Text = String.Format("{0:C}", CDbl(txtAtTag_zolaris.Text)) If txtAtWoche_atlas.Text <> "" Then txtAtWoche_atlas.Text = String.Format("{0:C}", CDbl(txtAtWoche_atlas.Text)) If txtAtWoche_zolaris.Text <> "" Then txtAtWoche_zolaris.Text = String.Format("{0:C}", CDbl(txtAtWoche_zolaris.Text)) If txtDeTag.Text <> "" Then txtDeTag.Text = String.Format("{0:C}", CDbl(txtDeTag.Text)) If txtDeWoche.Text <> "" Then txtDeWoche.Text = String.Format("{0:C}", CDbl(txtDeWoche.Text)) If txtDe2Tag.Text <> "" Then txtDe2Tag.Text = String.Format("{0:C}", CDbl(txtDe2Tag.Text)) If txtDe2Woche.Text <> "" Then txtDe2Woche.Text = String.Format("{0:C}", CDbl(txtDe2Woche.Text)) End Sub Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click buergschaft.brg_datum = datum.ToString("dd.MM.yyyy") buergschaft.brg_at_tag_atlas = StrIntValue(toDec(txtAtTag_atlas.Text)) buergschaft.brg_at_tag_zolaris = StrIntValue(toDec(txtAtTag_zolaris.Text)) buergschaft.brg_at_woche_atlas = StrIntValue(toDec(txtAtWoche_atlas.Text)) buergschaft.brg_at_woche_zolaris = StrIntValue(toDec(txtAtWoche_zolaris.Text)) buergschaft.brg_de_tag_atlas = StrIntValue(toDec(txtDeTag.Text)) buergschaft.brg_de_woche_atlas = StrIntValue(toDec(txtDeWoche.Text)) buergschaft.brg_at_tag = StrIntValue(toDec(buergschaft.brg_at_tag_atlas) + toDec(buergschaft.brg_at_tag_zolaris)) buergschaft.brg_at_woche = StrIntValue(toDec(buergschaft.brg_at_woche_atlas) + toDec(buergschaft.brg_at_woche_zolaris)) buergschaft.brg_de_tag = buergschaft.brg_de_tag_atlas buergschaft.brg_de_woche = buergschaft.brg_de_woche_atlas buergschaft.brg_de2_tag_atlas = StrIntValue(toDec(txtDe2Tag.Text)) buergschaft.brg_de2_woche_atlas = StrIntValue(toDec(txtDe2Woche.Text)) buergschaft.brg_de2_tag = buergschaft.brg_de2_tag_atlas buergschaft.brg_de2_woche = buergschaft.brg_de2_woche_atlas If BRG.setBrgUpdateInsertByDateAll(buergschaft) Then 'If BRG.setBuergschaft(buergschaft) Then Me.Close() End If End Sub Private Function StrIntValue(ByVal d As Decimal) As String If d = 0 Then Return "" Else : Return d.ToString End If End Function Private Function toDec(ByVal s As String) As Decimal If s = "" Then Return 0 Try Return CDec(s) Catch ex As Exception Return 0 End Try End Function Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Me.Close() End Sub Private Sub txtAtTag_atlas_TextChanged(sender As Object, e As EventArgs) Handles txtAtTag_atlas.LostFocus, txtAtTag_zolaris.LostFocus, txtAtWoche_atlas.LostFocus, txtAtWoche_zolaris.LostFocus, txtDeTag.LostFocus, txtDeWoche.LostFocus If sender.Text <> "" Then sender.Text = String.Format("{0:C}", CDbl(sender.Text)) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click buergschaft.brg_datum = datum.ToString("dd.MM.yyyy") Dim brg_AT As String = "05AT510000G000FP7" Dim brg_DE As String = "05DE0000000009345" Dim brg_DE_NEU As String = "17DE0000000071678" If cbxATLAS.Checked Then Dim AtWoche_atlas As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_AT) + BRG.getBrgSumFromFMZOLL_Zodiak(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_AT) If AtWoche_atlas <> "" Then txtAtWoche_atlas.Text = AtWoche_atlas If txtAtWoche_atlas.Text <> "" Then txtAtWoche_atlas.Text = String.Format("{0:C}", CDbl(txtAtWoche_atlas.Text)) Dim DeWoche As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_DE) If DeWoche <> "" Then txtDeWoche.Text = DeWoche If txtDeWoche.Text <> "" Then txtDeWoche.Text = String.Format("{0:C}", CDbl(txtDeWoche.Text)) Dim De2Woche As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_DE_NEU) + BRG.getBrgSumFromFMZOLL_Zodiak(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_DE_NEU) If De2Woche <> "" Then txtDe2Woche.Text = De2Woche If txtDe2Woche.Text <> "" Then txtDe2Woche.Text = String.Format("{0:C}", CDbl(txtDe2Woche.Text)) End If If cbxZOLARIS.Checked Then Dim AtWoche_zolaris As String = BRG.getBrgSumFromFMZOLL_Zolaris(datum.ToShortDateString, datum.ToShortDateString, "50", "60", brg_AT) If AtWoche_zolaris <> "" Then txtAtWoche_zolaris.Text = AtWoche_zolaris If txtAtWoche_zolaris.Text <> "" Then txtAtWoche_zolaris.Text = String.Format("{0:C}", CDbl(txtAtWoche_zolaris.Text)) End If If cbxTagessaldo.Checked Then If cbxATLAS.Checked Then Dim deTag_atlas As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_DE) If deTag_atlas <> "" Then txtDeTag.Text = deTag_atlas If txtDeTag.Text <> "" Then txtDeTag.Text = String.Format("{0:C}", CDbl(txtDeTag.Text)) Dim de2Tag_atlas As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_DE_NEU) + BRG.getBrgSumFromFMZOLL_Zodiak(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_DE_NEU) If de2Tag_atlas <> "" Then txtDe2Tag.Text = de2Tag_atlas If txtDe2Tag.Text <> "" Then txtDe2Tag.Text = String.Format("{0:C}", CDbl(txtDe2Tag.Text)) Dim AtTag_atlas As String = BRG.getBrgSumFromFMZOLL_Zabis(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_AT) + BRG.getBrgSumFromFMZOLL_Zodiak(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_AT) If AtTag_atlas <> "" Then txtAtTag_atlas.Text = AtTag_atlas If txtAtTag_atlas.Text <> "" Then txtAtTag_atlas.Text = String.Format("{0:C}", CDbl(txtAtTag_atlas.Text)) End If If cbxZOLARIS.Checked Then Dim atTag_zolaris As String = BRG.getBrgSumFromFMZOLL_Zolaris(datum.AddMonths(-3).ToShortDateString, datum.ToShortDateString, "50", "50", brg_AT, " AND DatumBestimmungErreicht IS NULL ") If atTag_zolaris <> "" Then txtAtTag_zolaris.Text = atTag_zolaris If txtAtTag_zolaris.Text <> "" Then txtAtTag_zolaris.Text = String.Format("{0:C}", CDbl(txtAtTag_zolaris.Text)) End If End If 'buergschaft.brg_at_tag_atlas = StrIntValue(toDec(txtAtTag_atlas.Text)) ' buergschaft.brg_at_tag_zolaris = StrIntValue(toDec(txtAtTag_zolaris.Text)) ' buergschaft.brg_at_woche_atlas = StrIntValue(toDec(BRG.getBrgSumFromFMZOLL(datum.ToShortDateString, "50", "60", brg_AT))) ' buergschaft.brg_at_woche_zolaris = StrIntValue(toDec(txtAtWoche_zolaris.Text)) ' buergschaft.brg_de_tag_atlas = StrIntValue(toDec(txtDeTag.Text)) ' buergschaft.brg_de_woche_atlas = StrIntValue(toDec(BRG.getBrgSumFromFMZOLL(datum.ToShortDateString, "50", "60", brg_DE))) ' buergschaft.brg_at_tag = StrIntValue(toDec(buergschaft.brg_at_tag_atlas) + toDec(buergschaft.brg_at_tag_zolaris)) ' buergschaft.brg_at_woche = StrIntValue(toDec(buergschaft.brg_at_woche_atlas) + toDec(buergschaft.brg_at_woche_zolaris)) ' buergschaft.brg_de_tag = buergschaft.brg_de_tag_atlas ' buergschaft.brg_de_woche = buergschaft.brg_de_woche_atlas End Sub End Class