Beispiel #1
0
        public void Load_data()
        {
            string str = "select * from tblLuong";

            System.Data.DataTable dt = KiemTraKetNoi.getDatatable(str);
            dataLuong.DataSource = dt;
        }
Beispiel #2
0
        public void Load_data()
        {
            string str = "select * from tblTTNhanVien";

            System.Data.DataTable dt = KiemTraKetNoi.getDatatable(str);
            dataNhanVien.DataSource = dt;
        }
Beispiel #3
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txtID.Text == "" || txtPass.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập tên đăng nhập hoặc mật khẩu!", "Thông báo");
                return;
            }
            DataTable dt = KiemTraKetNoi.getDatatable("Select * from tblUser where ID = '" + txtID.Text + "' and Password = '******'");

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Xin chào " + txtID.Text + "! Bạn đã đăng nhập thành công!", "Thông báo");
                this.Hide();
                Form main = new frmMain(txtID.Text, txtPass.Text);
                main.Show();
            }

            else
            {
                MessageBox.Show("Đăng nhập không thành công!", "Thông báo");
                txtID.Clear();
                txtPass.Clear();
                txtID.Focus();
            }
        }
Beispiel #4
0
        private void frmLuongNV_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            string str = "select * from tblLuong";

            System.Data.DataTable dt = KiemTraKetNoi.getDatatable(str);
            dataLuong.DataSource = dt;
            btnThem.Enabled      = false;
        }
Beispiel #5
0
        private void frmNguoiDung_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            //MessageBox.Show(username + password);
            string str = "select * from tblUser";

            System.Data.DataTable dt = KiemTraKetNoi.getDatatable(str);
            dataNguoiDung.DataSource = dt;
        }
Beispiel #6
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            string update = "update tblUser set Password='******' where(ID=N'" + txtTaiKhoan.Text + "' and Password='******')";
            string ten    = txtTaiKhoan.Text;

            if (ten == "")
            {
                MessageBox.Show("Bạn chưa nhập tên truy cập");
            }
            else
            {
                if (txtMatKhauCu.Text == "")
                {
                    MessageBox.Show("Bạn chưa nhập mật khẩu");
                }
                else
                {
                    if (txtMatKhauMoi.Text == "")
                    {
                        MessageBox.Show("Bạn chưa nhập mật khẩu mới");
                    }
                    else
                    {
                        if (txtXacNhanMatKhau.Text == "")
                        {
                            MessageBox.Show("Bạn chưa nhập lại mật khẩu");
                        }
                        else
                        {
                            if ((txtMatKhauMoi.Text == txtXacNhanMatKhau.Text) && txtMatKhauCu.Text == password)
                            {
                                DataTable dt = KiemTraKetNoi.getDatatable(update);
                                MessageBox.Show("Bạn đã thay đổi mật khẩu thành công");
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Bạn nhập lại mật khẩu không đúng");
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
 private void txtTimKiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (radMaNV.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE MaNV='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radTenNV.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE HoTen LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNoiSinh.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE NoiSinh LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radDiaChi.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE DiaChi LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radChuyenMon.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE ChuyenMon LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radTDHV.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE TDHV LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radDanToc.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE DanToc LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radTonGiao.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE TonGiao LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radQuocTich.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE QuocTich LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radLuongCB.Checked == true)
         {
             string Search            = "SELECT * FROM tblLuong WHERE LuongCoBan='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radDonVi.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE MaDonVi='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNoiCapBHXH.Checked == true)
         {
             string Search            = "SELECT * FROM tblBaoHiemXH WHERE NoiCap LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNoiDKKCB.Checked == true)
         {
             string Search            = "SELECT * FROM tblBaoHiemXH WHERE NoiDKKCB LIKE N'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radGioiTinh.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE GioiTinh=N'" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radSDT.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE SDT LIKE'%" + txtTimKiem.Text + "%'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radEmail.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE Email='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNgaySinh.Checked == true)
         {
             string Search            = "SELECT * FROM tblTTNhanVien WHERE NgaySinh='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNgayNhapLuong.Checked == true)
         {
             string Search            = "SELECT * FROM tblLuong WHERE NgayNhap='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNgaySuaLuong.Checked == true)
         {
             string Search            = "SELECT * FROM tblLuong WHERE NgaySua='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (radNgayCapBHXH.Checked == true)
         {
             string Search            = "SELECT * FROM tblBaoHiemXH WHERE NgayCap='" + txtTimKiem.Text + "'";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (txtTimKiem.Text == "Nhân viên nào có lương cao nhất?" || txtTimKiem.Text == "nhân viên nào có lương cao nhất?" || txtTimKiem.Text == "lương cao nhất?")
         {
             string Search            = "SELECT * FROM tblLuong  where LuongCoBan = (select max(LuongCoBan) from tblLuong )";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
         if (txtTimKiem.Text == "Nhân viên nào có lương thấp nhất?" || txtTimKiem.Text == "nhân viên nào có lương thấp nhất?" || txtTimKiem.Text == "lương thấp nhất?")
         {
             string Search            = "SELECT * FROM tblLuong  where LuongCoBan = (select min(LuongCoBan) from tblLuong )";
             System.Data.DataTable dt = KiemTraKetNoi.getDatatable(Search);
             dataTimKiem.DataSource = dt;
             int count = dataTimKiem.Rows.Count - 1;
             txtKQTimKiem.Text = count.ToString();
         }
         //
     }
     catch (Exception)
     { }
 }