Home

File-Based Applications:
College Park Auto-Shop

 

Introduction

The .NET Framework has a great deal of support for file processing. It does this through various stream-based classes of the System.IO namespace. For example, the FileInfo class provides information and operations on files. Serialization can be performed using any list-based class. Besides file processing, the .NET Framework also supports printing, which is done through the Graphics class.

Printing in Microsoft Windows has traditionally been difficult. To do this, you had to involve drawing, hooks, and callback functions, etc. In the .NET Framework, a great deal of the job was simplified by creating simple-to-use classes. In fact, many aspects were also made clearer such as what class does what and when. We reviewed those classes in Print or Page Setup. We will use the Print and Graphics classes here to see how to print.

 

The Print Dialog Box

 

Introduction

Besides saving or opening files, another operation users perform on a document consists of printing it. Printing is the ability to render, on paper, the result of a control's content or the contents of various controls. This is performed using an external device called a printer peripheral or simply a printer. To do this, users need access to a printer device. There are two main ways users print a document. They can ask the application they are using to send the document directly to a printer or they can use a dialog box to decide how the printing should be done.

 

Practical Learning Practical Learning: Introducing Printing

  1. Start Microsoft Visual C# or Visual Studio .NET and create a new Windows Forms application named CPAS1
  2. Design the form as follows:
     
    Control Name Text Other Properties
    Group   Order Identification  
    Label   Order Date:  
    DateTimePicker dtpOrderDate    
    Label   Order Time:  
    DateTimePicker dtpOrderTime   Format: Time
    Label   Order Number:  
    TextBox txtOrderNumber    
    GroupBox   Customer and Car Information  
    Label   Customer Name:  
    TextBox txtCustomerName    
    Label   Address  
    TextBox txtAddress    
    Label   City:  
    TextBox txtCity    
    Label   State:  
    TextBox txtState    
    Label   ZIP Code:  
    TextBox txtZIPCode   TextAlign: Right
    Label   Make / Model:  
    TextBox txtMake    
    TextBox txtModel    
    Label   Year:  
    TextBox txtCarYear   TextAlign: Right
    Label   Problem Description:  
    TextBox txtProblem    
    GroupBox   Parts Used  
    Label   Part Name  
    Label   Unit Price  
    Label   Qty  
    Label   Sub Total  
    TextBox txtPartName1    
    TextBox txtUnitPrice1 0.00 TextAlign: Right
    TextBox txtQuantity1 0 TextAlign: Right
    TextBox txtSubTotal1 0.00 TextAlign: Right
    Enabled: False
    TextBox txtPartName2    
    TextBox txtUnitPrice2 0.00 TextAlign: Right
    TextBox txtQuantity2 0 TextAlign: Right
    TextBox txtSubTotal2 0.00 TextAlign: Right
    Enabled: False
    TextBox txtPartName3    
    TextBox txtUnitPrice3 0.00 TextAlign: Right
    TextBox txtQuantity3 0 TextAlign: Right
    TextBox txtSubTotal3 0.00 TextAlign: Right
    Enabled: False
    TextBox txtPartName4    
    TextBox txtUnitPrice4 0.00 TextAlign: Right
    TextBox txtQuantity4 0 TextAlign: Right
    TextBox txtSubTotal4 0.00 TextAlign: Right
    Enabled: False
    TextBox txtPartName5    
    TextBox txtUnitPrice5 0.00 TextAlign: Right
    TextBox txtQuantity5 0 TextAlign: Right
    TextBox txtSubTotal5 0.00 TextAlign: Right
    Enabled: False
    GroupBox   Jobs Performed  
    Label   Price  
    TextBox txtJobPerformed1    
    TextBox txtJobPrice1 0.00 TextAlign: Right
    TextBox txtJobPerformed2    
    TextBox txtJobPrice2 0.00 TextAlign: Right
    TextBox txtJobPerformed3    
    TextBox txtJobPrice3 0.00 TextAlign: Right
    TextBox txtJobPerformed4    
    TextBox txtJobPrice4 0.00 TextAlign: Right
    TextBox txtJobPerformed5    
    TextBox txtJobPrice5 0.00 TextAlign: Right
    GroupBox   Recommendations to Customer  
    TextBox txtRecommendations   Multiline: True
    ScrollBars: Vertical
    GroupBox   Order Summary  
    Button btnCalculateOrder Calculate Order  
    Label   Total Parts:  
    TextBox txtTotalParts 0.00 TextAlign: Right
    Label   Total Labor:  
    TextBox txtTotalLabor 0.00 TextAlign: Right
    Label   Tax Rate:  
    TextBox txtTaxRate 7.75 TextAlign: Right
    Label   %  
    Label   Tax Amount:  
    TextBox txtTaxAmount 0.00 TextAlign: Right
    Label   Repair Total:  
    TextBox txtRepairTotal 0.00 TextAlign: Right
    Button btnSave Save this Order in the Above Date and Start New Order  
    Button btnOpen Open a Previous Repair Order  
    Button btnResetOrder Reset Order  
    Button btnPrint Print Repair Order  
    Button btnPreview Print Preview  
    Button btnClose Close  
  3. Save all
  4. On the form, double-click the Calculate Order button and implement its Click event as follows:
      
    private void btnCalculateOrder_Click(object sender, System.EventArgs e)
    {
    	decimal part1UnitPrice = 0.00M, part1SubTotal = 0.00M, part2UnitPrice = 0.00M,
    		part2SubTotal = 0.00M, part3UnitPrice = 0.00M, part3SubTotal = 0.00M,
    		part4UnitPrice = 0.00M, part4SubTotal = 0.00M, part5UnitPrice = 0.00M,
    		part5SubTotal = 0.00M, totalParts = 0.00M;
    	int    part1Quantity = 0, part2Quantity = 0, part3Quantity = 0,
    		part4Quantity = 0, part5Quantity = 0;
    	decimal job1Price = 0.00M, job2Price = 0.00M, job3Price = 0.00M,
    		job4Price = 0.00M, job5Price = 0.00M;
    	decimal totalLabor = 0.00M;
    	decimal taxRate = 0.00M, taxAmount = 0.00M, totalOrder = 0.00M;
    
    	// Don't charge a part unless it is clearly identified
    	if( this.txtPartName1.Text == "" )
    	{
    		this.txtUnitPrice1.Text = "0.00";
    		this.txtQuantity1.Text  = "0";
    		this.txtSubTotal1.Text  = "0.00";
    		part1UnitPrice = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			part1UnitPrice = decimal.Parse(this.txtUnitPrice1.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Unit Price");
    			this.txtUnitPrice1.Text = "0.00";
    			this.txtUnitPrice1.Focus();
    		}
    
    		try
    		{
    			part1Quantity = int.Parse(this.txtQuantity1.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Quantity");
    			this.txtQuantity1.Text = "0";
    			this.txtQuantity1.Focus();
    		}
    	}
    
    	if( this.txtPartName2.Text == "" )
    	{
    		this.txtUnitPrice2.Text = "0.00";
    		this.txtQuantity2.Text  = "0";
    		this.txtSubTotal2.Text  = "0.00";
    		part2UnitPrice = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			part2UnitPrice = decimal.Parse(this.txtUnitPrice2.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Unit Price");
    			this.txtUnitPrice2.Text = "0.00";
    			this.txtUnitPrice2.Focus();
    		}
    
    		try 
    		{
    			part2Quantity = int.Parse(this.txtQuantity2.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Quantity");
    			this.txtQuantity2.Text = "0";
    			this.txtQuantity2.Focus();
    		}
    	}
    
    	if( this.txtPartName3.Text == "" )
    	{
    		this.txtUnitPrice3.Text = "0.00";
    		this.txtQuantity3.Text  = "0";
    		this.txtSubTotal3.Text  = "0.00";
    		part3UnitPrice = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			part3UnitPrice = decimal.Parse(this.txtUnitPrice3.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Unit Price");
    			this.txtUnitPrice3.Text = "0.00";
    			this.txtUnitPrice3.Focus();
    		}
    
    		try 
    		{
    			part3Quantity = int.Parse(this.txtQuantity3.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Quantity");
    			this.txtQuantity3.Text = "0";
    			this.txtQuantity3.Focus();
    		}
    	}
    
    	if( this.txtPartName4.Text == "" )
    	{
    		this.txtUnitPrice4.Text = "0.00";
    		this.txtQuantity4.Text  = "0";
    		this.txtSubTotal4.Text  = "0.00";
    		part4UnitPrice = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			part4UnitPrice = decimal.Parse(this.txtUnitPrice4.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Unit Price");
    			this.txtUnitPrice4.Text = "0.00";
    			this.txtUnitPrice4.Focus();
    		}
    
    		try 
    		{
    			part4Quantity = int.Parse(this.txtQuantity4.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Quantity");
    			this.txtQuantity4.Text = "0";
    			this.txtQuantity4.Focus();
    		}
    	}
    
    	if( this.txtPartName5.Text == "" )
    	{
    		this.txtUnitPrice5.Text = "0.00";
    		this.txtQuantity5.Text  = "0";
    		this.txtSubTotal5.Text  = "0.00";
    		part5UnitPrice = 0.00M;
    	}								
    	else
    	{
    		try 
    		{
    			part5UnitPrice = decimal.Parse(this.txtUnitPrice5.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Unit Price");
    			this.txtUnitPrice5.Text = "0.00";
    			this.txtUnitPrice5.Focus();
    		}
    
    		try 
    		{
    			part5Quantity = int.Parse(this.txtQuantity5.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Quantity");
    			this.txtQuantity5.Text = "0";
    			this.txtQuantity5.Focus();
    		}
    	}
    
    	// Don't bill the customer for a job that is not specified
    	if( this.txtJobPerformed1.Text == "" )
    	{
    		this.txtJobPrice1.Text = "0.00";
    		job1Price = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			job1Price = decimal.Parse(this.txtJobPrice1.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Job Price");
    			this.txtJobPrice1.Text = "0.00";
    			this.txtJobPrice1.Focus();
    		}
    	}
    				 
    	if( this.txtJobPerformed2.Text == "" )
    	{
    		this.txtJobPrice2.Text = "0.00";
    		job2Price = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			job2Price = decimal.Parse(this.txtJobPrice2.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Job Price");
    			this.txtJobPrice2.Text = "0.00";
    			this.txtJobPrice2.Focus();
    		}
    	}
    				
    	if( this.txtJobPerformed3.Text == "" )
    	{
    		this.txtJobPrice3.Text = "0.00";
    		job3Price = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			job3Price = decimal.Parse(this.txtJobPrice3.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Job Price");
    			this.txtJobPrice3.Text = "0.00";
    			this.txtJobPrice3.Focus();
    		}
    	}
    				 
    	if( this.txtJobPerformed4.Text == "" )
    	{
    		this.txtJobPrice4.Text = "0.00";
    		job4Price = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			job4Price = decimal.Parse(this.txtJobPrice4.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Job Price");
    			this.txtJobPrice4.Text = "0.00";
    			this.txtJobPrice4.Focus();
    		}
    	}
    				 
    	if( this.txtJobPerformed5.Text == "" )
    	{
    		this.txtJobPrice5.Text = "0.00";
    		job5Price = 0.00M;
    	}
    	else
    	{
    		try 
    		{
    			job5Price = decimal.Parse(this.txtJobPrice5.Text);
    		}
    		catch(FormatException)
    		{
    			MessageBox.Show("Invalid Job Price");
    			this.txtJobPrice5.Text = "0.00";
    			this.txtJobPrice5.Focus();
    		}
    	}
    			
    	part1SubTotal = part1UnitPrice * part1Quantity;
    	part2SubTotal = part2UnitPrice * part2Quantity;
    	part3SubTotal = part3UnitPrice * part3Quantity;
    	part4SubTotal = part4UnitPrice * part4Quantity;
    	part5SubTotal = part5UnitPrice * part5Quantity;
    
    	this.txtSubTotal1.Text = part1SubTotal.ToString("F");
    	this.txtSubTotal2.Text = part2SubTotal.ToString("F");
    	this.txtSubTotal3.Text = part3SubTotal.ToString("F");
    	this.txtSubTotal4.Text = part4SubTotal.ToString("F");
    	this.txtSubTotal5.Text = part5SubTotal.ToString("F");
    
    	totalParts    = part1SubTotal + part2SubTotal + part3SubTotal +
    		            part4SubTotal + part5SubTotal;
    	 
    	totalLabor    = job1Price + job2Price + job3Price +
    		            job4Price + job5Price;
    				 
    	try 
    	{
    		taxRate = decimal.Parse(this.txtTaxRate.Text);
    	}
    	catch(FormatException)
    	{
    		MessageBox.Show("Invalid Tax Rate");
    		this.txtTaxRate.Text = "7.75";
    		this.txtTaxRate.Focus();
    	}
    			
    	decimal totalPartsAndLabor = totalParts + totalLabor;
    	taxAmount  = totalPartsAndLabor * taxRate / 100;
    	totalOrder = totalPartsAndLabor + taxAmount;
    			
    	this.txtTotalParts.Text = totalParts.ToString("F");
    	this.txtTotalLabor.Text = totalLabor.ToString("F");
    	this.txtTaxAmount.Text  = taxAmount.ToString("F");
    	this.txtRepairTotal.Text = totalOrder.ToString("F");
    }
  5. Return to the form.
    Double-click the Reset Order button and implement its Click event as follows:
     
    private void btnResetOrder_Click(object sender, System.EventArgs e)
    {
    	this.txtCustomerName.Text = "";
    	this.txtAddress.Text = "";
    	this.txtCity.Text = "";
    	this.txtState.Text = "";
    	this.txtZIPCode.Text = "";
    	this.txtMake.Text = "";
    	this.txtModel.Text = "";
    	this.txtCarYear.Text = "";
    	this.txtProblem.Text = "";
    
    	this.txtPartName1.Text = "";
    	this.txtUnitPrice1.Text = "0.00";
    	this.txtQuantity1.Text  = "0";
    	this.txtSubTotal1.Text  = "0.00";
    	this.txtPartName2.Text = "";
    	this.txtUnitPrice2.Text = "0.00";
    	this.txtQuantity2.Text  = "0";
    	this.txtSubTotal2.Text  = "0.00";
    	this.txtPartName3.Text = "";
    	this.txtUnitPrice3.Text = "0.00";
    	this.txtQuantity3.Text  = "0";
    	this.txtSubTotal3.Text  = "0.00";
    	this.txtPartName4.Text = "";
    	this.txtUnitPrice4.Text = "0.00";
    	this.txtQuantity4.Text  = "0";
    	this.txtSubTotal4.Text  = "0.00";
    	this.txtPartName5.Text = "";
    	this.txtUnitPrice5.Text = "0.00";
    	this.txtQuantity5.Text  = "0";
    	this.txtSubTotal5.Text  = "0.00";
    
    	this.txtJobPerformed1.Text = "";
    	this.txtJobPrice1.Text = "0.00";
    	this.txtJobPerformed2.Text = "";
    	this.txtJobPrice2.Text = "0.00";
    	this.txtJobPerformed3.Text = "";
    	this.txtJobPrice3.Text = "0.00";
    	this.txtJobPerformed4.Text = "";
    	this.txtJobPrice4.Text = "0.00";
    	this.txtJobPerformed5.Text = "";
    	this.txtJobPrice5.Text = "0.00";
    
    	this.txtTotalParts.Text = "0.00";
    	this.txtTotalLabor.Text = "0.00";
    	this.txtTaxRate.Text    = "7.75";
    	this.txtTaxAmount.Text  = "0.00";
    	this.txtRepairTotal.Text = "0.00";
    
    	this.txtRecommendations.Text = "";
    	this.txtCustomerName.Focus();
    }
  6. Return to the form. In the Windows Forms section of the Toolbox, click SaveFileDialog and click the form
  7. Change its properties as follows:
    DefaultExt: rpr
    Filter: Customer Repairs (*.rpr)|*.rpr|All Files|
    Title: Save Current Repair Order
  8. In the Windows Forms section of the Toolbox, click OpenFileDialog and click the form
  9. Change its properties as follows:
    DefaultExt: rpr
    Filter: Customer Repairs (*.rpr)|*.rpr|All Files|
    Title: Open Existing Repair Order
  10. Double-click the Save this Order button
  11. In the top section of the file, type the following:
     
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.IO;
    using System.Globalization;
  12. Implement the event as follows:
     
    private void btnSave_Click(object sender, System.EventArgs e)
    {
    	// Just in case the user forgot to first calculate, do it now
    	 this.btnCalculateOrder_Click(sender, e);
    
    	 // Get the date this order is/was processed
    	 DateTime selDate = this.dtpOrderDate.Value;
    	 // The list of months
    	 string[] strMonth = { "January", "February", "March", "April",
    		                    "May",     "June",     "July",  "August",
    			"September", "October", "November", "December" };
    	 // Locate the numeric value of the month from the selected date
    	 int selMonth = selDate.Month - 1;
    	 // Locate the year value
    	 int selYear  = selDate.Year;
    	 // This is the name of the folder where the order will be saved
    	string strFolder = String.Concat("C:\\College Park Auto Shop\\",
    				strMonth[selMonth], " ", selYear.ToString());
    
     // This number will be used to incrementally create the files by their names
    	 int incremental = 1000;
    	 // Check the above folder. If it exists, don't create it
    	 // If it doesn't exist, then create it
    	 DirectoryInfo dirInfo = Directory.CreateDirectory(strFolder);
    
    	 // Get the list of files, if any, from the above folder
    	 FileInfo[] fleList = dirInfo.GetFiles();
    
    	 // If there is no file in the directory, then get ready to create the first file
    	 if( fleList.Length == 0 )
    	 {
    		 // Get ready to display it in the Save dialog box
    		 this.saveFileDialog1.FileName = this.txtOrderNumber.Text;
    	 }
    	 else // If there was at least one file in the directory
    	 {
    		 // Get a reference to the last file
    		 FileInfo fleLast = fleList[fleList.Length-1];
    		 // Get the name of the last file without its extension
    		 string fwe = Path.GetFileNameWithoutExtension(fleLast.FullName);
    		 // Increment the name of the file by 1
    		 incremental = int.Parse(fwe) + 1;
    		 // Get ready to display it in the Save dialog box
    		 this.saveFileDialog1.FileName = incremental.ToString();
    	 }
    
    	 // For convenience, display the Save dialog box in the directory
    	 // created above
    	 this.saveFileDialog1.InitialDirectory = dirInfo.FullName;
    
    	 // Find out if the user clicked OK after displaying the Save dialog box
    	 if( this.saveFileDialog1.ShowDialog() == DialogResult.OK )
    	 {
    		 // Create a new file using the name of the Save dialog box
    		 FileStream fleCPAS = new FileStream(this.saveFileDialog1.FileName, 
    					FileMode.Create, FileAccess.Write, FileShare.Write);
    		 BinaryWriter bnrCPAS = new BinaryWriter(fleCPAS);
    
    		 // Write each value in the file
    		 bnrCPAS.Write(this.dtpOrderDate.Value.ToString());
    		 bnrCPAS.Write(this.dtpOrderTime.Value.ToString());
    		 bnrCPAS.Write(this.txtOrderNumber.Text);
    		 bnrCPAS.Write(this.txtCustomerName.Text);
    		 bnrCPAS.Write(this.txtAddress.Text);
    		 bnrCPAS.Write(this.txtCity.Text);
    		 bnrCPAS.Write(this.txtState.Text);
    		 bnrCPAS.Write(this.txtZIPCode.Text);
    		 bnrCPAS.Write(this.txtMake.Text);
    		 bnrCPAS.Write(this.txtModel.Text);
    		 bnrCPAS.Write(this.txtCarYear.Text);
    		 bnrCPAS.Write(this.txtProblem.Text);
    
    		 bnrCPAS.Write(this.txtPartName1.Text);
    		 bnrCPAS.Write(this.txtUnitPrice1.Text);
    		 bnrCPAS.Write(this.txtQuantity1.Text);
    		 bnrCPAS.Write(this.txtSubTotal1.Text);
    		 bnrCPAS.Write(this.txtPartName2.Text);
    		 bnrCPAS.Write(this.txtUnitPrice2.Text);
    		 bnrCPAS.Write(this.txtQuantity2.Text);
    		 bnrCPAS.Write(this.txtSubTotal2.Text);
    		 bnrCPAS.Write(this.txtPartName3.Text);
    		 bnrCPAS.Write(this.txtUnitPrice3.Text);
    		 bnrCPAS.Write(this.txtQuantity3.Text);
    		 bnrCPAS.Write(this.txtSubTotal3.Text);
    		 bnrCPAS.Write(this.txtPartName4.Text);
    		 bnrCPAS.Write(this.txtUnitPrice4.Text);
    		 bnrCPAS.Write(this.txtQuantity4.Text);
    		 bnrCPAS.Write(this.txtSubTotal4.Text);
    		 bnrCPAS.Write(this.txtPartName5.Text);
    		 bnrCPAS.Write(this.txtUnitPrice5.Text);
    		 bnrCPAS.Write(this.txtQuantity5.Text);
    		 bnrCPAS.Write(this.txtSubTotal5.Text);
    
    		 bnrCPAS.Write(this.txtJobPerformed1.Text);
    		 bnrCPAS.Write(this.txtJobPrice1.Text);
    		 bnrCPAS.Write(this.txtJobPerformed2.Text);
    		 bnrCPAS.Write(this.txtJobPrice2.Text);
    		 bnrCPAS.Write(this.txtJobPerformed3.Text);
    		 bnrCPAS.Write(this.txtJobPrice3.Text);
    		 bnrCPAS.Write(this.txtJobPerformed4.Text);
    		 bnrCPAS.Write(this.txtJobPrice4.Text);
    		 bnrCPAS.Write(this.txtJobPerformed5.Text);
    		 bnrCPAS.Write(this.txtJobPrice5.Text);
    
    		 bnrCPAS.Write(this.txtTotalParts.Text);
    		 bnrCPAS.Write(this.txtTotalLabor.Text);
    		 bnrCPAS.Write(this.txtTaxRate.Text);
    		 bnrCPAS.Write(this.txtTaxAmount.Text);
    		 bnrCPAS.Write(this.txtRepairTotal.Text);
    
    		 bnrCPAS.Write(this.txtRecommendations.Text);
    
    		 this.btnResetOrder_Click(sender, e);
    	 }
    }
  13. Return to the form and double-click the Open button
  14. Implement its Click event as follows:
     
    private void btnOpen_Click(object sender, System.EventArgs e)
    {
    	this.openFileDialog1.InitialDirectory = "C:\\College Park Auto Shop";
    
    	if( this.openFileDialog1.ShowDialog() == DialogResult.OK )
    	{
    		FileStream fleCPAS = new FileStream(this.openFileDialog1.FileName,
    				FileMode.Open, FileAccess.Read, FileShare.Read);
    		BinaryReader bnrCPAS = new BinaryReader(fleCPAS);
    
    		this.dtpOrderDate.Value = 
    DateTime.Parse(bnrCPAS.ReadString(), new System.Globalization.CultureInfo("en-US", true));
    		this.dtpOrderTime.Value = 
    DateTime.Parse(bnrCPAS.ReadString(), new System.Globalization.CultureInfo("en-US", true));
    		this.txtOrderNumber.Text = bnrCPAS.ReadString();
    		this.txtCustomerName.Text  = bnrCPAS.ReadString();
    		this.txtAddress.Text = bnrCPAS.ReadString();
    		this.txtCity.Text = bnrCPAS.ReadString();
    		this.txtState.Text = bnrCPAS.ReadString();
    		this.txtZIPCode.Text = bnrCPAS.ReadString();
    		this.txtMake.Text = bnrCPAS.ReadString();
    		this.txtModel.Text = bnrCPAS.ReadString();
    		this.txtCarYear.Text = bnrCPAS.ReadString();
    		this.txtProblem.Text = bnrCPAS.ReadString();
    
    		this.txtPartName1.Text = bnrCPAS.ReadString();
    		this.txtUnitPrice1.Text = bnrCPAS.ReadString();
    		this.txtQuantity1.Text = bnrCPAS.ReadString();
    		this.txtSubTotal1.Text = bnrCPAS.ReadString();
    		this.txtPartName2.Text = bnrCPAS.ReadString();
    		this.txtUnitPrice2.Text = bnrCPAS.ReadString();
    		this.txtQuantity2.Text = bnrCPAS.ReadString();
    		this.txtSubTotal2.Text = bnrCPAS.ReadString();
    		this.txtPartName3.Text = bnrCPAS.ReadString();
    		this.txtUnitPrice3.Text = bnrCPAS.ReadString();
    		this.txtQuantity3.Text = bnrCPAS.ReadString();
    		this.txtSubTotal3.Text = bnrCPAS.ReadString();
    		this.txtPartName4.Text = bnrCPAS.ReadString();
    		this.txtUnitPrice4.Text = bnrCPAS.ReadString();
    		this.txtQuantity4.Text = bnrCPAS.ReadString();
    		this.txtSubTotal4.Text = bnrCPAS.ReadString();
    		this.txtPartName5.Text = bnrCPAS.ReadString();
    		this.txtUnitPrice5.Text = bnrCPAS.ReadString();
    		this.txtQuantity5.Text = bnrCPAS.ReadString();
    				 
    		this.txtSubTotal5.Text = bnrCPAS.ReadString();
    		this.txtJobPerformed1.Text = bnrCPAS.ReadString();
    		this.txtJobPrice1.Text = bnrCPAS.ReadString();
    		this.txtJobPerformed2.Text = bnrCPAS.ReadString();
    		this.txtJobPrice2.Text = bnrCPAS.ReadString();
    		this.txtJobPerformed3.Text = bnrCPAS.ReadString();
    		this.txtJobPrice3.Text = bnrCPAS.ReadString();
    		this.txtJobPerformed4.Text = bnrCPAS.ReadString();
    		this.txtJobPrice4.Text = bnrCPAS.ReadString();
    		this.txtJobPerformed5.Text = bnrCPAS.ReadString();
    		this.txtJobPrice5.Text = bnrCPAS.ReadString();
    		 
    		this.txtTotalParts.Text = bnrCPAS.ReadString();
    		this.txtTotalLabor.Text = bnrCPAS.ReadString();
    		this.txtTaxRate.Text = bnrCPAS.ReadString();
    		this.txtTaxAmount.Text = bnrCPAS.ReadString();
    		this.txtRepairTotal.Text = bnrCPAS.ReadString();
    		this.txtRecommendations.Text = bnrCPAS.ReadString();
    	}
    }
  15. Return to the form.
    Double-click the Close button and implement its Click event as follows:
     
    private void btnClose_Click(object sender, System.EventArgs e)
    {
    	Close();
    }
  16. Execute the application to test it
  17. Create a new record and click Calculate Order
     
  18. Click the Save this Order... button and accept all defaults
     
  19. Create another order, calculate it and save it
  20. Try opening a previously saved order
  21. Close the form and return to your programming environment

 
 

Home Copyright © 2005-2016, FunctionX Next