Esempio n. 1
0
        public static void updateOrCreate(Driver driver)
        {
            int tab_num = driver.tab_num;

            StateDatabaseDataSetTableAdapters.DriversTableAdapter adapter = new StateDatabaseDataSetTableAdapters.DriversTableAdapter();

            StateDatabaseDataSet.DriversDataTable drivers = new StateDatabaseDataSet.DriversDataTable();
            adapter.Fill(drivers);
            StateDatabaseDataSet.DriversRow driverRow = drivers.Where(x => x.tab_num == tab_num).FirstOrDefault();
            if (driverRow == null)
            {
                drivers.AddDriversRow(driver.name, driver.med, driver.cert_num, driver.cert_for, driver.tab_num);
            }
            else
            {
                driverRow.name     = driver.name;
                driverRow.med      = driver.med;
                driverRow.cert_num = driver.cert_num;
                driverRow.cert_for = driver.cert_for;
            }
            adapter.Update(drivers);
        }
Esempio n. 2
0
        public static Driver findByTabNum(string s)
        {
            int tab_num;

            if (int.TryParse(s, out tab_num))
            {
                StateDatabaseDataSetTableAdapters.DriversTableAdapter adapter = new StateDatabaseDataSetTableAdapters.DriversTableAdapter();

                StateDatabaseDataSet.DriversDataTable drivers = new StateDatabaseDataSet.DriversDataTable();
                adapter.Fill(drivers);

                StateDatabaseDataSet.DriversRow driver = drivers.Where(x => x.tab_num == tab_num).FirstOrDefault();

                if (driver == null)
                {
                    return(null);
                }
                return(new Driver(driver.Id, driver.name, driver.med, driver.cert_for, driver.cert_num));
            }
            else
            {
                return(null);
            }
        }