Esempio n. 1
0
 public void taiDuLieu()
 {
     HoTro ht = new HoTro();
     if (tabControl1.SelectedIndex == 0)
     {
         ht.TaiDuLieu(comboBoxId, "Product", "ProductId", "ProductId");
         ht.TaiDuLieu(comboBoxIdKh, "Customer", "CustomerId", "CustomerId");
     }
     else if (tabControl1.SelectedIndex == 1)
     {
         string caulenh = "select BillSaleId as 'Mã phiếu', convert(varchar,createDate,103)  as 'Ngày tạo',Customername as 'Tên khách hàng', FullName as 'Người lập phiếu' " +
                      "from BillSale join Customer" +
                      " on BillSale.CustomerId = Customer.CustomerId" +
                      " inner join Users " +
                      "on BillSale.UserId = Users.UserId";
         ht.HienThiVaoDataGridView(dataGridViewDSPhieuBan, caulenh);
     }
 }
Esempio n. 2
0
 public void taiDuLieu()
 {
     HoTro ht = new HoTro();
     if (tabQuanLyPhieuNhap.SelectedIndex == 0) {
         txtNgayThang.Text = DateTime.Now.ToString("dd/MM/yyyy");
         ht.TaiDuLieu(cboNhaCungCap, "Provider", "ProviderId", "ProviderName");
         ht.TaiDuLieu(cboLoaiSanPham, "Category", "CategoryId", "CategoryName");
         ht.TaiDuLieu(cboDonViTinh, "Units", "UnitId", "UnitName");
         ht.TaiDuLieu(cboTenSanPham, "ProductName", "ProductNameId", "ProdName");
         ht.TaiDuLieu(cboNguonGoc, "Country", "CountryId", "CountryName");
         ht.TaiDuLieu(cboNhaSanXuat, "Manufacturer", "ManId", "ManName");
     }
     else if (tabQuanLyPhieuNhap.SelectedIndex == 1) {
         string caulenh = "select BillPurchaseId as 'Mã phiếu', convert(varchar,createDate,103) as 'Ngày tạo', DeliveryStaff as 'Nhân viên giao hàng', ProviderName as 'Nhà cung cấp', FullName as 'Người lập phiếu' " +
                      "from BillPurchase join Provider" +
                      " on BillPurchase.ProviderId = Provider.ProviderId" +
                      " inner join Users " +
                      "on BillPurchase.UserId = Users.UserId";
         ht.HienThiVaoDataGridView(dataGridViewPhieuNhapHAng, caulenh);
     }
 }
Esempio n. 3
0
 private void cellClick(Int64 maPhieu)
 {
     HoTro ht = new HoTro();
     string caulenh = "select ProductId 'Mã sản phẩm', ProdName 'Tên sản phẩm', convert(varchar,mfgDate,103) 'Ngày sản xuất', convert(varchar,ExpDate,103) 'Ngày hết hạn', UnitName 'Đơn vị', PurchasePrice 'Giá bán', SalePrice 'Giá mua', discount 'Giảm giá', StatusName 'Trạng thái' " +
                      " from Product join ProductName" +
                      " on Product.ProductNameId = ProductName.ProductNameId" +
                      " join Units" +
                      " on Product.UnitId = Units.UnitId" +
                      " join ProductStatus" +
                      " on Product.StatusId = ProductStatus.StatusId" +
                      " where BillSaleId = " + maPhieu;
     ht.HienThiVaoDataGridView(dataGridViewHangHoa, caulenh);
 }
