You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
13 KiB

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Public Class frmpartnermavip
Inherits System.Windows.Forms.Form
#Region " Vom Windows Form Designer generierter Code "
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
End Sub
' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Für Windows Form-Designer erforderlich
Private components As System.ComponentModel.IContainer
'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
'Sie kann mit dem Windows Form-Designer modifiziert werden.
'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents plist As C1.Win.C1TrueDBGrid.C1TrueDBGrid
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmpartnermavip))
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.plist = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
CType(Me.plist, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.ImageList1
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(672, 28)
Me.ToolBar1.TabIndex = 0
'
'ToolBarButton1
'
Me.ToolBarButton1.ImageIndex = 0
Me.ToolBarButton1.Name = "ToolBarButton1"
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
Me.ImageList1.Images.SetKeyName(0, "")
Me.ImageList1.Images.SetKeyName(1, "")
Me.ImageList1.Images.SetKeyName(2, "")
Me.ImageList1.Images.SetKeyName(3, "")
Me.ImageList1.Images.SetKeyName(4, "")
Me.ImageList1.Images.SetKeyName(5, "")
Me.ImageList1.Images.SetKeyName(6, "")
Me.ImageList1.Images.SetKeyName(7, "")
Me.ImageList1.Images.SetKeyName(8, "")
Me.ImageList1.Images.SetKeyName(9, "")
Me.ImageList1.Images.SetKeyName(10, "")
Me.ImageList1.Images.SetKeyName(11, "")
Me.ImageList1.Images.SetKeyName(12, "")
Me.ImageList1.Images.SetKeyName(13, "")
Me.ImageList1.Images.SetKeyName(14, "")
Me.ImageList1.Images.SetKeyName(15, "")
Me.ImageList1.Images.SetKeyName(16, "")
Me.ImageList1.Images.SetKeyName(17, "")
Me.ImageList1.Images.SetKeyName(18, "")
Me.ImageList1.Images.SetKeyName(19, "")
Me.ImageList1.Images.SetKeyName(20, "")
Me.ImageList1.Images.SetKeyName(21, "")
Me.ImageList1.Images.SetKeyName(22, "")
Me.ImageList1.Images.SetKeyName(23, "")
Me.ImageList1.Images.SetKeyName(24, "")
Me.ImageList1.Images.SetKeyName(25, "")
Me.ImageList1.Images.SetKeyName(26, "")
Me.ImageList1.Images.SetKeyName(27, "")
'
'plist
'
Me.plist.AllowDelete = True
Me.plist.AlternatingRows = True
Me.plist.ContextMenu = Me.ContextMenu1
Me.plist.Cursor = System.Windows.Forms.Cursors.Default
Me.plist.Dock = System.Windows.Forms.DockStyle.Fill
Me.plist.FetchRowStyles = True
Me.plist.FilterBar = True
Me.plist.GroupByCaption = "Drag a column header here to group by that column"
Me.plist.Images.Add(CType(resources.GetObject("plist.Images"), System.Drawing.Image))
Me.plist.Location = New System.Drawing.Point(0, 28)
Me.plist.Name = "plist"
Me.plist.PreviewInfo.Location = New System.Drawing.Point(0, 0)
Me.plist.PreviewInfo.Size = New System.Drawing.Size(0, 0)
Me.plist.PreviewInfo.ZoomFactor = 75
Me.plist.PrintInfo.PageSettings = CType(resources.GetObject("plist.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
Me.plist.ScrollTips = True
Me.plist.Size = New System.Drawing.Size(672, 377)
Me.plist.TabIndex = 28
Me.plist.Text = "C1TrueDBGrid1"
Me.plist.PropBag = resources.GetString("plist.PropBag")
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.Text = "&Partner hinzufügen"
'
'MenuItem2
'
Me.MenuItem2.Index = 1
Me.MenuItem2.Text = "Eintrag inaktivieren"
'
'frmpartnermavip
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(672, 405)
Me.Controls.Add(Me.plist)
Me.Controls.Add(Me.ToolBar1)
Me.Name = "frmpartnermavip"
Me.Text = "Partner als Mitarbeiter/VIP"
CType(Me.plist, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub frmpartnermavip_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
reload_data()
End Sub
Private Sub Reload_Data()
Dim dt As DataTable
dt = getdata()
Me.plist.DataSource = dt
Me.plist.DataMember = dt.TableName
Dim i As Integer
Me.plist.Columns("Erstellt Am").NumberFormat = "dd.MM.yyyy HH:mm:ss"
Me.plist.Columns("Mutiert Am").NumberFormat = "dd.MM.yyyy HH:mm:ss"
For i = 0 To Me.plist.Splits(0).DisplayColumns.Count - 1
Me.plist.Splits(0).DisplayColumns(i).AutoSize()
Me.plist.Splits(0).DisplayColumns(i).Locked = True
Next
Me.plist.Columns("MA").ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
Me.plist.Columns("MA").ValueItems.DefaultItem = True
Me.plist.Columns("MA").DefaultValue = True
Me.plist.Splits(0).DisplayColumns("MA").Locked = False
Me.plist.Columns("VIP").ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
Me.plist.Columns("VIP").ValueItems.DefaultItem = True
Me.plist.Columns("VIP").DefaultValue = True
Me.plist.Splits(0).DisplayColumns("VIP").Locked = False
Me.plist.Columns("Aktiv").ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
Me.plist.Columns("Aktiv").ValueItems.DefaultItem = True
Me.plist.Columns("Aktiv").DefaultValue = True
Me.plist.Splits(0).DisplayColumns("Aktiv").Locked = False
End Sub
Private Function getdata() As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim i As Integer
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_partner_ma_vip_get"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
Throw New Exception("sp_check_dokumentreaktivierung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Function insert_new_partner(ByVal nrpar00 As Integer) As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim i As Integer
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_partner_ma_vip_insert"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@nrpar00", SqlDbType.Int, 5, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, nrpar00))
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiter", SqlDbType.Int, 5, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
MsgBox("Der gewählte Partner ist bereits in der Aufzählung vorhanden.", MsgBoxStyle.Critical)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Function update_partner(ByVal nrpar00 As Integer) As DataTable
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim i As Integer
Dim iAktiv As Integer
Dim iVIP As Integer
Dim iMA As Integer
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_partner_ma_vip_update"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
If LCase(Me.plist.Columns("Aktiv").Value) = "false" Then
iAktiv = 0
Else
iAktiv = 1
End If
If LCase(Me.plist.Columns("VIP").Value) = "false" Then
iVIP = 0
Else
iVIP = 1
End If
If LCase(Me.plist.Columns("MA").Value) = "false" Then
iMA = 0
Else
iMA = 1
End If
Try
scmCmdToExecute.Parameters.Add(New SqlParameter("@nrpar00", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, nrpar00))
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiter", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
scmCmdToExecute.Parameters.Add(New SqlParameter("@ma", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, iMA))
scmCmdToExecute.Parameters.Add(New SqlParameter("@vip", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, iVIP))
scmCmdToExecute.Parameters.Add(New SqlParameter("@aktiv", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, iAktiv))
sdaAdapter.Fill(dtToReturn)
Return dtToReturn
Catch ex As Exception
Throw New Exception("sp_check_dokumentreaktivierung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
Finally
scmCmdToExecute.Dispose()
sdaAdapter.Dispose()
End Try
End Function
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim f As New FrmPartnersuche()
f.ShowDialog()
If f.PartnerNr <> 0 Then
insert_new_partner(f.PartnerNr)
Me.Reload_Data()
Dim i As Integer
For i = 0 To Me.plist.Splits(0).Rows.Count
If Me.plist.Columns(0).CellValue(i) = f.PartnerNr Then
Me.plist.Bookmark = i
Exit For
End If
Next
End If
End Sub
Private Sub plist_AfterColUpdate(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ColEventArgs) Handles plist.AfterColUpdate
Dim i
i = Me.plist.Bookmark
Me.update_partner(Me.plist.Columns("partnernr").Value)
Me.Reload_Data()
Me.plist.Bookmark = i
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Me.Close()
End Sub
End Class