The final submission for this project involves the ability to select the input database dynamically, developing forms to display and modify the data, display the solution to the task planning problem visually, and creating a multiple- document interface to contain and manage all forms within a main container form. Open the project template and study the code in the classes Nodes, Arcs, Database, Optimization and frmSolver in detail. Then follow the instructions below to incorporate the remaining components and relevant code to complete your project for final submission.
FINAL SUBMISSION INSTRUCTIONS:
1- Create a new form class named frmTasks and set its Text property as "Tasks". Include a MenuStrip object on the form, include a menu item named "Save" and another menu item named "Delete" to the right of the first menu item. Add a DataGridView object to this form, name it as dgvGrid, and make it fill the remaining area using the Dock property. On the code page of frmTasks, include a public property called DB as a Database object, and another public property called SolverForm as frmSolver. In the design view, double click on the Save menu button to create its event handler sub. In this sub, call the UpdateTasks method of the DB property, and then call the SolveProblem sub of the SolverForm property. In the design view, double click on the Delete menu button to create its event handler sub. In this sub, check if dgvGrid.SelectedRows.Count is equal to 1. If so, include the code dgvGrid.Rows.RemoveAt(dgvGrid.CurrentRow.Index); otherwise ask the user to select only one row to delete using a message box. Repeat this procedure to create a new form class named frmBlocked.
2- Create a new form class named frmSolution and set its Text property as "Solution". Include a panel object (keep the default name Panel1) and dock it at the top of the form. Add a DataGridView object to this form, name it as dgvGrid, and make it fill the remaining area using the Dock property. On the code page of frmSolution, include a public property called DB as a Database object, and another public property called GridCreated as Boolean.
Create a public sub called DrawGrid. In this function do the following:
a. Clear the rows and columns of dgvGrid using Rows.Clear and Columns.Clear methods
b. Create a list of "stop" type nodes using a LINQ over DB.NodeSList.Values
c. Create a variable named colWidth as integer and set it equal to 0.8 * Me.Width / (DB.NumDays + 1). Create a variable named rowHeight as integer and set it to 0.8 * (Me.Height – Panel1.Height) / DB.NumHoursPerDay
d. Set the ColumnCount property of dgvGrid as DB.NumDays + 1. Set the Name property of dgvGrid.Columns(0) to "Hour"
e. In a For loop over index i from 1 to Db.NumDays, using a with construct on dvgGrid.Columns(i), set the Name property to "Day_" & i, set the Width property to colWidth, set both HeaderCell.Style.Alignment property and DefaultCellStyle.Alignment property to DataGridViewContentAlignment.MiddleCenter.
f. There is always one default row in dgvGrid. Add as many as DB.NumHoursPerDay – 1 rows to dgvGrid using dgvGrid.Rows.Add(<# of rows>) method.
g. Create list1 of arcs with Flow values greater than 0.1 using a LINQ over DB.ArcSList.Values, ordered by Head.DueDate of these arcs. Using a For Each loop with loop variable t over list1, create a variable named day as integer and set it to Math.Floor((t.Head.DueDate - 0.01) / DB.NumHoursPerDay) + 1. Create a variable named hour as integer and set it to t.Head.DueDate - (day - 1) * DB.NumHoursPerDay. Using a with construct on dgvGrid.Rows(hour - 1).Cells("Day_" & day), set Value property to t.TailName and set Style.Background property to t.Tail.TaskColor.
h. Create list2 of "blocked" type nodes using a LINQ over DB.NodeSList.Values. Using a For Each loop with loop variable n over list2, create a variable named day as integer and set it to Math.Floor((n.DueDate - 0.01) / DB.NumHoursPerDay) + 1. Create a variable named hour as integer and set it to n.DueDate - (day - 1) * DB.NumHoursPerDay. Using a with construct on dgvGrid.Rows(hour - 1).Cells("Day_" & day), set Value property to n.Name and set Style.Background property to Color.Gray.
In the Load event of frmSolution, call DrawGrid and set GridCreated to True. Find the SizeChanged event of frmSolution (in design view) from the Properties window (using the lightning bolt icon) and double click to the right of this event which creates the event handler sub. In this sub, call DrawGrid if GridCreted is True.
3- Create a new form named frmMain. Add a MenuStip object and a ToolStip object to this form. Change the IsMdiContainer property of the form to True. Change the Text Property of the form to "Task Planning". Following the MDI example, in the code page of frmMain, include a public property called FormSList which is a new instance of a sorted list of String type keys and Form objects as values. Create a GetForm function similar to the MDI example. Include cases for "Solver", "Solution", "Tasks" and "Blocked" with corresponding instances of their respective form classes. Include a sub called LoadSolverForm (similar so LoadNetworkForm in the MDI example). In the Load event handler sub of frmMain, initialize FormSList by entering the keys and leaving the values as Nothing, and calling the LoadSolverForm. Make frmMain the Startup form.
4- In the code page of frmSolver, add a public property named MainForm as frmMain. At the bottom of the page under the line INCLUDE NEW CODE BELOW THIS LINE, add a public sub named ShowSolution with one input argument frm as frmSolution. In this sub, set DB property of frm to MyDB, call DrawGrid, Show and BringToFront methods of frm in this given order. In the event handler of btnSolution.Click, call ShowSolution using MainForm.GetForm("Solution") as its input argument. Create a public sub named ShowTasks with one argument frm as frmTasks. In this sub, set dgvGrid.DataSource property of frm to MyDB.MyData.Tables("Tasks"). Set frm.DB to myDB, set frm.SolverForm to Me, call Show and BringToFront methods of frm. In the event handler sub for btnOpenTable.Click, use a Select Case construct over lstData.Text and call ShowTasks with the input argument MainForm.GetForm("Tasks"). Repeat the procedure that starts with ShowTasks sub also for the Blocked table.
5- In the design view of frmMain, click on the MenuStrip object. Include the menu item "Solver" with the sub menu items "File", "Open", "Solve", and "Solution"; include the menu item "Data" with sub menu items "Tasks" and "Blocked"; include the menu item "Window" (with no sub menu items); include the menu item "Help" with sub menu items "About" and "Team". Click on the MenuStrip object and set the MdiWindowListItem property to WindowToolStripMenuItem in the Properties window.
6- Create buttons corresponding to sub menu items on the ToolStrip object, where groups of buttons are separated by separator; change the names of buttons to be coordinated with their MenuStrip counterparts (e.g. change the name ToolStripButton1 to FileToolStripButton). Double click on each sub menu item to create event handlers (except for the Window menu); put a comma after the event declaration and add the click event of the corresponding ToolStripButton (e.g. Private Sub FileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FileToolStripMenuItem.Click, FileToolStripButton.Click).
7- In the FileToolStipMenuItem.Click event handler, create a variable frm as frmSolver, which is assigned to
GetForm("Solver"); then call BringToFront and SelectFile methods of frm. Repeat this for the event handlers for OpenToolStripMenuItem.Click and SolveToolStipMenuItem.Click using the respective form class types for frm and OpenDatabase and SolveProblem, methods of frm, respectively.
8- For SolutionToolStripMenuItem.Click, use a variable frm as frmSolver and assign it to GetForm("Solver"), then call frm.ShowSolution(GetForm("Solution")). Repeat this procedure for TasksToolStripMenuItem.Click with the call frm.ShowTasks(GetForm("Tasks")) and also for BlockedToolStripMenuItem.Click with the call frm.ShowBlocked(GetForm("Blocked")).
9- Add form frmAbout with the Text property "About" to provide summary information about your project. Add another form frmTeam with the Text property "Team" to list team member pictures and information. Include entries in the Select Case construct of the GetForm function for these forms and the initialization of the Load event of frmMain. In AboutToolStripMenuItem.Click even handler, create variable frm as frmAbout and assign it to GetForm("About"); then call Show and BringToFront event of frm. Repeat this procedure for TeamToolStripMenuItem.Click event handler.
10- You are encouraged to be creative and add more functions to your project to earn more credit. If you create new forms, keep in mind to update the MenuStrip, ToolStrip and FormSList accordingly. When your work is completed, zip the project folder and submit it to the FINAL SUBMISSION (TEAM) assignment.
This assignment has been answered 2 times in private sessions.
© 2020 Codify Tutor. All rights reserved