private void Confirm_Billing_Click(object sender, RoutedEventArgs e) { bool flag = false; billingCustomerName.Text = txtCustomerName.Text; billingOrderID.Text = txtOrderID.Text; //check the OrderStatus with trip information Order order = new Order(); flag = order.UpdateOrderCondition(billingOrderID.Text); //get planID with orderID PlanInfo planinfo = new PlanInfo(); planinfo.orderID = billingOrderID.Text; var planList = planinfo.GetPlanID(planinfo.orderID); if (planList.Count != 0) { planinfo.planID = planList[0].planID; } else { planinfo.planID = ""; MessageBox.Show("The planID is null. Please check the planID for the plan information.", "Check the plan information."); } //get Billing information Billing billing = new Billing(); var billingResult = billing.GetBillings(planinfo.planID, planinfo.orderID); //set Order.carrierID with selected carrierID if (billingResult[0] != null) { billing.command = "INSERT"; //assign data from table billing.billingID = "BILL" + billingResult[0].orderID; billing.orderID = billingResult[0].orderID; billing.planID = billingResult[0].planID; billing.customerID = billingResult[0].customerID; billing.jobType = billingResult[0].jobType; billing.quantity = billingResult[0].quantity; billing.vanType = billingResult[0].vanType; //FTL if (billing.jobType == 0) { billing.totalAmount = 4.985 * billingResult[0].distance + ((4.985 * billingResult[0].distance) * billingResult[0].ftlRate / 100); } //LTL else { billing.totalAmount = 0.2995 * billing.quantity * billingResult[0].distance + ((0.2995 * billing.quantity * billingResult[0].distance) * billing.ltlRate / 100); } } flag = billing.Save(); //#### Check the carrierAvailability if (flag == true) { MessageBox.Show("Billing's Information is created sucessfully.", "Create Billing Information."); Confirm_Invoice(billing.planID, billing.orderID); } else { MessageBox.Show("Billing's Information is not created. You need to check this.", "Billing Information failed."); } }