コード例 #1
0
        public static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter)
        {
            try
            {
                //add new row
                AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow();
                Console.WriteLine("Enter new color:");
                newRow.Color = (string)Console.ReadLine();
                Console.WriteLine("Enter new Make:");
                newRow.Make = (string)Console.ReadLine();
                Console.WriteLine("Enter new PetName:");
                newRow.PetName = (string)Console.ReadLine();
                table.AddInventoryRow(newRow);

                ////another way (Dont forget about position in constructor)
                //Console.WriteLine("Enter new color:");
                //string strColor = (string)Console.ReadLine();
                //Console.WriteLine("Enter new Make:");
                //string strMake = (string)Console.ReadLine();
                //Console.WriteLine("Enter new PetName:");
                //string strPetName = (string)Console.ReadLine();
                //table.AddInventoryRow(strMake, strColor, strPetName);

                adapter.Update(table);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void AddRecords(
            AutoLotDataSet.InventoryDataTable table,
            InventoryTableAdapter adapter)
        {
            try
            {
                // Get a new strongly typed row from the table.
                AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow();

                // Fill row with some sample data.
                newRow.Color = "Purple";
                newRow.Make  = "BMW";
                newRow.Name  = "Saku";

                // Insert the new row.
                table.AddInventoryRow(newRow);

                // Add one more row, using overloaded Add method.
                table.AddInventoryRow("Yugo", "Green", "Zippy");

                // Update database.
                adapter.Update(table);
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: orehovakatya/5sem
 private static void RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt)
 {
     AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarID(999);
     dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
     rowToDelete = tb.FindByCarID(888);
     dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: tijokjoy/exercises
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n");

            AutoLotDataSet.InventoryDataTable table =
                new AutoLotDataSet.InventoryDataTable();

            InventoryTableAdapter dAdapt = new InventoryTableAdapter();

            dAdapt.Fill(table);

            // Add rows, update, and reprint.
            AddRecords(table, dAdapt);
            table.Clear();
            dAdapt.Fill(table);
            PrintInventory(table);
            Console.ReadLine();

            RemoveRecords(table, dAdapt);
            dAdapt.Fill(table);
            PrintInventory(table);
            Console.ReadLine();

            CallStoredProc();
            Console.ReadLine();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            WriteLine("***** Fun with Strongly Typed DataSets *****\n");

            // Caller creates the DataSet object.
            var table = new AutoLotDataSet.InventoryDataTable();

            // Inform adapter of the Select command text and connection.
            var adapter = new InventoryTableAdapter();

            // Fill our DataSet with a new table, named Inventory.
            adapter.Fill(table);
            PrintInventory(table);
            WriteLine();

            // Add rows, update and reprint.
            AddRecords(table, adapter);
            table.Clear();
            adapter.Fill(table);
            PrintInventory(table);
            WriteLine();

            // Remove rows we just made and reprint.
            RemoveRecords(table, adapter);
            table.Clear();
            adapter.Fill(table);
            PrintInventory(table);
            WriteLine();

            CallStoredProc();
            ReadLine();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: simple555a/DotNetAppDev
 private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) // Удаление записей
 {
     AutoLotDataSet.InventoryRow toDeleteRow = table.FindByCarID(999);
     adapter.Delete(toDeleteRow.CarID, toDeleteRow.Make, toDeleteRow.Color, toDeleteRow.PetName);
     toDeleteRow = table.FindByCarID(888);
     adapter.Delete(toDeleteRow.CarID, toDeleteRow.Make, toDeleteRow.Color, toDeleteRow.PetName);
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: usedflax/flaxbox
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n");

            // Caller creates the DataSet object.
            AutoLotDataSet.InventoryDataTable table =
                new AutoLotDataSet.InventoryDataTable();

            // Inform adapter of the Select command text and connection.
            InventoryTableAdapter dAdapt =
               new InventoryTableAdapter();

            // Fill our DataSet with a new table, named Inventory.
            dAdapt.Fill(table);
            PrintInventory(table);
            Console.WriteLine();

            // Add rows, update and reprint.
            AddRecords(table, dAdapt);
            table.Clear();
            dAdapt.Fill(table);
            PrintInventory(table);
            Console.WriteLine();

            // Remove rows we just made and reprint.
            RemoveRecords(table, dAdapt);
            table.Clear();
            dAdapt.Fill(table);
            PrintInventory(table);
            Console.WriteLine();

            CallStoredProc();
            Console.ReadLine();
        }
コード例 #8
0
        //  用生成的代码插入数据
        public static void AddRecords(AutoLotDataSet.InventoryDataTable tb,
                                      InventoryTableAdapter dAdapt)
        {
            try
            {
                //  从表中获取新的强类型的行
                AutoLotDataSet.InventoryRow newRow = tb.NewInventoryRow();

                //  使用一些示例数据填充该行
                newRow.CarID   = 999;
                newRow.Color   = "Purple";
                newRow.Make    = "BMW";
                newRow.PetName = "Saku";

                //  插入新行
                tb.AddInventoryRow(newRow);

                //  使用重载的Add方法添加另一个行
                tb.AddInventoryRow(888, "Yugo", "Green", "Zippy");

                //  更新数据库
                dAdapt.Update(tb);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: maziesmith/.NetCSharp
        private static void PrintInventory(AutoLotDataSet.InventoryDataTable table)
        {
            //Print out the column names

            foreach (var tableColumn in table.Columns)
            {
                Write(tableColumn + "\t");
            }
            WriteLine("\n-------------------------------");

            //print the datatable
            foreach (DataRow item in table.Rows)
            {
                Write($"{item["Carid"].ToString()}\t");
                Write($"{item["Make"].ToString()}\t");
                Write($"{item["Color"].ToString()}\t");
                Write($"{item["PetName"].ToString()}\t");
                WriteLine();
            }
            //use either or
            //for (int curRow = 0; curRow < table.Rows.Count; curRow++)
            //{
            //    for (int curCol = 0; curCol < table.Columns.Count; curCol++)
            //    {
            //        Write($"{table.Rows[curRow][curCol] }\t");
            //    }
            //    WriteLine();
            //}
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n");

            AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable();

            InventoryTableAdapter dAdapt = new InventoryTableAdapter();

            dAdapt.Fill(table);
            PrintInventory(table);

            // Добавить строки, обновить и вывести повторно
            AddRecords(table, dAdapt);
            table.Clear();
            dAdapt.Fill(table);
            PrintInventory(table);

            // Удалить строки, обновить и вывести повторно
            RemoveRecords(table, dAdapt);
            table.Clear();
            dAdapt.Fill(table);
            PrintInventory(table);

            CallStoredProc();
            Console.ReadLine();
        }
コード例 #11
0
        private static void AddRecords(AutoLotDataSet.InventoryDataTable dt, InventoryTableAdapter dAdapt)
        {
            try
            {
                // Получить из таблицы новую строго типизированную строку
                AutoLotDataSet.InventoryRow newRow = dt.NewInventoryRow();

                // Заполнить строку данными
                newRow.CarID   = 999;
                newRow.Color   = "Purple";
                newRow.Make    = "BMW";
                newRow.PetName = "Saku";

                // Вставить новую строку
                dt.AddInventoryRow(newRow);

                // Добавить еще одну строку, используя перегруженный метод добавления
                dt.AddInventoryRow(777, "Yugo", "Green", "Zippy");

                // Обновить базу данных
                dAdapt.Update(dt);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: simple555a/DotNetAppDev
 private static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter) // Добавление записей
 {
     AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow();                                      // Получение из таблицы новой строго типизированной строки
     newRow.CarID   = 999;                                                                              // Заполнение строки данными
     newRow.Color   = "Purple";
     newRow.Make    = "BMW";
     newRow.PetName = "Saku";
     table.AddInventoryRow(newRow); // Вставка новой строки
     table.AddInventoryRow(888, "Yugo", "Green", "Zippy");
     adapter.Update(table);         // Обновление базы данных
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: simple555a/DotNetAppDev
        static void Main(string[] args)
        {
            AutoLotDataSet.InventoryDataTable table   = new AutoLotDataSet.InventoryDataTable();
            InventoryTableAdapter             adapter = new InventoryTableAdapter();

            AddRecords(table, adapter);
            table.Clear();
            adapter.Fill(table);
            PrintInventory(table);
            Console.ReadLine();
        }
コード例 #14
0
        private static void RemoveRow(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter, int n)
        {
            var rows = table.Rows;

            if ((n = ((AutoLotDataSet.InventoryRow)rows[rows.Count - n]).CarId) > 12)
            {
                WriteLine($"- remove row with CarId {n}");
                AutoLotDataSet.InventoryRow row = table.FindByCarId(n);
                adapter.Delete(row.CarId, row.Make, row.Color, row.PetName);
            }
        }
コード例 #15
0
        private static void AddRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter)
        {
            AutoLotDataSet.InventoryRow newRow = table.NewInventoryRow();
            newRow.Color   = "Purple";
            newRow.Make    = "BMW";
            newRow.PetName = "Saku";
            table.AddInventoryRow(newRow);

            table.AddInventoryRow("Yugo", "Green", "Zippy");

            adapter.Update(table);
        }
コード例 #16
0
        private static void ShowTable()
        {
            ForegroundColor = ConsoleColor.Yellow;
            WriteLine("=> Diaplay Inventory Data Using AutoLogDAL library version 3");

            var table   = new AutoLotDataSet.InventoryDataTable();
            var adapter = new InventoryTableAdapter();

            adapter.Fill(table);

            PrintInventory(table);
        }
コード例 #17
0
 private static void RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt)
 {
     try {
         AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarID(991);
         dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
         rowToDelete = tb.FindByCarID(887);
         dAdapt.Delete(rowToDelete.CarID, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: maziesmith/.NetCSharp
 public static void RemoveRecord(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter)
 {
     try
     {
         AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(1);
         adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
         rowToDelete = table.FindByCarId(2);
         adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
     }
     catch (Exception ex)
     {
         WriteLine(ex.Message);
     }
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: NuCode1497/ADOTutorials
 private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter)
 {
     try
     {
         Write("Enter ID of car to delete: ");
         string carID = ReadLine() ?? "0";
         AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(int.Parse(carID));
         adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
     }
     catch (Exception ex)
     {
         WriteLine(ex.Message);
     }
 }
コード例 #20
0
        private static void AddRows()
        {
            ForegroundColor = ConsoleColor.Cyan;
            WriteLine("=> Add Two Rows Using AutoLogDAL library version 3");

            var table   = new AutoLotDataSet.InventoryDataTable();
            var adapter = new InventoryTableAdapter();

            adapter.Fill(table);

            AddRecords(table, adapter);
            table.Clear();
            adapter.Fill(table);
            PrintInventory(table);
        }
コード例 #21
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Strongly Typed DataSets *****\n");

            // Caller creates the DataSet object.
            var table = new AutoLotDataSet.InventoryDataTable();

            // Inform adapter of the Select command text and connection.
            var adapter = new InventoryTableAdapter();

            // Fill our DataSet with a new table, named Inventory.
            adapter.Fill(table);

            PrintInventory(table); Console.ReadLine();
        }
コード例 #22
0
        static void Main(string[] args)
        {
            Console.WriteLine("**********Work with Strongly Typed DataSet***********");

            var table   = new AutoLotDataSet.InventoryDataTable();
            var adapter = new InventoryTableAdapter();

            //AddRecords(table, adapter);

            adapter.Fill(table);
            RemoveRecords(table, adapter);
            adapter.Fill(table);
            PrintInventory(table);
            Console.ReadLine();
        }
コード例 #23
0
        private static void DelRows()
        {
            ForegroundColor = ConsoleColor.DarkYellow;
            WriteLine("=> Delete Records Using AutoLogDAL library");

            var table   = new AutoLotDataSet.InventoryDataTable();
            var adapter = new InventoryTableAdapter();

            adapter.Fill(table);

            DelRecords(table, adapter);
            table.Clear();
            adapter.Fill(table);
            PrintInventory(table);
        }
コード例 #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** LINQ over DataSet *****\n");

            //  获取包含AutoLot数据库中当期Inventory的强类型DataTable
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            PrintAllCarIDs(data);
            ShowRedCars(data);
            BuildDataTableFromQuery(data);
            Console.ReadLine();
        }
コード例 #25
0
 private static void RemoveRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter adapter)
 {
     try
     {
         Console.WriteLine("Enter carId what you want delete: ");
         int carIdToDelete = int.Parse(Console.ReadLine().ToString());
         AutoLotDataSet.InventoryRow rowToDelete = tb.FindByCarId(carIdToDelete);
         adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.PetName);
         adapter.Update(tb);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        private static void RemoveRecords(AutoLotDataSet.InventoryDataTable table, InventoryTableAdapter adapter)
        {
            try
            {
                AutoLotDataSet.InventoryRow rowToDelete = table.FindByCarId(table.Last().CarId);

                adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.Name);
                rowToDelete = table.FindByCarId(table.Last().CarId - 1);
                adapter.Delete(rowToDelete.CarId, rowToDelete.Make, rowToDelete.Color, rowToDelete.Name);
                adapter.Update(table);
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message);
            }
        }
コード例 #27
0
        static void Main(string[] args)
        {
            WriteLine("**** LINQ over DataSet ****\n");

            //Get a strongly typed DataTable containing the current Inventory
            // of the AutoLot Database
            AutoLotDataSet        dal          = new AutoLotDataSet();
            InventoryTableAdapter tableAdapter = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = tableAdapter.GetData();

            //Invoke the methods that follow here!
            PrintAllCarIDs(data);
            ShowRedCars(data);
            ReadLine();
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: simple555a/DotNetAppDev
        private static void BuildDataTableFromQuery(AutoLotDataSet.InventoryDataTable data)
        {
            var cars = from car in data.AsEnumerable()
                       where car.Field <int>("CarId") > 5
                       select car;
            DataTable newTable = cars.CopyToDataTable(); // Использование этого результирующего набора для создания нового DataTable

            for (int currentRow = 0; currentRow < newTable.Rows.Count; currentRow++)
            {
                for (int currentColumn = 0; currentColumn < newTable.Columns.Count; currentColumn++)
                {
                    Console.Write(newTable.Rows[currentRow][currentColumn].ToString().Trim() + "\t");
                }
            }
            Console.WriteLine();
        }
コード例 #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("****** LINQ over DataSet ******\n");

            // Получить строго типизированный объект DataTable, содержащий
            // текущие данные таблицы Inventory из базы данных AutoLot
            AutoLotDataSet        dal = new AutoLotDataSet();
            InventoryTableAdapter da  = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = da.GetData();

            PrintAllCarIDs(data);
            ShowBlackCars(data);
            BuildDataTableFromQuery(data);
            Console.ReadLine();
        }
コード例 #30
0
 static void PrintInventory(AutoLotDataSet.InventoryDataTable dt)
 {
     for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
     {
         Console.Write(dt.Columns[curCol].ColumnName + "\t");
     }
     Console.WriteLine("\n-----------------------------");
     for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
     {
         for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
         {
             Console.Write(dt.Rows[curRow][curCol].ToString() + "\t");
         }
         Console.WriteLine();
     }
 }
コード例 #31
0
        private static void UseEnumerable()
        {
            ForegroundColor = ConsoleColor.Yellow;
            WriteLine("=> Linq-Complatible DataTable");

            AutoLotDataSet        dal     = new AutoLotDataSet();
            InventoryTableAdapter adapter = new InventoryTableAdapter();

            AutoLotDataSet.InventoryDataTable data = adapter.GetData();

            PrintAllCarIDs(data);
            ShowBalckCars(data);
            ShowBlackSafety(data);

            BuildDataTableFromQuery(data);
        }
コード例 #32
0
        static void Main(string[] args) {
            AutoLotDataSet.InventoryDataTable table = new AutoLotDataSet.InventoryDataTable();
            InventoryTableAdapter dAdapt = new InventoryTableAdapter();

            AddRecords(table, dAdapt);
            table.Clear();
            
            dAdapt.Fill(table);


            RemoveRecords(table, dAdapt);

            PrintInventory(table);
            CallStoreProc();
            Console.ReadLine();
        }