Ejemplo n.º 1
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            Decode mahoa = new Decode();
            string uname = txtUsername.Text.Trim();
            string pass = txtPassword.Text.Trim();

            if (!string.IsNullOrEmpty(uname) && !string.IsNullOrEmpty(pass))
                try
                {
                    dbConnect.Open();

                    User user = (from User p in dbConnect.db
                                 where p.Username == uname
                                 select p).SingleOrDefault();

                    if (user != null && user.password == mahoa.Encrypt(pass, "ahung_dhung_hai_huu", null))
                    {
                        loginUsename = uname;
                        loginSuccess = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
                    }
                }
                finally
                {
                    dbConnect.Close();
                }
            else
            {
                MessageBox.Show("Bạn phải nhập tên đăng nhập và mật khẩu");
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     User g = new User();
     Decode mahoa = new Decode();
     if (tenuser.Text.Trim() != "" && pass.Text.Trim() != "")
         g.adduser(tenuser.Text, mahoa.Encrypt(pass.Text.Trim(),"ahung_dhung_hai_huu",null));
     else
         MessageBox.Show("bạn chưa nhập tên user hoặc password");
     refesh();
 }