57 lines
3.3 KiB
VB.net
57 lines
3.3 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
|
|
Dim SQL = String.Format("EXEC PRDD_COPY_RECORD {0}, '{1}'", CURRENT_RECORD_ID, Environment.UserName)
|
|
If ClassDatabase.Execute_non_Query_withConn(SQL, 1) = True Then
|
|
Dim sel = String.Format("SELECT MAX(GUID) FROM TBPMO_RECORD WHERE UPPER(ADDED_WHO) = '{0}'", Environment.UserName.ToUpper)
|
|
Dim REC_ID = ClassDatabase.Execute_Scalar(sel)
|
|
Dim Upd = String.Format("UPDATE TBPMO_RECORD SET PARENT_RECORD = {0},CHANGED_WHO = '{1}' WHERE GUID = {2}", REC_ID, Environment.UserName, CURRENT_RECORD_ID)
|
|
If ClassDatabase.Execute_non_Query(Upd) = True Then
|
|
Dim ins = String.Format("INSERT INTO TBPMO_RECORD_VARIANT (RECORD_ID,REASON_CODE,COMMENT,ADDED_WHO) VALUES ({0},'{1}','{2}','{3}')", CURRENT_RECORD_ID, cmbReason.SelectedText, txtComment.Text, Environment.UserName)
|
|
If ClassDatabase.Execute_non_Query(ins) = True Then
|
|
Upd = String.Format("UPDATE TBPMO_RECORD SET RECORD_ENTITY_ID = (SELECT RECORD_ENTITY_ID FROM TBPMO_RECORD WHERE GUID = {0}),CHANGED_WHO = '{1}' WHERE GUID = {2}", CURRENT_RECORD_ID, Environment.UserName, REC_ID)
|
|
If ClassDatabase.Execute_non_Query(Upd) = True Then
|
|
CURRENT_RECORD_ID = REC_ID
|
|
Me.DialogResult = System.Windows.Forms.DialogResult.OK
|
|
Me.Close()
|
|
End If
|
|
End If
|
|
End If
|
|
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_FORM_ID)
|
|
DT_REASONS = ClassDatabase.Return_Datatable(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
|