コード例 #1
0
ファイル: Form9.cs プロジェクト: rattanasuk/CoffeeCaFe
        private void button2_Click(object sender, EventArgs e)
        {
            Form5 asd = new Form5();

            asd.GetData(SendData());
            asd.Show();
            this.Close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DB db = new DB();

            String username = textBox1.Text;
            String password = textBox2.Text;

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `staffs` WHERE `StaffID` = @usn and `StaffPassword` = @pass", db.getConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;

            adapter.SelectCommand = command;

            adapter.Fill(table);


            if (table.Rows.Count > 0)
            {
                this.Hide();
                Form5 form1 = new Form5();
                form1.GetData(SendData());
                form1.Show();
            }
            else
            {
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username To Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Password To Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Wrong Username Or Password", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: Form10.cs プロジェクト: rattanasuk/CoffeeCaFe
        private void button1_Click(object sender, EventArgs e)
        {
            string          sql3 = "SELECT * FROM staffs";
            MySqlConnection con3 = new MySqlConnection("server=localhost;port=3306;username=root;password=;database=coffee cafe");
            MySqlCommand    cmd1 = new MySqlCommand(sql3, con3);

            con3.Open();
            MySqlDataReader reader3       = cmd1.ExecuteReader();
            List <string>   StaffID       = new List <string>();
            List <string>   StaffCode     = new List <string>();
            List <string>   StaffName     = new List <string>();
            List <string>   Gender        = new List <string>();
            List <string>   StaffPassword = new List <string>();
            List <string>   StaffLevel    = new List <string>();

            while (reader3.Read())
            {
                StaffID.Add(reader3.GetString("StaffID"));
                StaffCode.Add(reader3.GetString("StaffCode"));
                StaffName.Add(reader3.GetString("StaffName"));
                Gender.Add(reader3.GetString("Gender"));
                StaffPassword.Add(reader3.GetString("StaffPassword"));
                StaffLevel.Add(reader3.GetString("StaffLevel"));
            }
            int checkloop = 0;

            for (int i = 0; i < StaffID.Count; ++i)
            {
                if (StaffLevel[i] == "Staff")
                {
                    if (textBox1.Text == StaffID[i])
                    {
                        if (textBox2.Text == StaffPassword[i])
                        {
                            checkloop = 1;



                            Form5 form5 = new Form5();
                            form5.Show();
                            form5.GetData(SendData());
                            this.Hide();
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                    }
                }
                if (StaffLevel[i] == "Manager")
                {
                    if (textBox1.Text == StaffID[i])
                    {
                        if (textBox2.Text == StaffPassword[i])
                        {
                            checkloop = 1;
                            Form2 form2 = new Form2();
                            form2.Show();
                            this.Hide();
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                    }
                }
                if (StaffLevel[i] == "Admin")
                {
                    if (textBox1.Text == StaffID[i])
                    {
                        if (textBox2.Text == StaffPassword[i])
                        {
                            checkloop = 1;

                            Form5 form5 = new Form5();
                            form5.GetData(SendData());
                            form5.Show();
                            this.Hide();
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                    }
                }
            }
            if (checkloop == 0)
            {
                MessageBox.Show("ID or Password ไม่ถูกต้อง");
            }
        }