Example #1
0
        private void getDataNhanVien()
        {
            sSearch = txtSearch.Text;
            if (cbTrangThai.SelectedIndex == 0)
            {
                sTrangThai = 2;
            }
            else if (cbTrangThai.SelectedIndex == 1)
            {
                sTrangThai = 1;
            }
            else
            {
                sTrangThai = 0;
            }
            if (cbSearchChucVu.SelectedIndex == 0)
            {
                sRole = 0;
            }
            else
            {
                sRole = Ham.GetIdFromCombobox(cbSearchChucVu.SelectedItem.ToString());
            }

            DataTable tb = cn.getDataTable("select u.id,u.ten,u.ngaysinh,u.sdt,u.gioitinh,u.diachi,u.taikhoan,u.active,(convert(varchar,u.roleId) + ' -' + r.ten) as 'Quyền' from HTUser u " +
                                           "join HTRole r on u.roleId = r.id where (" + sTrangThai + " = 2 or u.active = " + sTrangThai + ") and (" + sRole + " = 0 or u.roleid = " + sRole + ")");

            dataGridView1.DataSource = tb;
        }
        private void CheckEmailUsername()
        {
            string email, username;

            email    = txtEmail.Text;
            username = txtUsername.Text;
            var data = cn.getDataTable("select * from HTUser where active = 1 and email ='" + email + "' and taikhoan = '" + username + "'");

            if (data.Rows.Count > 0)
            {
                btnGuiMa.Enabled     = true;
                btnCheckCode.Enabled = true;
                lbThongBao.Text      = "";
                IdUser = Int32.Parse(data.Rows[0][0].ToString());
                TaoMaXacNhan();
                lbThongBao.Text = "";
            }
            else
            {
                btnGuiMa.Enabled     = false;
                btnCheckCode.Enabled = false;
                lbThongBao.Text      = "Email hoặc mật khẩu không đúng!";
                lbSuccess.Text       = "";
            }
        }
Example #3
0
        private void getNhanVien()
        {
            var nv = cn.getDataTable("select id,ten from htuser where roleId != 3");

            if (nv.Rows.Count > 0)
            {
                foreach (DataRow item in nv.Rows)
                {
                    cbSNhanVien.Items.Add(item[0].ToString() + " - " + item[1].ToString());
                }
            }
        }
Example #4
0
        private void getQuyen()
        {
            var data = conn.getDataTable("select (convert(varchar,id) + ' -' + ten) as 'quyen' from HTRole");

            if (data.Rows.Count > 0)
            {
                foreach (DataRow item in data.Rows)
                {
                    cbQuyen.Items.Add(item[0].ToString());
                }
            }
        }
 private void GetAll()
 {
     dataGridView1.DataSource       = con.getDataTable("SELECT ROW_NUMBER() OVER(ORDER BY ID) as 'STT' ,id as 'Mã', ten as 'Tên',diachi as 'Mô tả', sdt as 'SDT', email as 'Email' FROM NhaCungCap");
     dataGridView1.Columns[0].Width = 44;
     dataGridView1.Columns[1].Width = 44;
     dataGridView1.Columns[2].Width = 44;
 }
Example #6
0
        private void getTonKho()
        {
            var data = cn.getDataTable("select ROW_NUMBER() OVER(order by s.ten) as STT,s.id as 'Mã', " +
                                       "s.ten,s.soluong as 'Số lượng tồn',s.gianhap as 'Giá nhập',s.giaban as 'Giá bán',k.ten as 'Kho' from sanpham s" +
                                       " join kho k on s.khoId = k.id where ('" + search + "' = '' or s.ten like N'%" + search + "%') " +
                                       "ORDER BY STT OFFSET " + (PageIndex - 1) * PageSize + " ROWS FETCH NEXT " + PageSize + " ROWS ONLY");

            dataGridView1.DataSource = data;
        }
Example #7
0
 private void GetSanPham()
 {
     dataGridView1.DataSource = conn.getDataTable("SELECT s.id as 'Mã',s.ten as 'Tên',s.soluong as 'Số lượng',s.gianhap as 'Giá nhập',s.giaban as 'Giá bán',s.giaKM as 'Giá KM',(convert(varchar,k.id )+ ' -' + k.ten) as 'Kho',(convert(varchar,ncc.id) + ' -' + ncc.ten) as 'NCC'" +
                                                  ",(convert(varchar,l.id) + ' -' + l.ten) as 'Loại',s.active as 'Hoạt động' FROM SanPham s left join Kho k on s.khoId = k.id left join NhaCungCap ncc on s.nccId = ncc.id left join LoaiSanPham l on s.loaispId = l.id " +
                                                  "where ('"
                                                  + txtSten.Text + "' = '' or s.ten like N'%" + txtSten.Text + "%') and (" + SkhoId + " = 0 or k.id = " + SkhoId + ") and ("
                                                  + SloaiId + " = 0 or l.id = " + SloaiId + ") and (" + SnccId + " = 0 or ncc.id = " + SnccId + ") and (" + StrangThai + " = -1 or s.active = " + StrangThai + ")");
 }
