예제 #1
0
        private static void InsertNewCar(InventoryDAL invDAL)
        {
            // First get the user data.
            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();

            // Now pass to data access library.
            // invDAL.InsertAuto(newCarID, newCarColor, newCarMake, newCarPetName);
            NewCar c = new NewCar
            {
                CarID   = newCarID,
                Color   = newCarColor,
                Make    = newCarMake,
                PetName = newCarPetName
            };

            invDAL.InsertAuto(c);
        }
예제 #2
0
        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 car = new NewCar
            {
                CarID   = newCarID,
                Color   = newCarColor,
                Make    = newCarMake,
                PetName = newCarPetName
            };

            invDAL.InsertAuto(car);
        }
예제 #3
0
        private static void InsertNewCar(InventoryDAL invDal)
        {
            Write("Enter Car ID: ");
            var newCarID = int.Parse(ReadLine() ?? "0");

            Write("Enter Car Color: ");
            var newCarColor = ReadLine();

            Write("Enter Car Make: ");
            var newCarMake = ReadLine();

            Write("Enter Pet Name: ");
            var newCarPetName = ReadLine();

            //the insert method takes on a car class
            var c = new NewCar
            {
                CarId   = newCarID,
                Color   = newCarColor,
                Make    = newCarMake,
                PetName = newCarPetName
            };

            //Now pass to dat access library
            invDal.InsertAuto(c);
            WriteLine("Car has been inserted");
        }
예제 #4
0
        private static void InsertNewCar(InventoryDAL invDAL)
        {
            Write("Enter Car ID: ");
            var newCarId = int.Parse(ReadLine() ?? "0");

            Write("Enter Car Color: ");
            var newCarColor = ReadLine();

            Write("Enter Car Make: ");
            var newCarMake = ReadLine();

            Write("Enter Pet Name: ");
            var newCarPetName = ReadLine();

            // Now pass to data access library.
            // invDAL.InsertAuto(newCarId, newCarColor, newCarMake, newCarPetName);
            var c = new NewCar
            {
                CarId   = newCarId,
                Color   = newCarColor,
                Make    = newCarMake,
                PetName = newCarPetName
            };

            invDAL.InsertAuto(c);
        }
예제 #5
0
        static void Main(string[] args)
        {
            InventoryDAL dal  = new InventoryDAL();
            var          list = dal.GetAllInventory();

            // list all cars in the inventory
            Console.WriteLine((new string('*', 15)) + " All Cars " + (new string('*', 15)));
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            foreach (var itm in list)
            {
                Console.WriteLine($"{itm.CarId}\t{itm.Make}\t{itm.Color}\t{itm.PetName}");
            }
            Console.WriteLine();

            // list the first car in order of color
            var car = dal.GetCar(list.OrderBy(x => x.Color).Select(x => x.CarId).First());

            Console.WriteLine((new string('*', 15)) + " First Car By Color " + (new string('*', 15)));
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");
            Console.WriteLine();

            // try/catch logic to delete a car in inventory
            try
            {
                dal.DeleteCar(5);
                Console.WriteLine("Car deleted");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An exception occurred: {ex.Message}");
            }
            Console.WriteLine();

            // insert a new car object into the inventory
            dal.InsertAuto(new Car {
                Color = "Blue", Make = "Pilot", PetName = "TowMonster"
            });
            list = dal.GetAllInventory();
            var newCar = list.First(x => x.PetName == "TowMonster");

            Console.WriteLine((new string('*', 15)) + " New Car " + (new string('*', 15)));
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{newCar.CarId}\t{newCar.Make}\t{newCar.Color}\t{newCar.PetName}");
            dal.DeleteCar(newCar.CarId);
            Console.WriteLine();

            // list the inventory again
            Console.WriteLine((new string('*', 15)) + " All Cars After an Insertion & a Deletion " + (new string('*', 15)));
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            foreach (var itm in list)
            {
                Console.WriteLine($"{itm.CarId}\t{itm.Make}\t{itm.Color}\t{itm.PetName}");
            }
            Console.WriteLine();

            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }
