public MainViewModel() { PhoneNumber = Properties.Settings.Default.User; SqlConnectionCar record = new SqlConnectionCar(); ObservableCollection <Car> carsDB = record.GiveUsersRecordsByPhoneNumber(PhoneNumber); CarsCollection = new ObservableCollection <Car>(); if (carsDB != null) { foreach (var item in carsDB) { CarsCollection.Add(item); } } if (CarsCollection.Count == 0) { ButtonVisability = false; } else { ButtonVisability = true; } SqlConnect spam = new SqlConnect(); bool admin = spam.IsAdminById(); if (admin) { PanelVisability = true; ButtonVisability = true; } }
private string getUserName() { SqlConnect spam = new SqlConnect(); bool admin = spam.IsAdminById(); if (admin) { UserName = "******"; } else { UserName = "******"; } return(userName); }
public UserAutoViewModel() { SqlConnect spam = new SqlConnect(); if (!spam.IsAdminById()) { PanelVisability = true; PanelVisabilityComboBox = false; PhoneNumber = Properties.Settings.Default.User; SqlConnectionCar record = new SqlConnectionCar(); ObservableCollection <Car> carsDB = record.GiveUsersRecordsByPhoneNumber(PhoneNumber); CarsCollection = new ObservableCollection <Car>(); if (carsDB != null) { foreach (var item in carsDB) { CarsCollection.Add(item); } } if (CarsCollection.Count != 0) { var carNumber = (from number in CarsCollection select number.CarNumber); CarNumber = carNumber.First(); var carRegion = (from region in CarsCollection select region.CarRegion); CarRegion = carRegion.First(); var carSeries = (from series in CarsCollection select series.CarSeries); CarSeries = carSeries.First(); var carSpace = (from space in CarsCollection select space.SpaceType); SpaceType = carSpace.First(); var leaseTime = (from time in CarsCollection select time.LeaseTime); LeaseTime = leaseTime.First(); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); } } else { PanelVisability = false; PanelVisabilityComboBox = true; } }