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.
230 lines
9.8 KiB
230 lines
9.8 KiB
Imports System.IO
|
|
Imports System.Data
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Data.SqlClient
|
|
|
|
Namespace TKB.VV.Utils
|
|
''' <summary>
|
|
''' Standard-Messages in div. Formatenm
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
Public Class MyMessage
|
|
#Region "Deklarationen"
|
|
''' <summary>
|
|
''' Dataview Meldungstexte um Textelemente für die Ausgabe zu suchen
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
Private meldungstexte As New DataView()
|
|
#End Region
|
|
|
|
#Region "Dispose"
|
|
Sub dispose()
|
|
meldungstexte.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "DBZugriffe"
|
|
''' <summary>
|
|
''' Meldungen aus der Datenbanklesen, sofern diese noch nicht ausgelesen worden sind. Nach dem ersten Lesen werden
|
|
''' die Daten aus der Tabelle Meldungstexte ohne erneutem DB-Zugriff verwendet
|
|
''' </summary>
|
|
''' <param name="i"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Get_Meldungstext(ByVal i As Integer) As String
|
|
Dim meldungen As New TKB.VV.DB.clsMeldungstexte
|
|
Dim res As Integer
|
|
meldungen.cpMainConnectionProvider = conn
|
|
If Me.meldungstexte.Count = 0 Then
|
|
Me.meldungstexte.Table = meldungen.SelectAll
|
|
End If
|
|
meldungstexte.Sort = "meldungstextnr"
|
|
res = meldungstexte.Find(i)
|
|
Try
|
|
Get_Meldungstext = Me.meldungstexte(res).Item(2)
|
|
Catch
|
|
Get_Meldungstext = ""
|
|
End Try
|
|
meldungen.Dispose()
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
#Region "Meldungen"
|
|
''' <summary>
|
|
''' Standardmessage
|
|
''' </summary>
|
|
''' <param name="i">Messagenr</param>
|
|
''' <param name="typ">Messagetyp</param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function show_standardmessage(ByVal i As Integer, ByVal typ As MsgBoxStyle) As Integer
|
|
Me.ShowMyDialog(Get_Meldungstext(i), typ, MsgBoxStyle.OkOnly)
|
|
'MsgBox(Get_Meldungstext(i), typ)
|
|
End Function
|
|
''' <summary>
|
|
''' Yes-No-Meldung
|
|
''' </summary>
|
|
''' <param name="i">Meldungsnr</param>
|
|
''' <returns>MsgboxResult</returns>
|
|
''' <remarks></remarks>
|
|
Public Function Show_MessageYesNo(ByVal i As Integer) As MsgBoxResult
|
|
Return Me.ShowMyDialog(Get_Meldungstext(i), MsgBoxStyle.Question, MsgBoxStyle.YesNo)
|
|
'Show_MessageYesNo = MsgBox(Get_Meldungstext(i), MsgBoxStyle.YesNo + MsgBoxStyle.Question)
|
|
End Function
|
|
''' <summary>
|
|
''' Standard-Meldung, welcher 2 Strings als Parameter übergeben werden, damit diese im Meldungstext ersetzt werden können.
|
|
''' Parameter im Meldungstext #1 oder #2
|
|
''' </summary>
|
|
''' <param name="i"></param>
|
|
''' <param name="typ"></param>
|
|
''' <param name="Text1"></param>
|
|
''' <param name="Text2"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function show_standardmessage_ReplaceText(ByVal i As Integer, ByVal typ As MsgBoxStyle, ByVal Text1 As String, ByVal Text2 As String) As Integer
|
|
Dim s As String
|
|
s = Get_Meldungstext(i)
|
|
s = s.Replace("#1", Text1)
|
|
s = s.Replace("#2", Text2)
|
|
Return Me.ShowMyDialog(s, typ, MsgBoxStyle.OkOnly)
|
|
' MsgBox(s, typ)
|
|
End Function
|
|
''' <summary>
|
|
''' Yes-No-Meldung, welcher 2 Strings als Parameter übergeben werden, damit diese im Meldungstext ersetzt werden können.
|
|
''' Parameter im Meldungstext #1 oder #2
|
|
''' </summary>
|
|
''' <param name="i">MeldungsNr</param>
|
|
''' <param name="Text1">erster Text zum ersetzen</param>
|
|
''' <param name="Text2">zweiter Text zum ersetzen</param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function show_MessageYesNo_ReplaceText(ByVal i As Integer, ByVal Text1 As String, ByVal Text2 As String) As MsgBoxResult
|
|
Dim s As String
|
|
s = Get_Meldungstext(i)
|
|
s = s.Replace("#1", Text1)
|
|
s = s.Replace("#2", Text2)
|
|
Return Me.ShowMyDialog(s, MsgBoxStyle.Question, MsgBoxStyle.YesNo)
|
|
'show_MessageYesNo_ReplaceText = MsgBox(s, MsgBoxStyle.YesNo + MsgBoxStyle.Question)
|
|
End Function
|
|
''' <summary>
|
|
''' Ausgabe der Meldung, welche übergeben wird. Als Option können 2 Texte zum Ersetzen übergeben werden.
|
|
''' Parameter im Meldungstext #1 oder #2
|
|
''' </summary>
|
|
''' <param name="OrgText">Meldungstext</param>
|
|
''' <param name="Text1">erster Text zum ersetzen</param>
|
|
''' <param name="Text2">zweiter Text zum ersetzen</param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function ReplaceTextinMSG(ByVal OrgText As String, ByVal Text1 As String, ByVal Text2 As String) As String
|
|
OrgText = OrgText.Replace("#1", Text1)
|
|
OrgText = OrgText.Replace("#2", Text2)
|
|
ReplaceTextinMSG = OrgText
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Meldung Yes-No-Cancel
|
|
''' </summary>
|
|
''' <param name="i"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Show_MessageYesNoCancel(ByVal i As Integer) As MsgBoxResult
|
|
Return Me.ShowMyDialog(Get_Meldungstext(i), MsgBoxStyle.Question, MsgBoxStyle.YesNoCancel)
|
|
'Show_MessageYesNoCancel = MsgBox(Get_Meldungstext(i), MsgBoxStyle.YesNoCancel + MsgBoxStyle.Question)
|
|
End Function
|
|
|
|
|
|
'Private Function ShowMessage(ByVal profilnr As Integer, ByVal messagenr As Integer, ByVal fnkt As Integer, ByVal style As Integer) As Boolean
|
|
' 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_show_hinweismeldung"
|
|
' scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
' scmCmdToExecute.Connection = conn.scoDBConnection
|
|
' Try
|
|
' scmCmdToExecute.Parameters.Add(New SqlParameter("@profilnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, profilnr))
|
|
' scmCmdToExecute.Parameters.Add(New SqlParameter("@hinweisnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, messagenr))
|
|
' scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, fnkt))
|
|
' scmCmdToExecute.Parameters.Add(New SqlParameter("@showit", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
|
' sdaAdapter.Fill(dtToReturn)
|
|
' i = scmCmdToExecute.Parameters.Item("@showit").Value
|
|
' If i <> 0 Then
|
|
' ShowMessage = True
|
|
' Else
|
|
' ShowMessage = False
|
|
' End If
|
|
' Catch ex As Exception
|
|
' ' // some error occured. Bubble it to caller and encapsulate Exception object
|
|
' Throw New Exception("Dokument_Information_Wert::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
|
' Finally
|
|
' scmCmdToExecute.Dispose()
|
|
' sdaAdapter.Dispose()
|
|
' End Try
|
|
'End Function
|
|
''' <summary>
|
|
''' Zeig den eigenen Messagebox-Dialog
|
|
''' </summary>
|
|
''' <param name="msgtext"></param>
|
|
''' <param name="cancelvisible"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function ShowMyDialog(ByVal msgtext As String, ByVal ImageStyle As MsgBoxStyle, ByVal Buttons As MsgBoxStyle) As MsgBoxResult
|
|
Dim f As New frmMsgBox
|
|
f.btnno.Visible = False
|
|
f.btnAbbruch.Visible = False
|
|
f.btnYes.Visible = False
|
|
f.btnOK.Visible = False
|
|
Select Case Buttons
|
|
Case MsgBoxStyle.OkCancel
|
|
f.btnYes.Visible = True
|
|
f.btnAbbruch.Visible = True
|
|
Case MsgBoxStyle.YesNo
|
|
f.btnYes.Visible = True
|
|
f.btnno.Visible = True
|
|
Case MsgBoxStyle.YesNoCancel
|
|
f.btnYes.Visible = True
|
|
f.btnno.Visible = True
|
|
f.btnAbbruch.Visible = True
|
|
Case MsgBoxStyle.OkOnly
|
|
f.btnOK.Visible = True
|
|
End Select
|
|
f.imgCritical.Visible = False
|
|
f.imgExclamation.Visible = False
|
|
f.imgInformation.Visible = False
|
|
f.imgQuestion.Visible = False
|
|
Select Case ImageStyle
|
|
Case MsgBoxStyle.Critical
|
|
f.imgCritical.Visible = True
|
|
Case MsgBoxStyle.Exclamation
|
|
f.imgExclamation.Visible = True
|
|
Case MsgBoxStyle.Information
|
|
f.imgInformation.Visible = True
|
|
Case MsgBoxStyle.Question
|
|
f.imgQuestion.Visible = True
|
|
End Select
|
|
|
|
f.txtmsg.Text = msgtext
|
|
'f.btnYes.Visible = True
|
|
'f.btnno.Visible = True
|
|
f.ShowDialog()
|
|
Select Case f.DialogResult
|
|
Case DialogResult.Abort, DialogResult.Cancel
|
|
Return MsgBoxResult.Cancel
|
|
Case DialogResult.No
|
|
Return MsgBoxResult.No
|
|
Case DialogResult.Yes
|
|
Return MsgBoxResult.Yes
|
|
Case Else
|
|
|
|
End Select
|
|
End Function
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
End Namespace
|