예제 #6
0
        private void btnInsertAuto_Click(object sender, EventArgs e)
        {
            string make    = txtInsertMake.Text.Trim();
            string color   = txtInsertColor.Text.Trim();
            string petName = txtInsertPetName.Text.Trim();

            inventoryDAL.InsertAuto(make, color, petName);
        }
예제 #7
0
    public void InsertCar(int id, string make, string color, string petname)
    {
        InventoryDAL d = new InventoryDAL();

        d.OpenConnection(ConnString);
        d.InsertAuto(id, color, make, petname);
        d.CloseConnection();
    }
예제 #8
0
    public void InsertCar(InventoryRecord car)
    {
        InventoryDAL d = new InventoryDAL();

        d.OpenConnection(ConnString);
        d.InsertAuto(car.ID, car.Color, car.Make, car.PetName);
        d.CloseConnection();
    }
예제 #9
0
        static void Main(string[] args)
        {
            InventoryDAL 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.GetCarById(list.OrderBy(x => x.Color)
                                     .Select(x => x.CarId)
                                     .First());

            Console.WriteLine("**** First by color*****");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");

            try
            {
                dal.DeleteeAuto(dal.GetCarById(5));
                Console.WriteLine("Car deleted!");
            }catch (Exception ex)
            {
                Console.WriteLine($"An exception occured: {ex.Message}");
            }

            dal.InsertAuto(new Car {
                Make = "Pilot", Color = "Blue", PetName = "TowMonster"
            });

            list = dal.GetAllInventory();

            var newCar = list.First(x => x.PetName.Trim(' ') == "TowMonster");

            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.DeleteeAuto(newCar);

            var petName = dal.GetCarById(newCar.CarId);

            Console.WriteLine("**** New car *****");
            Console.WriteLine($"Car pet name is {petName}!");
            Console.WriteLine("Press space for continue...");

            MoveCustomer(dal);
            DoBulkCopy();
            Console.ReadLine();
        }
예제 #10
0
        public static void AddNewCar(InventoryDAL dal)
        {
            Car newCar = new Car()
            {
                PetName = "Camaro",
                Make    = "Ford",
                Color   = "Yellow"
            };

            dal.InsertAuto(newCar);
        }
    protected void btnAddCar_Click(object sender, EventArgs e)
    {
        // Update the Inventory table
        // and call RefreshGrid().
        InventoryDAL dal = new InventoryDAL();

        dal.OpenConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True");
        dal.InsertAuto(int.Parse(txtCarID.Text), txtCarColor.Text,
                       txtCarMake.Text, txtCarPetName.Text);
        dal.CloseConnection();
        RefreshGrid();
    }
예제 #12
0
        static void Main(string[] args)
        {
            InventoryDAL dal  = new InventoryDAL();
            var          list = dal.GetAllInventory();

            WriteLine("***** Get All Inventory *****");
            DisplayCars(list);
            WriteLine();
            Car car = dal.GetCar(list.OrderBy(x => x.Color).Select(x => x.CarId).First()); // ..OrderBy is a Linq thing

            WriteLine("*** First Car By Color***");
            WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");

            try
            {
                dal.DeleteCar(5);
                WriteLine("Car 5 deleted.");
            }
            catch (Exception ex)
            {
                WriteLine($"An exception occurred: {ex.Message}");
            }

            dal.InsertAuto(new Car {
                Color = "Blue", Make = "Pilot", PetName = "TowMonster"
            });
            list = dal.GetAllInventory();
            Car newCar = list.First(x => x.PetName == "TowMonster");

            WriteLine("*** New Car ***");
            WriteLine("CarId\tMake\tColor\tPetName");
            WriteLine($"{newCar.CarId}\t{newCar.Make}\t{newCar.Color}\t{newCar.PetName}");
            dal.DeleteCar(newCar.CarId);
            string petName = dal.LookupPetName(car.CarId);

            WriteLine("*** New Car ***");
            WriteLine($"Car pet name: {petName}");
            WriteLine();

            WriteLine("\n***** All Cars Currently in DB *****");
            list = dal.GetAllInventory();
            DisplayCars(list);

            // WriteLine("\n*** Move Customer Example Using Transactions ***");
            // MoveCustomer();

            // DoBulkCopy example
            DoBulkCopy();

            WriteLine("\n\nPress <Enter> to Continue. . .");
            ReadLine();
        }
