private void btnOpen_Click(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 = { "Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec" };
string strFilename = day.ToString() + strMonth[month-1] +
year.ToString() + ".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("Text", dsDailyOrders, "Workorder.CustomerName"));
txtAddress.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Addres"));
txtCity.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.City"));
txtState.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.State"));
txtZIPCode.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.ZIPCode"));
txtMake.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Make"));
txtModel.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Model"));
txtCarYear.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.CarYear"));
txtProblem.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Problem"));
txtPartName1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.PartName1"));
txtUnitPrice1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.UnitPrice1"));
txtQuantity1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Quantity1"));
txtSubTotal1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.SubTotal1"));
txtPartName2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.PartName2"));
txtUnitPrice2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.UnitPrice2"));
txtQuantity2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Quantity2"));
txtSubTotal2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.SubTotal2"));
txtPartName3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.PartName3"));
txtUnitPrice3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.UnitPrice3"));
txtQuantity3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Quantity3"));
txtSubTotal3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.SubTotal3"));
txtPartName4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.PartName4"));
txtUnitPrice4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.UnitPrice4"));
txtQuantity4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Quantity4"));
txtSubTotal4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.SubTotal4"));
txtPartName5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.PartName5"));
txtUnitPrice5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.UnitPrice5"));
txtQuantity5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Quantity5"));
txtSubTotal5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.SubTotal5"));
txtJobPerformed1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPerformed1"));
txtJobPrice1.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPrice1"));
txtJobPerformed2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPerformed2"));
txtJobPrice2.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPrice2"));
txtJobPerformed3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPerformed3"));
txtJobPrice3.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPrice3"));
txtJobPerformed4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPerformed4"));
txtJobPrice4.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPrice4"));
txtJobPerformed5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPerformed5"));
txtJobPrice5.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.JobPrice5"));
txtRecommendations.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.Recommendation"));
txtTotalParts.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.TotalPart"));
txtTotalLabor.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.TotalLabor"));
txtTaxRate.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.TaxRate"));
txtTaxAmount.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.TaxAmount"));
txtTotalOrder.DataBindings.Add(new System.Windows.Forms.Binding("Text", dsDailyOrders, "Workorder.TotalOrder"));
}
else // If there is no data, let the user know
MessageBox.Show(String.Concat("No workorder available for ", this.dtpOrderDate.Value.ToString()));
}
}
|