2023-05-22 16:55:44 +02:00

63 lines
3.2 KiB
VB.net

Imports System.Windows.Forms
Public Class frmNewVariant
Dim DT_REASONS As DataTable
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
If cmbReason.SelectedIndex <> -1 Then
Dim result As MsgBoxResult
Dim msg = "Möchten Sie nun eine neue Variante anlegen?"
If USER_LANGUAGE <> "de-DE" Then
msg = "Would You now really create a new variant?"
End If
result = MessageBox.Show(msg, "Create variant:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.Yes Then
msg = "Wollen Sie die der Vorgängerversion zugeordenten Dateien mit der neuen Variante verlinken?"
If USER_LANGUAGE <> "de-DE" Then
msg = "Would You like to link the files of the 'old' varaint with the new variant?"
End If
Dim RelinkFiles As Integer = 0
result = MessageBox.Show(msg, "Create variant:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.Yes Then
RelinkFiles = 1
End If
Dim SQL = String.Format("EXEC PRPMO_CREATE_VARIANT {0},'{1}','{2}','{3}','{4}'", CURRENT_RECORD_ID, USER_USERNAME, cmbReason.Text, txtComment.Text, RelinkFiles)
If MYDB_ECM.ExecuteNonQuery(SQL) = True Then
Dim sel = String.Format("SELECT MAX(GUID) FROM TBPMO_RECORD WHERE UPPER(ADDED_WHO) = '{0}'", USER_USERNAME.ToUpper)
CURRENT_RECORD_ID = MYDB_ECM.GetScalarValue(sel)
msg = "Die neue Variante wurde erzeugt?"
If USER_LANGUAGE <> "de-DE" Then
msg = "The new variant was created successfully?"
End If
MsgBox(msg, MsgBoxStyle.Information)
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
Else
MsgBox("Unexpected Error in Creating Variant. Please check the log!", MsgBoxStyle.Critical)
End If
End If
Else
MsgBox("Please choose an entry out of the combobox!", MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub frmNewVariant_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
Dim sel = String.Format("SELECT * FROM TBPMO_ENTITY_VARIANT_REASONS WHERE ENTITY_ID = {0}", CURRENT_ENTITY_ID)
DT_REASONS = MYDB_ECM.GetDatatable(sel)
cmbReason.DataSource = DT_REASONS
cmbReason.DisplayMember = DT_REASONS.Columns("REASON_CODE").ColumnName
cmbReason.ValueMember = DT_REASONS.Columns(0).ColumnName
Me.cmbReason.SelectedIndex = -1
Me.txtComment.Text = ""
Catch ex As Exception
MsgBox("Error in Loading Basic Data: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class