Example #1
0
        public void viewInvoice(tblInvoice thisInvoice)
        {
            myForm = new invoiceViewForm();
            myInvoice = thisInvoice;

            var newConnection = new dbContextDataContext();

            var Lines = newConnection.tblPatientStats.Where(lines => lines.InvoiceNo == thisInvoice.InvoiceNo);
            foreach (var line in Lines)
            {
                myInvoiceLines.Add(line);
            }

            myTransaction = newConnection.tblTransactions.
                Where(transaction => (transaction.InvoiceNo == thisInvoice.InvoiceNo) && (transaction.TranType == "I")).FirstOrDefault();
            myClaimant = newConnection.tblClaimants.Where(claimant => claimant.ClaimantID == myTransaction.ClaimantID).FirstOrDefault();

            if (myTransaction == null)
            {
                myTransaction = new tblTransaction();
            }

            if (myInvoice == null)
            {
                myInvoice = new tblInvoice();
            }

            if (myClaimant == null)
            {
                myClaimant = new tblClaimant();
            }

            var receiptAmounts = newConnection.tblInvoiceReceipts.Where(rm => rm.InvoiceNo == myInvoice.InvoiceNo);
            var receipts = from rm in receiptAmounts
                           from r in newConnection.tblReceipts.Where(r => r.ReceiptNo == rm.ReceiptNo)
                           select r;

            // Second query to get receipts from another table. I might combine the two tables come deployment.

            var receiptAmounts2 = from rm in newConnection.tblReceiptInvoices
                            where rm.InvoiceNo == myInvoice.InvoiceNo
                            select new
                            {
                                InvoiceNo = rm.InvoiceNo,
                                ReceiptNo = rm.ReceiptNo,
                                InvRecAmnt = rm.Received
                            };

            foreach (var receipt in receiptAmounts2)
            {
                var receiptAmount = new tblInvoiceReceipt();
                receiptAmount.InvoiceNo = receipt.InvoiceNo;
                receiptAmount.InvRecAmnt = receipt.InvRecAmnt;
                receiptAmount.ReceiptNo = receipt.ReceiptNo;
                myReceiptAmounts.Add(receiptAmount);
            }

            foreach (var receipt in receipts)
            {
                myReceipts.Add(receipt);
            }

            foreach (var receiptAmount in receiptAmounts)
            {
                myReceiptAmounts.Add(receiptAmount);
            }

            myForm.invoiceDateEdit.DateTime = myTransaction.TranDate.Value;
            registeFormEvents();
            updateInvoiceForm();
            makeInvoiceOfficial();
            myForm.ShowDialog();
            Cursor.Current = Cursors.Default;
            applyPaid();
        }
Example #2
0
        public void newInvoice()
        {
            myForm = new invoiceViewForm();

            registeFormEvents();

            myForm.invoiceDateEdit.DateTime = System.DateTime.Today;
            myForm.ShowDialog();
            applyPaid();

            if ((myForm.DialogResult == DialogResult.OK) && (myInvoice.InvoiceNo == 0))
            {
                if (myInvoiceLines.Any())
                {
                    commitInvoice();
                }
            }
            myForm.Dispose();
        }