public static Vehicle getVehicleFromJob(string jobID) { Vehicle vehicle = new Vehicle(); using (MySqlConnection con = new MySqlConnection(connection)) { string query = "SELECT vrm FROM JobVehicle WHERE jobID = '" + jobID + "'"; using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Connection = con; con.Open(); using (MySqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { vehicle = VehicleProvider.getVehicleFromVRM(sdr["vrm"].ToString()); break; } } con.Close(); } } return(vehicle); }
public static List <Vehicle> getCustomerVehicles(string customerID) { List <Vehicle> vehicles = new List <Vehicle>(); using (MySqlConnection con = new MySqlConnection(connection)) { string query = "SELECT vrm FROM CustomersVehicles WHERE customerID = '" + customerID + "'"; using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Connection = con; con.Open(); using (MySqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { vehicles.Add(VehicleProvider.getVehicleFromVRM(sdr["vrm"].ToString())); } } con.Close(); } } return(vehicles); }
public static Job getJobDetails(string jobID) { Job job = new Job(); using (MySqlConnection con = new MySqlConnection(connection)) { string query = "SELECT * FROM Jobs WHERE jobID = '" + jobID + "'"; using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Connection = con; con.Open(); using (MySqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { job = new Job(); job.jobID = (sdr["jobID"]).ToString(); job.start = DateTime.Parse(sdr["startDate"].ToString()); try { job.end = DateTime.Parse(sdr["endDate"].ToString()); } catch { job.end = null; } try { job.paid = DateTime.Parse(sdr["paidDate"].ToString()); } catch { job.paid = null; } job.bay = Int32.Parse(sdr["bay"].ToString()); job.status = sdr["status"].ToString(); job.type = sdr["type"].ToString(); job.customer = VehicleProvider.getCustomerFromVehicle(getVehicleFromJob(jobID).vrm); job.discount = CustomerProvider.getDiscounts(VehicleProvider.getCustomerFromVehicle(getVehicleFromJob(jobID).vrm).customerID); job.vehicle = getVehicleFromJob(jobID); job.notes = getJobNotes(jobID); job.parts = getPartsForJob(jobID); job.labour = getLabour(jobID); job.mechanic = getAssigedMechanic(jobID); } } con.Close(); } } return(job); }