Exemplo n.º 1
0
        private void BtnDangNhap_Click(object sender, RoutedEventArgs e)
        {
            string user = txtUser.Text;
            string pass = txtPass.Password.ToString();

            try
            {
                pass = SupportMethod.ConvertToSHA1(pass);


                string sql = "select * from _USERS where USERNAME = '******' and PASSS = '" + pass + "'";
                System.Data.DataTable dt = dbConnect.GetDataTableBySql(sql);

                if (dt.Rows.Count > 0)
                {
                    var     fullName = dt.Rows[0]["TENDAU"].ToString() + " " + dt.Rows[0]["TENCUOI"].ToString();
                    Boolean isLogin  = true;
                    MainWindow.hasInfo["Ten"]      = user;
                    MainWindow.hasInfo["PathFTP"]  = user;
                    MainWindow.hasInfo["TenDau"]   = dt.Rows[0]["TENDAU"].ToString();
                    MainWindow.hasInfo["TenCuoi"]  = dt.Rows[0]["TENCUOI"].ToString();
                    MainWindow.hasInfo["FullName"] = fullName;
                    Switcher.Close(isLogin);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        private void BtnCapNhat_Click(object sender, RoutedEventArgs e)
        {
            var oldPass = SupportMethod.ConvertToSHA1(txtPassCu.Password);

            if (!oldPass.Equals(dbConnect.GetStringBySql("select PASSS from _USERS  where USER = '******'")))
            {
                System.Windows.MessageBox.Show("Mật khẩu cũ không chính xác", "Thông báo");
                return;
            }
            if (!txtPassMoi.Password.Equals(txtXacNhan.Password))
            {
                System.Windows.MessageBox.Show("Mật khẩu không khớp", "Thông báo");
                return;
            }
            var newPass = SupportMethod.ConvertToSHA1(txtPassMoi.Password);
            var sql     = "update _USERS set PASSS = '" + newPass + "', TENDAU = '" + txtTenDau + "', TENCUOI = '" + txtTenCuoi + "' where USER = '******'";

            try
            {
                dbConnect.UpdateTableBySql(sql);
                .MessageBox.Show("Cập nhật thành công", "Thông báo");
            }catch (Exception ex)