private void btnBillAndSave_Click(object sender, EventArgs e) { try { if (IsValidKM(CurrentKm) && WorkPay > 0) { Service sv = new Service(DateTime.Now, CurrentKm, WorkPay, allInspections, servicedBy, LastTotal); if (_client != null) { using (ViewInvoice vI = new ViewInvoice(new Invoice(sv.ServiceId, _vehicle, sv, _client, servicedBy, VAT, (CalculateTotal() + WorkPay), LastTotal), false)) { vI.ShowDialog(); if (vI.DialogResult == DialogResult.OK) { UpdateStock(); _vehicle.ServiceList.Add(sv); } } } else if (_company != null) { using (ViewInvoice vI = new ViewInvoice(new Invoice(sv.ServiceId, _vehicle, sv, _company, servicedBy, VAT, (CalculateTotal() + WorkPay), LastTotal), false)) { vI.ShowDialog(); if (vI.DialogResult == DialogResult.Yes) { UpdateStock(); _vehicle.ServiceList.Add(sv); } else { MessageBox.Show("Service Aborted!", "New service", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } DialogResult dg = MessageBox.Show("New service added successfully!", "New service", MessageBoxButtons.OK, MessageBoxIcon.Information); if (dg == DialogResult.OK) { UC_ViewServices services = new UC_ViewServices(_vehicle); this.Controls.Clear(); this.Controls.Add(services); } } } catch (Exception) { //MessageBox.Show("Your current kilometres are invalid!"); } }
public void Paraqit() { DialogResult dg = MessageBox.Show($"Service for vehicle with plate number: {_vehicle.LicensePlate}\r\nDO YOU WANT TO SEE DETAILS?", "Details of Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dg == DialogResult.Yes) { Invoice inv = blInvoice.GetInvoice(invId); this.Hide(); using (ViewInvoice vi = new ViewInvoice(inv, true)) { vi.ShowDialog(); } this.Show(); } }