This commit is contained in:
Digital Data - Marlon Schreiber
2017-10-26 17:24:35 +02:00
parent 0addb3a1e8
commit 8a9ce6726a
6 changed files with 117 additions and 64 deletions

View File

@@ -1,7 +1,7 @@
Imports DD_Record_Organizer.ClassDatabase
Imports DD_Record_Organizer.ClassControlBuilder
Imports DD_LIB_Standards
Imports System.Data.SqlClient
Public Class ClassControlCommandsUI
Private _CtrlBuilder As ClassControlBuilder
@@ -333,13 +333,17 @@ Public Class ClassControlCommandsUI
Try
Dim ADDED_WHO As String = USER_USERNAME
If LogErrorsOnly = False Then ClassLogger.Add(" >> (SaveRecord) Update RecordID: " & RecordID, False)
UpdateAllControls(FormID, RecordID, _CtrlBuilder.AllControls)
Return "Datensatz aktualisiert - " & Now
If UpdateAllControls(FormID, RecordID, _CtrlBuilder.AllControls) = True Then
Return "Datensatz aktualisiert - " & Now
Else
Return "ERROR"
End If
'End If
Catch ex As Exception
MsgBox("Unexpected Error in SaveRecord: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Function
Private Sub InsertAllControls(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection)
@@ -369,7 +373,7 @@ Public Class ClassControlCommandsUI
InsertAllControls(FormID, RecordID, DirectCast(ctrl, GroupBox).Controls)
End If
Else
InsertControlValue(CONTROL_ID, RecordID, CONTROL_VALUE, CURRENT_ENTITY_ID)
CreateControlProcedure(CONTROL_ID, RecordID, CONTROL_VALUE, CURRENT_ENTITY_ID)
End If
Next
End Sub
@@ -481,8 +485,9 @@ Public Class ClassControlCommandsUI
End Try
End Sub
Private Sub UpdateAllControls(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection)
Private Function UpdateAllControls(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection)
Try
Dim _error As Boolean = False
Dim sw As New SW("UpdateAllControls")
Dim del = String.Format("DELETE FROM TBPMO_CONTROL_VALUE_CHANGE_HISTORY WHERE UPPER(ADDED_WHO) = '{0}'", USER_USERNAME.ToUpper)
ClassDatabase.Execute_non_Query(del)
@@ -539,7 +544,9 @@ Public Class ClassControlCommandsUI
Continue For
End If
If CONTROL_VALUE <> "" Then
InsertControlValue(CONTROL_ID, RecordID, CONTROL_VALUE, CURRENT_ENTITY_ID)
If CreateControlProcedure(CONTROL_ID, RecordID, CONTROL_VALUE, CURRENT_ENTITY_ID) = 0 Then
_error = True
End If
End If
End If
Else ' Update Control
@@ -572,13 +579,18 @@ Public Class ClassControlCommandsUI
Next
sw.Done()
If _error = True Then
Return False
Else
Return True
End If
Catch ex As Exception
MsgBox("Unexpected Error in UpdateAllControls: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End Sub
End Function
Public Shared Sub UpdateMultipleValues(ControlId As Integer, RecordId As Integer, value As String)
Try
@@ -608,11 +620,8 @@ Public Class ClassControlCommandsUI
If Not _addValue = "" Then
Dim converted_value = Check_and_Format_Value(ControlId, RecordId, _addValue)
If Not IsNothing(converted_value) Then
ClassControlCommandsUI.InsertControlValue(ControlId, RecordId, converted_value, CURRENT_ENTITY_ID)
ClassControlCommandsUI.CreateControlProcedure(ControlId, RecordId, converted_value, CURRENT_ENTITY_ID)
'Dim ins = String.Format("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID, RECORD_ID, VALUE,ADDED_WHO) VALUES({0}, {1}, '{2}','{3}')", ControlId, RecordId, converted_value, USER_USERNAME)
'ClassDatabase.Execute_non_Query(ins)
'ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(CURRENT_ENTITY_ID, ControlId, RecordId, converted_value)
End If
End If
Next
@@ -831,6 +840,7 @@ Public Class ClassControlCommandsUI
Dim oDate = ClassHelper.Convert_to_Database_Date(Value)
Value = oDate.ToString()
End Select
Value = Value.Replace("'", "´")
Return Value
Catch ex As Exception
MsgBox("Unexpected Error in Check_and_Format_Value: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
@@ -838,7 +848,39 @@ Public Class ClassControlCommandsUI
Return Nothing
End Try
End Function
Public Shared Function InsertControlValue(ControlID As Integer, RecordID As Integer, Value As String, ENTITY_ID As Integer)
Public Shared Function CreateControlProcedure(ControlID As Integer, RecordID As Integer, Value As String, ENTITY_ID As Integer)
Try
Dim _result As Integer
Dim converted_value = Check_and_Format_Value(ControlID, RecordID, Value)
If Not IsNothing(converted_value) Then
Dim connection As New SqlConnection
connection.ConnectionString = MyConnectionString
Using cmd As New SqlCommand("PRPMO_CREATE_CONTROL_VALUE", connection)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@pRECORD_ID", RecordID)
cmd.Parameters.AddWithValue("@pCONTROL_ID", ControlID)
cmd.Parameters.AddWithValue("@pVALUE", converted_value)
cmd.Parameters.AddWithValue("@pADDED_WHO", USER_USERNAME)
cmd.Parameters.Add("@pRESULT", SqlDbType.Int)
cmd.Parameters("@pRESULT").Direction = ParameterDirection.Output
connection.Open()
cmd.ExecuteNonQuery()
connection.Close()
_result = cmd.Parameters("@pRESULT").Value
If _result = 1 And clsDatabase.DB_PROXY_INITIALIZED = True Then
ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(ENTITY_ID, ControlID, RecordID, converted_value)
End If
Return _result
End Using
Else
_result = 0
End If
Catch ex As Exception
ClassHelper.MSGBOX_Handler("ERROR", "Error", "Error in CreateControlProcedure: ", ex.Message)
Return 0
End Try
End Function
Public Shared Function InsertControlValueOld(ControlID As Integer, RecordID As Integer, Value As String, ENTITY_ID As Integer)
Try
Dim AddedWho = USER_USERNAME
Dim converted_value = Check_and_Format_Value(ControlID, RecordID, Value)