Create New Module

Top  Previous  Next

19. Then Add new project to the solution

 

clip0159

 

 

20. Select Class Library - To create new module.

 

clip0160

 

21. Delete the class1.vb

 

clip0161

22. Add New Form, select inherited form

 

clip0162

 

 

 

23.Select StdDBTranForm.

 

clip0163

 

 

 

24.The New Form1 will be created. Drop a DataGridView in to Browse tab and rename it to BrowseGrid.

 

clip0164

 

 

25.Click Add New Data Source

 

clip0165

 

 

26. Before Adding New Data Source, Build the CSAccountDatabaseIntf Assembly.

 

clip0167

 

 

27. Select MyModule, choice datasource tab, Add New Datasource, then Select Object and next.

 

clip0166

 

 

 

 

28. Navigate till see Dataset1, if can't find Dataset1 means the build for CSAccountDatabaseIntf assembly is fail, please build again.

 

clip0168

 

 

 

29. Choice next and finish, the object for the CSAccountDatabaseIntf will appeared.

 

clip0169

 

 

 

30.Drag and Drop the MST_ACCOUNT to the form1 BrowseGrid at Browse Tab.

 

clip0170

 

 

 

31. The Fields will be automatically created.

clip0171

 

 

32. The example programming code is similiar to FmAccount form in CSGLedger Module, please refer.

 

clip0172

 

Imports CSAccountDatabaseIntf

Imports CSAccountDatabaseIntf.CSGLDataset

Public Class Form1

   Public Overrides Sub DBControlsEnabled(ByVal InValue As Boolean)

       BrowseGrid.ReadOnly = Not InValue

       BrowseGrid.AllowUserToAddRows = InValue

       BrowseGrid.AllowUserToDeleteRows = InValue

   End Sub

 

   Public Overrides Property SystemManager() As CSAccountDatabaseIntf.ICSAccountDatabaseIntf

       Get

           Return MyBase.SystemManager

       End Get

       Set(ByVal value As CSAccountDatabaseIntf.ICSAccountDatabaseIntf)

           MyBase.SystemManager = value

           Try

               SystemManager.LoadCSGLMasterDataset()

               DataSet1 = SystemManager.GetxxxDataset

               Dataset = DataSet1

               MST_ACCOUNTBindingSource.DataSource = DataSet1

           Catch ex As Exception

               If TypeOf ex Is System.Net.Sockets.SocketException Then

                   MsgBox("Server inactive or no network connection !")

                   Exit Property

               End If

               Throw ex

           End Try

       End Set

   End Property

 

   Public Overrides Property KeyInfo() As CSAccountDatabaseIntf.FormKeyInfo

       Get

           m_KeyInfo.KeyNo = -1

           m_KeyInfo.KeyCode = CStr(CType(MST_ACCOUNTBindingSource.Current, DataRowView)("ACC_CODE"))

           Return MyBase.KeyInfo

       End Get

       Set(ByVal value As CSAccountDatabaseIntf.FormKeyInfo)

           MyBase.KeyInfo = value

       End Set

   End Property

 

   Public Overrides ReadOnly Property FirstControl() As System.Windows.Forms.Control

       Get

           Return Nothing 'Control for the Details Tab

       End Get

   End Property

 

   Private Sub FmAccount_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       BindDataSource(MST_ACCOUNTBindingSource)

   End Sub

 

   Private Sub FmAccount_BeforeNewAndEdit(ByVal Sender As System.Object, ByVal e As CSAccountDatabaseIntf.BeforeAfterEditNewEventAgrs) Handles MyBase.BeforeNewAndEdit

       If e.IsNew = False Then

           TabControl.SelectedIndex = 1

       End If

   End Sub

 

   Private Sub FmAccount_tsbtnSaveClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.tsbtnSaveClick

       MST_ACCOUNTBindingSource.EndEdit()

       SystemManager.SavexxxDataset(DataSet1)

       DataSet1.MST_ACCOUNT.AcceptChanges()

   End Sub

 

   Private Sub FmAccount_tsbtnCancelClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.tsbtnCancelClick

       MST_ACCOUNTBindingSource.CancelEdit()

       DataSet1.MST_ACCOUNT.RejectChanges()

   End Sub

 

   Private Sub FmAccount_BeforesbtnSaveclick(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.BeforesbtnSaveclick

       e.Cancel = False

       If DBStatus = FormDBStatus.FormAdd Then

           Dim MyAccRow() As DataRow = DataSet1.MST_ACCOUNT.Select("ACC_CODE='" + CStr(CType(MST_ACCOUNTBindingSource.Current, DataRowView)("ACC_CODE")) + "'")

           If MyAccRow.Length > 0 Then

               MsgBox("Acc# already exists !")

               'ACC_CODETextBox.Select()

               e.Cancel = True

           End If

       End If

       If e.Cancel = False Then

           MST_ACCOUNTBindingSource.EndEdit()

           Dim MyRow() As MST_ACCOUNTRow = CType(DataSet1.MST_ACCOUNT.Select("RETAINED_EARNINGS=1"), MST_ACCOUNTRow())

           If MyRow.Length > 1 Then

               Dim MyRowView As DataRowView = CType(MST_ACCOUNTBindingSource.Current, DataRowView)

               If CBool(MyRowView("RETAINED_EARNINGS")) = True Then

                   MsgBox("Only 1 record are allow for Retained Eearnings")

                   e.Cancel = True

               End If

           End If

       End If

   End Sub

 

   Private Sub FmAccount_BeforeDelete(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.BeforeDelete

       e.Cancel = False

       If MST_ACCOUNTBindingSource.Count > 0 Then

           If SystemManager.CheckAccExists(CStr(CType(MST_ACCOUNTBindingSource.Current, DataRowView)("ACC_CODE"))) Then

               MsgBox("Financial Template data exists !")

               e.Cancel = True

           End If

       End If

   End Sub

End Class

 

 

 

33. Select CSGLedger Module and select FormsInfo.vb, right click and copy

 

clip0174

 

 

 

34. Paste it on MyModule

 

clip0175

 

35. Open up and delete All AddForm Function except first one.

 
clip0176

 

 

36. The FormsInfo class define the module info to be read later.

 

AddForm("Form1", "MyModule.Form1", GetType(Form1), Nothing)