System::Void btnOpen_Click(System::Object * sender, System::EventArgs * e)
{
// Get the date that the Order Date displays
DateTime tmeToday = this->dtpOrderDate->Value;
int day = tmeToday.Day;
int month = tmeToday.Month;
int year = tmeToday.Year;
String *strMonth[] = { S"Jan", S"Feb", S"Mar", S"Apr",
S"May", S"Jun", S"Jul", S"Aug",
S"Sep", S"Oct", S"Nov", S"Dec" };
String *strFilename = String::Concat(day.ToString(), strMonth[month-1],
year.ToString(), S".xml");
// If the file exists already, open it
if( File::Exists(strFilename) )
{
// Get a reference to the object that holds the daily repairs
InfoCenter *frmInfo = new InfoCenter();
// Empty the local data set of any data. This is required if
// we want the user to be able to open different daily sets of repairs
this->dsDailyOrders->Clear();
// Refresh or initialize the local set with the information
// stored centrally
this->dsDailyOrders = frmInfo->dsWorkorders;
// Open the set of orders placed on the day selected
dsDailyOrders->ReadXml(strFilename);
// Because a control can be bound anew every time the user opens a new set
// Unbind each control to refresh it
txtCustomerName->DataBindings->Clear();
txtAddress->DataBindings->Clear();
txtCity->DataBindings->Clear();
txtState->DataBindings->Clear();
txtZIPCode->DataBindings->Clear();
txtMake->DataBindings->Clear();
txtModel->DataBindings->Clear();
txtCarYear->DataBindings->Clear();
txtProblem->DataBindings->Clear();
txtPartName1->DataBindings->Clear();
txtUnitPrice1->DataBindings->Clear();
txtQuantity1->DataBindings->Clear();
txtSubTotal1->DataBindings->Clear();
txtPartName2->DataBindings->Clear();
txtUnitPrice2->DataBindings->Clear();
txtQuantity2->DataBindings->Clear();
txtSubTotal2->DataBindings->Clear();
txtPartName3->DataBindings->Clear();
txtUnitPrice3->DataBindings->Clear();
txtQuantity3->DataBindings->Clear();
txtSubTotal3->DataBindings->Clear();
txtPartName4->DataBindings->Clear();
txtUnitPrice4->DataBindings->Clear();
txtQuantity4->DataBindings->Clear();
txtSubTotal4->DataBindings->Clear();
txtPartName5->DataBindings->Clear();
txtUnitPrice5->DataBindings->Clear();
txtQuantity5->DataBindings->Clear();
txtSubTotal5->DataBindings->Clear();
txtJobPerformed1->DataBindings->Clear();
txtJobPrice1->DataBindings->Clear();
txtJobPerformed2->DataBindings->Clear();
txtJobPrice2->DataBindings->Clear();
txtJobPerformed3->DataBindings->Clear();
txtJobPrice3->DataBindings->Clear();
txtJobPerformed4->DataBindings->Clear();
txtJobPrice4->DataBindings->Clear();
txtJobPerformed5->DataBindings->Clear();
txtJobPrice5->DataBindings->Clear();
txtRecommendations->DataBindings->Clear();
txtTotalParts->DataBindings->Clear();
txtTotalLabor->DataBindings->Clear();
txtTaxRate->DataBindings->Clear();
txtTaxAmount->DataBindings->Clear();
txtTotalOrder->DataBindings->Clear();
// Bind each control with data gotten from the newly opened file
txtCustomerName->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.CustomerName"));
txtAddress->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Address"));
txtCity->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.City"));
txtState->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.State"));
txtZIPCode->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.ZIPCode"));
txtMake->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Make"));
txtModel->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Model"));
txtCarYear->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.CarYear"));
txtProblem->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Problem"));
txtPartName1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.PartName1"));
txtUnitPrice1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.UnitPrice1"));
txtQuantity1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Quantity1"));
txtSubTotal1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.SubTotal1"));
txtPartName2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.PartName2"));
txtUnitPrice2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.UnitPrice2"));
txtQuantity2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Quantity2"));
txtSubTotal2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.SubTotal2"));
txtPartName3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.PartName3"));
txtUnitPrice3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.UnitPrice3"));
txtQuantity3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Quantity3"));
txtSubTotal3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.SubTotal3"));
txtPartName4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.PartName4"));
txtUnitPrice4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.UnitPrice4"));
txtQuantity4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Quantity4"));
txtSubTotal4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.SubTotal4"));
txtPartName5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.PartName5"));
txtUnitPrice5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.UnitPrice5"));
txtQuantity5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Quantity5"));
txtSubTotal5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.SubTotal5"));
txtJobPerformed1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPerformed1"));
txtJobPrice1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPrice1"));
txtJobPerformed2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPerformed2"));
txtJobPrice2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPrice2"));
txtJobPerformed3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPerformed3"));
txtJobPrice3->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPrice3"));
txtJobPerformed4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPerformed4"));
txtJobPrice4->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPrice4"));
txtJobPerformed5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPerformed5"));
txtJobPrice5->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.JobPrice5"));
txtRecommendations->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.Recommendations"));
txtTotalParts->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.TotalParts"));
txtTotalLabor->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.TotalLabor"));
txtTaxRate->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.TaxRate"));
txtTaxAmount->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.TaxAmount"));
txtTotalOrder->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", dsDailyOrders, S"Workorder.TotalOrder"));
}
else // If there is no data, let the user know
MessageBox::Show(String::Concat(S"No workorder available for ", this->dtpOrderDate->Value.ToString()));
}
|