コード例 #1
0
 private void Btn_Login_Click(object sender, EventArgs e)
 {
     if (TxtBx_username.TextLength == 0 && TxtBx_pass.TextLength == 0)
     {
         MessageBox.Show("Please fill the required fields to login!");
     }
     else
     {
         int ID       = controllerObj.CheckAccount(TxtBx_username.Text, TxtBx_pass.Text);
         int Position = controllerObj.CheckPosition(ID);
         if (Position == 1) // Successful Login
         {
             _loggedin = true;
             EmpMainMenu emp = new EmpMainMenu(ID);
             emp.Show();
             TxtBx_pass.Clear();
             TxtBx_username.Clear();
             // Hide the Login Form
             this.Hide();
         }
         else if (Position == 2 || Position == 3) // Successful Login
         {
             _loggedin = true;
             // Create an Object of "Provided_Functionalities" Form and Show it
             ManagerMainMenu func = new ManagerMainMenu(ID);
             func.Show();
             TxtBx_pass.Clear();
             TxtBx_username.Clear();
             // Hide the Login Form
             this.Hide();
         }
         else
         {
             MessageBox.Show("Wrong username or password!");
         }
     }
 }
コード例 #2
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (textBox1.TextLength == 0 && textBox2.TextLength == 0 && textBox3.TextLength == 0 && textBox4.TextLength == 0 && textBox7.TextLength == 0)
            {
                MessageBox.Show("Please fill the required fields to sign up!");
            }
            else
            {
                //to check for existance of employee
                //1st ID
                bool IDCheck = controllerObj.CheckID(int.Parse(textBox4.Text));
                if (IDCheck == true) //ID does exist
                {
                    //2nd Name
                    bool NameCheck = controllerObj.CheckName(textBox3.Text, int.Parse(textBox4.Text));
                    if (NameCheck == true)
                    {
                        //2nd to check for username previous existance
                        bool UserNameCheck = controllerObj.CheckUserName(textBox1.Text);
                        if (UserNameCheck == false)
                        {
                            //3rd to check password is over 8 chars
                            if (textBox2.Text.Length >= 8)
                            {
                                //4th to check e-mail is valid with @
                                if (textBox7.Text.Contains('@') || String.IsNullOrEmpty(textBox7.Text))
                                {
                                    string email = textBox7.Text;
                                    if (String.IsNullOrEmpty(textBox7.Text) == true)
                                    {
                                        email = "NULL";
                                    }
                                    int a = controllerObj.InsertAccount(int.Parse(textBox4.Text), textBox1.Text, textBox2.Text, email);
                                    MessageBox.Show("You successfully signed-up, Welcome!");
                                    int PositionCheck = controllerObj.CheckPosition(int.Parse(textBox4.Text));
                                    if (PositionCheck == 1)
                                    {
                                        EmpMainMenu emp = new EmpMainMenu(int.Parse(textBox4.Text));
                                        emp.Show(this);
                                        this.Hide();
                                    }
                                    else if (PositionCheck == 1)
                                    {
                                        ManagerMainMenu manager = new ManagerMainMenu(int.Parse(textBox4.Text));
                                        manager.Show(this);
                                        this.Hide();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Please check the email you entered!");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Password must be at least 8 characters!");
                            }
                        }

                        else
                        {
                            MessageBox.Show("Username already exists, please choose another one!");
                        }
                    }

                    else
                    {
                        MessageBox.Show("Name is incorrect, please try again!");
                    }
                }
                else
                {
                    MessageBox.Show("Please check your ID, either it doesn't exist or you already have an account!");
                }
            }
        }