Example #1
0
        private void PopulateFields()
        {
            DataTable dt  = prescription.GetPrescription(prescriptionId);
            DataRow   row = dt.Rows[0];

            labelPrescriptionId.Text = row["Prescription Id"].ToString();
            labelDoctorName.Text     = row["Doctor"].ToString();
            labelPatientName.Text    = row["Patient"].ToString();
            labelDosage.Text         = row["Dosage"].ToString();

            if (dt.Rows != null && dt.Rows.Count != 0)
            {
                DataTable drugDt = drug.GetDrugsFromPrescriptionID(prescriptionId);
                dgvAllDrugs.DataSource = drugDt;
            }
        }
Example #2
0
        private void SetValues()
        {
            DataTable dt       = invoice.GetInvoiceData(appointmentID);
            DataRow   row      = dt.Rows[0];
            String    docFName = row["Doctor First Name"].ToString();
            String    docLName = row["Doctor Last Name"].ToString();
            String    patFName = row["Patient First Name"].ToString();
            String    patLName = row["Patient Last Name"].ToString();

            labelInvoiceNum.Text      = row["Appointment ID"].ToString();
            labelPatientName.Text     = patFName + " " + patLName;
            labelDoctorName.Text      = docFName + " " + docLName;
            labelDoctorSpecialty.Text = row["Doctor Specialty"].ToString();
            labelDate.Text            = DateTime.Now.ToShortDateString();
            labelPatientAddress.Text  = row["Patient Address"].ToString();
            labelPatienContact.Text   = row["Patient Contact"].ToString();

            DataTable labTestDT = labTest.GetAllAppointmentLabTest(appointmentID);
            List <Tuple <string, string, decimal> > invoiceBilling = new List <Tuple <string, string, decimal> >();

            DataTable invoiceDataTable = new DataTable();

            invoiceDataTable.Columns.Add("Service / Drug".ToString());
            invoiceDataTable.Columns.Add("Cost".ToString());

            decimal totalCost = 0;

            if (labTestDT.Rows != null && labTestDT.Rows.Count != 0)
            {
                foreach (DataRow testRow in labTestDT.Rows)
                {
                    int       testID    = Convert.ToInt32(testRow["test_id"]);
                    DataTable serviceDt = labService.GetAllLabServiceForTest(testID);

                    foreach (DataRow serviceRow in serviceDt.Rows)
                    {
                        Console.WriteLine("Row");
                        Tuple <string, string, decimal> serivceInfo = new Tuple <string, string, decimal>("Service", serviceRow["Service"].ToString(), Convert.ToDecimal(serviceRow["Cost"]));
                        invoiceBilling.Add(serivceInfo);

                        totalCost = totalCost + Convert.ToDecimal(serviceRow["Cost"]);

                        DataRow dr = invoiceDataTable.NewRow();
                        dr["Service / Drug"] = "Service: " + serviceRow["Service"].ToString();
                        dr["Cost"]           = serviceRow["Cost"].ToString();
                        invoiceDataTable.Rows.Add(dr);

                        //DataGridViewRow dgr = new DataGridViewRow();
                        //dgr.
                    }
                }
            }


            DataTable prescriptionDt = prescription.getPrescriptionIDFromAppointment(appointmentID);

            if (prescriptionDt.Rows != null && prescriptionDt.Rows.Count != 0)
            {
                int       prescriptionID = Convert.ToInt32(prescriptionDt.Rows[0]["prescription_id"]);
                DataTable drugsDT        = drug.GetDrugsFromPrescriptionID(prescriptionID);

                if (drugsDT.Rows != null && drugsDT.Rows.Count != 0)
                {
                    foreach (DataRow drugRow in drugsDT.Rows)
                    {
                        Tuple <string, string, decimal> drugInfo = new Tuple <string, string, decimal>("Drug", drugRow["Drug"].ToString(), Convert.ToDecimal(drugRow["Cost"]));
                        invoiceBilling.Add(drugInfo);

                        totalCost = totalCost + Convert.ToDecimal(drugRow["Cost"]);

                        DataRow dr = invoiceDataTable.NewRow();
                        dr["Service / Drug"] = "Drug: " + drugRow["Drug"].ToString();
                        dr["Cost"]           = drugRow["Cost"].ToString();
                        invoiceDataTable.Rows.Add(dr);
                    }
                }
            }

            DataRow dataRow = invoiceDataTable.NewRow();

            dataRow["Service / Drug"] = "Total";
            dataRow["Cost"]           = totalCost.ToString();
            invoiceDataTable.Rows.Add(dataRow);

            for (int i = 0; i < invoiceBilling.Count; i++)
            {
                Console.WriteLine(invoiceBilling[i]);
            }

            dgvInvoice.DataSource = invoiceDataTable;



            //labelAppointmentID.Text = appointmentID.ToString();
            //labelDoctorName.Text = docFName + " " + docLName;
            //labelDoctorSpecialty.Text = patFName + " " + patLName;
            //labelPatientAllergies.Text = allergies;
            //labelPatientDOB.Text = DOB;
            //labelPatientBloodType.Text = bloodType;
            //labelAppointmentStatus.Text = status;
        }