예제 #1
0
        private void Button_Click_Home(object sender, RoutedEventArgs e)
        {
            Welcome newWindow = new Welcome();

            Application.Current.MainWindow = newWindow;

            newWindow.Show();

            this.Close();
        }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     State.User = API.CheckUser(userBox.Text.Trim());
     if (State.User != null)
     {
         if (State.User.Password == passwordBox.Password)
         {
             var welcome = new Welcome();
             welcome.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Please Check your password.");
         }
     }
     else
     {
         MessageBox.Show("Please Check your username.");
     }
 }
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            using (var ctx = new Context())
            {
                try
                {
                    if (textBoxFirstName.Text.Length == 0)
                    {
                        errormessage.Text = "Firstname can not be blank.";
                    }
                    else if (textBoxLastName.Text.Length == 0)
                    {
                        errormessage.Text = "Lastname can not be blank.";
                    }

                    else if (textBoxBirthday.Text.Length == 0)
                    {
                        errormessage.Text = "Birthday can not be blank.";
                    }

                    else if (textBoxUser.Text.Length == 0)
                    {
                        errormessage.Text = "Username can not be blank.";
                    }
                    else if (passwordBox1.Text.Length == 0)
                    {
                        errormessage.Text = "Password can not be blank.";
                    }
                    else if (passwordBoxConfirm.Text.Length == 0)
                    {
                        errormessage.Text = "Confirm password can not be blank.";
                    }
                    else if (passwordBox1.Text.Length != passwordBoxConfirm.Text.Length)
                    {
                        errormessage.Text = "Confirm password must be same as password.";
                    }
                    else
                    {
                        State.User = API.CheckUser(textBoxUser.Text);
                        if (State.User != null)
                        {
                            errormessage.Text = "Username already taken.";
                        }

                        else
                        {
                            ctx.Customer.Add(new Customer {
                                First_Name = textBoxFirstName.Text, Last_Name = textBoxLastName.Text, Birthday = Convert.ToInt32(textBoxBirthday.Text), User_Name = textBoxUser.Text, Password = passwordBox1.Text
                            });
                            ctx.SaveChanges();
                            MessageBox.Show("You have Registered successfully.");
                            var welecome = new Welcome();
                            welecome.Show();
                            this.Close();
                        }
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }