Example #1
0
        public InvoiceForm(int patID, bool isPatID)
        {
            InitializeComponent();
            cbStatus.SelectedIndex = 0;

            m_invBuilder = new InvoiceBuilder();

            m_currentInvoice = m_invBuilder.Invoice;

            selectPatient(patID);
        }
Example #2
0
        public InvoiceForm(int invID)
        {
            InitializeComponent();
            // Constuct invoice builder with premade invoice
            m_invBuilder = new InvoiceBuilder(invID);
            m_currentInvoice = m_invBuilder.Invoice;
            // Set binding source
            invoiceBindingSource.DataSource = m_currentInvoice;

            dtpBillDate.Value = m_currentInvoice.invDate;
            cbStatus.SelectedIndex = (m_currentInvoice.invStatus != null) ? (int)m_currentInvoice.invStatus : 0;

            selectPatient(m_currentInvoice.patID);
            // Read only mode since this invoice is already saved
            m_bIsUpdate = true;

            tsbDelete.Enabled = true;
            tsbSavePDF.Enabled = true;
            tsbStatement.Enabled = true;

            populateDataGrid();
        }
Example #3
0
        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;
        }