280 lines
9.8 KiB
VB.net
280 lines
9.8 KiB
VB.net
Imports System.Windows.Controls
|
|
Imports com.sun.org.apache.xalan.internal
|
|
Imports GrapeCity.ActiveReports.SectionReportModel
|
|
Imports Microsoft.Office.Interop
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmLeistundenFIBUKonten
|
|
|
|
Dim lfibu As New cLeistungFIBU
|
|
Dim editall As Boolean = False
|
|
|
|
|
|
Sub New(permission As Boolean)
|
|
InitializeComponent()
|
|
editall = permission
|
|
End Sub
|
|
|
|
Private Sub frmLeistundenFIBUKonten_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
cbxLeistungSelected.Items.Clear()
|
|
cbxLeistungSelected.fillWithSQL("SELECT [LeistungsNr] ,[LeistungsBez] FROM [Leistungen] ", True, "FMZOLL", True)
|
|
|
|
cboLeistung.Items.AddRange(cbxLeistungSelected.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
|
|
|
|
Dim listofFirmen = cFirmen.LOAD_LIST
|
|
|
|
cbxFirma.Items.Clear()
|
|
cbxFirma.fillWithSQL("SELECT Firma_ID, Firma_Bez FROM [tblFirma]", True, "FMZOLL", True)
|
|
|
|
cbxFirma.changeItem(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA_ID)
|
|
|
|
cbxFirma.Enabled = editall
|
|
btnDelete.Enabled = editall
|
|
|
|
initDGVSachkonten(cbxFirma._value)
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub initDGVSachkonten(Optional firmaID As Integer = 0, Optional searchparam As String = "", Optional leistungsNr As Integer = 0)
|
|
|
|
lblWarning.Text = ""
|
|
|
|
Dim SQLString As String = "SELECT l.LeistungsNr, l.LeistungsBez, fibu.SachkontoInlandSteuerpflichtig, fibu.SachkontoInlandSteuerfrei, fibu.SachkontoEUSteuerpflichtig, fibu.SachkontoEUSteuerfrei, fibu.Sachkonto3Land, fibu.Firma_ID, fibu.letzteAenderungUser, fibu.letzteAenderung FROM [VERAG].[dbo].[LeistungenBUKonten] as FIBU inner join Leistungen as l on l.LeistungsNr = FIBU.LeistungsNr where 1 = 1"
|
|
Dim SQLWHere = ""
|
|
If firmaID > 0 Then
|
|
SQLWHere &= " AND FIBU.Firma_ID = " & firmaID & ""
|
|
End If
|
|
|
|
If searchparam <> "" Then
|
|
SQLWHere &= " AND (FIBU.SachkontoInlandSteuerpflichtig like '%" & searchparam & "%' OR FIBU.SachkontoInlandSteuerfrei like '%" & searchparam & "%' OR FIBU.SachkontoEUSteuerpflichtig like '%" & searchparam & "%' OR FIBU.SachkontoEUSteuerfrei like '%" & searchparam & "%' OR FIBU.Sachkonto3Land like '%" & searchparam & "%')"
|
|
End If
|
|
|
|
If leistungsNr > 0 Then
|
|
SQLWHere &= " AND (FIBU.LeistungsNr = " & leistungsNr & ")"
|
|
End If
|
|
|
|
|
|
dgvSachkonten.SET_SQL(SQLString & SQLWHere, "FMZOLL", ,)
|
|
dgvSachkonten.LOAD()
|
|
|
|
|
|
If dgvSachkonten.Columns.Count < 1 Then Exit Sub
|
|
|
|
With dgvSachkonten
|
|
|
|
.MultiSelect = False
|
|
.RowHeadersVisible = False
|
|
.ReadOnly = True
|
|
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
|
.Columns("LeistungsNr").HeaderText = "LeistungsNr"
|
|
.Columns("LeistungsBez").HeaderText = "Bezeichnung"
|
|
.Columns("LeistungsBez").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
.Columns("SachkontoInlandSteuerpflichtig").Width = 100
|
|
.Columns("SachkontoInlandSteuerpflichtig").HeaderText = "Inland Stpfl."
|
|
|
|
.Columns("SachkontoInlandSteuerfrei").Width = 100
|
|
.Columns("SachkontoInlandSteuerfrei").HeaderText = "Inland Stfrei."
|
|
|
|
.Columns("SachkontoEUSteuerpflichtig").Width = 100
|
|
.Columns("SachkontoEUSteuerpflichtig").HeaderText = "EU Stpfl."
|
|
|
|
.Columns("SachkontoEUSteuerfrei").Width = 100
|
|
.Columns("SachkontoEUSteuerfrei").HeaderText = "EU Stfrei."
|
|
|
|
.Columns("Sachkonto3Land").Width = 100
|
|
.Columns("Sachkonto3Land").HeaderText = "Drittland"
|
|
|
|
.Columns("Firma_ID").HeaderText = "Firma"
|
|
.Columns("letzteAenderungUser").HeaderText = "letzte Änderung durch"
|
|
.Columns("letzteAenderung").HeaderText = "letzte Änderung"
|
|
|
|
If .RowCount = 0 Then Me.Cursor = Cursors.Default : Exit Sub
|
|
|
|
End With
|
|
|
|
|
|
For Each row As DataGridViewRow In dgvSachkonten.Rows
|
|
|
|
|
|
If row.Cells("Firma_ID").Value IsNot DBNull.Value AndAlso IsNumeric(row.Cells("Firma_ID").Value) Then
|
|
If CInt(row.Cells("Firma_ID").Value) > 0 Then
|
|
|
|
Dim tmpFirma = New VERAG_PROG_ALLGEMEIN.cFirmen(row.Cells("Firma_ID").Value)
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
|
|
|
|
If checkIfFirmaIsFilled(True) = False Then Exit Sub
|
|
|
|
|
|
|
|
If Not mainPanel.Enabled Then mainPanel.Enabled = True
|
|
|
|
For Each contr As Windows.Forms.Control In mainPanel.Controls
|
|
If (contr.GetType.FullName = "System.Windows.Forms.TextBox" Or contr.GetType.FullName = "VERAG_PROG_ALLGEMEIN.MyTextBox") Then contr.Text = ""
|
|
Next
|
|
cboLeistung.changeItem("")
|
|
|
|
End Sub
|
|
|
|
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
|
|
If dgvSachkonten.SelectedRows.Count > 0 Then
|
|
|
|
Dim lfibu As New cLeistungFIBU(dgvSachkonten.SelectedRows(0).Cells("LeistungsNr").Value, dgvSachkonten.SelectedRows(0).Cells("Firma_ID").Value)
|
|
|
|
If vbYes = MsgBox("Möchten Sie diesen Sachkontenzuweisung für LeistungsNr " & lfibu.LeistungsNr & " für Firma " & lfibu.Firma_ID & " wirklich löschen?", vbYesNo) Then
|
|
lfibu.DELETE()
|
|
initDGVSachkonten(cbxFirma._value)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function checkNrIsValid(LeistungsNrID As Integer) As Boolean
|
|
|
|
If dgvSachkonten.Rows.Count = 0 Then Return True
|
|
If checkIfFirmaIsFilled(False) = False Then Return False
|
|
|
|
|
|
For Each row As DataGridViewRow In dgvSachkonten.Rows
|
|
If Not IsDBNull(row.Cells("LeistungsNr").Value) AndAlso Not IsDBNull(row.Cells("Firma_ID").Value) Then
|
|
If row.Cells("LeistungsNr").Value = LeistungsNrID AndAlso row.Cells("Firma_ID").Value = cbxFirma._value Then
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub dgvSachkonten_SelectionChanged(sender As Object, e As EventArgs) Handles dgvSachkonten.SelectionChanged
|
|
Try
|
|
|
|
If dgvSachkonten.SelectedRows.Count < 1 Then
|
|
mainPanel.Enabled = False
|
|
Exit Sub
|
|
|
|
Else
|
|
mainPanel.Enabled = True
|
|
End If
|
|
|
|
lfibu = New cLeistungFIBU(dgvSachkonten.SelectedRows(0).Cells("LeistungsNr").Value, dgvSachkonten.SelectedRows(0).Cells("Firma_ID").Value)
|
|
|
|
txtInlandstpfl.Text = lfibu.SachkontoInlandSteuerpflichtig
|
|
txtInlandstfrei.Text = lfibu.SachkontoInlandSteuerfrei
|
|
txtEUstpfl.Text = lfibu.SachkontoEUSteuerpflichtig
|
|
txtEUstfrei.Text = lfibu.SachkontoEUSteuerfrei
|
|
txtDrittland.Text = lfibu.Sachkonto3Land
|
|
cboLeistung.changeItem(lfibu.LeistungsNr)
|
|
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
|
|
Try
|
|
checkIfFirmaIsFilled(False)
|
|
|
|
Dim txtKS As New cLeistungFIBU()
|
|
|
|
If checkFields() = False Then Exit Sub
|
|
|
|
txtKS.LeistungsNr = cboLeistung._value
|
|
txtKS.SachkontoInlandSteuerpflichtig = txtInlandstpfl.Text
|
|
txtKS.SachkontoInlandSteuerfrei = txtInlandstfrei.Text
|
|
txtKS.SachkontoEUSteuerpflichtig = txtEUstpfl.Text
|
|
txtKS.SachkontoEUSteuerfrei = txtEUstfrei.Text
|
|
txtKS.Sachkonto3Land = txtDrittland.Text
|
|
txtKS.Firma_ID = cbxFirma._value
|
|
txtKS.letzteAenderung = DateTime.Now
|
|
txtKS.letzteAenderungUser = VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME
|
|
|
|
txtKS.SAVE()
|
|
|
|
dgvSachkonten.GetOrder()
|
|
initDGVSachkonten(cbxFirma._value)
|
|
dgvSachkonten.SetOrder()
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub cbxFirma_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxFirma.SelectedValueChanged
|
|
Try
|
|
|
|
dgvSachkonten.GetOrder()
|
|
initDGVSachkonten(IIf(cbxFirma._value <> "", cbxFirma._value, -1), txtSuche.Text)
|
|
dgvSachkonten.SetOrder()
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
|
|
End Sub
|
|
|
|
Private Function checkIfFirmaIsFilled(initialSave As Boolean, Optional setWarning As Boolean = True)
|
|
|
|
If cbxFirma._value = "" Then
|
|
If ((dgvSachkonten.SelectedRows(0).Cells("Firma_ID").Value Is DBNull.Value Or dgvSachkonten.SelectedRows(0).Cells("Firma_ID").Value < 0) Or initialSave = True) Then 'And initialSave = False ???
|
|
|
|
If setWarning Then
|
|
lblWarning.Text = "Bitte Firma auswählen!"
|
|
Else
|
|
lblWarning.Text = ""
|
|
End If
|
|
|
|
Return False
|
|
End If
|
|
lblWarning.Text = ""
|
|
Return True
|
|
|
|
End If
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Private Function checkFields() As Boolean
|
|
|
|
If cboLeistung._value <> "" AndAlso checkNrIsValid(cboLeistung._value) Then
|
|
|
|
lblWarning.Text = ""
|
|
Return True
|
|
Else
|
|
lblWarning.Text = "LeistungsNr setzen!"
|
|
Return False
|
|
End If
|
|
|
|
|
|
|
|
End Function
|
|
|
|
Private Sub txtSuche_KeyDown(sender As Object, e As KeyEventArgs) Handles txtSuche.KeyDown
|
|
If e.KeyCode = Keys.Enter Then
|
|
|
|
initDGVSachkonten(IIf(cbxFirma._value <> "", cbxFirma._value, -1), txtSuche.Text)
|
|
e.Handled = True
|
|
|
|
End If
|
|
End Sub
|
|
|
|
End Class |