Professional Documents
Culture Documents
Introduction
This is a sample application that demonstrates how to create a file-based database.
This application is a dry cleaning business. To start, a customer would bring clothes to the
store. The clerk registers the customer's information (name and phone number) and the
clothes he or she brought. Other pieces of information are entered such as the date and the
time the clothes were brought. To motivate customers, this store cleans the clothes the same
day if the customer brings them before 9AM.
Windows Controls:
Label
Text Box
Group Box
Menu Strip
Combo Box
Print Dialog
Print Document
Masked Text Box
Print Preview Dialog
Label &Receipt #:
Customer
Label
Name:
TextBox txtCustomerName
Customer
Label
Phone:
TextBox txtCustomerPhone
Label Date Left:
DateTimePicker dtpDateLeft
Date
Label
Expected:
DateTimePicker dtpDateExpected
Time
Label
Expected:
Order
Label
&Status:
ComboBox cbxOrderStatus
D&ate Picked
Label
Up:
DateTimePicker dtpDatePickedUp
Time Pic&kep
Label
Up:
DateTimePicker dtpTimePickedUp
Order
GroupBox
Processing
Label Qty
Label Shirts
Label Pants
TextBox txtPantsUnitPrice 1.95 TextAlign: Right
Items:
None
Women Suit
Dress
Regular Skirt
Skirt With Hook
Men's Suit 2Pc
ComboBox cbxItem1 None
Men's Suit 3Pc
Sweaters
Silk Shirt
Tie
Coat
Jacket
Swede
Items:
None
Women Suit
Dress
Regular Skirt
Skirt With Hook
Men's Suit 2Pc
ComboBox cbxItem2 None
Men's Suit 3Pc
Sweaters
Silk Shirt
Tie
Coat
Jacket
Swede
Items:
None
ComboBox cbxItem3 None
Women Suit
Dress
Regular Skirt
Skirt With Hook
Men's Suit 2Pc
Men's Suit 3Pc
Sweaters
Silk Shirt
Tie
Coat
Jacket
Swede
Items:
None
Women Suit
Dress
Regular Skirt
Skirt With Hook
Men's Suit 2Pc
ComboBox cbxItem4 None
Men's Suit 3Pc
Sweaters
Silk Shirt
Tie
Coat
Jacket
Swede
Order
GroupBox
Summary
Cleaning
Label
Total:
Label %
Label Tax Amount:
14. Double-click the Time Left control and implement its ValueChanged event as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace GeorgetownDryCleaner1
{
public partial class Central : Form
{
int iFilename;
bool IsNewCleaningOrder;
string Filename;
public Central()
{
InitializeComponent();
}
Path.GetFileNameWithoutExtension(fleLast.FullName);
// Increment the name of the file by 1
try
{
iFilename = int.Parse(fwe) + 1;
}
catch (FormatException)
{
}
}
txtCustomerName.Text = "";
txtCustomerPhone.Text = "";
dtpDateLeft.Value = DateTime.Today;
dtpTimeLeft.Value = DateTime.Today;
dtpDateExpected.Value = DateTime.Today;
dtpTimeExpected.Value = DateTime.Today;
txtUnitPriceShirts.Text = "1.25";
txtQuantityShirts.Text = "0";
txtSubTotalShirts.Text = "0.00";
txtUnitPricePants.Text = "1.95";
txtQuantityPants.Text = "0";
txtSubTotalPants.Text = "0.00";
cbxItem1.Text = "None";
txtUnitPriceItem1.Text = "0.00";
txtQuantityItem1.Text = "0";
txtSubTotalItem1.Text = "0.00";
cbxItem2.Text = "None";
txtUnitPriceItem2.Text = "0.00";
txtQuantityItem2.Text = "0";
txtSubTotalItem2.Text = "0.00";
cbxItem3.Text = "None";
txtUnitPriceItem3.Text = "0.00";
txtQuantityItem3.Text = "0";
txtSubTotalItem3.Text = "0.00";
cbxItem4.Text = "None";
txtUnitPriceItem4.Text = "0.00";
txtQuantityItem4.Text = "0";
txtSubTotalItem4.Text = "0.00";
txtCleaningTotal.Text = "0.00";
txtTaxRate.Text = "7.75";
txtTaxAmount.Text = "0.00";
txtCleaningTotal.Text = "0.00";
txtCustomerName.Focus();
}
}
}
IsNewCleaningOrder = false;
} // If a cleaning order was already opened, we will simply
update it
else
Filename = @"C:\Georgetown Dry Cleaner\Receipts\" +
txtReceiptNumber.Text + ".gcs";
try
{
stmGCS.WriteLine(txtCustomerName.Text);
stmGCS.WriteLine(txtCustomerPhone.Text);
stmGCS.WriteLine(dtpDateLeft.Value.ToString("D"));
stmGCS.WriteLine(dtpTimeLeft.Value.ToString("t"));
stmGCS.WriteLine(dtpDateExpected.Value.ToString("D"));
stmGCS.WriteLine(dtpTimeExpected.Value.ToString("t"));
stmGCS.WriteLine(cbxStatus.Text);
stmGCS.WriteLine(dtpDatePickedUp.Value.ToString("D"));
stmGCS.WriteLine(dtpTimePickedUp.Value.ToString("t"));
stmGCS.WriteLine(txtUnitPriceShirts.Text);
stmGCS.WriteLine(txtQuantityShirts.Text);
stmGCS.WriteLine(txtSubTotalShirts.Text);
stmGCS.WriteLine(txtUnitPricePants.Text);
stmGCS.WriteLine(txtQuantityPants.Text);
stmGCS.WriteLine(txtSubTotalPants.Text);
stmGCS.WriteLine(cbxItem1.Text);
stmGCS.WriteLine(txtUnitPriceItem1.Text);
stmGCS.WriteLine(txtQuantityItem1.Text);
stmGCS.WriteLine(txtSubTotalItem1.Text);
stmGCS.WriteLine(cbxItem2.Text);
stmGCS.WriteLine(txtUnitPriceItem2.Text);
stmGCS.WriteLine(txtQuantityItem2.Text);
stmGCS.WriteLine(txtSubTotalItem2.Text);
stmGCS.WriteLine(cbxItem3.Text);
stmGCS.WriteLine(txtUnitPriceItem3.Text);
stmGCS.WriteLine(txtQuantityItem3.Text);
stmGCS.WriteLine(txtSubTotalItem3.Text);
stmGCS.WriteLine(cbxItem4.Text);
stmGCS.WriteLine(txtUnitPriceItem4.Text);
stmGCS.WriteLine(txtQuantityItem4.Text);
stmGCS.WriteLine(txtSubTotalItem4.Text);
stmGCS.WriteLine(txtCleaningTotal.Text);
stmGCS.WriteLine(txtTaxRate.Text);
stmGCS.WriteLine(txtTaxAmount.Text);
stmGCS.WriteLine(txtNetPrice.Text);
}
finally
{
stmGCS.Close();
}
}
private void txtUnitPriceShirts_Leave(object sender, EventArgs e)
{
decimal unitPriceShirts = 0.00M, unitPricePants = 0.00M,
unitPriceItem1 = 0.00M, unitPriceItem2 = 0.00M,
unitPriceItem3 = 0.00M, unitPriceItem4 = 0.00M;
decimal subTotalShirts = 0.00M, subTotalPants = 0.00M,
subTotalItem1 = 0.00M, subTotalItem2 = 0.00M,
subTotalItem3 = 0.00M, subTotalItem4 = 0.00M;
int qtyShirts = 1, qtyPants = 1, qtyItem1 = 1,
qtyItem2 = 1, qtyItem3 = 1, qtyItem4 = 4;
decimal cleaningTotal = 0.00M, taxRate = 0.00M,
taxAmount = 0.00M, netPrice = 0.00M;
try
{
unitPricePants = decimal.Parse(this.txtUnitPricePants.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered for the price of " +
"pants is not valid" +
"\nPlease try again");
return;
}
try
{
qtyPants = int.Parse(this.txtQuantityPants.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered for the number of " +
"pants is not valid" +
"\nPlease try again");
return;
}
try
{
qtyItem1 = int.Parse(this.txtQuantityItem1.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered is not valid" +
"\nPlease try again");
return;
}
}
try
{
qtyItem2 = int.Parse(this.txtQuantityItem2.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered is not valid" +
"\nPlease try again");
return;
}
}
try
{
qtyItem3 = int.Parse(this.txtQuantityItem3.Text);
}
catch (FormatException)
{
MessageBox.Show("The value you entered is not valid" +
"\nPlease try again");
return;
}
}
taxRate = decimal.Parse(this.txtTaxRate.Text);
// Calculate the amount owed for the taxes
taxAmount = cleaningTotal * taxRate / 100;
// Add the tax amount to the total order
netPrice = cleaningTotal + taxAmount;
SaveCleaningOrder();
}
cbxStatus.Text = rdrGCS.ReadLine();
dtpDatePickedUp.Value =
DateTime.Parse(rdrGCS.ReadLine());
dtpTimePickedUp.Value =
DateTime.Parse(rdrGCS.ReadLine());
txtUnitPriceShirts.Text = rdrGCS.ReadLine();
txtQuantityShirts.Text = rdrGCS.ReadLine();
txtSubTotalShirts.Text = rdrGCS.ReadLine();
txtUnitPricePants.Text = rdrGCS.ReadLine();
txtQuantityPants.Text = rdrGCS.ReadLine();
txtSubTotalPants.Text = rdrGCS.ReadLine();
cbxItem1.Text = rdrGCS.ReadLine();
txtUnitPriceItem1.Text = rdrGCS.ReadLine();
txtQuantityItem1.Text = rdrGCS.ReadLine();
txtSubTotalItem1.Text = rdrGCS.ReadLine();
cbxItem2.Text = rdrGCS.ReadLine();
txtUnitPriceItem2.Text = rdrGCS.ReadLine();
txtQuantityItem2.Text = rdrGCS.ReadLine();
txtSubTotalItem2.Text = rdrGCS.ReadLine();
cbxItem3.Text = rdrGCS.ReadLine();
txtUnitPriceItem3.Text = rdrGCS.ReadLine();
txtQuantityItem3.Text = rdrGCS.ReadLine();
txtSubTotalItem3.Text = rdrGCS.ReadLine();
cbxItem4.Text = rdrGCS.ReadLine();
txtUnitPriceItem4.Text = rdrGCS.ReadLine();
txtQuantityItem4.Text = rdrGCS.ReadLine();
txtSubTotalItem4.Text = rdrGCS.ReadLine();
txtCleaningTotal.Text = rdrGCS.ReadLine();
txtTaxRate.Text = rdrGCS.ReadLine();
txtTaxAmount.Text = rdrGCS.ReadLine();
txtNetPrice.Text = rdrGCS.ReadLine();
}
finally
{
rdrGCS.Close();
}
}
catch (FileNotFoundException)
{
MessageBox.Show("There is no cleaning order " +
"with that receipt number");
}
}
}
e.Graphics.DrawString(dtpDateLeft.Value.ToString("D"), fntString,
Brushes.Black, 300, 260);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 280, 700, 280);
e.Graphics.DrawString("Shirts",
fntString, Brushes.Black, 150,
380);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtUnitPriceShirts.Text, fntString,
Brushes.Black, 350, 380, fmtString);
e.Graphics.DrawString(txtQuantityShirts.Text, fntString,
Brushes.Black, 440, 380, fmtString);
e.Graphics.DrawString(txtSubTotalShirts.Text, fntString,
Brushes.Black, 550, 380, fmtString);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 140, 400, 640, 400);