![]() |
MS Visual C++ .NET Applications: Georgetown Cleaning Services |
|
Introduction to Serialization |
|
|
|
This application follows the Georgetown Cleaning Services that was primarily used to demonstrate the use of various Windows controls such as the date picker, the time picker, and bitmap buttons. One of the issues that was not dealt with was the ability to save the customers orders. In this application, after a customer's order has been processed, we will allow the user to save it. |
|
|


![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

private: System::Void dtpTimeLeft_ValueChanged(System::Object * sender, System::EventArgs * e)
{
DateTime dateLeft = this->dtpDateLeft->Value;
DateTime timeLeft = this->dtpTimeLeft->Value;
DateTime time9AM = DateTime(timeLeft.Year, timeLeft.Month, timeLeft.Day, 9, 0, 0);
// If the customer leaves clothes before 9AM...
if( timeLeft <= time9AM )
{
// ... then they should be ready the same day after 5PM
this->dtpDateExpected->Value = dateLeft;
this->dtpTimeExpected->Value = DateTime(dateLeft.Year, dateLeft.Month, dateLeft.Day, 17, 0, 0);
}
else
{
// If the clothese were left after 9AM, they will be availablethe following morning at 8AM
this->dtpDateExpected->Value = DateTime(dateLeft.Year, dateLeft.Month, dateLeft.Day + 1);
this->dtpTimeExpected->Value = DateTime(dateLeft.Year, dateLeft.Month, dateLeft.Day + 1, 8, 0, 0);
}
}
|
System::Void btnCalcShirts_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
// Retrieve the number of this item
// Just in case the user types an invalid value, we are using a try...catch
try {
quantity = this->txtShirtsQuantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the number of shirts is not valid"
S"\nPlease try again");
}
// Retrieve the unit price of this item
// Just in case the user types an invalid value, we are using a try...catch
try {
unitPrice = this->txtShirtsUnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price of shirts is not valid"
S"\nPlease try again");
}
// Calculate the sub-total for this item
subTotal = quantity * unitPrice;
// Display the sub-total in the corresponding text box
this->txtShirtsSubTotal->Text = subTotal.ToString(S"F");
}
|
System::Void btnCalcPants_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
try {
quantity = this->txtPantsQuantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the number of pants is not valid"
S"\nPlease try again");
}
try {
unitPrice = this->txtPantsUnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price of pants is not valid"
S"\nPlease try again");
}
subTotal = quantity * unitPrice;
this->txtPantsSubTotal->Text = subTotal.ToString("F");
}
|
System::Void btnCalcItem1_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
try {
quantity = this->txtItem1Quantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered is not valid"
S"\nPlease try again");
}
try {
unitPrice = this->txtItem1UnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price is not valid"
S"\nPlease try again");
}
subTotal = quantity * unitPrice;
this->txtItem1SubTotal->Text = subTotal.ToString("F");
}
private: System::Void btnCalcItem2_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
try {
quantity = this->txtItem2Quantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered is not valid"
S"\nPlease try again");
}
try {
unitPrice = this->txtItem2UnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price is not valid"
S"\nPlease try again");
}
subTotal = quantity * unitPrice;
this->txtItem2SubTotal->Text = subTotal.ToString("F");
}
private: System::Void btnCalcItem3_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
try {
quantity = this->txtItem3Quantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered is not valid"
S"\nPlease try again");
}
try {
unitPrice = this->txtItem3UnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price is not valid"
S"\nPlease try again");
}
subTotal = quantity * unitPrice;
this->txtItem3SubTotal->Text = subTotal.ToString("F");
}
private: System::Void btnCalcItem4_Click(System::Object * sender, System::EventArgs * e)
{
int quantity = 1;
double unitPrice, subTotal;
try {
quantity = this->txtItem4Quantity->Text->ToInt16(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered is not valid"
S"\nPlease try again");
}
try {
unitPrice = this->txtItem4UnitPrice->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The value you entered for the price is not valid"
S"\nPlease try again");
}
subTotal = quantity * unitPrice;
this->txtItem4SubTotal->Text = subTotal.ToString("F");
}
|
private: System::Void btnCalculate_Click(System::Object * sender, System::EventArgs * e)
{
double priceShirts, pricePants,
priceItem1, priceItem2, priceItem3, priceItem4,
cleaningTotal;
double taxRate, taxAmount;
double orderTotal;
// Just in case the user forgot to calculate the sub totals, do it now
this->btnCalcShirts_Click(sender, e);
this->btnCalcPants_Click(sender, e);
this->btnCalcItem1_Click(sender, e);
this->btnCalcItem2_Click(sender, e);
this->btnCalcItem3_Click(sender, e);
this->btnCalcItem4_Click(sender, e);
// Retrieve the value of the sub-total for each category of items
priceShirts = this->txtShirtsSubTotal->Text->ToDouble(0);
pricePants = this->txtPantsSubTotal->Text->ToDouble(0);
priceItem1 = this->txtItem1SubTotal->Text->ToDouble(0);
priceItem2 = this->txtItem2SubTotal->Text->ToDouble(0);
priceItem3 = this->txtItem3SubTotal->Text->ToDouble(0);
priceItem4 = this->txtItem4SubTotal->Text->ToDouble(0);
// Calculate the total
cleaningTotal = priceShirts + pricePants +
priceItem1 + priceItem2 + priceItem3 + priceItem4;
// Retrieve the value of the tax rate
try {
taxRate = this->txtTaxRate->Text->ToDouble(0);
}
catch(FormatException *)
{
MessageBox::Show(S"The tax rate you entered is invalid"
S"\nPlease try again");
}
// Calculate the amount owed for the taxes
taxAmount = cleaningTotal * taxRate / 100;
// Add the tax amount to the total order
orderTotal = cleaningTotal + taxAmount;
// Display the values of the order summary
this->txtCleaningTotal->Text = cleaningTotal.ToString(S"F");
this->txtTaxAmount->Text = taxAmount.ToString(S"F");
this->txtOrderTotal->Text = orderTotal.ToString(S"F");
}
|
private: System::Void btnNewOrder_Click(System::Object * sender, System::EventArgs * e)
{
this->txtCustomerName->Text = S"";
this->txtCustomerPhone->Text = S"";
this->txtShirtsUnitPrice->Text = S"0.95";
this->txtShirtsQuantity->Text = S"0";
this->txtShirtsSubTotal->Text = S"0.00";
this->txtPantsUnitPrice->Text = S"2.75";
this->txtPantsQuantity->Text = S"0";
this->txtPantsSubTotal->Text = S"0.00";
this->txtItem1UnitPrice->Text = S"0.00";
this->txtItem1Quantity->Text = S"0";
this->txtItem1SubTotal->Text = S"0.00";
this->txtItem2UnitPrice->Text = S"0.00";
this->txtItem2Quantity->Text = S"0";
this->txtItem2SubTotal->Text = S"0.00";
this->txtItem3UnitPrice->Text = S"0.00";
this->txtItem3Quantity->Text = S"0";
this->txtItem3SubTotal->Text = S"0.00";
this->txtItem4UnitPrice->Text = S"0.00";
this->txtItem4Quantity->Text = S"0";
this->txtItem4SubTotal->Text = S"0.00";
this->txtCleaningTotal->Text = S"0.00";
this->txtTaxRate->Text = S"5.75";
this->txtTaxAmount->Text = S"0.00";
this->txtOrderTotal->Text = S"0.00";
this->txtCustomerName->Focus();
}
|
System::Void btnClose_Click(System::Object * sender, System::EventArgs * e)
{
Close();
}
|
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
System::Void btnClose_Click(System::Object * sender, System::EventArgs * e)
{
Close();
}
|
![]() |
||||||||
|
#pragma once
#include "NewCleaningOrder.h"
#include "CleaningOrders.h"
namespace GCS3
{
. . . No Change
private: System::Windows::Forms::Button * btnNewOrder;
private: System::Windows::Forms::Button * btnOrders;
private: System::Windows::Forms::Button * btnClose;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container * components;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
. . . No Change
}
private: System::Void btnNewOrder_Click(System::Object * sender, System::EventArgs * e)
{
NewCleaningOrder *frmOrder = new NewCleaningOrder();
frmOrder->ShowDialog();
}
private: System::Void btnOrders_Click(System::Object * sender, System::EventArgs * e)
{
CleaningOrders *frmOrder = new CleaningOrders();
frmOrder->ShowDialog();
}
private: System::Void btnClose_Click(System::Object * sender, System::EventArgs * e)
{
Close();
}
};
}
|
|
|
||
| Home | Copyright © 2004-2005 FunctionX, Inc. | Next |
|
|
||