private void tsbSave_Click(object sender, EventArgs e) { if (!ValidateChildren()) { return; } if (cbDoctor.SelectedIndex == -1) { MessageBox.Show("A doctor needs to be selected"); return; } // Go through the rows and update invoice builder values to possible user entered values foreach (DataGridViewRow row in dgvInvoice.Rows) { if (!row.IsNewRow) { try { m_invBuilder.modifyItemPrice(row.Index, Convert.ToDecimal(dgvInvoice.Rows[row.Index].Cells[3].Value)); m_invBuilder.modifyItemDiscount(row.Index, Convert.ToDecimal(dgvInvoice.Rows[row.Index].Cells[4].Value)); m_invBuilder.modifyItemQuanity(row.Index, Convert.ToInt32(dgvInvoice.Rows[row.Index].Cells[5].Value)); } catch (Exception) { MessageBox.Show("Invalid values given, use only numbers for Quantity, discount and price"); return; } } } int invID = m_invBuilder.saveInvoice(m_nPatientID, cbStatus.SelectedIndex, (int)cbDoctor.SelectedValue, dtpBillDate.Value); if (invID == -1) // Error occured { MessageBox.Show("An unknown error occured saving the invoice", "Something bad happened", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // enable the delete and reprot button tsbSavePDF.Enabled = true; tsbDelete.Enabled = true; // Position the current invoice as the datasource of the form; m_currentInvoice = m_invBuilder.Invoice; invoiceBindingSource.DataSource = m_currentInvoice; // Set the invoice total value at top of form lblTotal.Text = "$" + Convert.ToSingle(Database.InvoiceMgr.Instance.getInvoiceTotal(m_currentInvoice)); // Set some flags to indicate update mode now m_bIsUpdate = true; m_invBuilder.IsSaved = true; DialogResult r = MessageBox.Show("Invoice commited to " + m_currentPatient.FullName + "'s account\nWould you like to process a payment now?", "Payout", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { PaymentForm frmPay = new PaymentForm(m_currentPatient.patID, Database.InvoiceMgr.Instance.getInvoiceTotal(m_currentInvoice), invID, m_currentInvoice.docID); frmPay.ShowDialog(); } r = MessageBox.Show("Print reciept?", "PatientManager", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { generateInvoiceReport(true); } r = MessageBox.Show("Generate patient account statement?", "PatientManager", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { generateAccountStatement(true); } } // Used for when called a dialog to check if the invoice was saved successfully DialogResult = DialogResult.OK; }
private void tsbPayment_Click(object sender, EventArgs e) { if (!checkForOpenForm("PaymentForm")) { if (!checkForActiveDoctors()) { return; } PaymentForm pFrm = new PaymentForm(); pFrm.MdiParent = this; pFrm.Show(); } }