Example #8
0
        private void GetSanPham()
        {
            panelSearchLoai.Visible = true;
            panelThu2.Visible       = true;
            checkBoLoc();
            var data = conn.getDataTable("select top 30 s.id,s.ten,s.giaKM,s.giaBan,s.luotxem,a.anh,s.soluong from SanPham s " +
                                         "join (select * from AnhSanPham where id in (select max(id) from AnhSanPham group by sanphamId)) as a on s.id = a.sanphamId " +
                                         "where ('" + Ssearch + "' = '' or s.ten like '%" + Ssearch + "%') and ( " + SloaiDienThoai + " = 0 or s.loaispId = " + SloaiDienThoai + ") " +
                                         "and ( " + SNhaCungCap + " = 0 or s.nccId = " + SNhaCungCap + ") and (" + SGiaTu + " = 0 or s.giaban >= " + SGiaTu + ") and (" + SGiaDen + " = 0 or s.giaban <= " + SGiaDen + ")" +
                                         " and (" + SRamTu + " = 0 or s.ram >= " + SRamTu + ") " +
                                         "and (" + SRamDen + " = 0 or s.ram <= " + SRamDen + ") and (" + SRomTu + " = 0 or s.rom >= " + SRomTu + ")  and (" + SRomDen + " = 0 or s.rom <= " + SRomDen + ") " +
                                         "and (" + SManHinhTu + " = 0 or s.manhinh >= " + SManHinhTu + ")  and (" + SManHinhDen + " = 0 or s.manhinh <= " + SManHinhDen + ") and active = 1 " + orderBy + orderByType);

            lbTong.Text = data.Rows.Count.ToString();
            if (data.Rows.Count > 0)
            {
                panelShowSP.Controls.Clear();
                w     = 0;
                h     = 20;
                count = 0;

                foreach (DataRow item in data.Rows)
                {
                    int    id  = Int32.Parse(item[0].ToString());
                    string ten = item[1].ToString();

                    int    giaKM   = Int32.Parse(item[2].ToString());
                    int    giaBan  = Int32.Parse(item[3].ToString());
                    int    luotxem = Int32.Parse(item[4].ToString());
                    int    sl      = Int32.Parse(item[6].ToString());
                    string anh     = item[5].ToString();
                    createDienThoai(id, ten, giaKM, giaBan, luotxem, anh, sl);
                }

                panelShowSP.Controls.Add(panelButtom);
            }
            else
            {
                panelShowSP.Controls.Clear();
                panelShowSP.Controls.Add(panelEmptySP);
                panelEmptySP.Visible = true;
            }
        }
Example #9
0
        private void getSP()
        {
            var data = conn.getDataTable("select s.id,s.ten,s.soluong,s.giaban,s.giaKM,s.mausac, s.manhinh,s.camera,s.cpu,s.ram,s.rom,s.baohanh,s.phukiendikem,s.ngaynhap,s.mota,s.luotxem,s.danhgia,l.ten from SanPham s join loaisanpham l on s.loaispId = l.id where s.id = " + Id);

            if (data.Rows.Count > 0)
            {
                lbTen.Text = data.Rows[0][1].ToString() + " - " + data.Rows[0][10].ToString() + " GB";
                if (data.Rows[0][4].ToString() == "0")
                {
                    lbGiaKM.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng";
                    giaban       = Int32.Parse(data.Rows[0][3].ToString());
                }
                else
                {
                    lbGiaKM.Text  = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][4].ToString())) + " đồng";
                    lbgiaBan.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng";
                    giaban        = Int32.Parse(data.Rows[0][4].ToString());
                }
                lbTienChu.Text = Ham.ChuyenSo((giaban * Int32.Parse(txtSL.Text)).ToString()) + " đồng";
                lbMauSac.Text  = data.Rows[0][5].ToString();
                if (data.Rows[0][2].ToString() == "0")
                {
                    lbKho.Text         = "Hết hàng";
                    btnDatHang.Enabled = false;
                    btnGiam.Enabled    = false;
                    btnTang.Enabled    = false;
                    txtSL.Enabled      = false;
                }
                else
                {
                    lbKho.Text = data.Rows[0][2].ToString();
                }

                lbMota.Text        = data.Rows[0][14].ToString();
                lbManHinh.Text     = data.Rows[0][6].ToString() + " INCH FULLHD";
                lbCamera.Text      = data.Rows[0][7].ToString();
                lbCPU.Text         = data.Rows[0][8].ToString();
                lbRam.Text         = data.Rows[0][9].ToString() + "GB";
                lbRom.Text         = data.Rows[0][10].ToString() + "GB";
                lbLoaiSanPham.Text = data.Rows[0][17].ToString();
            }
        }
Example #10
0
 private void getUser()
 {
     tb                       = cn.getDataTable("select * from HTUser where id = " + id);
     txtTen.Text              = tb.Rows[0][1].ToString();
     datePickNgaySinh.Value   = DateTime.Parse(tb.Rows[0][2].ToString());
     txtSdt.Text              = tb.Rows[0][3].ToString();
     cbGioiTinh.SelectedIndex = tb.Rows[0][4].ToString() == "True" ? 0 : 1;
     txtQueQuan.Text          = tb.Rows[0][5].ToString();
     txtUsername.Text         = tb.Rows[0][6].ToString();
     passwordCu               = tb.Rows[0][7].ToString();
 }
Example #11
0
 private void getAll()
 {
     if (activeForm != null)
     {
         activeForm.Visible = false;
     }
     panel1.Visible = false;
     panelCha.Controls.Add(dataGridView1);
     dataGridView1.DataSource = cn.getDataTable("select distinct h.id, h.noigiaohang, h.ngaydat,h.trangthai from hoadon h join chitiethoadon ct on h.id = ct.hoadonId join sanpham s on ct.sanphamId = s.id" +
                                                " where h.khachhangId = " + LuuThongTin.id + " group by h.id, s.ten, h.noigiaohang, h.ngaydat, h.trangthai order by h.id desc");
 }
Example #12
0
        private void GetAll()
        {
            var data = con.getDataTable("SELECT ROW_NUMBER() OVER(ORDER BY ID) as 'STT' ,id as 'Mã', ten as 'Tên',mota as 'Mô tả' FROM LoaiSanPham");

            if (data.Rows.Count > 0)
            {
                dataGridView1.DataSource       = data;
                dataGridView1.Columns[0].Width = 44;
                dataGridView1.Columns[1].Width = 44;
                dataGridView1.Columns[2].Width = 44;
            }
        }
Example #13
0
        private void LoginAdmin()
        {
            var read = conn.getDataTable("SELECT * FROM HTUser WHERE taikhoan = N'" + txtTaiKhoan.Text +
                                         "' and matkhau = '" + Ham.EncodePassword(txtMatKhau.Text) + "' and active = 'true'");

            if (read.Rows.Count > 0)
            {
                LuuThongTin.id       = int.Parse(read.Rows[0][0].ToString());
                LuuThongTin.ten      = read.Rows[0][1].ToString();
                LuuThongTin.ngaysinh = read.Rows[0][2].ToString();
                LuuThongTin.sdt      = read.Rows[0][3].ToString();
                LuuThongTin.gioitinh = read.Rows[0][4].ToString() == "True" ? true : false;
                LuuThongTin.diachi   = read.Rows[0][5].ToString();
                LuuThongTin.taikhoan = read.Rows[0][6].ToString();
                LuuThongTin.roleId   = Int32.Parse(read.Rows[0][9].ToString());
                LuuThongTin.email    = read.Rows[0][10].ToString();

                var role = conn.getDataTable("SELECT * FROM HTRole WHERE id = " + LuuThongTin.roleId);
                LuuThongTin.role = role.Rows[0][1].ToString();
                Console.WriteLine(LuuThongTin.role);
                this.Hide();
                if (LuuThongTin.role == "Khachhang")
                {
                    // KHACH HANG
                    TrangChuKhachHang trangChu = new TrangChuKhachHang();
                    trangChu.ShowDialog();
                }
                else
                {
                    // NHAN VIEN
                    TrangChuNhanVien trangChu = new TrangChuNhanVien();
                    trangChu.ShowDialog();
                }
            }
            else
            {
                lbLoginFailed.Text = "Tài khoản hoặc mật khẩu không đúng !";
            }
        }
Example #14
0
        private void getDataChon()
        {
            var data = cn.getDataTable("select top 10 s.id,s.ten,s.gianhap,s.giaBan,s.luotxem,a.anh,s.soluong from SanPham s " +
                                       "join (select * from AnhSanPham where id in (select max(id) from AnhSanPham group by sanphamId)) as a on s.id = a.sanphamId " +
                                       "where ( '" + txtSearch.Text + "' = '' or s.ten like N'%" + txtSearch.Text + "%' ) order by ten");

            panelPickSP.Controls.Clear();
            if (data.Rows.Count > 0)
            {
                foreach (DataRow item in data.Rows)
                {
                    string ma, ten, gianhap, sl, anh;
                    ma      = item[0].ToString();
                    ten     = item[1].ToString();
                    gianhap = item[2].ToString();
                    sl      = item[6].ToString();
                    anh     = item[5].ToString();

                    AutoGenChon(ma, ten, gianhap, sl, anh);
                }
            }
        }
Example #15
0
 private void GetAll()
 {
     dataGridView1.DataSource       = con.getDataTable("SELECT ROW_NUMBER() OVER(ORDER BY ID) as 'STT' ,id as 'Mã', ten as 'Tên',diachi as 'Địa chỉ' FROM Kho");
     dataGridView1.Columns[0].Width = 44;
     dataGridView1.Columns[1].Width = 44;
 }