private static void InsertCar(Car car) { Dal.InsertAuto(car); InitCars(); Console.WriteLine("***Car inserting***"); Console.WriteLine("*********************"); }
public void AddCar(Inventory newCar) { Cars.Add(newCar); using (InventoryDal inventory = (new InventoryDal())) { inventory.InsertAuto(ModelTransformations.InventoryToCar(newCar)); } }
public void InsertCar(InventoryRecord car) { var d = new InventoryDal(); d.OpenConnection(ConnString); d.InsertAuto(car.Id, car.Color, car.Make, car.PetName); d.CloseConnection(); }
public void InsertCar(int id, string make, string color, string petName) { var d = new InventoryDal(); d.OpenConnection(ConnString); d.InsertAuto(id, color, make, petName); d.CloseConnection(); }
protected void addCarButton_Click(object sender, EventArgs e) { // Обновить таблицу Inventory и вызвать RefreshGrid() var dal = new InventoryDal(); dal.OpenConnection(ConnectionString); dal.InsertAuto(new NewCar() { CarId = int.Parse(carIdTextBox.Text), Color = carIdTextBox.Text, Make = makeTextBox.Text, PetName = petNameTextBox.Text }); dal.CloseConnection(); RefreshGrid(); }
public static void DalTest() { var dal = new InventoryDal(); var list = dal.GetAllInventory(); Console.WriteLine("***** All Cars ******"); Console.WriteLine("CarId\tMake\tColor\tPet Name"); foreach (var item in list) { Console.WriteLine($"{item.CarId}\t{item.Make}\t{item.Color}\t{item.PetName}"); } Console.WriteLine(); var car = dal.GetCar(list.OrderBy(x => x.Color).Select(x => x.CarId).First()); Console.WriteLine("***** First Car by Color ********"); Console.WriteLine("CarId\tMake\tColor\tPet Name"); Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}"); try { dal.DeleteCar(5); Console.WriteLine("Car deleted"); } catch (Exception ex) { Console.WriteLine($"An exception occured: {ex.Message}"); } dal.InsertAuto(new Car { Color = "Blue", Make = "Pilot", PetName = "TownMonster" }); list = dal.GetAllInventory(); var newCar = list.First(x => x.PetName == "TownMonster"); Console.WriteLine("***** New Car ********"); Console.WriteLine("CarId\tMake\tColor\tPet Name"); Console.WriteLine($"{newCar.CarId}\t{newCar.Make}\t{newCar.Color}\t{newCar.PetName}"); dal.DeleteCar(newCar.CarId); var petName = dal.LookUpPetName(car.CarId); Console.WriteLine($"Car pet name: {petName}"); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); }
private static void InsertNewCar(InventoryDal invDal) { int newCarID; string newCarColor, newCarMake, newCarPetName; Console.Write("Enter Car ID: "); newCarID = int.Parse(Console.ReadLine()); Console.Write("Enter Car Color: "); newCarColor = Console.ReadLine(); Console.Write("Enter Car Make: "); newCarMake = Console.ReadLine(); Console.Write("Enter Pet Name: "); newCarPetName = Console.ReadLine(); NewCar c = new NewCar { CarId = newCarID, Color = newCarColor, Make = newCarMake, PetName = newCarPetName }; invDal.InsertAuto(c); }
private static void InsertNewCar(InventoryDal inventory) { Console.Write("Enter Car Id: "); var newCarId = int.Parse(Console.ReadLine() ?? "0"); Console.Write("Enter Car Color: "); var newCarColor = Console.ReadLine(); Console.Write("Enter Car Make: "); var newCarMake = Console.ReadLine(); Console.Write("Enter Pet Name: "); var newCarPetName = Console.ReadLine(); var c = new NewCar { CarId = newCarId, Color = newCarColor, Make = newCarMake, PetName = newCarPetName }; inventory.InsertAuto(c); }