private void Send_Click(object sender, RoutedEventArgs e) { try { if (MyMessege.Text != null || MyMessege.Text.Length < 300 || MyMessege.Text.Length > 1) { using (KPContext kp = new KPContext()) { Review review = new Review() { UserId = Convert.ToInt32(UserId.Text), ParkingId = 1, Review1 = MyMessege.Text, TimeRev = GetNetworkDateTime() }; MyMessege.Clear(); kp.Review.Add(review); kp.SaveChanges(); MessageBox.Show("Спасибо! Ваш отзыв очень ценен для нас."); } } else { throw new Exception(); } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } }
private void Find_Click(object sender, RoutedEventArgs e) { using (KPContext kP = new KPContext()) { try { ObservableCollection <Users> collect = new ObservableCollection <Users>(); string regularfname = $"{Fname.Text}"; var userinfo = kP.Users.ToList(); foreach (var i in userinfo) { if (Regex.IsMatch(i.email, regularfname)) { collect.Add(i); } } AdminUserFindResult adminUserFindResult = new AdminUserFindResult(); adminUserFindResult.Showing(collect); adminUserFindResult.Show(); this.Close(); } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
public void Regist() { if (ValidReg() == true) { using (KPContext kp = new KPContext()) { Users user = new Users() { Secondname = secondname, Firstname = firstname, email = _email, Mobile = mobile, password = GetHashPassword(_password), Admin = false }; kp.Users.Add(user); kp.SaveChanges(); } MessageBox.Show("Пользователь успешно создан"); foreach (System.Windows.Window window in System.Windows.Application.Current.Windows) { if (window.DataContext == this) { window.Close(); } } } }
public MainWindow() { InitializeComponent(); try { using (KPContext kP = new KPContext()) { var costplaceinfo = kP.Place.ToList(); var cost = costplaceinfo.First(); CostPlace.Text = cost.cost.ToString() + " копеек/минута"; } } catch (Exception) { MessageBox.Show("попробуйте позже"); } }
public void Enter() { using (KPContext kp = new KPContext()) { int checkingenter = 0; var forenter = kp.Database.SqlQuery <Users>($"select * from Users where Users.email = '{emailforEnter}'"); foreach (var check in forenter) { if (check.email == emailforEnter && check.password == PasswrdforEnter && check.Admin == true) { checkingenter++; MainAdmin mainAdmin = new MainAdmin(); MainUserInfo mainUserInfo = new MainUserInfo(); mainUserInfo.Show(check.UserId.ToString(), check.Firstname, check.Secondname, check.email, check.Mobile); mainAdmin.Showing(mainUserInfo.info.Firstname); mainAdmin.Show(); foreach (System.Windows.Window window in System.Windows.Application.Current.Windows) { if (window.DataContext == this) { window.Close(); } } } if (check.email == emailforEnter && check.password == GetHashPassword(PasswrdforEnter) && check.Admin == false) { checkingenter++; MainWindow main = new MainWindow(); main.UserInfo(check.UserId, check.Firstname, check.Secondname, check.email, check.Mobile); main.Show(); foreach (System.Windows.Window window in System.Windows.Application.Current.Windows) { if (window.DataContext == this) { window.Close(); } } } } if (checkingenter == 0) { MessageBox.Show("Проверьте корректность введенных данных"); } } }
private void Delete_Click(object sender, RoutedEventArgs e) { using (KPContext kP = new KPContext()) { try { Users users = new Users(); users = (Users)ListUser.SelectedItem; int revofdelete = kP.Database.ExecuteSqlCommand($"delete from Review where UserId = {users.UserId}"); int numbofdelete = kP.Database.ExecuteSqlCommand($"delete from Users where Users.UserId = {users.UserId}"); MessageBox.Show("Пользователь успешно удален"); this.Close(); } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
public AdminTimeParkingViewModel() { using (KPContext kP = new KPContext()) { try { bookings = new ObservableCollection <AdminTimeParkingModel>(); var bookinginfo = kP.Booking.ToList(); foreach (var i in bookinginfo) { AdminTimeParkingModel adminTimeParkingModel = new AdminTimeParkingModel(); adminTimeParkingModel.Add("Имя Пользователя: " + i.Users.Firstname, "Номер Места: " + i.Place.Number.ToString(), "Начало времени: " + i.TimeStart.ToString(), "Конец времени: " + i.TimeEnd.ToString()); bookings.Add(adminTimeParkingModel); } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
private void Reload_Click(object sender, RoutedEventArgs e) { try { using (KPContext kP = new KPContext()) { FreeBusy.Text = " "; float all = 0; float busy = 0; var inf = kP.Place.ToList(); if (inf != null) { foreach (var i in inf) { all++; if (i.Status == false) { busy++; } } if (busy == all) { FreeBusy.Text = "Переполнено"; } if (busy != all && busy > 0) { FreeBusy.Text = Convert.ToString(busy / all * 100) + "%"; } if (busy == 0) { FreeBusy.Text = "Все свободны"; } } } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } }
public void Delete() { using (KPContext kP = new KPContext()) { try { int numberofdelete = kP.Database.ExecuteSqlCommand($"delete from Review where ReviewId = {review.Id}"); MessageBox.Show("Комментарий удален"); foreach (System.Windows.Window window in System.Windows.Application.Current.Windows) { if (window.DataContext == this) { window.Close(); } } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
public void Showing() { try { using (KPContext kp = new KPContext()) { var revs = kp.Review.ToList(); alls = new ObservableCollection <AllRev>(); foreach (var i in revs) { AllRev allRev = new AllRev(); allRev.Add(i.Users.Firstname, i.TimeRev.ToString(), i.Review1); alls.Add(allRev); } ListReview.ItemsSource = alls; } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } }
public void Regist() { if (ValidReg() == true) { using (KPContext kp = new KPContext()) { Users user = new Users() { Secondname = secondname, Firstname = firstname, email = _email, Mobile = mobile, password = GetHashPassword(_password), Admin = false }; kp.Users.Add(user); kp.SaveChanges(); } MessageBox.Show("Регистрация прошла успешно"); Clear(); } }
public void Showing(string place) { using (KPContext kP = new KPContext()) { try { alls = new ObservableCollection <Place>(); var place_info = kP.Place.ToList(); foreach (var i in place_info) { if (i.Sector == place) { alls.Add(i); } } ListPlace.ItemsSource = alls; } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
public AdminReviewViewModel() { using (KPContext kP = new KPContext()) { try { var revi = kP.Review.ToList(); Reviews = new ObservableCollection <AdminReviewModel>(); var sortrevi = from t in revi orderby t.TimeRev select t; foreach (var r in sortrevi) { AdminReviewModel model = new AdminReviewModel(); model.Add(r.ReviewId, r.Users.Firstname, r.TimeRev.ToString(), r.Review1); Reviews.Add(model); } } catch (Exception) { MessageBox.Show("Попробуйте позже"); } } }
public FilmsController(KPContext context) { _context = context; }
private void EnterExitPark_Click(object sender, RoutedEventArgs e) { string sector = " "; if (CheckA.IsChecked == true) { sector = CheckA.Content.ToString(); } if (CheckB.IsChecked == true) { sector = CheckB.Content.ToString(); } if (CheckC.IsChecked == true) { sector = CheckC.Content.ToString(); } using (KPContext kP = new KPContext()) { try { PlaceClear(); var ForEnterOrExit = kP.Database.SqlQuery <Booking>($"select * from Booking where Booking.UserID = '{UserId.Text}'"); if (ForEnterOrExit != null) { var info = ForEnterOrExit.LastOrDefault(); var PlaceInfo = kP.Place.ToList(); if (info != null) { if (info.TimeEnd != null) //Парковка { foreach (var i in PlaceInfo) { if (i.Status == true) { if (i.Sector == sector) { //int intodata = kP.Database.ExecuteSqlCommand($"insert into Booking (UserID,PlaceID,TimeStart) values ({Convert.ToInt32(UserId.Text)},{Convert.ToInt32(i.PlaceId)},'GETDATE()'"); Booking booking = new Booking(); booking.UserID = Convert.ToInt32(UserId.Text); booking.PlaceID = Convert.ToInt32(i.PlaceId); booking.TimeStart = GetNetworkDateTime(); kP.Booking.Add(booking); kP.SaveChanges(); int upd = kP.Database.ExecuteSqlCommand($"Update Place set Status = 'false' where PlaceId = {i.PlaceId}"); MessageBox.Show("Проезжайте к месту и сектору указаному ниже"); PlaceSector.Text = "Сектор: " + i.Sector; PlaceNumber.Text = "Номер: " + i.Number; break; } } } } if (info.TimeEnd == null) // выезд из парковки { double endcost; DateTime dateTime = new DateTime(); dateTime = GetNetworkDateTime(); int chnge = kP.Database.ExecuteSqlCommand($"Update Booking set TimeEnd = '{dateTime}' where BookingId = {Convert.ToInt32(info.BookingId)}"); int upd2 = kP.Database.ExecuteSqlCommand($"Update Place set Status = 'true' where PlaceId = {Convert.ToInt32(info.PlaceID)}"); var aboutcost = PlaceInfo.Last(); endcost = CheckTime(info.TimeStart, dateTime); PlaceSector.Text = "Время стоянки: " + Convert.ToString(endcost); endcost = endcost * aboutcost.cost; PlaceNumber.Text = "Стоимость: " + Convert.ToString(endcost); } } if (info == null) { foreach (var i in PlaceInfo) { if (i.Status == true) { if (i.Sector == sector) { //int intodata = kP.Database.ExecuteSqlCommand($"insert into Booking (UserID,PlaceID,TimeStart) values ({Convert.ToInt32(UserId.Text)},{Convert.ToInt32(i.PlaceId)},'GETDATE()'"); Booking booking = new Booking(); booking.UserID = Convert.ToInt32(UserId.Text); booking.PlaceID = Convert.ToInt32(i.PlaceId); booking.TimeStart = GetNetworkDateTime(); kP.Booking.Add(booking); kP.SaveChanges(); int upd = kP.Database.ExecuteSqlCommand($"Update Place set Status = 'false' where PlaceId = {i.PlaceId}"); MessageBox.Show("Проезжайте к месту и сектору указаному ниже"); PlaceSector.Text = "Сектор: " + i.Sector; PlaceNumber.Text = "Номер: " + i.Number; break; } } } } } } catch (Exception) { MessageBox.Show("Попробуйте в другое время"); } } }
public bool ValidReg() { try { char[] Firstnamech = firstname.ToCharArray(); char[] Secondnamech = secondname.ToCharArray(); string regular_mobile = "[+]{1}[0-9]{12}"; string regular_email = "[@]{1}"; if (Regex.IsMatch(_email, regular_email) == false || _email.Length > 100 || _email.Length < 1) { throw new Exception("Email введен не корректно"); } if (Regex.IsMatch(mobile, regular_mobile, RegexOptions.IgnoreCase) == false) { throw new Exception("Номер телефона введен не корректно"); } foreach (char i in Firstnamech) { if (char.IsLetter(i) == false || Firstnamech.Length > 50 || Firstnamech.Length < 1) { throw new Exception("Имя введено не корректно"); } } foreach (char i in Secondnamech) { if (char.IsLetter(i) == false || Secondnamech.Length > 50 || Secondnamech.Length < 1) { throw new Exception("Фамилия введена не корректно"); } } if (_password != passwordAgn) { throw new Exception("Пароль не совпадает"); } if (_password.Length > 50 || _password.Length < 6) { throw new Exception("Пароль введен не корректно"); } if (Firstname.Length < 1 || Firstname.Length > 50) { throw new Exception("Имя введено не корректно"); } if (Secondname.Length > 50 || Secondname.Length < 1) { throw new Exception("Фамилия введена не корректно"); } using (KPContext kp = new KPContext()) { var users1 = kp.Database.SqlQuery <Users>($"select * from Users where Users.Mobile = '{mobile}'"); foreach (var usercheck in users1) { if (usercheck.Mobile != null) { MessageBox.Show("Телефон с таким номером уже зарегестрирован"); return(false); } } users1 = kp.Database.SqlQuery <Users>($"select * from Users where Users.email = '{_email}'"); foreach (var usercheck in users1) { if (usercheck.email != null) { MessageBox.Show("Такая почта уже зарегестрирована"); return(false); } } } return(true); } catch (Exception ex) { if (ex.Message == "Ссылка на объект не указывает на экземпляр объекта.") { MessageBox.Show("Проверьте корректность введенных данных"); return(false); } MessageBox.Show(ex.Message); return(false); } }
public CountriesController(KPContext context) { _context = context; }
public UsersController(KPContext context) { _context = context; }
public GenresController(KPContext context) { _context = context; }
public HomeController(KPContext context) { _context = context; }
public ActorsController(KPContext context) { _context = context; }