示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ctr == 2)
            {
                MessageBox.Show("you have one try left to login");
                ctr--;
            }

            if (ctr == 0)
            {
                MessageBox.Show("You have tried to Login Many Times, What's Wrong with you?");
                this.Close();
            }


            else if (textBox1.Text != "" && textBox2.Text != "")
            {
                // CASHIER
                if (comboBox1.Text == "Cashier")
                {
                    try
                    {
                        if (connDB.Clogin(textBox1.Text, textBox2.Text, comboBox1.Text))
                        {
                            loginfo.uname = textBox1.Text;
                            MessageBox.Show("Welcome Cashier: " + textBox1.Text.ToUpper());
                            cashierHome cs = new cashierHome();
                            cs.Show();
                            this.Hide();
                            login = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    if (login == false)
                    {
                        --ctr;
                        MessageBox.Show("Invalid Login Details");
                    }
                }

                //ADMIN
                if (comboBox1.Text == "Admin")
                {
                    try
                    {
                        if (connDB.Clogin(textBox1.Text, textBox2.Text, comboBox1.Text))
                        {
                            loginfo.uname = textBox1.Text;
                            MessageBox.Show("Welcome Admin: " + textBox1.Text.ToUpper());
                            admin ad = new admin();
                            ad.Show();
                            this.Hide();
                            login = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    if (login == false)
                    {
                        ctr--;
                        MessageBox.Show("Invalid Login Details");
                    }
                }
            }
            else
            {
                MessageBox.Show("Logging in without details? BRUHHH.");
                ctr--;
            }
        }