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);
            }
        }
Пример #2
0
 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);
 }
Пример #3
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);
            }
        }
Пример #4
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);
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
 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);
 }
Пример #7
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);
            }
        }
Пример #8
0
 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);         // Обновление базы данных
 }
Пример #9
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);
        }
Пример #10
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);
     }
 }
Пример #11
0
 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);
     }
 }
Пример #12
0
 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);
     }
 }
Пример #13
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);
            }
        }
Пример #15
0
 public static void AddRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt)
 {
     try
     {
         AutoLotDataSet.InventoryRow newRow = tb.NewInventoryRow();
         //
         newRow.CarID   = 991;
         newRow.Color   = "Purple";
         newRow.Make    = "BMW";
         newRow.PetName = "Saku";
         //
         tb.AddInventoryRow(newRow);
         tb.AddInventoryRow(887, "Yugo", "Green", "Zippy");
         dAdapt.Update(tb);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #16
0
        public static void AddRecords(AutoLotDataSet.InventoryDataTable tb, InventoryTableAdapter dAdapt)
        {
            // Get a new strongly typed row from the table.
            AutoLotDataSet.InventoryRow newRow = tb.NewInventoryRow();

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

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

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

            // Update database.
            dAdapt.Update(tb);
        }