Ejemplo n.º 1
0
        private void Btn_login_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_userName.Text))                  // Check empty box
            {
                MessageBox.Show("Please input 'Email' ");
            }
            else if (String.IsNullOrEmpty(pb_password.Password.ToString()))
            {
                MessageBox.Show("Please input 'Password' ");
            }
            else
            {
                int keyCheck = 1;
                foreach (string listEmail in DataAccessUser.CheckEmail())       //check email and password
                {
                    if (listEmail == tb_userName.Text)
                    {
                        foreach (string listPassword in DataAccessUser.CheckPassword())
                        {
                            if (listPassword == pb_password.Password.ToString())
                            {
                                WindowMenu windowMenu = new WindowMenu();
                                this.Close();
                                windowMenu.Show();

                                keyCheck = 2;
                                break;
                            }
                        }
                    }
                    if (keyCheck == 2)
                    {
                        break;
                    }
                }


                if (keyCheck == 1)
                {
                    MessageBox.Show("Email or Password is not correct");
                }

                pb_password.Clear();
            }



            //tb_userName.Foreground = Brushes.Red; //เปลี่ยนสี text
        }
Ejemplo n.º 2
0
 private void Btn_delete_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(tb_email.Text)) //ถ้าในกล่องข้อความว่างเปล่า
     {
         MessageBox.Show("Please input 'Email' to delete");
     }
     else
     {
         if (MessageBox.Show("Do you want to delete" + tb_email.Text + " ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             DataAccessUser.DeleteData(tb_email.Text);
             MessageBox.Show("Delete user : "******" complete", "Delete complete");
             ClearDataInTextbox();
         }
     }
 }
Ejemplo n.º 3
0
        private void Btn_show_Click(object sender, RoutedEventArgs e)
        {
            //-----------------show all data in table----------------------------------------------
            string data    = "";
            int    counter = 0;

            foreach (string list in DataAccessUser.GetData())
            {
                counter = counter + 1;
                data    = data + list + "\n";
            }

            if (counter == 0)
            {
                MessageBox.Show("No member data found", "Member detail");
            }
            else
            {
                MessageBox.Show(data, "Member detail");
            }
        }
Ejemplo n.º 4
0
        private void Btn_add_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_email.Text))
            {
                MessageBox.Show("Please input your 'EAMIL'");
            }
            else if (String.IsNullOrEmpty(tb_password.Text))
            {
                MessageBox.Show("Please input your 'PASSWORD'");
            }
            else if (String.IsNullOrEmpty(tb_firstname.Text))
            {
                MessageBox.Show("Please input your 'FIRSTNAME'");
            }
            else if (String.IsNullOrEmpty(tb_lastname.Text))
            {
                MessageBox.Show("Please input your 'LASTNAME'");
            }
            else
            {
                int keyCheck = 1;
                foreach (string list in DataAccessUser.CheckEmail())
                {
                    if (list == tb_email.Text)
                    {
                        keyCheck = 2;
                        MessageBox.Show("This Eamil is already exist");
                        ClearDataInTextbox();
                        break;
                    }
                }

                if (keyCheck == 1)
                {
                    DataAccessUser.AddData(tb_email.Text, tb_password.Text, tb_firstname.Text, tb_lastname.Text);
                    MessageBox.Show("Add user complete");
                    ClearDataInTextbox();
                }
            }
        }
Ejemplo n.º 5
0
 public MainWindow()
 {
     InitializeComponent();
     DataAccessUser.InitializeUserDatabase();
 }