예제 #13
0
        static void Main(string[] args)
        {
            InventoryDAL dal  = new InventoryDAL();
            var          list = dal.GetAllInventory();

            WriteLine(" ***************** All Cars ***************** ");
            WriteLine("CarId\tMake\tColor\tPet Name");

            foreach (var item in list)
            {
                WriteLine($"{item.CarId}\t{item.Make}\t{item.Color}\t{item.PetName}\n");
            }
            var car = dal.GetCar(list.OrderBy(x => x.Color).Select(x => x.CarId).First());

            WriteLine(" ***************** First Car By Color *************** ");
            WriteLine("CarId\tMake\tColor\tPet Name");
            WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");

            try
            {
                dal.DeleteCar(5);
                WriteLine("Car Deleted.");
            }

            catch (Exception ex)
            {
                WriteLine($"An exception occured: {ex.Message}");
            }

            dal.InsertAuto(new Car {
                Color   = "Blue", Make = "Pilot",
                PetName = "TowMonster"
            });
            list = dal.GetAllInventory();

            var newCar = list.First(x => x.PetName == "TowMonster");

            WriteLine(" ***************** New Car ********************* ");
            WriteLine("CarId\tMake\tColor\tPet Name");
            WriteLine($"{newCar.CarId}\t{newCar.Make}\t{newCar.Color}\t{newCar.PetName}");
            dal.DeleteCar(newCar.CarId);

            /*
             * following lines is for store procedure ignore
             * var petName = dal.LookUpPetName(car.CarId);
             * WriteLine(" ***************** New Car ******************** ");
             * WriteLine($"Car pet name: {petName}");
             */
            Write("Press enter to continue...");
            ReadLine();
        }
예제 #14
0
        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();
            invDAL.InsertAuto(newCarID, newCarColor, newCarMake, newCarPetName);
        }
예제 #15
0
        private static void InsertNewCar()
        {
            InventoryDAL Dal = new InventoryDAL();

            Console.WriteLine("Введите марку");
            string make = Console.ReadLine();

            Console.WriteLine("Введиет цвет");
            string color = Console.ReadLine();

            Console.WriteLine("Псевдоним");
            string petName = Console.ReadLine();

            Dal.InsertAuto(make, color, petName);
        }
예제 #16
0
        static void Main(string[] args)
        {
            InventoryDAL dal  = new InventoryDAL();
            var          list = dal.GetAllInventory();

            Console.WriteLine(" ********** All Cars **********1");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            foreach (var itm in list)
            {
                Console.WriteLine($"{itm.CarId}\t{itm.Make}\t{itm.Color}" +
                                  $"\t{itm.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 occurred: {ex.Message}");
            }
            dal.InsertAuto(new Car {
                Color = "Blue", Make = "Pilot", PetName = "TowMonster"
            });
            list = dal.GetAllInventory();
            var newCar = list.First(x => x.PetName == "TowMonster");

            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.Id);
            var petName = DllNotFoundException.LookUpPetName(car.CarId);

            Console.WriteLine(" ********** New Car ********** ");
            Console.WriteLine($"Car pet name; {petName}");
            Console.Write("Press enter to continue...");
            Console.ReadLine();
        }
예제 #17
0
        private static void InsertNewCar(InventoryDAL invDAL)
        {
            Write("Enter Car ID: ");
            var newCarId = int.Parse(ReadLine() ?? "0");

            Write("Enter Car Color: ");
            var newCarColor = ReadLine();

            Write("Enter Car Make: ");
            var newCarMake = ReadLine();

            Write("Enter Car Pet Name: ");
            var newCarPetName = ReadLine();

            invDAL.InsertAuto(newCarId, newCarColor, newCarMake, newCarPetName);
        }
