Esempio n. 1
0
        private void loginbutton_Click(object sender, EventArgs e)
        {
            i = 0;
            MySqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from user_account where u_id='" + usernametextbox.Text + "'and password='******'";
            cmd.ExecuteNonQuery();
            var name = usernametextbox.Text;

            comm             = con.CreateCommand();
            comm.CommandText = "Insert into project.login_his values @u_id";
            comm.Parameters.AddWithValue("@u_id", name);
            UserInfo.Name = usernametextbox.Text;
            DataTable        dt = new DataTable();
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);

            da.Fill(dt);
            i = Convert.ToInt32(dt.Rows.Count.ToString());

            if (i == 0)
            {
                MessageBox.Show("The username or password is incorrect. Try again!");
                usernametextbox.Clear();
                passwordtextbox.Clear();
                usernametextbox.Select();
            }
            else
            {
                string         data    = usernametextbox.Text;
                register_login newform = (register_login)Application.OpenForms["register_login"];
                newform.Close();
                this.Close();
                Acc fm = new Acc(data);
                fm.Show();
                con.Close();
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            register_login f2 = new register_login();

            f2.ShowDialog();
        }