예제 #1
0
파일: Driver.cs 프로젝트: eqk/waybill
        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);
        }
예제 #2
0
파일: Driver.cs 프로젝트: eqk/waybill
        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);
            }
        }