static void Main() { //ClientClass client = ClientService.AddNewClient(new ClientClass(487, 0, "Danik", "+1234567")); Session.InitializeCars(); ClientService.InitializeClients(); RentService.InitializeRents(); TransactionService.InitializeTransactions(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); List <CarClass> cars = AutoParkService.AutoPark; /*foreach (var i in cars) * { * Console.WriteLine($"bodyworkSN = {i.Bodywork.SerialNumber}, engineSN = {i.Engine.SerialNumber}" + * $", kilometrage = {i.Kilometrage}, cost = {i.Cost}" + * $", carStatus = {i.CarStatus}"); * }*/ Console.WriteLine(SQLEngines.GetInstance().Search("24887")); Console.WriteLine(SQLBodyworks.GetInstance().Search("11414")); Console.WriteLine(SQLRents.GetInstance().Search("1")); //Console.WriteLine(SQLCars.GetInstance().Search("5")); //Application.Run(new WorkForm(client)); //Console.WriteLine(SQLClients.GetInstance().Search("Danik")); Application.Run(new LoginForm()); }
public IEnumerable <CarClass> GetList() { string query = "SELECT * FROM cars"; MySqlDataReader reader = GetReader(query); while (reader.Read()) { int carId = int.Parse(reader[0].ToString()); BodyworkClass bodywork = SQLBodyworks.GetInstance().Search(reader[1].ToString()); EngineClass engine = SQLEngines.GetInstance().Search(reader[2].ToString()); ClientClass client = ClientService.SearchClientById(int.Parse(reader[3].ToString())); int kilometrage = int.Parse(reader[4].ToString()); int cost = int.Parse(reader[5].ToString()); int carStatus = int.Parse(reader[6].ToString()); yield return(new CarClass(carId, bodywork, engine, client, kilometrage, cost, carStatus)); } reader.Close(); }
public CarClass Search(string carId) { string query = "SELECT * FROM cars WHERE carId='" + carId + "'"; CarClass car = null; MySqlDataReader reader = GetReader(query); try { reader.Read(); BodyworkClass bodywork = SQLBodyworks.GetInstance().Search(reader[1].ToString()); EngineClass engine = SQLEngines.GetInstance().Search(reader[2].ToString()); ClientClass client = ClientService.SearchClientById(int.Parse(reader[3].ToString())); int kilometrage = int.Parse(reader[4].ToString()); int cost = int.Parse(reader[5].ToString()); int carStatus = int.Parse(reader[6].ToString()); car = new CarClass(int.Parse(carId), bodywork, engine, client, kilometrage, cost, carStatus); } catch (Exception e) { Console.WriteLine(e.Message); } finally { reader.Close(); } return(car); }