FunctionX - Practical Learning Logo

College Park Auto-Shop

 

Introduction

Most of the time, when you are asked to create an application that would be used to manage a business such as a car repair shop, you would think of a database. Such an application can also be created using regular programming. For example, you can easily and safely use the features of file processing or file handling to create and manage the application.

File processing allows you to create values and store them to a medium to be able to retrieve them when needed. As other topics on this site indicate, the Microsoft Foundation Class library provides an impressive support for file processing. We are going to use the Document/View features of the MFC to create an application that can be used to process customer repair orders for a car repair business.

 

Practical Learning: Introducing the Application

  1. Start Microsoft Visual C++ and create a new MFC Application
  2. Create it as Single Document and name it CPAS2
  3. Set the File Extension to cps
  4. Set the Number Of Files On Recent File List to 8
  5. Base the view class on CFormView

Application Design

Based on experience we have had to a car repair shop or from calling a friend to fix our car, there are things we should keep in mind when preparing the application. Because we are working for a business, we need some information about the customer and the car to repair. We also need to describe what is wrong with the car.

After getting the information about the customer, we can start repairing the car. Most of the times, when a car gets repaired, there are parts that the technician buys. These parts are charged to the customers and included in the bill. Of course, the customer should know what parts were used to fix the car. For this reason, we will make sure that our application specifies this by creating an area for the technician to enter them.

Besides the parts, a customer may also need to know what specific jobs were performed on the car. Therefore, we will create an area where the customer can list the jobs performed. At this time, we can start creating the application.

 

