- From the Printing section of the Toolbox, click PrintDocument and
click the form
- In the Properties window, set its (Name) to docPrint and
press Enter
- Under the form, double-click docPrint and implement its event as
follows:
private void docPrint_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawLine(new Pen(Color.Black, 2), 80, 90, 750, 90);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 80, 93, 750, 93);
string strDisplay = "Bethesda Car Rental";
System.Drawing.Font fntString = new Font("Times New Roman", 28,
FontStyle.Bold);
e.Graphics.DrawString(strDisplay, fntString,
Brushes.Black, 240, 100);
strDisplay = "Car Rental Order";
fntString = new System.Drawing.Font("Times New Roman", 22,
FontStyle.Regular);
e.Graphics.DrawString(strDisplay, fntString,
Brushes.Black, 320, 150);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 80, 187, 750, 187);
e.Graphics.DrawLine(new Pen(Color.Black, 2), 80, 190, 750, 190);
fntString = new System.Drawing.Font("Times New Roman", 12,
FontStyle.Bold);
e.Graphics.DrawString("Receipt #: ", fntString,
Brushes.Black, 100, 220);
fntString = new System.Drawing.Font("Times New Roman", 12,
FontStyle.Regular);
e.Graphics.DrawString(txtReceiptNumber.Text, fntString,
Brushes.Black, 260, 220);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 240, 380, 240);
fntString = new System.Drawing.Font("Times New Roman", 12,
FontStyle.Bold);
e.Graphics.DrawString("Processed By: ", fntString,
Brushes.Black, 420, 220);
fntString = new System.Drawing.Font("Times New Roman", 12,
FontStyle.Regular);
e.Graphics.DrawString(txtEmployeeName.Text, fntString,
Brushes.Black, 550, 220);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 420, 240, 720, 240);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.FillRectangle(Brushes.Gray,
new Rectangle(100, 260, 620, 20));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle(100, 260, 620, 20));
e.Graphics.DrawString("Customer", fntString,
Brushes.White, 100, 260);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Driver's License #: ", fntString,
Brushes.Black, 100, 300);
e.Graphics.DrawString("Name: ", fntString,
Brushes.Black, 420, 300);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtDrvLicNumber.Text, fntString,
Brushes.Black, 260, 300);
e.Graphics.DrawString(txtCustomerName.Text, fntString,
Brushes.Black, 540, 300);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 320, 720, 320);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Address: ", fntString,
Brushes.Black, 100, 330);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtCustomerAddress.Text, fntString,
Brushes.Black, 260, 330);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 350, 720, 350);
strDisplay = txtCustomerCity.Text + " " +
cbxCustomerStates.Text + " " +
txtCustomerZIPCode.Text;
fntString = new System.Drawing.Font("Times New Roman",
12, FontStyle.Regular);
e.Graphics.DrawString(strDisplay, fntString,
Brushes.Black, 260, 360);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 260, 380, 720, 380);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.FillRectangle(Brushes.Gray,
new Rectangle(100, 410, 620, 20));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle(100, 410, 620, 20));
e.Graphics.DrawString("Car Information", fntString,
Brushes.White, 100, 410);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Tag #: ", fntString,
Brushes.Black, 100, 450);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtTagNumber.Text, fntString,
Brushes.Black, 260, 450);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 470, 380, 470);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Year: ", fntString,
Brushes.Black, 420, 450);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtCarYear.Text, fntString,
Brushes.Black, 530, 450);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 420, 470, 720, 470);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Make: ", fntString,
Brushes.Black, 100, 480);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtMake.Text, fntString,
Brushes.Black, 260, 480);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 500, 380, 500);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Model: ", fntString,
Brushes.Black, 420, 480);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtModel.Text, fntString,
Brushes.Black, 530, 480);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 420, 500, 720, 500);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Car Condition: ", fntString,
Brushes.Black, 100, 510);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(cbxCarConditions.Text, fntString,
Brushes.Black, 260, 510);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 100, 530, 380, 530);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Tank Level: ", fntString,
Brushes.Black, 420, 510);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(cbxTankLevels.Text, fntString,
Brushes.Black, 530, 510);
e.Graphics.DrawLine(new Pen(Color.Black, 1), 420, 530, 720, 530);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Mileage Start:", fntString,
Brushes.Black, 100, 540);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtMileageStart.Text, fntString,
Brushes.Black, 260, 540);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
100, 560, 380, 560);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Mileage End:", fntString,
Brushes.Black, 420, 540);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtMileageEnd.Text, fntString,
Brushes.Black, 530, 540);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
420, 560, 720, 560);
e.Graphics.FillRectangle(Brushes.Gray,
new Rectangle(100, 590, 620, 20));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle(100, 590, 620, 20));
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Order Timing Information", fntString,
Brushes.White, 100, 590);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Start Date:", fntString,
Brushes.Black, 100, 620);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(dtpStartDate.Value.ToString("D"),
fntString, Brushes.Black, 260, 620);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
100, 640, 720, 640);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("End Date:", fntString,
Brushes.Black, 100, 650);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(dtpEndDate.Value.ToString("D"), fntString,
Brushes.Black, 260, 650);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
100, 670, 520, 670);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Days:", fntString,
Brushes.Black, 550, 650);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtDays.Text, fntString,
Brushes.Black, 640, 650);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
550, 670, 720, 670);
e.Graphics.FillRectangle(Brushes.Gray,
new Rectangle(100, 700, 620, 20));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle(100, 700, 620, 20));
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Order Evaluation", fntString,
Brushes.White, 100, 700);
StringFormat fmtString = new StringFormat();
fmtString.Alignment = StringAlignment.Far;
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Rate Applied:", fntString,
Brushes.Black, 100, 740);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtRateApplied.Text, fntString,
Brushes.Black, 300, 740, fmtString);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
100, 760, 380, 760);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Tax Rate:", fntString,
Brushes.Black, 420, 740);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtTaxRate.Text, fntString,
Brushes.Black, 640, 740, fmtString);
e.Graphics.DrawString("%", fntString,
Brushes.Black, 640, 740);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
420, 760, 720, 760);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Sub-Total:", fntString,
Brushes.Black, 100, 770);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtSubTotal.Text, fntString,
Brushes.Black, 300, 770, fmtString);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
100, 790, 380, 790);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Tax Amount:", fntString,
Brushes.Black, 420, 770);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtTaxAmount.Text, fntString,
Brushes.Black, 640, 770, fmtString);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
420, 790, 720, 790);
fntString = new Font("Times New Roman", 12, FontStyle.Bold);
e.Graphics.DrawString("Order Total:", fntString,
Brushes.Black, 420, 800);
fntString = new Font("Times New Roman", 12, FontStyle.Regular);
e.Graphics.DrawString(txtOrderTotal.Text, fntString,
Brushes.Black, 640, 800, fmtString);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
420, 820, 720, 820);
}
- Return to the Order Processing form
- From the Printing section of the Toolbox, click PrintDialog and
click the form
- In the Properties window, change its Name to dlgPrint
- Still in the Properties windows, set its Document property to
docPrint
- On the Order Processing form, double-click the Print button and
implement its event as follows:
private void btnPrint_Click(object sender, EventArgs e)
{
if (dlgPrint.ShowDialog() == DialogResult.OK)
docPrint.Print();
}
- Return to the Order Processing form
- From the Printing section of the Toolbox, click PrintPreviewDialog
and click the form
- In the Properties window, change its (Name) to dlgPrintPreview
- Still in the Properties windows, set its Document property to
docPrint
- On the Order Processing form, double-click the Print Preview
button
- Implement the event as follows:
private void btnPrintPreview_Click(object sender, EventArgs e)
{
dlgPrintPreview.ShowDialog();
}
- Return to the Order Processing form
- Double-click the Open button
- Implement its event as follows:
private void btnOpen_Click(object sender, EventArgs e)
{
RentalOrder order = null;
if (txtReceiptNumber.Text == "")
{
MessageBox.Show("You must enter a receipt number");
return;
}
ReceiptNumber = int.Parse(txtReceiptNumber.Text);
if (ListOfRentalOrders.TryGetValue(ReceiptNumber, out order))
{
txtEmployeeNumber.Text = order.EmployeeNumber;
txtEmployeeNumber_Leave(sender, e);
cbxOrderStatus.Text = order.OrderStatus;
txtTagNumber.Text = order.CarTagNumber;
txtTagNumber_Leave(sender, e);
txtDrvLicNumber.Text = order.CustomerDrvLicNbr;
txtCustomerName.Text = order.CustomerName;
txtCustomerAddress.Text = order.CustomerAddress;
txtCustomerCity.Text = order.CustomerCity;
cbxCustomerStates.Text = order.CustomerState;
txtCustomerZIPCode.Text = order.CustomerZIPCode;
cbxCarConditions.Text = order.CarCondition;
cbxTankLevels.Text = order.TankLevel;
txtMileageStart.Text = order.MileageStart.ToString();
txtMileageEnd.Text = order.MileageEnd.ToString();
dtpStartDate.Value = order.DateStart;
dtpEndDate.Value = order.DateEnd;
txtDays.Text = order.Days.ToString();
txtRateApplied.Text = order.RateApplied.ToString("F");
txtSubTotal.Text = order.SubTotal.ToString("F");
txtTaxRate.Text = order.TaxRate.ToString("F");
txtTaxAmount.Text = order.TaxAmount.ToString("F");
txtOrderTotal.Text = order.OrderTotal.ToString("F");
}
else
{
MessageBox.Show("There is no rental order with that receipt number");
return;
}
}
- Return to the Order Processing form
- Double-click the New Rental
Order/Reset button
- Implement the event as follows:
private void btnNewRentalOrder_Click(object sender, EventArgs e)
{
txtEmployeeNumber.Text = "";
txtEmployeeName.Text = "";
txtDrvLicNumber.Text = "";
txtCustomerName.Text = "";
txtCustomerAddress.Text = "";
txtCustomerCity.Text = "";
cbxCustomerStates.Text = "";
txtCustomerZIPCode.Text = "";
txtTagNumber.Text = "";
cbxCarConditions.Text = "";
txtMake.Text = "";
txtModel.Text = "";
txtCarYear.Text = "";
cbxTankLevels.Text = "Empty";
txtMileageStart.Text = "0";
txtMileageEnd.Text = "0";
dtpStartDate.Value = DateTime.Today;
dtpEndDate.Value = DateTime.Today;
txtDays.Text = "";
cbxOrderStatus.Text = "";
txtRateApplied.Text = "0.00";
txtSubTotal.Text = "0.00";
txtTaxRate.Text = "7.75";
txtTaxAmount.Text = "0.00";
txtOrderTotal.Text = "0.00";
BinaryFormatter bfmRentalOrders = new BinaryFormatter();
string strFilename =
@"\\EXPRESSION\Bethesda Car Rental\RentalOrders.cro";
if (File.Exists(strFilename))
{
FileStream stmRentalOrders = new FileStream(strFilename,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
try
{
ListOfRentalOrders = (Dictionary<int,
RentalOrder>)bfmRentalOrders.Deserialize(stmRentalOrders);
foreach (KeyValuePair<int,
RentalOrder> order in ListOfRentalOrders)
ReceiptNumber = order.Key + 1;
}
finally
{
stmRentalOrders.Close();
}
}
else
{
ReceiptNumber = 100001;
ListOfRentalOrders = new Dictionary<int, RentalOrder>();
}
txtReceiptNumber.Text = ReceiptNumber.ToString();
}
- Return to the Order Processing form
- Double-click an unoccupied
area of its body
- Implement the Load event as follows:
private void OrderProcessing_Load(object sender, EventArgs e)
{
btnNewRentalOrder_Click(sender, e);
}
- Return to the Order Processing form
- Double-click the Close button and implement its event as follows:
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
- To save the project, on the Standard toolbar, click the Save All
button
|
|