Exemplo n.º 1
0
        private void buttonDangNhap_Click(object sender, EventArgs e)
        {
            NguoiDung_DTO x = (new M_NguoiDungBLL()).Get(txtusername.Text);

            if (x != null)
            {
                if (MD5Encode.GetMd5Hash(txtpass.Text) == x.Pass)
                {
                    MainForm mainform = new MainForm(x);
                    this.Visible = false;
                    if (mainform.ShowDialog() == DialogResult.OK)
                    {
                        this.Close();
                    }
                    else // đăng xuất ra
                    {
                        this.Visible = true;
                        txtusername.Focus();
                        txtusername.SelectAll();
                    }
                    return;
                }
            }

            nhapsai++;
            if (nhapsai > 5)
            {
                MessageBox.Show("Phát hiện nghi vấn hack !", "Thông báo");
                this.Close();
            }

            MessageBox.Show("Tên đăng nhập hoặc mật khẩu không chính xác, vui lòng nhập lại");
            txtusername.Focus();
        }
Exemplo n.º 2
0
        private void buttonLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (Edit == 0) //add
                {
                    NguoiDung.Insert(new NguoiDung_DTO()
                    {
                        UserName = txtUser.Text,
                        Pass     = MD5Encode.GetMd5Hash(txtpass.Text),
                        Quyen    = comboBoxQuyen.Text
                    });
                }
                if (Edit == 1) //edit
                {
                    NguoiDung.Update(new NguoiDung_DTO()
                    {
                        UserName = txtUser.Text,
                        Pass     = MD5Encode.GetMd5Hash(txtpass.Text),
                        Quyen    = comboBoxQuyen.Text
                    });
                }

                if (Edit == 2) //mk
                {
                    if (!NguoiDung.KiemTra(txtUser.Text, MD5Encode.GetMd5Hash(txtpass.Text)))
                    {
                        MessageBox.Show("Tên đăng nhập hoặc mật khẩu sai");
                        return;
                    }
                    NguoiDung.Update(new NguoiDung_DTO()
                    {
                        UserName = txtUser.Text,
                        Pass     = MD5Encode.GetMd5Hash(txtnewpass.Text),
                        Quyen    = comboBoxQuyen.Text
                    });
                }
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }
        }