public MainWindow() { InitializeComponent(); LoginF loginF = new LoginF(); loginF.ShowDialog(); #region Login if (!LoginClass.key) { Close(); } #endregion #region DBSelect using (MyDBconnection bconnection = new MyDBconnection()) { bconnection.Staffs.Load(); bconnection.Ranks.Load(); int RID = 0; var stf = bconnection.Staffs.Where(x => x.Login == LoginClass.LoginName && x.Password == LoginClass.LoginPassword); foreach (Staff staff in stf) { RID = staff.RankID; } var rnk = bconnection.Ranks.Where(X => X.RankID == RID); foreach (Rank rank in rnk) { RankName.Text = rank.RankName; Rank.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + $"\\Image\\Pagon\\{rank.RankPhoto}", UriKind.Absolute)); } } #endregion LogoImg.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + $"\\Image\\Logo\\TrafficPoliceLogo.svg")); }
private void SerchAvto_Click(object sender, RoutedEventArgs e) { if (!RequestsClass.keySerch) { RequestsClass.CheckDriverLicence(DriverLicenceSeriesTbox.Text.ToString(), DriverLicenceNumberTbox.Text.ToString()); return; } using (MyDBconnection db = new MyDBconnection()) { db.Cars.Load(); DatagridFirst.ItemsSource = db.Cars.Local.Where(x => x.DriverID == RequestsClass.Driver); } }
private void SerchAvto_Click(object sender, RoutedEventArgs e) { if (!RequestsClass.keySerch) { RequestsClass.CheckVIn(VinTbox.Text.ToString()); return; } using (MyDBconnection db = new MyDBconnection()) { db.Cars.Load(); DatagridFirst.ItemsSource = db.Cars.Local.Where(x => x.Vin == VinTbox.Text.ToString());; } }
private void SerchDriverLicence_Click(object sender, RoutedEventArgs e) { if (!RequestsClass.keySerch) { RequestsClass.CheckVIn(VinTbox.Text.ToString()); return; } using (MyDBconnection db = new MyDBconnection()) { db.DriversLicenses.Load(); DatagridFirst.ItemsSource = db.DriversLicenses.Local.Where(x => x.DriverID == RequestsClass.Driver); } }
private void SetchInsurance_Click(object sender, RoutedEventArgs e) { if (!RequestsClass.keySerch) { RequestsClass.CheckVIn(VinTbox.Text.ToString()); return; } using (MyDBconnection db = new MyDBconnection()) { db.Insurances.Load(); DatagridFirst.ItemsSource = db.Insurances.Local.Where(x => x.InsuranceID == RequestsClass.PackageDocuments); } }
private void SerchDriver_Click(object sender, RoutedEventArgs e) { if (!keySerch) { CheckVIn(); return; } using (MyDBconnection db = new MyDBconnection()) { db.Drivers.Load(); DatagridFirst.ItemsSource = db.Drivers.Local.Where(x => x.DriverID == Driver); } }
private void SetchInsurance_Click(object sender, RoutedEventArgs e) { if (!keySerch) { CheckVIn(); return; } using (MyDBconnection db = new MyDBconnection()) { db.Insurances.Load(); DatagridFirst.ItemsSource = db.Insurances.Local.Where(x => x.InsuranceID == PackageDocuments); } }
private void SerchAvto_Click(object sender, RoutedEventArgs e) { // if (VinTbox.Text.Length != 17) { MessageBox.Show("Длина vin - 17 символов"); return; } using (MyDBconnection db = new MyDBconnection()) { db.Cars.Load(); // DatagridFirst.ItemsSource = db.Cars.Local.Where(x => x.Vin == VinTbox.Text.ToString()); // var ur = db.Cars.Where(x => x.Vin == VinTbox.Text.ToString()); foreach (Car car in ur) { PackageDocuments = car.CarID;; Driver = car.DriverID; } } keySerch = true; }
private void LoginButton_Click(object sender, RoutedEventArgs e) { using (MyDBconnection bconnection = new MyDBconnection()) { bconnection.Staffs.Load(); var Staff = bconnection.Staffs.Where(x => x.Login == LoginTbox.Text.ToString() && x.Password == PasswordTbox.Text.ToString()); if (Staff.Count() != 1) { MessageBox.Show("Такого пользователя не существует"); LoginClass.key = false; return; } else { LoginClass.key = true; LoginClass.LoginName = LoginTbox.Text.ToString(); LoginClass.LoginPassword = PasswordTbox.Text.ToString();; Close(); } } }
public static void CheckVIn(string Vin) { keySerch = false; if (Vin.Length != 17) { MessageBox.Show("Длина vin - 17 символов"); return; } using (MyDBconnection db = new MyDBconnection()) { db.Cars.Load(); db.Cars.Local.Where(x => x.Vin == Vin); var ur = db.Cars.Where(x => x.Vin == Vin); foreach (Car car in ur) { PackageDocuments = car.CarID;; Driver = car.DriverID; } } keySerch = true; }
public static void CheckDriverLicence(string series, string number) { keySerch = false; int num; int ser; try { num = Convert.ToInt32(number); ser = Convert.ToInt32(series); } catch { MessageBox.Show("Серия и номер должны быть числами"); return; } if (series.Length == 0 || series.Length != 4 || number.Length == 0 || number.Length != 6) { MessageBox.Show("Серия должна состоять из 4 цифр \n Номер должен состоять из 6 цифр"); return; } using (MyDBconnection db = new MyDBconnection()) { db.DriversLicenses.Load(); db.Drivers.Load(); db.Cars.Load(); var driveLicence = db.DriversLicenses.Local.Where(x => x.DriversLicenseSeries == ser && x.DriversLicenseNumber == num); foreach (DriversLicense DLIcence in driveLicence) { Driver = DLIcence.DriverID; } var car1 = db.Cars.Local.Where(x => x.DriverID == Driver); foreach (Car car in car1) { PackageDocuments = car.CarID; } } keySerch = true; }
private void CheckVIn() { int NumberPss; int SeriesPass; if (PassportNumberTbox.Text.Length != 6 || PassportNumberTbox.Text.Length == 0 || PassportSeriesTbox.Text.Length == 0 || PassportSeriesTbox.Text.Length == 4) { MessageBox.Show("Длина серии = 4 цифры, длина номера = 6 цифр"); return; } try { NumberPss = Convert.ToInt32(PassportNumberTbox.Text); SeriesPass = Convert.ToInt32(PassportSeriesTbox.Text); } catch { MessageBox.Show("Серия и номер должны быть цифрами"); return; } using (MyDBconnection db = new MyDBconnection()) { db.Cars.Load(); // db.Cars.Local.Where(x => x.Vin == VinTbox.Text.ToString()); // var ur = db.Cars.Where(x => x.Vin == VinTbox.Text.ToString()); // foreach (Car car in ur) { PackageDocuments = car.CarID; ; Driver = car.DriverID; } } keySerch = true; }