Пример #1
0
        private void themSachToolStripButton_Click(object sender, EventArgs e)
        {
            //QuanLyLoaiSach frmQL = new QuanLyLoaiSach();
            //frmQL.TopLevel = false;
            //frmQL.FormBorderStyle = FormBorderStyle.None;
            //frmQL.Dock = DockStyle.Fill;
            //panel1.Controls.Add(frmQL);
            //frmQL.Top = panel1.Top;
            //frmQL.Left = (panel1.Right - panel1.Left) / 2;
            //frmQL.Show();

            //QuanLyLoaiSach frmQLS = new QuanLyLoaiSach();
            //frmQLS.ShowDialog();

            //    TimKiemSach frmTimKiem = new TimKiemSach();
            //  frmTimKiem.ShowDialog();
            if (frmDangNhap.kiemTraDangNhap == true)
            {
                frmQuanLySach frm = new frmQuanLySach();
                frm.ShowDialog();
            }
            else
            {
                frmDangNhap frm = new frmDangNhap();
                frm.ShowDialog();
            }
        }
Пример #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUsername.Text == "")
                {
                    MessageBox.Show("Chưa nhập username");
                    return;
                }
                if (txtPassword.Text == "")
                {
                    MessageBox.Show("Chưa nhập password");
                    return;
                }
                QuanThuDTO quanthuDTO = null;
                QuanThuBUS quanthuBUS = new QuanThuBUS();
                string     username   = txtUsername.Text;
                quanthuDTO = quanthuBUS.Search(username);

                byte[] plainTextBytes = ASCIIEncoding.ASCII.GetBytes(txtPassword.Text.ToString());

                MD5CryptoServiceProvider myMD5 = new MD5CryptoServiceProvider();
                byte[] byteHash = myMD5.ComputeHash(plainTextBytes);

                StringBuilder sOutput = new StringBuilder(byteHash.Length);
                for (int i = 0; i < byteHash.Length; i++)
                {
                    sOutput.Append(byteHash[i].ToString("X2"));  // X2 formats to hexadecimal
                }

                if (quanthuDTO == null)
                {
                    MessageBox.Show("Không tìm thấy quản thư có username là : " + txtUsername.Text);
                    return;
                }
                else
                {
                    if (quanthuDTO.Password == sOutput.ToString() && quanthuDTO.Loai == 1)
                    {
                        //this.Visible = false;
                        kiemTraDangNhap = true;
                        this.Close();
                        frmQuanLySach frm = new frmQuanLySach();
                        frm.ShowDialog();
                    }
                    else
                    {
                        if (quanthuDTO.Password == sOutput.ToString() && quanthuDTO.Loai == 2)
                        {
                            kiemTraDangNhap = true;
                            frmQuanTriVien frm = new frmQuanTriVien();
                            frm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("Password không hợp lệ");
                            return;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }