Final Project Part 1- MDI

Multi-Document Interface

Open the project. Then rename the form frmMain as frmDashboard in the Solution Explorer (make sure that frmMain is collapsed into a single form icon, right-click and choose Rename and type frmDashboard). Change the Text property of this form to “Dashboard”. Create a new form named frmMain, set its Text property to “Client Staffing Optimization” and its IsMdiContainer property to True. This new form is going to be your MDI container form. In the code page of frmDashboard, create a public property called MainForm as a frmMain form type. The go the code page of frmMain and do the following:

- Declare a public property FormSList as a new sorted list of string keys and Form type values.

- Create a private sub called UpdateFormSList with one string parameter named formName. In this sub, use a Select Case structure with formName and include the case “Dashboard”. Under this case, assign a new instance of frmDashboard as the value to FormSList using the formName as the key (i.e.

FormSList(formName).

- Create a public function called GetForm with one string parameter named formName, which returns a Form type object. In this function, use an if-then-else structure, where you check whether the value corresponding to the key as formName is not Nothing. If this condition is satisfied, you return the value from FormSList that corresponds to formName as the key (i.e. FormSList(formName); else you call UpdateFormSList with formName as its parameter. After the if-then-else structure, use a with construct for the form FormSList(formName). Inside the with construct, assign Me to the MdiParent property, assign FormWindowState.Maximized to the WindowState property. After the with construct, return the form FormSList(formName).

- Create a private sub called LoadDashboard. In this sub, declare a variable of type frmDashboard and call GetForm with the parameter “Dashboard” to assign to this variable. Assign Me to the MainForm property of this variable, then call the Show sub of this variable, and then call the BringToFront sub of this variable.

- Create a private sub called InitializeFormSList. In this sub, use a With structure with FormSList, and inside the With structure, use the sub Add with “Dashboard” as key and Nothing as value. After the With structure call the sub LoadDashboard. In the design view of frmMain, double-click on the top bar of the form to create the Load event handler; call InitializeFormSList in this even handler.

- Create a private function named DatabaseLoaded that returns a Boolean value. In this function, declare a variable of type frmDashboard and use GetForm with the parameter “Dashboard” to assign to this variable. Include a Try-Catch structure. Under the Try block, use an if-then structure to check if the DB (database) property of this variable is nothing, in which case you throw an exception with a message to the user to load a database first. After the if-then structure (still within the Try block), return True. In the Catch block use a message box to display the message from the exception, and then return false.

- In the design view, add a menu strip object to frmMain. Add the top-level menu item “File” to the menu strip. Under this menu item, add menu items “Open Database” and “Exit Application”. Double- click on “Open Database” menu item to create its event handler. In this even handler, add an if-then structure to check if the call to DatabaseLoaded function equals true. Inside the if-then structure, create a variable of type frmDashboard and call GetForm with parameter “Dashboard” to assign to this

 

variable. Call BringToFront sub of this variable, and then call OpenDatabase sub of this variable. Double- click on “Exit Application” to create its event handler. In this event handler, declare an integer type variable and call a message box (on the right hand side of the assignment operator “=” ) to assign to this variable with a message to ask the user if they want to exit the application. Include an if-then structure to check if this variable is equal to DialogResult.Yes. Inside the if-then structure, call Application.Exit()

- Add the top-level menu item “Solution” to the menu strip, under which add menu item “Dashboard” and menu item “Optimize”. Double-click on menu item “Dashboard” to create its event handler. In the event handler call the LoadDashboard sub. In the code page of frmDashboard, create a public sub called OptimizeAll. Move the code under the event handler for btnOptimize.Click to the sub OptimizeAll. Call the sub OptimizeAll in the event handler for btnOptimize.Click. In the design view of frmMain, double- click on the menu item “Optimize” to create its event handler. In this event handler, add an if-then structure to check if the call to DatabaseLoaded function equals true. Inside the if-then structure, create a variable of type frmDashboard and call GetForm with parameter “Dashboard” to assign to this variable. Call BringToFront sub of this variable, and then call OptimizeAll sub of this variable.

Need a custom answer at your budget?

This assignment has been answered 6 times in private sessions.

Or buy a ready solution below.

Buy ready solution

Solution previews

© 2024 Codify Tutor. All rights reserved