Esempio n. 4
0
        private void btnTimKiemQuanLy_Click(object sender, EventArgs e)
        {
            try {
                dataGridViewHangHoa.DataSource = null;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            if (txtTimKiemQuanLy.Text.Length == 0) {
                HoTro.baoLoi("Nhập thông tin để tìm kiếm") ;
                return ;
            }
            if (!checkBoxMaPhieu.Checked && !chkNhanviengh.Checked && !cbngaytao.Checked && !chkNguoiLapPhieu.Checked) {
                HoTro.baoLoi("Chọn trường để tìm kiếm");
                return;
            }

            HoTro ht = new HoTro();
            string caulenh = "select BillSaleId as 'Mã phiếu', createDate as 'Ngày tạo',Customername as 'Tên khách hàng', FullName as 'Người lập phiếu' " +
                         "from BillSale join Customer" +
                         " on BillSale.CustomerId = Customer.CustomerId" +
                         " inner join Users " +
                         "on BillSale.UserId = Users.UserId";
            StringBuilder builder = new StringBuilder();
            if (checkBoxMaPhieu.Checked) {
                try {
                    builder.Append("BillSale.BillSaleId = " + Int64.Parse(txtTimKiemQuanLy.Text));
                } catch (Exception ex) { }
            }
            if (chkNhanviengh.Checked) {
                if (builder.Length > 0) builder.Append(" or ") ;
                builder.Append("Customer.Customername like '%" + txtTimKiemQuanLy.Text + "%' " );
            }
            if (cbngaytao.Checked && ht.toSQLDateTime(txtTimKiemQuanLy.Text) != null)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("BillSale.createDate ='" + ht.toSQLDateTime(txtTimKiemQuanLy.Text).ToShortDateString() + "' " );
            }
            if (chkNguoiLapPhieu.Checked)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("Users.FullName like '%" + txtTimKiemQuanLy.Text + "%' ");
            }
            if (builder.Length > 0) {
                builder.Insert(0, " where ");
            }
            caulenh += builder.ToString();
            ht.HienThiVaoDataGridView(dataGridViewDSPhieuBan, caulenh);
        }
Esempio n. 5
0
        private void btnTimKiemQuanLy_Click(object sender, EventArgs e)
        {
            if (txtTimKiemQuanLy.Text.Length == 0)
            {
                HoTro.baoLoi("Nhập thông tin để tìm kiếm");
                return;
            }
            if (!checkBoxMaPhieu.Checked && !chkNhanviengh.Checked && !cbngaytao.Checked && !chkNguoiLapPhieu.Checked && !chkNhacungcap.Checked)
            {
                HoTro.baoLoi("Chọn trường để tìm kiếm");
                return;
            }

            HoTro ht = new HoTro();
            string caulenh = "select BillPurchaseId as 'Mã phiếu', createDate as 'Ngày tạo', DeliveryStaff as 'Nhân viên giao hàng', ProviderName as 'Nhà cung cấp', FullName as 'Người lập phiếu' " +
                             "from BillPurchase join Provider" +
                             " on BillPurchase.ProviderId = Provider.ProviderId" +
                             " inner join Users " +
                             "on BillPurchase.UserId = Users.UserId";

            StringBuilder builder = new StringBuilder();
            if (checkBoxMaPhieu.Checked)
            {
                try
                {
                    builder.Append("BillPurchase.BillPurchaseId = " + Int64.Parse(txtTimKiemQuanLy.Text));
                }
                catch (Exception ex) { }
            }
            if (chkNhanviengh.Checked)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("BillPurchase.DeliveryStaff like '%" + txtTimKiemQuanLy.Text + "%' ");
            }
            if (cbngaytao.Checked && ht.toSQLDateTime(txtTimKiemQuanLy.Text) != null)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("BillPurchase.createDate ='" + ht.toSQLDateTime(txtTimKiemQuanLy.Text).ToShortDateString() + "' ");
            }
            if (chkNhacungcap.Checked)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("Provider.ProviderName like '%" + txtTimKiemQuanLy.Text + "%' ");
            }
            if (chkNguoiLapPhieu.Checked)
            {
                if (builder.Length > 0) builder.Append(" or ");
                builder.Append("Users.FullName like '%" + txtTimKiemQuanLy.Text + "%' ");
            }
            if (builder.Length > 0)
            {
                builder.Insert(0, " where ");
            }
            caulenh += builder.ToString();
            ht.HienThiVaoDataGridView(dataGridViewPhieuNhapHAng, caulenh);
        }