Пример #1
0
        private bool CheckOldPass()
        {
            string sCheckLogin = "******" + this.sID + "'";

            this.Connection.OpenConnection();
            SqlCommand    command = this.Connection.CreateSQLCmd(sCheckLogin);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.HasRows)
            {
                MD5Encoder PasswordEncoder = new MD5Encoder();
                if (reader.Read() == false)
                {
                    break;
                }
                if (reader.GetString(0) == PasswordEncoder.FromString(this.tbOldPass.Text))
                {
                    Connection.CloseConnection();
                    return(true);
                }
                Connection.CloseConnection();
                return(false);
            }
            Connection.CloseConnection();
            return(false);
        }
Пример #2
0
        private void btnChangeEmailF_Click(object sender, EventArgs e)
        {
            MD5Encoder PasswdEncoder = new MD5Encoder();

            try
            {
                if (tbxCurPass.Text == "" | tbxChangeMailVC.Text == "" | tbxNewEmail.Text == "")
                {
                    MessageBox.Show("vui lòng không để trống thông tin!", "Đổi email");
                }
                else
                {
                    if (PasswdEncoder.FromString(tbxCurPass.Text) == this.sPasswd && CheckCode() == 1)
                    {
                        try
                        {
                            Connection.OpenConnection();

                            string     sql     = @"UPDATE USERS SET EMAIL ='" + tbxNewEmail.Text + "' WHERE(ID_USER= '******')";
                            SqlCommand command = Connection.CreateSQLCmd(sql);
                            command.ExecuteNonQuery();

                            MessageBox.Show("Đổi email thành công!", "Đổi email");
                        }
                        catch (Exception a)
                        {
                            MessageBox.Show(a.Message);
                        }
                        finally
                        {
                            Connection.CloseConnection();
                        }
                    }
                    else if (tbxCurPass.Text != this.sPasswd && CheckCode() == 1)
                    {
                        lbWrongPasswd.Visible = true;
                    }
                    else if (tbxCurPass.Text == this.sPasswd && CheckCode() == 0)
                    {
                        lbWrongVeriCode.Visible = true;
                    }
                    else
                    {
                        lbWrongVeriCode.Visible = true;
                        lbWrongPasswd.Visible   = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Пример #3
0
 private void bSignUp_Click(object sender, EventArgs e)
 {
     try
     {
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         if (CheckPassword() == 1 && CheckCode() == 1 && CheckFullInfo() == 1 && CheckExistID() == 0)
         {
             USER user = new USER();
             user.ID = tbxID.Text;
             MD5Encoder PasswordEncoder = new MD5Encoder();
             user.Password    = PasswordEncoder.FromString(tbxPass.Text);
             user.Birthday    = dateBirth.Value;
             user.Email       = tbxEmail.Text;
             user.Name        = tbxName.Text;
             user.Class       = tbxClass.Text;
             user.Gender      = tbxGender.Text;
             this.EmailVerify = new EmailVerify(user.Email);
             user.AddUserToDatabase();
             MessageBox.Show("Đăng ký thành công!", "StudentSupportApp", buttons);
             this.Close();
             this.parent.Show();
         }
         else if (CheckCode() == 0)
         {
             MessageBox.Show("Mã xác nhận không đúng! Vui lòng thử lại!", "StudentSupportApp", buttons);
             lbCodeSent.Hide();
         }
         else if (CheckPassword() == 2)
         {
             lbShortPass.Visible = true;
         }
         else if (CheckPassword() == 3)
         {
             lbConfirmWrong.Visible = true;
         }
         else if (CheckExistID() == 1)
         {
             lbUsedID.Visible = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
 }
Пример #4
0
 public int CheckLogin()
 {
     try
     {
         string sCheckLogin = "******" + this.sID + "'";
         this.Connection.OpenConnection();
         SqlCommand    command = this.Connection.CreateSQLCmd(sCheckLogin);
         SqlDataReader reader  = command.ExecuteReader();
         while (reader.HasRows)
         {
             MD5Encoder PasswordEncoder = new MD5Encoder();
             if (reader.Read() == false)
             {
                 break;
             }
             if (reader.GetString(0) == PasswordEncoder.FromString(this.sPassword))
             {
                 this.Connection.CloseConnection();
                 reader.Close();
                 return(1);
             }
             reader.Close();
             this.Connection.CloseConnection();
             return(-1);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(ex);
         rp.Show();
     }
     finally
     {
         this.Connection.CloseConnection();
     }
     return(0);
 }
Пример #5
0
        public void ChangePassword()
        {
            try
            {
                MD5Encoder PasswordEncoder = new MD5Encoder();
                string     newPass         = PasswordEncoder.FromString(tbNewPass1.Text);

                Connection.OpenConnection();
                string     sql     = @"UPDATE USERS SET PASS ='******' WHERE(ID_USER= '******')";
                SqlCommand command = Connection.CreateSQLCmd(sql);
                command.ExecuteNonQuery();
                Connection.CloseConnection();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            finally
            {
                MessageBox.Show("Đã xong!", "ĐỔI MẬT KHẨU", MessageBoxButtons.OK);
            }
        }