|
DB Visual ARCHITECT (DB-VA) can generate C#.NET source code so you can implement your application by C# programming language directly but you also can choose another language (VB.NET or C++) based on your taste in the .NET Framework. DB-VA generates DLL files and persistent libraries that can be referenced by .NET projects of language other than C#.
In this chapter:
Visual Basic .NET (VB.NET) is an Object-Oriented computer language that can be viewed as an evolution of Microsoft’s Visual Basic (VB) implemented on the Microsoft .NET framework. The .NET Framework contains a virtual machine called Common Intermediate Language (CIL). Simply put, programs are compiled to produce CIL and the CIL is distributed to user to run on a virtual machine. VB.NET, C++, C# compilers are available from Microsoft for creating CIL. In DB-VA you can generate C# persistent source code and DLL files, so you can reference the DLL file and Persistent Library in Visual Studio .NET 2003 and develop the VB.NET application.
In the following section, you will develop a VB.NET application. The application is exactly the same as the one in Chapter 4 – Developing Standalone .NET Application sample but this time you use VB.NET instead of C# for development. You need to download Chapter 4 sample application because it contains the DLL file and persistent libraries for your VB.NET project.

By checking this option, DB-VA will generate DLL files which can be referenced by .NET projects of language other than C#. DB-VA generates a batch file for this DLL file at the same time. You can modify the configure file (hibernate.cfg.xml) manually and use the batch file to recompile and build an up-to-date DLL file for referenced project.
![]()






|
VB.NET |
C# |
|
Imports school Imports Orm |
using school; using Orm; |
|
VB.NET |
C# |
|
Dim t As PersistentTransaction = SchoolSystemPersistentManager.Instance.GetSession.BeginTransaction |
PersistentTransaction t = SchoolSystemPersistentManager.Instance().GetSession().BeginTransaction(); |


|
Private Sub okButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okButton.Click If (loginIDTextBox.Text.Length = 0 Or passwordTextBox.Text.Length = 0) Then MessageBox.Show("Login id or password missing") Return End If Dim t As PersistentTransaction = SchoolSystemPersistentManager.Instance.GetSession.BeginTransaction Try If (_userType = CREATE_TEACHER) Then User = TeacherFactory.CreateTeacher() ElseIf (_userType = CREATE_STUDENT) Then User = StudentFactory.CreateStudent() End If |
|
|
Source File : Standalone School System VB.NET\RegisterDialog.vb |
|
|
User.Password = passwordTextBox.Text User.LoginID = loginIDTextBox.Text If (TypeOf User Is Teacher) Then CType(User, Teacher).Email = emailTextBox.Text End If |
|
Source File : Standalone School System VB.NET\RegisterDialog.vb |
|
User.Save() t.Commit() DialogResult = DialogResult.OK Close() Catch ex As Exception Console.WriteLine(ex.InnerException.Message) DialogResult = DialogResult.Cancel t.RollBack() End Try |
|
Source File : Standalone School System VB.NET\RegisterDialog.vb |
After the user login the School System, the system query different Course objects from the database according to user role. If the user is a student, the system shows all the courses. The student can select and register the course. If the user is a teacher, the system shows courses are created by that teacher. The teacher can update or delete the course in the system.
Student Login:

Teacher Login:

|
Private Sub UpdateTreeView() Dim lCourses() As Course If (TypeOf CurrentUser Is Student) Then lCourses = CourseFactory.ListCourseByQuery(Nothing, Nothing) ElseIf (TypeOf CurrentUser Is Teacher) Then lCourses = CType(CurrentUser, Teacher).courses.ToArray() End If ... End Sub |
|
Source File : Standalone School System VB.NET \SchoolSystemForm.vb |
You can modify the user information and update the record in database. After the user login, the User object is stored in the application, so you can set new information to the user object and update the database record.


|
Private Sub okButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okButton.Click If (nameTextBox.Text.Length = 0 Or passwordTextBox.Text.Length = 0) Then MessageBox.Show("Missing login id and password") Else Dim t As PersistentTransaction = SchoolSystemPersistentManager.Instance.GetSession.BeginTransaction Try _user.Name = nameTextBox.Text _user.Password = passwordTextBox.Text If (TypeOf _user Is Teacher) Then CType(_user, Teacher).Email = emailTextBox.Text End If _user.Save() DialogResult = DialogResult.OK t.Commit() Catch ex As Exception DialogResult = DialogResult.Cancel t.RollBack() End Try End If Close() End Sub |
|
Source File : Standalone School System VB.NET\ModifyUserDialog.cs |
Teacher can create course for students to register, and they can cancel courses in the system. They only need to click delete button of the course then the course information will be deleted in the database and all its relationships with registered students will be removed.



|
Private Sub deleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deleteButton.Click If (MessageBox.Show("Delete", "Delete", MessageBoxButtons.OKCancel).Equals(DialogResult.OK)) Then |
|
Source File : Standalone School System VB.NET\CoursePanel.vb |
|
Dim t As PersistentTransaction = SchoolSystemPersistentManager.Instance().GetSession().BeginTransaction() Try _CourseNode.Course().DeleteAndDissociate() _CourseNode.Remove() t.Commit() Catch ex As Exception Console.WriteLine(ex.InnerException.Message) t.RollBack() End Try End If End Sub |
|
Source File : Standalone School System VB.NET\CoursePanel.vb |
The VB.NET project is implemented in Visual Studio .NET 2003. To execute the VB.NET Application, select Debug > Start (F5) from the menu bar.


|
|
|||||||