Exemplo n.º 1
0
        public static Customer getCustomerFromVehicle(string vrm)
        {
            Customer customer = new Customer();

            using (MySqlConnection con = new MySqlConnection(connection))
            {
                string query = "SELECT customerID FROM CustomersVehicles WHERE vrm = @vrm";
                using (MySqlCommand cmd = new MySqlCommand(query))
                {
                    cmd.Parameters.AddWithValue("@vrm", vrm);
                    cmd.Connection = con;
                    con.Open();
                    using (MySqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            customer = CustomerProvider.getCustomerFromID(sdr["customerID"].ToString());
                            break;
                        }
                    }

                    con.Close();
                }
            }

            return(customer);
        }
Exemplo n.º 2
0
        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);
        }