Practical Learning: Introducing the Application

  1. In the Resource View, expand CPAS2 and CPAS2.rc
  2. Expand the Dialog folder and double-click IDD_CPAS2_FORM
  3. Delete the TODO line and design the form as follows:
     
    Control ID Caption Additional Properties
    Group Box Group Box   Order Identification  
    Static Text Static Text   Customer Name:  
    Edit Control IDC_CUSTOMERNAME    
    Static Text Static Text   Address:  
    Edit Control IDC_CUSTOMERADDRESS    
    Static Text Static Text   City:  
    Edit Control IDC_CUSTOMERCITY    
    Static Text   State:  
    Edit Control IDC_CUSTOMERSTATE    
    Static Text   ZIP Code:  
    Edit Control IDC_CUSTOMERZIPCODE    
    Static Text   Car Year:  
    Edit Control IDC_CARYEAR    
    Static Text   Car Make:  
    Edit Control IDC_MAKE    
    Static Text   Model:  
    Edit Control IDC_MODEL    
    Static Text   Car Make:  
    Edit Control IDC_MAKE    
    Static Text   Problem Description:  
    Edit Control IDC_PROBLEMDESCRIPTION   Multiline: True
    Vertical Scroll: True
    Want Return: True
    Group Box   Parts Used  
    Static Text   Part Name  
    Static Text   Unit Price  
    Static Text   Quantity  
    Static Text   Sub-Total  
    Edit Control IDC_PART1NAME    
    Edit Control IDC_PART1UNITPRICE   Align Text: Right
    Edit Control IDC_PART1QUANTITY   Align Text: Right
    Edit Control IDC_PART1SUBTOTAL   Align Text: Right
    Edit Control IDC_PART2NAME    
    Edit Control IDC_PART2UNITPRICE   Align Text: Right
    Edit Control IDC_PART2QUANTITY   Align Text: Right
    Edit Control IDC_PART2SUBTOTAL   Align Text: Right
    Edit Control IDC_PART3NAME    
    Edit Control IDC_PART3UNITPRICE   Align Text: Right
    Edit Control IDC_PART3QUANTITY   Align Text: Right
    Edit Control IDC_PART3SUBTOTAL   Align Text: Right
    Edit Control IDC_PART4NAME    
    Edit Control IDC_PART4UNITPRICE   Align Text: Right
    Edit Control IDC_PART4QUANTITY   Align Text: Right
    Edit Control IDC_PART4SUBTOTAL   Align Text: Right
    Edit Control IDC_PART5NAME    
    Edit Control IDC_PART5UNITPRICE   Align Text: Right
    Edit Control IDC_PART5QUANTITY   Align Text: Right
    Edit Control IDC_PART5SUBTOTAL   Align Text: Right
    Group Box   Jobs Performed  
    Static Text   Job Description  
    Static Text   Job Price  
    Edit Control IDC_JOB1DESCRIPTION    
    Edit Control IDC_JOB1PRICE   Align Text: Right
    Edit Control IDC_JOB2DESCRIPTION    
    Edit Control IDC_JOB2PRICE   Align Text: Right
    Edit Control IDC_JOB3DESCRIPTION    
    Edit Control IDC_JOB3PRICE   Align Text: Right
    Edit Control IDC_JOB4DESCRIPTION    
    Edit Control IDC_JOB4PRICE   Align Text: Right
    Edit Control IDC_JOB5DESCRIPTION    
    Edit Control IDC_JOB5PRICE   Align Text: Right
    Group Box   Order Summary  
    Static Text   Job Description  
    Static Text   Repair Date  
    Edit Control IDC_REPAIRDATE    
    Static Text   Time Ready:  
    Edit Control IDC_TIMEREADY    
    Static Text   Total Parts:  
    Edit Control IDC_TOTALPARTS   Align Text: Right
    Static Text   Total Labor:  
    Edit Control IDC_TOTALLABOR   Align Text: Right
    Static Text   Tax Rate:  
    Edit Control IDC_TAXRATE   Align Text: Right
    Static Text   Tax Amount:  
    Edit Control IDC_TAXAMOUNT   Align Text: Right
    Static Text   Repair Total:  
    Edit Control IDC_REPAIRTOTAL   Align Text: Right
    Static Text   Notes or Recommendations:  
    Edit Control IDC_NOTES   Multiline: True
    Vertical Scroll: True
    Want Return: True
  4. Right-click each text box and click Add Event Handler to add the following member variables for each control:
     
    Identifier Type Value Variable
    IDC_CUSTOMERNAME CString m_CustomerName
    IDC_CUSTOMERADDRESS CString m_CustomerAddress
    IDC_CUSTOMERCITY CString m_CustomerCity
    IDC_CUSTOMERSTATE CString m_CustomerState
    IDC_CUSTOMERZIPCODE CString m_CustomerZIPCode
    IDC_CARYEAR CString m_CarYear
    IDC_MAKE CString m_Make
    IDC_MODEL CString m_Model
    IDC_PROBLEMDESCRIPTION CString m_ProblemDescription
    IDC_PART1NAME CString m_Part1Name
    IDC_PART1UNITPRICE CString m_Part1UnitPrice
    IDC_PART1QUANTITY CString m_Part1Quantity
    IDC_PART1SUBTOTAL CString m_Part1SubTotal
    IDC_PART2NAME CString m_Part2Name
    IDC_PART2UNITPRICE CString m_Part2UnitPrice
    IDC_PART2QUANTITY CString m_Part2Quantity
    IDC_PART2SUBTOTAL CString m_Part2SubTotal
    IDC_PART3NAME CString m_Part3Name
    IDC_PART3UNITPRICE CString m_Part3UnitPrice
    IDC_PART3QUANTITY CString m_Part3Quantity
    IDC_PART3SUBTOTAL CString m_Part3SubTotal
    IDC_PART4NAME CString m_Part4Name
    IDC_PART4UNITPRICE CString m_Part4UnitPrice
    IDC_PART4QUANTITY CString m_Part4Quantity
    IDC_PART4SUBTOTAL CString m_Part4SubTotal
    IDC_PART5NAME CString m_Part5Name
    IDC_PART5UNITPRICE CString m_Part5UnitPrice
    IDC_PART5QUANTITY CString m_Part5Quantity
    IDC_PART5SUBTOTAL CString m_Part5SubTotal
    IDC_JOB1DESCRIPTION CString m_Job1Description
    IDC_JOB1PRICE CString m_Job1Price
    IDC_JOB2DESCRIPTION CString m_Job2Description
    IDC_JOB2PRICE CString m_Job2Price
    IDC_JOB3DESCRIPTION CString m_Job3Description
    IDC_JOB3PRICE CString m_Job3Price
    IDC_JOB4DESCRIPTION CString m_Job4Description
    IDC_JOB4PRICE CString m_Job4Price
    IDC_JOB5DESCRIPTION CString m_Job5Description
    IDC_JOB5PRICE CString m_Job5Price
    IDC_REPAIRDATE CString m_RepairDate
    IDC_TIMEREADY CString m_TimeReady
    IDC_TOTALPARTS CString m_TotalParts
    IDC_TOTALLABOR CString m_TotalLabor
    IDC_TAXRATE CString m_TaxRate
    IDC_TAXAMOUNT CString m_TaxAmount
    IDC_REPAIRTOTAL CString m_RepairTotal
    IDC_NOTES CString m_Notes
  5. Change the design of the IDR_MAINFRAME icon as follows:
     
  6. In the Class View, right-click CCPAS2View -> Add -> Add Function...
  7. Set the Return Type to void
  8. Set the Function Name to CalculateRepairTotal
  9. Set the Access to private
  10. Click Finish
  11. Set the default values in the top section of the file as follows:
     
    	, m_TotalParts(_T("0.00"))
    	, m_TotalLabor(_T("0.00"))
    	, m_TaxRate(_T("7.75"))
    	, m_TaxAmount(_T("0.00"))
    	, m_RepairTotal(_T("0.00"))
    	, m_Notes(_T(""))
  12. Implement the event as follows:
     
    void CCPAS2View::CalculateRepairTotal(void)
    {
    	UpdateData();
    	double Part1UnitPrice, Part2UnitPrice, Part3UnitPrice,
    		   Part4UnitPrice, Part5UnitPrice;
    	int Part1Quantity, Part2Quantity, Part3Quantity,
    		Part4Quantity, Part5Quantity;
    	double Part1SubTotal, Part2SubTotal, Part3SubTotal, 
    		   Part4SubTotal, Part5SubTotal;
    	double Job1Price, Job2Price, Job3Price,
    		   Job4Price, Job5Price;
    	double TotalParts, TotalLabor,
    		   TaxRate, TaxAmount, RepairTotal;
    
    	Part1UnitPrice = atof(this->m_Part1UnitPrice);
    	Part1Quantity  = atoi(this->m_Part1Quantity);
    	Part1SubTotal  = Part1UnitPrice * Part1Quantity;
    	m_Part1SubTotal.Format("$%.2f", Part1SubTotal);
    
    	Part2UnitPrice = atof(this->m_Part2UnitPrice);
    	Part2Quantity  = atoi(this->m_Part2Quantity);
    	Part2SubTotal  = Part2UnitPrice * Part2Quantity;
    	m_Part2SubTotal.Format("$%.2f", Part2SubTotal);
    
    	Part3UnitPrice = atof(this->m_Part3UnitPrice);
    	Part3Quantity  = atoi(this->m_Part3Quantity);
    	Part3SubTotal  = Part3UnitPrice * Part3Quantity;
    	m_Part3SubTotal.Format("$%.2f", Part3SubTotal);
    
    	Part4UnitPrice = atof(this->m_Part4UnitPrice);
    	Part4Quantity  = atoi(this->m_Part4Quantity);
    	Part4SubTotal  = Part4UnitPrice * Part4Quantity;
    	m_Part4SubTotal.Format("$%.2f", Part4SubTotal);
    
    	Part5UnitPrice = atof(this->m_Part5UnitPrice);
    	Part5Quantity  = atoi(this->m_Part5Quantity);
    	Part5SubTotal  = Part5UnitPrice * Part5Quantity;
    	m_Part5SubTotal.Format("$%.2f", Part5SubTotal);
    
    	Job1Price  = atof(this->m_Job1Price);
    	Job2Price  = atof(this->m_Job2Price);
    	Job3Price  = atof(this->m_Job3Price);
    	Job4Price  = atof(this->m_Job4Price);
    	Job5Price  = atof(this->m_Job5Price);
    
    	TotalParts = Part1SubTotal + Part2SubTotal + Part3SubTotal
    		       + Part4SubTotal + Part5SubTotal;
    	m_TotalParts.Format("$%.2f", TotalParts);
    
    	TotalLabor = Job1Price + Job2Price + Job3Price
    		       + Job4Price + Job5Price;
    	m_TotalLabor.Format("$%.2f", TotalLabor);
    
    	TaxRate     = atof(this->m_TaxRate) / 100;
    	TaxAmount   = (TotalParts + TotalLabor) * TaxRate;
    	RepairTotal	= TotalParts + TotalLabor + TaxAmount;
    
    	m_TaxAmount.Format("$%.2f", TaxAmount);
    	m_RepairTotal.Format("$%.2f", RepairTotal);
    
    	UpdateData(FALSE);
    }
  13. Access the form and click the first edit control under Qty
  14. In the Properties window, click the Control Events button
  15. Click EN_KILLFOCUS
  16. Click its right side box then click the arrow of its combo box and select OnEnKillfocusPart1quantity
  17. Implement the event as follows:
     
    void CCPAS2View::OnEnKillfocusPart1quantity()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  18. Repeat these steps for the second edit control under Qty:
     
    void CCPAS2View::OnEnKillfocusPart2quantity()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  19. Repeat these steps for the third edit control under Qty:
     
    void CCPAS2View::OnEnKillfocusPart3quantity()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  20. Repeat these steps for the fourth edit control under Qty:
     
    void CCPAS2View::OnEnKillfocusPart4quantity()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  21. Repeat these steps for the fifth edit control under Qty:
     
    void CCPAS2View::OnEnKillfocusPart5quantity()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  22. Repeat these steps for the first edit control under Job Price:
     
    void CCPAS2View::OnEnKillfocusJob1price()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  23. Repeat these steps for the second edit control under Job Price:
     
    void CCPAS2View::OnEnKillfocusJob2price()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  24. Repeat these steps for the third edit control under Job Price:
     
    void CCPAS2View::OnEnKillfocusJob3price()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  25. Repeat these steps for the fourth edit control under Job Price:
     
    void CCPAS2View::OnEnKillfocusJob4price()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  26. Repeat these steps for the fifth edit control under Job Price:
     
    void CCPAS2View::OnEnKillfocusJob5price()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  27. Repeat these steps for the Tax Rate edit control:
     
    void CCPAS2View::OnEnKillfocusTaxrate()
    {
    	// TODO: Add your control notification handler code here
    	CalculateRepairTotal();
    }
  28. In the header file of the document class, declare a variable for each value that will be used in file processing:
     
    // CPAS2Doc.h : interface of the CCPAS2Doc class
    //
    
    
    #pragma once
    
    class CCPAS2Doc : public CDocument
    {
    protected: // create from serialization only
    	CCPAS2Doc();
    	DECLARE_DYNCREATE(CCPAS2Doc)
    
    // Attributes
    public:
    	CString CustomerName;
    	CString CustomerAddress;
    	CString CustomerCity;
    	CString CustomerState;
    	CString CustomerZIPCode;
    	CString CarYear;
    	CString Make;
    	CString Model;
    	CString ProblemDescription;
    	CString Part1Name;
    	CString Part1UnitPrice;
    	CString Part1Quantity;
    	CString Part1SubTotal;
    	CString Part2Name;
    	CString Part2UnitPrice;
    	CString Part2Quantity;
    	CString Part2SubTotal;
    	CString Part3Name;
    	CString Part3UnitPrice;
    	CString Part3Quantity;
    	CString Part3SubTotal;
    	CString Part4Name;
    	CString Part4UnitPrice;
    	CString Part4Quantity;
    	CString Part4SubTotal;
    	CString Part5Name;
    	CString Part5UnitPrice;
    	CString Part5Quantity;
    	CString Part5SubTotal;
    	CString Job1Description;
    	CString Job1Price;
    	CString Job2Description;
    	CString Job2Price;
    	CString Job3Description;
    	CString Job3Price;
    	CString Job4Description;
    	CString Job4Price;
    	CString Job5Description;
    	CString Job5Price;
    	CString RepairDate;
    	CString TotalParts;
    	CString TotalLabor;
    	CString TaxRate;
    	CString TaxAmount;
    	CString RepairTotal;
    	CString Notes;
    
    // Operations
    public:
    
    // Overrides
    	public:
    	virtual BOOL OnNewDocument();
    	virtual void Serialize(CArchive& ar);
    
    // Implementation
    public:
    	virtual ~CCPAS2Doc();
    #ifdef _DEBUG
    	virtual void AssertValid() const;
    	virtual void Dump(CDumpContext& dc) const;
    #endif
    
    protected:
    
    // Generated message map functions
    protected:
    	DECLARE_MESSAGE_MAP()
    };                
  29. To prepare the file for processing, access the Serialize() method of the document and change it as follows:
     
    // CCPAS2Doc serialization
    
    void CCPAS2Doc::Serialize(CArchive& ar)
    {
    	if (ar.IsStoring())
    	{
    		ar << CustomerName << CustomerAddress << CustomerCity
    		   << CustomerState << CustomerZIPCode << CarYear 
    		   << Make << Model << ProblemDescription 
    		   << Part1Name << Part1UnitPrice << Part1Quantity 
    		   << Part1SubTotal << Part2Name << Part2UnitPrice 
    		   << Part2Quantity << Part2SubTotal << Part3Name 
    		   << Part3UnitPrice << Part3Quantity << Part3SubTotal 
    		   << Part4Name << Part4UnitPrice << Part4Quantity 
    		   << Part4SubTotal << Part5Name << Part5UnitPrice 
    		   << Part5Quantity << Part5SubTotal << Job1Description 
    		   << Job1Price << Job2Description << Job2Price 
    		   << Job3Description << Job3Price << Job4Description 
    		   << Job4Price << Job5Description << Job5Price 
    		   << RepairDate << TotalParts << TotalLabor 
    		   << TaxRate << TaxAmount << RepairTotal << Notes; 
    	}
    	else
    	{
    		ar >> CustomerName >> CustomerAddress >> CustomerCity
    		   >> CustomerState >> CustomerZIPCode >> CarYear 
    		   >> Make >> Model >> ProblemDescription 
    		   >> Part1Name >> Part1UnitPrice >> Part1Quantity 
    		   >> Part1SubTotal >> Part2Name >> Part2UnitPrice 
    		   >> Part2Quantity >> Part2SubTotal >> Part3Name 
    		   >> Part3UnitPrice >> Part3Quantity >> Part3SubTotal 
    		   >> Part4Name >> Part4UnitPrice >> Part4Quantity 
    		   >> Part4SubTotal >> Part5Name >> Part5UnitPrice 
    		   >> Part5Quantity >> Part5SubTotal >> Job1Description 
    		   >> Job1Price >> Job2Description >> Job2Price 
    		   >> Job3Description >> Job3Price >> Job4Description 
    		   >> Job4Price >> Job5Description >> Job5Price 
    		   >> RepairDate >> TotalParts >> TotalLabor 
    		   >> TaxRate >> TaxAmount >> RepairTotal >> Notes; 
    	}
    }
  30. In the Resource View, expand the Menu node and double-click IDR_MAINFRAME
  31. Click File
  32. Right-click Save and click Add Event Handler
  33. In the Class List of the Event Handler Wizard, click CCPAS2View
  34. Accept the name of the function handler as OnFileSave and click Add And Edit
  35. Implement it as follows:
     
    void CCPAS2View::OnFileSave()
    {
    	// TODO: Add your command handler code here
    	this->UpdateData();
    	CCPAS2Doc *pDoc = GetDocument();
    
    	pDoc->CustomerName = this->m_CustomerName;
    	pDoc->CustomerAddress = this->m_CustomerAddress;
    	pDoc->CustomerCity = this->m_CustomerCity;
    	pDoc->CustomerState = this->m_CustomerState;
    	pDoc->CustomerZIPCode = this->m_CustomerZIPCode;
    	pDoc->CarYear = this->m_CarYear;;
    	pDoc->Make = this->m_Make;
    	pDoc->Model = this->m_Model;
    	pDoc->ProblemDescription = this->m_ProblemDescription;
    	pDoc->Part1Name = this->m_Part1Name;
    	pDoc->Part1UnitPrice = this->m_Part1UnitPrice;
    	pDoc->Part1Quantity = this->m_Part1Quantity;
    	pDoc->Part1SubTotal = this->m_Part1SubTotal;
    	pDoc->Part2Name = this->m_Part2Name;
    	pDoc->Part2UnitPrice = this->m_Part2UnitPrice;
    	pDoc->Part2Quantity = this->m_Part2Quantity;
    	pDoc->Part2SubTotal = this->m_Part2SubTotal;
    	pDoc->Part3Name = this->m_Part3Name;
    	pDoc->Part3UnitPrice = this->m_Part3UnitPrice;
    	pDoc->Part3Quantity = this->m_Part3Quantity;
    	pDoc->Part3SubTotal = this->m_Part3SubTotal;
    	pDoc->Part4Name = this->m_Part4Name;
    	pDoc->Part4UnitPrice = this->m_Part4UnitPrice;
    	pDoc->Part4Quantity = this->m_Part4UnitPrice;
    	pDoc->Part4SubTotal = this->m_Part4SubTotal;
    	pDoc->Part5Name = this->m_Part5Name;
    	pDoc->Part5UnitPrice = this->m_Part5UnitPrice;
    	pDoc->Part5Quantity = this->m_Part5Quantity;
    	pDoc->Part5SubTotal = this->m_Part5SubTotal;
    	pDoc->Job1Description = this->m_Job1Description;
    	pDoc->Job1Price = this->m_Job1Price;
    	pDoc->Job2Description = this->m_Job2Description;
    	pDoc->Job2Price = this->m_Job2Price;
    	pDoc->Job3Description = this->m_Job3Description;
    	pDoc->Job3Price = this->m_Job3Price;
    	pDoc->Job4Description = this->m_Job4Description;
    	pDoc->Job4Price = this->m_Job4Price;
    	pDoc->Job5Description = this->m_Job5Description;
    	pDoc->Job5Price = this->m_Job5Price;
    	pDoc->RepairDate = this->m_RepairDate;
    	pDoc->TotalParts = this->m_TotalParts;
    	pDoc->TotalLabor = this->m_TotalLabor;
    	pDoc->TaxRate = this->m_TaxRate;
    	pDoc->TaxAmount = this->m_TaxAmount;
    	pDoc->RepairTotal = this->m_RepairTotal;
    	pDoc->Notes = this->m_Notes;
    
    	CFile fleCPAS;
    
    	char strFilter[] = { "Car Repair Files (*.cps)|*.cps|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };
    
    	CFileDialog FileDlg(FALSE, ".cps", NULL, 0, strFilter);
    
    	if( FileDlg.DoModal() == IDOK )
    	{
    		fleCPAS.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite);
    		CArchive ar(&fleCPAS, CArchive::store);
    		pDoc->Serialize(ar);
    
    		ar.Close();
    	}
    	else
    		return;
    
    	fleCPAS.Close();
    }
  36. On top of the Code Editor, click CPAS2.rc (IDR_MAINFRAME - Menu)
  37. Right-click Open and click Add Event Handler
  38. In the Class List of the Event Handler Wizard, if necessary, click CCPAS2View.
    Accept the name of the function handler as OnFileOpen and click Add And Edit
  39. Implement it as follows:
     
    void CCPAS2View::OnFileOpen()
    {
    	// TODO: Add your command handler code here
    	this->UpdateData();
    	CCPAS2Doc *pDoc = GetDocument();
    
    	CFile fleCPAS;
    
    	char strFilter[] = { "Car Repair Files (*.cps)|*.cps|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };
    
    	CFileDialog FileDlg(FALSE, ".cps", NULL, 0, strFilter);
    	
    	if( FileDlg.DoModal() == IDOK )
    	{
    		if( fleCPAS.Open(FileDlg.GetFileName(), CFile::modeRead) == FALSE )
    			return;
    		CArchive ar(&fleCPAS, CArchive::load);
    		pDoc->Serialize(ar);
    
    		this->m_CustomerName       = pDoc->CustomerName;
    		this->m_CustomerAddress    = pDoc->CustomerAddress;
    		this->m_CustomerCity       = pDoc->CustomerCity;
    		this->m_CustomerState      = pDoc->CustomerState;
    		this->m_CustomerZIPCode    = pDoc->CustomerZIPCode;
    		this->m_CarYear            = pDoc->CarYear;
    		this->m_Make               = pDoc->Make;
    		this->m_Model              = pDoc->Model;
    		this->m_ProblemDescription = pDoc->ProblemDescription;
    		this->m_Part1Name          = pDoc->Part1Name;
    		this->m_Part1UnitPrice     = pDoc->Part1UnitPrice;
    		this->m_Part1Quantity      = pDoc->Part1Quantity;
    		this->m_Part1SubTotal      = pDoc->Part1SubTotal;
    		this->m_Part2Name          = pDoc->Part2Name;
    		this->m_Part2UnitPrice     = pDoc->Part2UnitPrice;
    		this->m_Part2Quantity      = pDoc->Part2Quantity;
    		this->m_Part2SubTotal      = pDoc->Part2SubTotal;
    		this->m_Part3Name          = pDoc->Part3Name;
    		this->m_Part3UnitPrice     = pDoc->Part3UnitPrice;
    		this->m_Part3Quantity      = pDoc->Part3Quantity;
    		this->m_Part3SubTotal      = pDoc->Part3SubTotal;
    		this->m_Part4Name          = pDoc->Part4Name;
    		this->m_Part4UnitPrice     = pDoc->Part4UnitPrice;
    		this->m_Part4UnitPrice     = pDoc->Part4Quantity;
    		this->m_Part4SubTotal      = pDoc->Part4SubTotal;
    		this->m_Part5Name          = pDoc->Part5Name;
    		this->m_Part5UnitPrice     = pDoc->Part5UnitPrice;
    		this->m_Part5Quantity      = pDoc->Part5Quantity;
    		this->m_Part5SubTotal      = pDoc->Part5SubTotal;
    		this->m_Job1Description    = pDoc->Job1Description;
    		this->m_Job1Price          = pDoc->Job1Price;
    		this->m_Job2Description    = pDoc->Job2Description;
    		this->m_Job2Price          = pDoc->Job2Price;
    		this->m_Job3Description    = pDoc->Job3Description;
    		this->m_Job3Price          = pDoc->Job3Price;
    		this->m_Job4Description    = pDoc->Job4Description;
    		this->m_Job4Price          = pDoc->Job4Price;
    		this->m_Job5Description    = pDoc->Job5Description;
    		this->m_Job5Price          = pDoc->Job5Price;
    		this->m_RepairDate         = pDoc->RepairDate;
    		this->m_TotalParts         = pDoc->TotalParts;
    		this->m_TotalLabor         = pDoc->TotalLabor;
    		this->m_TaxRate            = pDoc->TaxRate;
    		this->m_TaxAmount          = pDoc->TaxAmount;
    		this->m_RepairTotal        = pDoc->RepairTotal;
    		this->m_Notes              = pDoc->Notes;
    
    		ar.Close();
    	}
    	else
    		return;
    
    	fleCPAS.Close();
    	UpdateData(FALSE);
    }
  40. Access the frame's source file to remove the default title and set your own as follows:
     
    // MainFrm.cpp : implementation of the CMainFrame class
    //
    
    . . .
    
    /////////////////////////////////////////////////////////////////////////////
    // CMainFrame construction/destruction
    
    . . .
    
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    		return -1;
    	
    	. . .
    	
    	this->SetWindowText("College Park Auto-Shop - Repair Orders");
    	this->CenterWindow();
    
    	return 0;
    }
    
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    	if( !CFrameWnd::PreCreateWindow(cs) )
    		return FALSE;
    
    	cs.style &= ~FWS_ADDTOTITLE;
    
    	return TRUE;
    }
    
    /////////////////////////////////////////////////////////////////////////////
    // CMainFrame diagnostics
    
    . . .
    
  41. Execute the application
  42. Create a repair order
     
  43. To save the the record, on the toolbar, click the Save button
  44. Set the file name to 1001 and click Save
  45. Close the application and execute it again
  46. To open a receipt, on the toolbar, click the Open button
  47. Locate the folder where you saved the repair order and click 1001
  48. Click open and notice that the saved repair order is opened
 

Copyright © 2005 FunctionX, Inc.