Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Visual Basic Quesion: Write an application that tracks the amount of billable ti

ID: 641581 • Letter: V

Question

 Visual Basic Quesion:  Write an application that tracks the amount of billable time that the user spends on consulting projects. The application reads an input client file and appends information to a billing file, which it creates the first time it runs. Startup Form: When the user begins working on a project, the client name is selected from a ComboBox control. In Figure 1-25, the user has clicked the Start button, so the billing timer is running. Notice that the Start button is disabled. In Figure 1-26, the user has clicked the Stop button. At that moment, the application shows the amount of elapsed time and writes a record to the billing file. 
 Coordinate the command buttons carefully to make sure the user cannot click out of sequence. The following table shows the two possible program states that affect the buttons. The program is in State 1 when it starts; after clicking the Start button, the program enters State 2. When the Stop button is clicked, the program returns to State 1.     State                  Start                          Stop                     Exit    1                      Enabled                        Disabled                 Enabled    2                      Disabled                       Enabled                  Disabled  When the user clicks the Start button, display a status message Billing in Progress ... to show that the clock is running. Do not permit the user to select a different client while the clock is running. When the Stop button is clicked, display the stop time and the number of billable hours and minutes. The name of the selected client should appear in the window caption. TimeClock Class: Create a class named TimeClock that encapsulates the time-related calculations performed by the program. Use a TimeSpan object to hold the difference between two Date-Time values. The following table lists the TimeClock properties:     Name          Type          Attributes Description    StartTime     DateTime      ReadOnly    StopTime      DateTime      ReadOnly    Elapsed       TimeSpan      ReadOnly   Duration between the starting and ending times    ClientName    String  The following table lists the TimeClock methods:     Name                 Return Type         Attributes          Description    StartClock           none                public              Begins the timing sequence    StopClock            none                public              Ends the timing sequence 
 BillingData Class: Create a class named BillingData to handle the client and billing files. Use the Visual Studio editor to create the client file. Insert at least five records in the client file before running the program. Each record in the client file contains a client name. Your program will create the billing file the first time it runs. Subsequent runs will append to the file.xEach record in the billing file contains the following fields: billing date, client name, start time, stop time, and elapsed time. The following is a sample record:                      02-01-2003,Jones and Smith,21:51,22:10,1:19 

Explanation / Answer

Client Billing

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
    <ProjectType>Local</ProjectType>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}</ProjectGuid>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ApplicationIcon>
    </ApplicationIcon>
    <AssemblyKeyContainerName>
    </AssemblyKeyContainerName>
    <AssemblyName>TimeClock</AssemblyName>
    <AssemblyOriginatorKeyFile>
    </AssemblyOriginatorKeyFile>
    <AssemblyOriginatorKeyMode>None</AssemblyOriginatorKeyMode>
    <DefaultClientScript>JScript</DefaultClientScript>
    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
    <DefaultTargetSchema>IE50</DefaultTargetSchema>
    <DelaySign>false</DelaySign>
    <OutputType>WinExe</OutputType>
    <OptionCompare>Binary</OptionCompare>
    <OptionExplicit>On</OptionExplicit>
    <OptionStrict>Off</OptionStrict>
    <RootNamespace>TimeClock</RootNamespace>
    <StartupObject>TimeClock.Form1</StartupObject>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <MyType>WindowsFormsWithCustomSubMain</MyType>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <OldToolsVersion>2.0</OldToolsVersion>
    <TargetFrameworkProfile />
    <PublishUrl>publish</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <OutputPath>bin</OutputPath>
    <DocumentationFile>TimeClock.xml</DocumentationFile>
    <BaseAddress>285212672</BaseAddress>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>
    </DefineConstants>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <DebugSymbols>true</DebugSymbols>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>1</WarningLevel>
    <NoWarn>42016,42017,42018,42019,42032,42353,42354,42355</NoWarn>
    <DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>bin</OutputPath>
    <DocumentationFile>TimeClock.xml</DocumentationFile>
    <BaseAddress>285212672</BaseAddress>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>
    </DefineConstants>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <DebugSymbols>false</DebugSymbols>
    <Optimize>true</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>1</WarningLevel>
    <NoWarn>42016,42017,42018,42019,42032,42353,42354,42355</NoWarn>
    <DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
    <Reference Include="System">
      <Name>System</Name>
    </Reference>
    <Reference Include="System.Data">
      <Name>System.Data</Name>
    </Reference>
    <Reference Include="System.Drawing">
      <Name>System.Drawing</Name>
    </Reference>
    <Reference Include="System.Windows.Forms">
      <Name>System.Windows.Forms</Name>
    </Reference>
    <Reference Include="System.Xml">
      <Name>System.XML</Name>
    </Reference>
</ItemGroup>
<ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Drawing" />
    <Import Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
    <Compile Include="AssemblyInfo.vb">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="BillingData.vb">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="frmMain.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="TimeClock.vb">
      <SubType>Code</SubType>
    </Compile>
    <EmbeddedResource Include="frmMain.resx">
      <DependentUpon>frmMain.vb</DependentUpon>
    </EmbeddedResource>
</ItemGroup>
<ItemGroup>
    <None Include="app.config" />
</ItemGroup>
<ItemGroup>
    <Folder Include="My Project" />
</ItemGroup>
<ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
      <Visible>False</Visible>
      <ProductName>Windows Installer 3.1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)Microsoft.VisualBasic.targets" />
<PropertyGroup>
    <PreBuildEvent>
    </PreBuildEvent>
    <PostBuildEvent>
    </PostBuildEvent>
</PropertyGroup>
</Project>

TimeCLock

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeClock", "TimeClock.vbproj", "{6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}"
EndProject
Global
   GlobalSection(SolutionConfigurationPlatforms) = preSolution
       Debug|Any CPU = Debug|Any CPU
       Release|Any CPU = Release|Any CPU
   EndGlobalSection
   GlobalSection(ProjectConfigurationPlatforms) = postSolution
       {6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
       {6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
       {6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
       {6989087F-E23E-4CBA-8AED-FFBEB8A2DFAF}.Release|Any CPU.Build.0 = Release|Any CPU
   EndGlobalSection
   GlobalSection(SolutionProperties) = preSolution
       HideSolutionNode = FALSE
   EndGlobalSection
EndGlobal

Imports System.IO
Imports System.IO.File

Public Class BillingData

   Private mBillingFile As StreamWriter
   Private mClientFile As StreamReader
   Private mClientColl As New Collection

   Sub New()
       If Exists("billing.txt") Then
           mBillingFile = AppendText("billing.txt")
       Else
           mBillingFile = CreateText("billing.txt")
       End If

       mClientFile = OpenText("clients.txt")
       While mClientFile.Peek <> -1
           mClientColl.Add(mClientFile.ReadLine())           'company name
       End While
       mClientFile.Close()
   End Sub

   Public ReadOnly Property ClientColl() As Collection
       Get
           Return mClientColl
       End Get
   End Property

   Public Sub WriteBilling(ByVal record As String)
       mBillingFile.WriteLine(record)
   End Sub

   Public Sub CloseBilling()
       mBillingFile.Close()
   End Sub

End Class