MS
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
Public Class frmMass_Change
|
||||
Imports System.ComponentModel
|
||||
|
||||
Public Class frmMass_Change
|
||||
Dim SQL As String
|
||||
Private Sub frmMass_Change_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Try
|
||||
SUCCESSFULL = False
|
||||
Dim msg = "Anzahl zu ändernde Datensätze: "
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "Count of records to be changed:"
|
||||
msg = "Count of records to be changed: "
|
||||
End If
|
||||
lblCount.Text = msg & MASS_RECORD_IDs2CHANGE.Count
|
||||
cmbColumn.Items.Clear()
|
||||
@@ -19,7 +21,7 @@
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in load form:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
Private Sub btncancel_Click(sender As Object, e As EventArgs) Handles btncancel.Click
|
||||
Me.Close()
|
||||
@@ -36,85 +38,15 @@
|
||||
Dim result As MsgBoxResult
|
||||
result = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
If result = MsgBoxResult.Yes Then
|
||||
Dim val = txtNewValue.Text
|
||||
Dim SQL = String.Format("SELECT GUID FROM TBPMO_CONTROL WHERE COL_NAME = '{0}' AND FORM_ID = {1}", cmbColumn.Text, CURRENT_ENTITY_ID)
|
||||
Dim control_Id = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If Not IsNothing(control_Id) Then
|
||||
If control_Id > 0 Then
|
||||
SQL = String.Format("SELECT CONTROL_TYPE_ID FROM TBPMO_CONTROL WHERE GUID = {0}", control_Id)
|
||||
Dim control_type_ID = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If control_type_ID = 4 Then
|
||||
|
||||
Try
|
||||
val = CDate(val)
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in Converting value '" & val & "' to date", MsgBoxStyle.Critical)
|
||||
Cursor = Cursors.Default
|
||||
Exit Sub
|
||||
End Try
|
||||
End If
|
||||
If control_type_ID = 7 Or control_type_ID = 12 Or control_type_ID = 14 Then
|
||||
msg = "Achtung: für diese Spalte existieren mehrere Werte. Diese Werte werden gelöscht." & vbNewLine & "Wollen Sie dennoch fortfahren?"
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "Attention: there are multiple values for this column. These values will be deleted." & vbNewLine & "Would You like to continue?"
|
||||
End If
|
||||
Dim result1 As MsgBoxResult
|
||||
result1 = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
If result1 = MsgBoxResult.No Then
|
||||
Exit Sub
|
||||
Else
|
||||
For Each Record As String In MASS_RECORD_IDs2CHANGE
|
||||
Dim del = String.Format("DELETE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", control_Id, CInt(Record))
|
||||
ClassDatabase.Execute_non_Query(del, False)
|
||||
ClassProxy.PRPROXY_CONTROL_DEL(CInt(Record), CURRENT_ENTITY_ID, control_Id)
|
||||
Next
|
||||
|
||||
End If
|
||||
End If
|
||||
Try
|
||||
Dim err As Boolean = False
|
||||
Dim RIGHT_ONLY_READ_RECORD_FILE = False
|
||||
For Each Record As String In MASS_RECORD_IDs2CHANGE
|
||||
If SQL_RECORD_AND_FILE_READ_ONLY <> "" Then
|
||||
RIGHT_ONLY_READ_RECORD_FILE = ClassHelper.Check_Record_Read_only(CInt(Record), CURRENT_ENTITY_ID)
|
||||
End If
|
||||
If RIGHT_ONLY_READ_RECORD_FILE = False Then
|
||||
SQL = String.Format("SELECT GUID FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", control_Id, CInt(Record))
|
||||
Dim ex_GUID = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If Not IsNothing(ex_GUID) Then
|
||||
SQL = String.Format("UPDATE TBPMO_CONTROL_VALUE SET VALUE = '{0}',CHANGED_WHO = '{1}' WHERE GUID = {2}", val, USER_USERNAME, ex_GUID)
|
||||
If ClassDatabase.Execute_non_Query(SQL, False) = False Then
|
||||
MsgBox("Error in updating the value for Record: " & Record & vbNewLine & "Please check the logfile.", MsgBoxStyle.Exclamation)
|
||||
Else
|
||||
ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(CURRENT_ENTITY_ID, control_Id, CInt(Record), val)
|
||||
End If
|
||||
Else
|
||||
SQL = String.Format("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES ({0},{1},'{2}','{3}')", control_Id, CInt(Record), val, USER_USERNAME)
|
||||
If ClassDatabase.Execute_non_Query(SQL, False) = False Then
|
||||
MsgBox("Error in inserting the value for Record: " & Record & vbNewLine & "Please check the logfile.", MsgBoxStyle.Exclamation)
|
||||
Else
|
||||
ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(CURRENT_ENTITY_ID, control_Id, CInt(Record), val)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
SUCCESSFULL = True
|
||||
msg = "Alle Änderungen wurden ausgeführt!"
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "All changes were executed!"
|
||||
End If
|
||||
MsgBox(msg, MsgBoxStyle.Information)
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Getting record to be changed:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
Else
|
||||
MsgBox("No defined column found! (1)", MsgBoxStyle.Information)
|
||||
End If
|
||||
Else
|
||||
MsgBox("No defined column found! (2)", MsgBoxStyle.Information)
|
||||
End If
|
||||
Me.Cursor = Cursors.WaitCursor
|
||||
SQL = String.Format("SELECT GUID FROM TBPMO_CONTROL WHERE COL_NAME = '{0}' AND FORM_ID = {1}", cmbColumn.Text, CURRENT_ENTITY_ID)
|
||||
ProgressBar1.Visible = True
|
||||
lblStateBW.Text = "Preparing BackgroundWorker..."
|
||||
lblStateBW.Visible = True
|
||||
ProgressBar1.Maximum = MASS_RECORD_IDs2CHANGE.Count
|
||||
AddHandler BackgroundWorker.DoWork, AddressOf bwDowork
|
||||
'.. und starten
|
||||
BackgroundWorker.RunWorkerAsync()
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -123,4 +55,113 @@
|
||||
End Try
|
||||
Cursor = Cursors.Default
|
||||
End Sub
|
||||
Dim _Error = False
|
||||
Sub bwDowork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
|
||||
Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
|
||||
Dim val = txtNewValue.Text
|
||||
|
||||
Dim control_Id = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If Not IsNothing(control_Id) Then
|
||||
If control_Id > 0 Then
|
||||
SQL = String.Format("SELECT CONTROL_TYPE_ID FROM TBPMO_CONTROL WHERE GUID = {0}", control_Id)
|
||||
Dim control_type_ID = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If control_type_ID = 4 Then
|
||||
Try
|
||||
val = CDate(val)
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in Converting value '" & val & "' to date", MsgBoxStyle.Critical)
|
||||
Cursor = Cursors.Default
|
||||
Exit Sub
|
||||
End Try
|
||||
End If
|
||||
If control_type_ID = 7 Or control_type_ID = 12 Or control_type_ID = 14 Then
|
||||
stateBW = "Deleting the old values..."
|
||||
'Dim msg As String
|
||||
'msg = "Achtung: für diese Spalte existieren mehrere Werte. Diese Werte werden gelöscht." & vbNewLine & "Wollen Sie dennoch fortfahren?"
|
||||
'If USER_LANGUAGE <> "de-DE" Then
|
||||
' msg = "Attention: there are multiple values for this column. These values will be deleted." & vbNewLine & "Would You like to continue?"
|
||||
'End If
|
||||
'Dim result1 As MsgBoxResult
|
||||
'result1 = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
For Each Record As String In MASS_RECORD_IDs2CHANGE
|
||||
Dim del = String.Format("DELETE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", control_Id, CInt(Record))
|
||||
ClassDatabase.Execute_non_Query(del, False)
|
||||
ClassProxy.PRPROXY_CONTROL_DEL(CInt(Record), CURRENT_ENTITY_ID, control_Id)
|
||||
Next
|
||||
End If
|
||||
Try
|
||||
Dim RIGHT_ONLY_READ_RECORD_FILE = False
|
||||
Dim i As Integer = 1
|
||||
For Each Record As String In MASS_RECORD_IDs2CHANGE
|
||||
stateBW = String.Format("Working on record {0} of {1}...", i, MASS_RECORD_IDs2CHANGE.Count.ToString)
|
||||
If SQL_RECORD_AND_FILE_READ_ONLY <> "" Then
|
||||
RIGHT_ONLY_READ_RECORD_FILE = ClassHelper.Check_Record_Read_only(CInt(Record), CURRENT_ENTITY_ID)
|
||||
End If
|
||||
If RIGHT_ONLY_READ_RECORD_FILE = False Then
|
||||
SQL = String.Format("SELECT GUID FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", control_Id, CInt(Record))
|
||||
Dim ex_GUID = ClassDatabase.Execute_Scalar(SQL, True)
|
||||
If Not IsNothing(ex_GUID) Then
|
||||
SQL = String.Format("UPDATE TBPMO_CONTROL_VALUE SET VALUE = '{0}',CHANGED_WHO = '{1}' WHERE GUID = {2}", val, USER_USERNAME, ex_GUID)
|
||||
If ClassDatabase.Execute_non_Query(SQL, False) = False Then
|
||||
_Error = True
|
||||
ClassLogger.Add(">> Error in updating the value for Record: " & Record, False)
|
||||
|
||||
Else
|
||||
ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(CURRENT_ENTITY_ID, control_Id, CInt(Record), val)
|
||||
End If
|
||||
Else
|
||||
SQL = String.Format("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES ({0},{1},'{2}','{3}')", control_Id, CInt(Record), val, USER_USERNAME)
|
||||
If ClassDatabase.Execute_non_Query(SQL, False) = False Then
|
||||
_Error = True
|
||||
ClassLogger.Add(">> Error in inserting the value for Record: " & Record, False)
|
||||
Else
|
||||
ClassProxy.PRPROXY_CONTROL_VALUE_UPD_INS(CURRENT_ENTITY_ID, control_Id, CInt(Record), val)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
BackgroundWorker.ReportProgress(i)
|
||||
i += 1
|
||||
Next
|
||||
SUCCESSFULL = True
|
||||
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Unexpected Error in Getting record to be changed:" & ex.Message)
|
||||
_Error = True
|
||||
End Try
|
||||
Else
|
||||
ClassLogger.Add("No defined column found! (1)")
|
||||
_Error = True
|
||||
End If
|
||||
Else
|
||||
ClassLogger.Add("No defined column found! (2)")
|
||||
_Error = True
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Dim stateBW As String
|
||||
Private Sub BackgroundWorker_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker.ProgressChanged
|
||||
Me.ProgressBar1.Value = e.ProgressPercentage
|
||||
lblStateBW.Text = stateBW
|
||||
End Sub
|
||||
|
||||
Private Sub BackgroundWorker_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker.RunWorkerCompleted
|
||||
Me.ProgressBar1.Visible = False
|
||||
Me.lblStateBW.Visible = False
|
||||
Dim msg As String
|
||||
msg = "Alle Änderungen wurden ausgeführt!"
|
||||
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "All changes were executed!"
|
||||
End If
|
||||
If _Error = True Then
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = msg & vbNewLine & "But errors occured while updating values! Check the log"
|
||||
Else
|
||||
msg = msg & vbNewLine & "Aber während des Update-Vorgangs erreigneten sich Fehler! Prüfen Sie die Logdatei!"
|
||||
End If
|
||||
|
||||
End If
|
||||
MsgBox(msg, MsgBoxStyle.Information)
|
||||
Me.Cursor = Cursors.Default
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user