Пример #1
0
        public QuanThuDTO Search(string Username)
        {
            QuanThuDAO quanthuDao = new QuanThuDAO();
            QuanThuDTO quanthuDto = quanthuDao.Search(Username);

            return(quanthuDto);
        }
Пример #2
0
        public void Insert(QuanThuDTO QuanThu)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Insert into QUANTHU([Username], [Password], [HoTen], [DiaChi], [DienThoai], [Loai]) values (?, ?, ?, ?, ?, ?)";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@Username", OleDbType.VarWChar);
            command.Parameters.Add("@Password", OleDbType.VarWChar);
            command.Parameters.Add("@HoTen", OleDbType.VarWChar);
            command.Parameters.Add("@DiaChi", OleDbType.VarWChar);
            command.Parameters.Add("@DienThoai", OleDbType.VarWChar);
            command.Parameters.Add("@Loai", OleDbType.Integer);

            command.Parameters["@Username"].Value  = QuanThu.Username;
            command.Parameters["@Password"].Value  = QuanThu.Password;
            command.Parameters["@HoTen"].Value     = QuanThu.HoTen;
            command.Parameters["@DiaChi"].Value    = QuanThu.DiaChi;
            command.Parameters["@DienThoai"].Value = QuanThu.DienThoai;
            command.Parameters["@Loai"].Value      = QuanThu.Loai;

            command.ExecuteNonQuery();

            /*command.CommandText = "Select @@IDENTITY";
             * QuanThu.MaDocGia = (int)command.ExecuteScalar();*/

            connection.Close();
        }
Пример #3
0
        public QuanThuDTO Search(string Username)
        {
            QuanThuDTO      QuanThu    = null;
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "select * from QUANTHU where Username = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@Username", OleDbType.WChar);
            command.Parameters["@Username"].Value = Username;
            OleDbDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                QuanThu = new QuanThuDTO();

                QuanThu.Username  = (string)reader["Username"];
                QuanThu.Password  = (string)reader["Password"];
                QuanThu.HoTen     = (string)reader["HoTen"];
                QuanThu.DiaChi    = (string)reader["DiaChi"];
                QuanThu.DienThoai = (string)reader["DienThoai"];
                QuanThu.Loai      = (int)reader["Loai"];
            }

            reader.Close();
            connection.Close();
            return(QuanThu);
        }
Пример #4
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtTimMaSo.Text == "" && txtTimUsername.Text == "")
         {
             MessageBox.Show("Chưa nhập thông tin về quản thư cần tìm");
             return;
         }
         if (rdbUsername.Checked == true)
         {
             QuanThuBUS quanthuBUS = new QuanThuBUS();
             QuanThuDTO quanthuDTO = null;
             quanthuDTO = quanthuBUS.Search(txtTimUsername.Text.ToString());
             if (quanthuDTO == null)
             {
                 MessageBox.Show("Không tìm thấy thông tin");
                 return;
             }
             else
             {
                 txtUsername.Text  = quanthuDTO.Username;
                 txtHoTen.Text     = quanthuDTO.HoTen;
                 txtDiaChi.Text    = quanthuDTO.DiaChi;
                 txtDienThoai.Text = quanthuDTO.DienThoai;
             }
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #5
0
        public void Insert(QuanThuDTO QuanThu)
        {
            QuanThuDAO quanthuDAO = new QuanThuDAO();

            quanthuDAO.Insert(QuanThu);
        }
Пример #6
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);
            }
        }
Пример #7
0
        private void btnTaoTaiKhoan_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUsername.Text == "")
                {
                    MessageBox.Show("Chưa nhập Username");
                    return;
                }
                if (txtPass.Text == "")
                {
                    MessageBox.Show("Chưa nhập Password");
                    return;
                }
                if (txtRePass.Text == "")
                {
                    MessageBox.Show("Chưa nhập lại Password");
                    return;
                }
                if (txtHoTen.Text == "")
                {
                    MessageBox.Show("Chưa nhập họ tên");
                    return;
                }
                if (txtDiaChi.Text == "")
                {
                    MessageBox.Show("Chưa nhập địa chỉ");
                    return;
                }
                if (txtDienThoai.Text == "")
                {
                    MessageBox.Show("Chưa nhập số điện thoại");
                    return;
                }
                if (txtPass.Text != txtRePass.Text)
                {
                    MessageBox.Show("Password chưa khớp");
                    return;
                }

                byte[] plainTextBytes = ASCIIEncoding.ASCII.GetBytes(txtPass.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
                }


                QuanThuBUS quanthuBUS = new QuanThuBUS();
                QuanThuDTO quanthuDTO = new QuanThuDTO();

                quanthuDTO.Username  = txtUsername.Text;
                quanthuDTO.Password  = sOutput.ToString();
                quanthuDTO.DiaChi    = txtDiaChi.Text;
                quanthuDTO.DienThoai = txtDienThoai.Text;
                quanthuDTO.HoTen     = txtHoTen.Text;
                quanthuDTO.Loai      = 1;

                quanthuBUS.Insert(quanthuDTO);
                MessageBox.Show("Tài khoản đã được tạo");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }