Building the Contoso Auto Sales Office Business Application Part 3文档格式.docx
《Building the Contoso Auto Sales Office Business Application Part 3文档格式.docx》由会员分享,可在线阅读,更多相关《Building the Contoso Auto Sales Office Business Application Part 3文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
ReadPart2:
BuildingtheContosoAutoSalesOfficeBusinessApplicationPart2-GeneratingAutomobileQuotes
Introduction
ContosoAutoSalesisafictitiousautomobiledealerspecializinginhigh-endautomobiles.Contosohascomputersystemstotalktosuppliers,togenerateaninvoicewhenacustomerpurchasesanautomobile,tobillforservicevisitsandtopayemployees.Itwantsasystemtomanagetheday-to-dayinteractionwithcustomersandimproveitslevelofpre-salescustomerservice.
ContosoAutowouldlikeasolutionbasedonOffice2007thataddressesthefollowingscenarios:
∙ThesalesmanagerneedstocontactcustomerswhohaverequestedanappointmentbycallingContosoorvisitingtheWebsite.ShewantstosendamailacknowledgingtheappointmentrequestandthenscheduleappointmentsusingOutlook.
∙SalesconsultantswanttouseWordtocreateandprintpricequotesforautomobiles,reflectingavailableoptionsselectedbyacustomer.
∙ThefinancingmanagerwantstouseExceltogeneratefinancinginformationforcustomerswithpendingquotes.Hewantstheabilitytogeneratethisinformationinteractively,butalsowantsitcreatedautomaticallywhenthesalesconsultantgeneratesaquote.
∙ThesalesmanagerwantstouseExceltorunreportsshowingquotesbymanufacturer,model,customerandemployee.Shewantstoviewreportsofflineonherlaptopandwantsthereportsautomaticallyupdatedwithuptodateinformation.
InthetutorialsintheBuildingtheContosoAutoSalesOfficeBusinessApplicationseries,youwilluseVisualStudio2008tocreateanOfficeBusinessApplicationthataddresseachofthescenarioslistedabove,usingOutlook2007,Word2007andExcel2007.ThetutorialscontainbothVisualBasicandC#code.
Exercise1:
CreatetheExcelFinancingAdd-inProject
Inthesecondtutorialinthisseries(GenerateAutomobileQuotes)yousawhowtobuildaWordsolutionthatgeneratesquotes.Onceacustomerhasaquote,heorsheknowshowmuchacarwithaparticularsetofoptionswillcost.Thenextquestionwilloftenbehowmuchwillitcosttofinancethecar?
Excelisaperfectplaceforthistypeofcalculation.
ContosousesExceltogeneratefinancinginformation.Thefinancingmanagermeetswithacustomer.Thecustomerhasquotespendingforoneormorevehiclesandwantstoseefinancingoptionsforeachautomobile.Thefinancingmanagergeneratesthisinformationforeachquote.Thiscanbealaboriousprocessasthefinancingmanagerentersinformationintothespreadsheet.Alloftheinformationiscontainedinthequote,soContosowouldlikeanautomatedsolutionthatdoesn’trequiremanualtypingofexistinginformation.
Inthistutorial,youwillcreateanExcel2007financingsolution.TheExcelsolutionwillsupportthefollowing:
∙Theabilityofthefinancingmanagertoselectaquotefromthelistofquotesforacustomer.
∙TheabilitytoretrievethequoteinformationfromthedatabaseandpopulateanExcelworkbook.
∙Theabilitytosavethefinanceinformationsothatitcanbeeasilyviewedandreprinted.
Thesolutionyouwillbuildwillenablethefinancingmanagertogeneratefinancinginformation.YouwillbasethissolutionontheAutomobileFinancingworkbook.Thisworkbookcontainstwoworksheets.
TheCoverSheetworksheet(seeFigure1)willdisplayinformationonthequote,includingmanufacturerandmodel,customer,vehiclecost,optionsandtotalcost.TheAutomobileFinancingworksheet(seeFigure2)willdisplayinformationontheloan,includingloanamount,interestrate,monthlypaymentandmore.Inaddition,itwilldisplayeachmonth’spaymentinformation.
Figure1.Thesolutiondisplaysquoteinformationonthisworksheet.
Figure2.Thesolutiondisplaysfinancinginformationonthisworksheet.
Theadd-inyouwillcreatewillworkwithdatathatresidesintheContosoAutoSQLServerdatabase.Refertothefirsttutorialinthisseriesforinformationonhowtocreatethisdatabase.
Togetstarted,inVisualStudio2008selectFile>
New>
ProjecttodisplaytheNewProjectdialogbox.Inthelistofprojecttypes,expandtheOfficenode.SelectVersion2007,displayingthelistoftemplates.IntheTemplatespane,selectExcel2007Workbook.NameyourprojectAutomobileFinancingandselectanappropriatefolderfortheproject.ClickOKtocreatetheproject.VisualStudiodisplaystheVisualStudioToolsforOfficeProjectWizard(seeFigure3).
Figure3.VisualStudiodisplaysthiswizardwhenyoucreatethesolution.
Youcanbasetheadd-inonaneworexistingworkbook.SelectCopyanexistingdocumentandclickBrowse.Navigatetothefolderwhereyoudownloadedthistutorial’ssampleproject.NavigatetotheStarterDocumentsandWorkbooksfolder.SelectAutomobileFinancing.xlsxandclickOpen.Thisreturnsyoutothewizard.ClickOK.ClickOKifVisualStudiodisplaysthemessageshowninFigure4.
Figure4.VisualStudiodisplaysthismessagewhenyoucreatethesolution.
IntheServerExplorer,expandtheDataConnectionsnode.IfyoudonothaveaconnectiontotheContosoAutodatabase,right-clickDataConnectionsandselectAddConnectiontodisplaytheAddConnectiondialogbox.IftheDatasourcedoesnotdisplayMicrosoftSQLServer(SqlClient),clickChange.ThisdisplaystheChangeDataSourcedialogbox.SelectMicrosoftSQLServer(SqlClient)andclickOK.
IntheAddConnectiondialogbox,enteryourcomputername(ifyouareusingSQLServer)or.\SQLEXPRESS(ifyouareusingSQLServerExpress)intheServernametextbox.SelectContosoAutofromthedatabasedrop-downlist.ClickOKtoclosetheAddConnectiondialogbox.
IntheServerExplorer,expandtheContosoAutonode.ExpandtheTablesnodetoseethetablesinthedatabase(seeFigure5).
Figure5.TheContosoAutodatabasecontainsthesetables.
TheQuotesandQuotePackagestables(seeFigure6)containtheinformationthatcomprisesexistingquotes.Thesolutionwillusethisdatawhengeneratingfinancinginformation.
Figure6.TheQuotesandQuotePackagestablescontaininformationforexistingquotes.
TheExcelsolutionyouarebuildinginthistutorialneedsaconnectiontotheContosoAutodatabase.SelectProject>
AutomobileFinancingProperties.SelecttheSettingstab.Toaddanewsetting,enterContosoAutoConnectionStringintheNamecolumn.Select(Connectionstring)fromtheTypedrop-downlist.
ClicktheellipsisintheValuetextbox.ThisdisplaystheConnectionPropertiesdialogbox.CreateaconnectiontotheContosoAutodatabase.ClickOKtoclosetheConnectionPropertiesdialogbox.ClosetheProjectDesigner,savingyourchanges.
YouwilluseaDataSettocommunicatewiththeContosoAutodatabase.RatherthancreatetheDataSetfromscratch,youwilluseanexistingversionofit.SelectProject>
AddExistingItemtodisplaytheOpenFiledialogbox.Navigatetothefolderwhereyoudownloadedthistutorial’ssampleproject.NavigatetotheDataSets\AutoFinancingfolder.ThennavigatetotheVBorCSfolder,dependingonthelanguageyouareusing.SelectContosoAutoDataSet.xsdandclickOKtoaddtheDataSettotheproject.
IntheSolutionExplorer,double-clickContosoAutoDataSet.xsdtoopentheDataSetDesigner(seeFigure7).TakeafewminutestofamiliarizeyourselfwiththetablesandTableAdapters.
Figure7.Theadd-inusesthisDataSettoworkwiththedataintheContosoAutodatabase.
ClosetheDataSetDesigner.Saveyourchanges.SelectBuild>
BuildSolutionandverifythattheprojectcompilescorrectly.
Exercise2:
GenerateFinancingInformationInteractively
Inthisexercise,youwillprovideContoso’sfinancemanagerwiththeabilitytointeractivelygeneratefinancinginformationforcustomers.ThequoteswillbebasedontheAutomobileFinancingExcelworkbook,whichcontainsaCoverSheetworksheetandanAutomobileFinancingworksheet.
DataBindFinancingInformation
TheCoverSheetworksheetwilldisplaythefollowinginformation:
∙Vehiclename
∙Customername
∙Listpriceoftheautomobile
∙Selectedoptionsandtheirprices
∙Totalcostoftheautomobile
ThesolutionwillretrievethisinformationfromtheCustomers,QuotesandQuotePackagestablesinthedatabase.
Thefinancemanagerneedstoenterthefollowingonthefinancingworksheettogeneratefinancinginformation:
∙Downpaymentamount
∙Loanamount
∙Interestrate
∙Lengthoftheloan
∙Startdateoftheloan
Thesolutionwillretrievethevehiclecostfromthequote.Thefinancemanagerwillmanuallyentertheinterestrate.Thesolutionwillsuggestdefaultvaluesforthelengthandstartdateoftheloan.
Inthenextstep,youwilladddataboundcontrolstotheCoverSheetworksheet.Thesecontrolswillcontainanddisplaytheinformationforaparticularquote.
Double-clickSheet1intheSolutionExplorertodisplaytheCoverSheetworksheet.SelectData>
ShowDataSourcestodisplaytheDataSourceswindow.ExpandtheQuoteHeadersnode.
Intheprevioustutorial,yousawthatyoucoulddraganddroptablecolumnsfromtheDataSourceswindowontoaWorddocumentandcreatedataboundcontentcontrols.InExcelyoucanalsocreatedataboundcontrolsonspreadsheetsbydraggingfromtheDataSourceswindow.
Theiconnexttoeachtableandcolumnint