private void btnEnter_Click(object sender, RoutedEventArgs e) { Person newPerson = new Person { Name = UserNameTextBox.Text, Password = Sha256Tools.GetHash(PasswordTextBox.Password) }; if (Authentification.Authentify(newPerson) && UserNameTextBox.Text != "" && PasswordTextBox.Password != "") { System.Windows.Forms.MessageBox.Show("You are already register, please use the sign in button", "User issue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (!Authentification.Authentify(newPerson) && UserNameTextBox.Text != "" && PasswordTextBox.Password != "") { using (var context = new ShowContext()) { context.Add(newPerson); UserSingleton.GetInstance.user = newPerson; context.SaveChanges(); System.Windows.Forms.MessageBox.Show("You are registered now"); this.Close(); } } else if (UserNameTextBox.Text == "" || PasswordTextBox.Password == "") { System.Windows.Forms.MessageBox.Show("You have to fill both boxes", "User issue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void BtnValidate_Click(object sender, RoutedEventArgs e) { if (SeatsQuantityTextBox.Text != "") { int currentItemQuantity = Convert.ToInt32(SeatsQuantityTextBox.Text); if (currentItemQuantity > 0 && currentItemQuantity <= CurrentPresAvailableSeats) { using (var context = new ShowContext()) { string selectedShowName = ShowNameTextBlock.Text; Show selectedShow = DisplayInformation.GetShowByName(selectedShowName); Presentation presentation = DisplayInformation.GetPresByPresDateAndShow(SelectedPresInfo.PresentationDate, selectedShow); List <Order> presOrder = DisplayInformation.GetOrderListByPresentation(presentation); Order newOrder = new Order() { OrderDate = DateTime.Now, Person = UserSingleton.GetInstance.user, Presentation = presentation, ReservedSeats = Convert.ToInt32(SeatsQuantityTextBox.Text) }; presOrder.Add(newOrder); context.Update(newOrder); context.SaveChanges(); MessageBox.Show("Your order is validated"); this.Close(); } } else { MessageBox.Show("The quantity has to be between 1 and " + CurrentPresAvailableSeats + " !"); } } else { MessageBox.Show("You must enter a seats quantity to validate!"); } }