WIP: EDM Designer, create table

This commit is contained in:
Jonathan Jenne
2018-09-04 16:42:12 +02:00
parent 77c20440d8
commit 720b6955fd
3 changed files with 52 additions and 23 deletions

View File

@@ -16,7 +16,7 @@ Public Class FrmNewTable
_logger = _logFactory.GetCurrentClassLogger()
End Sub
Private Sub FrmNewTable_Load(sender As Object, e As KeyEventArgs) Handles Me.Load
Private Sub FrmNewTable_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
_db = New Firebird(_logFactory, My.Settings.fbDatasource, My.Settings.fbDatabaseLocation, My.Settings.fbUser, My.Settings.fbPassword)
Catch ex As Exception
@@ -26,6 +26,26 @@ Public Class FrmNewTable
End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Dim oTableName As String = txtTablename.Text
If oTableName.Trim() = String.Empty Then
MsgBox("Table name cannot be empty!", MsgBoxStyle.Exclamation)
Exit Sub
End If
Dim oExistingTableId = _db.GetScalarValue($"SELECT GUID FROM TBEDM_TABLE WHERE DESCRIPTION = '{oTableName}'")
If oExistingTableId IsNot Nothing Then
MsgBox("Table already exists!", MsgBoxStyle.Exclamation)
Exit Sub
End If
Dim oResult = _db.GetScalarValue($"SELECT FNCREATE_TABLE('{oTableName}','{Environment.UserName}') FROM rdb$database;")
If oResult >= 0 Then
Close()
Else
MsgBox("An error occurred while creating the table. Check the log", MsgBoxStyle.Critical)
End If
End Sub
End Class