/// <summary> /// Event-handler for click event of submittt button. Here every calculation is performed and /// the result for one reservations will be showed in the labels and the all the reservations are stored /// in the Reservations tab. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { //if no customers are present prompt to add one if (cmbCustomer.Items.Count == 0) { MessageBox.Show("No Customers are registerd, add customers first.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //to check whether the user has provided all the input or not, if provided continue if (ValidInput()) { //Show the Select time form by passing the type of form selected by the user, title and from and to stations frmSelectTime = new SelectTimeForm(cmbTranportation.SelectedIndex + 1, SelectTitle(), cmbFrom.SelectedItem.ToString(), cmbTo.SelectedItem.ToString()); //if no matching transport between selected locations are found show the message if (frmSelectTime.ListBoxDetails.Count == 0) { MessageBox.Show("No transport available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); frmSelectTime.Close(); //do not show the selectTime form } else { //if some transports are available then continue if (frmSelectTime.ShowDialog() == DialogResult.OK) { //store the values of reservations in the labels lblCustomerName.Text = cmbCustomer.SelectedItem.ToString(); string[] str = InputUtility.GetWords(lstCustomers.Items[cmbCustomer.SelectedIndex].ToString()); lblCustomerPhone.Text = str[2]; lblReservationUpto.Text = frmSelectTime.Detail; string[] str1 = InputUtility.GetWords(frmSelectTime.Detail); string price = str1[4]; //calculate the total Price lblPrice.Text = GetPrice(price).ToString("#.##"); lblTotalTickets.Text = (numericInfants.Value + numericChildren.Value + numericAdults.Value).ToString(); //shwo the controls to confrim or cancel the reservations btnSubmit.Enabled = false; btnConfirm.Enabled = true; btnCancel.Enabled = true; } else { //to empty labels which save the reservation details EmptyReservationLabels(); } } //re-initialize all fields InitializeGUI(); } }
/// <summary> /// Event-handler for click event of submittt button. Here every calculation is performed and /// the result for one reservations will be showed in the labels and the all the reservations are stored /// in the Reservations tab. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { //if no customers are present prompt to add one if(cmbCustomer.Items.Count == 0) { MessageBox.Show("No Customers are registerd, add customers first.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //to check whether the user has provided all the input or not, if provided continue if(ValidInput()) { //Show the Select time form by passing the type of form selected by the user, title and from and to stations frmSelectTime = new SelectTimeForm(cmbTranportation.SelectedIndex + 1, SelectTitle(), cmbFrom.SelectedItem.ToString(), cmbTo.SelectedItem.ToString()); //if no matching transport between selected locations are found show the message if (frmSelectTime.ListBoxDetails.Count == 0) { MessageBox.Show("No transport available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); frmSelectTime.Close(); //do not show the selectTime form } else { //if some transports are available then continue if(frmSelectTime.ShowDialog() == DialogResult.OK) { //store the values of reservations in the labels lblCustomerName.Text = cmbCustomer.SelectedItem.ToString(); string[] str = InputUtility.GetWords(lstCustomers.Items[cmbCustomer.SelectedIndex].ToString()); lblCustomerPhone.Text = str[2]; lblReservationUpto.Text = frmSelectTime.Detail; string[] str1 = InputUtility.GetWords(frmSelectTime.Detail); string price = str1[4]; //calculate the total Price lblPrice.Text = GetPrice(price).ToString("#.##"); lblTotalTickets.Text = (numericInfants.Value + numericChildren.Value + numericAdults.Value).ToString(); //shwo the controls to confrim or cancel the reservations btnSubmit.Enabled = false; btnConfirm.Enabled = true; btnCancel.Enabled = true; } else { //to empty labels which save the reservation details EmptyReservationLabels(); } } //re-initialize all fields InitializeGUI(); } }