public void addBill(Bill b) { int patient_id = getUserIdFromName(b.patient); if (patient_id < 0) { throw new Exception("Invalid User ID: User does not exist in system, please register an account"); } if (b.bill_date == null) { b.bill_date = DateTime.Now; } string query = "insert into Billing (patient_id, bill_total, for_text, bill_date) " + String.Format("VALUES ({0}, {1}, '{2}', '{3:yyyy-MM-dd}')", patient_id, b.bill_total, b.for_text, b.bill_date); MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); MySqlCommand addUser = new MySqlCommand(query, connection); addUser.ExecuteNonQuery(); } catch (Exception e) { throw new Exception("Could not add user. Error: " + e.Message, e); } finally { connection.Close(); } }
public ActionResult SubmitPayment(int id, double hours) { if (Request.HttpMethod == "POST") { Appointment app = svc.getAppointmentById(id); Payment p = new Payment(); p.doctor = app.doctor; p.type = "appointment"; p.hours = hours; p.pay_rate = 10; p.for_text = app.patient; p.pay_date = DateTime.Now; PaymentProviderService paysvc = new PaymentProviderService(); paysvc.makePayment(p); Bill b = new Bill(); b.patient = app.patient; b.bill_total = p.pay_rate * p.hours; b.for_text = "appointment: " + p.doctor; b.bill_date = DateTime.Now; BillingProviderService billsvc = new BillingProviderService(); billsvc.addBill(b); svc.cancelAppointment(id, false); } return RedirectToAction("Index"); }
public List<Bill> getBilling(string query) { List<Bill> records = new List<Bill>(); MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); MySqlCommand verifyUser = new MySqlCommand(query, connection); verifyUser.ExecuteNonQuery(); object[] values = new object[5]; MySqlDataReader response = verifyUser.ExecuteReader(); try { while (response.Read()) { int num = response.GetValues(values); if (num == values.Length) { Bill r = new Bill(); r.id = (int)values[0]; r.patient = getUserNameFromID((int)values[1]); r.bill_total = (double)values[2]; r.for_text = (String)values[3]; r.bill_date = (DateTime)values[4]; records.Add(r); } } } finally { response.Close(); } } catch (Exception e) { throw new Exception("Could not access billing records. Error: " + e.Message, e); } finally { connection.Close(); } return records; }
public void addBill(Bill b) { _provider.addBill(b); }