Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            fTrangChu m = new fTrangChu();

            this.Hide();
            m.ShowDialog();
            this.Show();
        }
Ejemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection connectionSTR = new SqlConnection(@"Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=GymSystem;Integrated Security=True");

            try
            {
                connectionSTR.Open();
                string UserName = txtTK.Text;
                string PassWord = txtMK.Text;

                string     query = "SELECT * FROM dbo.TaiKhoan WHERE UserName = '******'AND PassWord = '******'";
                SqlCommand cmd   = new SqlCommand(query, connectionSTR);
                DataTable  dt    = new DataTable();               // tao 1 kho ao de luu tru du lieu

                SqlDataAdapter adapter = new SqlDataAdapter(cmd); // chuyen du lieu ve

                adapter.Fill(dt);                                 // do du lieu vao kho
                SqlDataReader data = cmd.ExecuteReader();
                if (data.Read() == true)
                {
                    fTrangChu f = new fTrangChu(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString());
                    // fMain f = new fMain();
                    this.Hide();
                    f.ShowDialog();
                    this.Show();
                }

                else
                {
                    MessageBox.Show("Sai tài khoản hoặc mật khẩu! Vui lòng nhập lại!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Lỗi kết nối!");
            }
        }