1、Building the Contoso Auto Sales Office Business Application Part 1Building the Contoso Auto Sales Office Business Application Part 1Building the Contoso Auto Sales Office Business Application Part 1 - Scheduling Customer AppointmentsRobert GreenMCW TechnologiesDownload the code for this tutorial on
2、Code GalleryIntroductionContoso Auto Sales is a fictitious automobile dealer specializing in high-end automobiles. Contoso has computer systems to talk to suppliers, to generate an invoice when a customer purchases an automobile, to bill for service visits and to pay employees. It wants a system to
3、manage the day-to-day interaction with customers and improve its level of pre-sales customer service.Contoso Auto would like a solution based on Office 2007 that addresses the following scenarios: The sales manager needs to contact customers who have requested an appointment by calling Contoso or vi
4、siting the Web site. She wants to send a mail acknowledging the appointment request and then schedule appointments using Outlook. Sales consultants want to use Word to create and print price quotes for automobiles, reflecting available options selected by a customer. The financing manager wants to u
5、se Excel to generate financing information for customers with pending quotes. He wants the ability to generate this information interactively, but also wants it created automatically when the sales consultant generates a quote. The sales manager wants to use Excel to run reports showing quotes by ma
6、nufacturer, model, customer and employee. She wants to view reports offline on her laptop and wants the reports automatically updated with up to date information.In this tutorial series, you will use Visual Studio 2008 to create an Office Business Application that address each of the scenarios liste
7、d above, using Outlook 2007, Word 2007 and Excel 2007. The tutorials contain both Visual Basic and C# code. Exercise 1: Create the Outlook Add-in ProjectPotential customers can request an appointment by visiting the Contoso Web site or by calling Contoso directly. The onus is now on Contoso to conta
8、ct that customer and schedule a day and time to meet with a sales consultant. Not responding means lost opportunities for sales. Contoso wants to use Outlook to respond to and schedule customer requests for appointments. The sales manager wants to respond via email to let the customer know she has r
9、eceived the appointment request and will contact the customer. She will then call the customer to arrange for an appointment with a sales consultant. In this tutorial, you will create an Outlook 2007 customer appointment management solution. You will add the following capabilities to Outlook: The ab
10、ility to send an email to all of the customers who have requested appointments. The automatic creation of follow-up tasks for each customer who requested an appointment. The ability to auto-fill meeting requests with customer and sales rep information and send the customer a confirmation email. To g
11、et started, in Visual Studio 2008 select File | New | Project to display the New Project dialog box. In the list of project types, expand the Office node. Select Version2007, displaying the list of templates shown in Figure 1.Figure 1. Visual Studio 2008 provides these Office 2007 templates.In the T
12、emplates pane, select Outlook 2007 Add-in. Name your project CustomerAppointments and select an appropriate folder for the project. Click OK to create the project. Your add-in will work with data that resides in the ContosoAuto SQL Server database. You first need to create the database. Open SQL Ser
13、ver Management Studio and connect to SQL Server (or SQL Server Express). Select File | Open | File to display the Open File dialog box. Navigate to the folder where you downloaded this tutorials sample project. Navigate to the Data folder. Select InstallContosoAuto.sql and click Open. Click Execute
14、to run the script. If you do not have SQL Server Management Studio, open a command prompt. To do this, locate the Command Prompt item in the Start menu. Right-click on it and select Run as administrator. Enter the following to install the database on your local sqlexpress instance:1. sqlcmd -S .sqle
15、xpress -i C:SampleLocationDataInstallContosoAuto.sqlReplace C:SampleLocation with the path to this tutorials sample project. The command above assumes you are using SQL Server Express. If you are using SQL Server, replace .sqlexpress with computer nameinstance name. For more information on sqlcmd, p
16、lease see the MSDN Library. Close the command prompt.Return to Visual Studio. In the Solution Explorer, right-click on Data Connections and select Add Connection to display the Add Connection dialog box. If the Data source does not display Microsoft SQL Server (SqlClient), click Change. This display
17、s the Change Data Source dialog box. Select Microsoft SQL Server (SqlClient) and click OK. In the Add Connection dialog box, enter your computer name (if you are using SQL Server) or .SQLEXPRESS(if you are using SQL Server Express) in the Server name text box. Select ContosoAuto from the database dr
18、op-down list. Click OK to close the Add Connection dialog box. In the Server Explorer, expand the ContosoAuto node. Expand the Tables node to see the tables in the database (see Figure 2). Figure 2. The ContosoAuto database contains these tables. To see the data in the Manufacturers table, right-cli
19、ck on Manufacturers and select Show Table Data. You should see the data shown in Figure 3. Use the same technique to view the sample data in the Models table (see Figure 4), AvailablePackages (see Figure 5) and Employees (see Figure 6) tables. The Manufacturers table contains the automobile makers.
20、The Models table contains the automobiles. The AvailablePackages table contains options available for each automobile. The Employees table contains Contoso Autos sales representatives and sales manager.Figure 3. The Manufacturers table contains this data. Figure 4. The Models table contains this dat
21、a. Figure 5. The AvailablePackages table contains this data. Figure 6. The Employees table contains this data. The Outlook solution you are building in this tutorial also needs a connection to the ContosoAuto database. Select Project | CustomerAppointments Properties. Select the Settings tab. To add
22、 a new setting, enter ContosoAutoConnectionString in the Name column. Select (Connection string) from the Type drop-down list. Click the ellipsis in the Value text box. This displays the Connection Properties dialog box. Create a connection to the ContosoAuto database. Click OK to close the Connecti
23、on Properties dialog box. Close the Project Designer, saving your changes. You will use a DataSet to communicate with the ContosoAuto database. Rather than create the DataSet from scratch, you will use an existing version of it. Select Project | Add Existing Item to display the Open File dialog box.
24、 Navigate to the folder where you downloaded this tutorials sample project. Navigate to the DataSetsCustomerAppointments folder. Then navigate to the VB or CS folder depending on the language you are using. SelectContosoAutoDataSet.xsd and click OK to add the DataSet to the project.In the Solution E
25、xplorer, double-click ContosoAutoDataSet.xsd to open the DataSet Designer (see Figure 7). Take a few minutes to familiarize yourself with the tables and TableAdapters. Figure 7. The add-in uses this DataSet to work with the data in the ContosoAuto database.Close the DataSet Designer. Save your chang
26、es. Select Build | Build Solution and verify that the project compiles correctly.Exercise 2: Build a Custom Outlook MenuIn this exercise, you will add a Customers menu to Outlook. The sales manager will use this menu to respond to customer appointment requests and to schedule appointments. Add the M
27、enu to OutlookThe ThisAddIn class currently has two methods. ThisAddIn_Startup runs when the add-in loads, shortly after Outlook starts. ThisAddIn_Shutdown runs when the add-in unloads, shortly before Outlook stops. Your first thought might be to put code like the following to add the Customers menu
28、 in the Startup event handler. Visual Basic Get a reference to the Outlook main menu barmainMenuBar = thisExplorer.CommandBars.ActiveMenuBar Locate the Help menuTry helpMenuIndex = mainMenuBar.Controls(Help).IndexCatch helpMenuIndex = mainMenuBar.Controls.CountEnd Try Create a Customers menu to the
29、left of the Help menumainMenu = CType(mainMenuBar.Controls.Add( _ Office.MsoControlType.msoControlPopup, Type.Missing, _ Type.Missing, helpMenuIndex, True), Office.CommandBarPopup)mainMenu.Caption = CustomersmainMenu.Visible = True1. / C#2. / Get a reference to the Outlook main menu bar3. mainMenuBa
30、r = thisExplorer.CommandBars.ActiveMenuBar;4. / Locate the Help menu5. try6. 7. helpMenuIndex = mainMenuBar.ControlsHelp.Index;8. 9. catch10. 11. helpMenuIndex = mainMenuBar.Controls.Count;12. 13. / Create a Customers menu to the left of the Help menu14. mainMenu = (Office.CommandBarPopup)15. (mainM
31、enuBar.Controls.Add(Office.MsoControlType.msoControlPopup,16. Type.Missing, Type.Missing, helpMenuIndex, true);17. mainMenu.Caption = Customers;18. mainMenu.Visible = true;This code will add a Customers menu. However, it will only appear in one window. Outlook will add the menu to whatever window it
32、 opened first when it started. This will typically be the Inbox, but the user can change Outlooks startup folder in the Options dialog. If you then open another window, such as the Calendar or Contacts, the Customers menu will not appear in that window. Contrast this with Word or Excel, where adding a menu item adds that menu to the application, not to whatever document is currently open. The CommandBars collection object represents the menu bar and toolbars in
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1