// Use this to insert a single new billing order public bool InsertNewRecord(BillingRecord record) { List <BillingRecord> temp = new List <BillingRecord>(); temp.Add(record); bool ret = InsertNewRecord(temp); return(ret); }
private List <BillingRecord> GetBillingInfo(SqlCommand command) { List <BillingRecord> records = new List <BillingRecord>(); try { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { // Get ordinals for the columns required to fill the record int ordid = reader.GetOrdinal("Order_ID"); int apptid = reader.GetOrdinal("Appointment_ID"); int apptdate = reader.GetOrdinal("ApptDate"); int hcn = reader.GetOrdinal("Patient_1"); int sex = reader.GetOrdinal("Sex_ID"); int lineid = reader.GetOrdinal("Line_ID"); int code = reader.GetOrdinal("Billing_Code_ID"); int fee = reader.GetOrdinal("Price"); int status = reader.GetOrdinal("Status_ID"); if (reader.HasRows) { // Read each row filling in the billing information while (reader.Read()) { BillingRecord rec = new BillingRecord(); rec.OrderId = GetSafeInt(reader, ordid); rec.Appointment = GetSafeInt(reader, apptid); rec.AppointmentDate = GetSafeDateTime(reader, apptdate); rec.HealthCardNumber = GetSafeString(reader, hcn); rec.Gender = GetSafeChar(reader, sex); rec.ServiceId = GetSafeInt(reader, lineid); rec.ServiceCode = GetSafeString(reader, code); rec.Fee = GetSafeString(reader, fee); rec.Status = GetSafeString(reader, status); records.Add(rec); // Add to the list } } } // end using connection.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } finally { // this allows the exception to percolate... connection.Close(); } return(records); }
// Add more services to an appointment or update an existing record public bool UpdateRecord(UPDATE_OPTION option, BillingRecord record) { bool ret = false; if (option == UPDATE_OPTION.APPOINTMENT_ID) { ret = UpdateByAppointmentId(record); } else if (option == UPDATE_OPTION.ORDER_ID) { ret = UpdateByOrderId(record); } else if (option == UPDATE_OPTION.LINE_ID) { ret = UpdateByLineId(record); } return(ret); }
private bool UpdateByLineId(BillingRecord record) { SqlCommand command = new SqlCommand("UpdateBillingLine", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@lineid", record.ServiceId)); command.Parameters.Add(new SqlParameter("@codeid", record.ServiceCode)); command.Parameters.Add(new SqlParameter("@statusid", record.Status)); int result = ExecuteNonQueryProcedureWithReturn(command); bool ret = false; if (result == 0) { ret = true; } return(ret); }
private bool UpdateByMultiple(BillingRecord record) { SqlCommand command = new SqlCommand("UpdateBillingByMultiple", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@hcn", record.HealthCardNumber)); command.Parameters.Add(new SqlParameter("@date", record.AppointmentDate)); command.Parameters.Add(new SqlParameter("@code", record.ServiceCode)); command.Parameters.Add(new SqlParameter("@statusid", record.Status)); int result = ExecuteNonQueryProcedureWithReturn(command); bool ret = false; if (result == 0) { ret = true; } return(ret); }