private void Button_Click_Save(object sender, RoutedEventArgs e) { try { using (course_work cw = new course_work()) { if (rev == true) { Feedback feedback = new Feedback() { feedbackID = FeedbackID.Trim(), userID = USERid.Trim(), feedback1 = Feedback_TextBox.Text.Trim(), login = LOGIN.Trim(), dateFeedback = GetNetworkDateTime(), }; cw.Feedback.Add(feedback); cw.SaveChanges(); } } MessageBox.Show("Спасибо за отзыв."); InfoForFeedback(); } catch (Exception) { MessageBox.Show("Нет подключения к интернету"); } }
private void Button_Buy_Click(object sender, RoutedEventArgs e) { try { using (course_work cw = new course_work()) { var forBD = cw.Database.SqlQuery <Ticket>($"select * from Ticket where Ticket.sessionID = '{SESSID}'"); foreach (var check in forBD) { if (check.row == Convert.ToInt32(ComboBoxRow.Text) && check.place == Convert.ToInt32(ComboBoxPlace.Text)) { valid = false; } } if (valid == true) { NumberOfFreeSeats--; Ticket ticket = new Ticket() { ticketID = TICKETID.Trim(), sessionID = SESSID.Trim(), userID = USERID.Trim(), filmName = FILMNAME.Trim(), price = PRICE, date = DATE, time = TIME, row = Convert.ToInt32(ComboBoxRow.Text), place = Convert.ToInt32(ComboBoxPlace.Text) }; cw.Ticket.Add(ticket); cw.SaveChanges(); TicketsSingleton(); MessageBox.Show("Запись прошла успешно."); course_work context = new course_work(); var customer = context.Session .Where(c => c.sessionID == SESSID) .FirstOrDefault(); customer.number_of_free_seats = NumberOfFreeSeats; context.SaveChanges(); } else { MessageBox.Show("Место занято."); } } } catch (Exception) { MessageBox.Show("Ошибка"); } }
private void Button_Del_Click(object sender, RoutedEventArgs e) { try { var contentListBox = ListBoxTicket.SelectedItem as AppViewTickets; if (contentListBox != null) { course_work context = new course_work(); Ticket customer = context.Ticket .Where(c => c.ticketID == contentListBox.TicketID) .FirstOrDefault(); context.Ticket.Remove(customer); context.SaveChanges(); } InfoForListBox(); } catch (Exception) { } }
private void Button_Reg_Click(object sender, RoutedEventArgs e) { if (emailbool == false) { EmailLabel.Content = "Неверно введеён E-mail."; } if (loginbool == false) { LoginLabel.Content = "Логин должен содержать от 4 до 30 символов."; } if (pass1bool == false) { Pass1Label.Content = "Пароль должен содержать от 4 до 30 символов и совпадать с другим паролем."; } if (pass2bool == false) { Pass2Label.Content = "Пароль должен содержать от 4 до 30 символов и совпадать с другим паролем."; } using (course_work cw = new course_work()) { var forBD = cw.Database.SqlQuery <UsersBD>($"select * from UsersBD where UsersBD.login = '******'"); foreach (var check in forBD) { if (check.login != null) { LoginLabel.Content = "Такой логин уже зарегестрирован"; loginbool = false; } } forBD = cw.Database.SqlQuery <UsersBD>($"select * from UsersBD where UsersBD.EmailBD = '{EmailTextBox.Text.Trim()}'"); foreach (var usercheck in forBD) { if (usercheck.EmailBD != null) { EmailLabel.Content = "Такая почта уже зарегестрирована"; emailbool = false; } } } if (emailbool == true && loginbool == true && pass1bool == true && pass2bool == true) { try { using (course_work cw = new course_work()) { UsersBD user = new UsersBD() { userID = UserID.Trim(), login = LoginTextBox.Text.Trim(), password = GetHashPassword(Pass1.Password.Trim()), EmailBD = EmailTextBox.Text.Trim(), admin = false, }; cw.UsersBD.Add(user); cw.SaveChanges(); } MessageBox.Show("Регистрация прошла успешно."); Close(); Sing_In sing_In = new Sing_In(); sing_In.Show(); } catch (Exception) { MessageBox.Show("Ошибка"); } } }