コード例 #1
0
ファイル: Login.cs プロジェクト: zuleikayee/SAD
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean flag = false;

            try
            {
                conn.Open();
                MySqlCommand     comm = new MySqlCommand("SELECT * FROM admin", conn);
                MySqlDataAdapter adp  = new MySqlDataAdapter(comm);
                DataTable        dt   = new DataTable();
                adp.Fill(dt);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String user = dt.Rows[i]["username"].ToString();
                    String pass = dt.Rows[i]["password"].ToString();
                    if (usernameTextBox.Text == user && passwordTextBox.Text == pass)
                    {
                        empty home = new empty();
                        home.dispUser = user;
                        home.adminID  = int.Parse(dt.Rows[0]["adminID"].ToString());
                        home.log      = this;
                        this.Hide();
                        home.Show();
                        flag = true;
                        break;
                    }
                }

                if (flag == false)
                {
                    label2.Text      = "Incorrect username and/or password";
                    label2.ForeColor = Color.White;
                }
                conn.Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
                conn.Close();
            }
            usernameTextBox.Text = "";
            passwordTextBox.Text = "";
        }
コード例 #2
0
 private void button13_Click(object sender, EventArgs e)
 {
     home.Show();
     this.Hide();
     home.refreshNotif();
 }