예제 #18
0
        public static void AutoLotClient()
        {
            var dal  = new InventoryDAL();
            var list = dal.GetAllInventory();

            Console.WriteLine("***** Show All Cars *****\n");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            foreach (var car in list)
            {
                Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");
            }
            Console.WriteLine();

            Console.WriteLine("***** First Car By Color *****\n");
            var firstCarByColor = dal.GetCar(list.OrderBy(c => c.Color).Select(c => c.CarId).First());

            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{firstCarByColor.CarId}\t{firstCarByColor.Make}\t" +
                              $"{firstCarByColor.Color}\t{firstCarByColor.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 = "TowMonster"
            });
            list = dal.GetAllInventory();
            var newCar = list.First(c => c.PetName == "TowMonster");

            Console.WriteLine("***** New Car *****\n");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{newCar.CarId}\t{newCar.Make}\t" +
                              $"{newCar.Color}\t{newCar.PetName}");

            var petName = dal.LookUpPetName(firstCarByColor.CarId);

            Console.WriteLine($"Car pet name (using SP): {petName}");
        }
예제 #19
0
        private static void InsertNewCar(InventoryDAL invDAL)
        {
            // Получение данных от пользователя.
            int    newCarlD;
            string newCarColor, newCarMake, newCarPetName;

            Console.Write("Введите ID автомобиля: ");
            newCarlD = int.Parse(Console.ReadLine());
            Console.Write("Введите цвет автомобиля: ");
            newCarColor = Console.ReadLine();
            Console.Write("Введите модели автомобиля: ");
            newCarMake = Console.ReadLine();
            Console.Write("Введите дружественного имени: ");
            newCarPetName = Console.ReadLine();

            // Передача информации в библиотеку доступа к данным.
            invDAL.InsertAuto(newCarlD, newCarColor, newCarMake, newCarPetName);
        }
예제 #20
0
        private static void InsertNewCar(InventoryDAL dal)
        {
            Write("Enter Car ID: ");
            var newCarId = int.Parse(ReadLine() ?? "0");

            Write("Enter Car Color: ");
            var newColor = ReadLine();

            Write("Enter Car Make: ");
            var newMake = ReadLine();

            Write("Enter Pet Name: ");
            var newPetName = ReadLine();
            var c          = new NewCar {
                CarId = newCarId, Color = newColor, Make = newMake, PetName = newPetName
            };

            dal.InsertAuto(c);
        }
예제 #21
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="dal"></param>
        static void InsertCar(InventoryDAL dal)
        {
            //获取用户数据
            int    newCarID;
            string newCarColor, newCarMake, newCarPetName;

            Console.WriteLine("Enter car ID:");
            newCarID = int.Parse(Console.ReadLine());

            Console.WriteLine("输入Color:");
            newCarColor = Console.ReadLine();

            Console.WriteLine("输入Car Make:");
            newCarMake = Console.ReadLine();

            Console.WriteLine("输入Pet Name:");
            newCarPetName = Console.ReadLine();

            dal.InsertAuto(newCarID, newCarMake, newCarColor, newCarPetName);
        }
예제 #22
0
        private static void InsertNewCar(InventoryDAL inventoryDal)
        {
            Write("Enter Car Color: ");
            var newCarColor = ReadLine();

            Write("Enter Car Make: ");
            var newCarMake = ReadLine();

            Write("Enter Pet Name: ");
            var newCarPetName = ReadLine();

            Console.WriteLine(newCarPetName);

            // Now pass to data access library.
            inventoryDal.InsertAuto(newCarColor, newCarMake, newCarPetName);

            //var c = new NewCar
            //{
            //    Color = newCarColor,
            //    Make = newCarMake,
            //    PetName = newCarPetN
            //};
            //inventoryDal.InsertAuto(c);
        }