private void XuatHoaDon() { string sidhd = ""; try { sidhd = txtID.Text.Trim(); } catch { } if (sidhd.Trim().Equals("") == false && sidhd.Trim().Equals("-1") == false) { Application.DoEvents(); tsProgressBar1.Visible = true; tsProgressBar1.PerformStep(); DataTable dt = new DataTable(); dt = (DataTable)flxMatHang.DataSource; Application.DoEvents(); tsProgressBar1.PerformStep(); frmReportHDBan frm = new frmReportHDBan(); rptHoaDonBan _rptHoaDonBan = new rptHoaDonBan(); ReportDocument reportDocument = new ReportDocument(); ParameterFields pfields = new ParameterFields(); #region Khai báo parametter tiêu đề ngày tháng ParameterField pTenKH = new ParameterField(); ParameterDiscreteValue dispTenKH = new ParameterDiscreteValue(); ParameterField pDienThoai = new ParameterField(); ParameterDiscreteValue dispDienThoai = new ParameterDiscreteValue(); ParameterField pNgayXuat = new ParameterField(); ParameterDiscreteValue dispNgayXuat = new ParameterDiscreteValue(); ParameterField pNoCu = new ParameterField(); ParameterDiscreteValue dispNoCu = new ParameterDiscreteValue(); ParameterField pTienDaTT = new ParameterField(); ParameterDiscreteValue dispTienDaTT = new ParameterDiscreteValue(); ParameterField pGhiChu = new ParameterField(); ParameterDiscreteValue disGhiChu = new ParameterDiscreteValue(); ParameterField pChietKhau = new ParameterField(); ParameterDiscreteValue disChietKhau = new ParameterDiscreteValue(); string tenKH = ""; string DT = ""; string ngayXuat = ""; string noCu = ""; string tienTT = ""; string ghiChu = ""; string chietKhau = ""; tenKH = txtTenKH.Text.Trim(); DT = txtDienThoai.Text.Trim(); ngayXuat = txtNgayXuat.Text.Trim(); noCu = txtNoToaTruoc.Text.Trim(); tienTT = txtTienThanhToan.Text.Trim(); ghiChu = txtGhiChu.Text.Trim(); chietKhau = txtChietKhau.Text.Trim(); Application.DoEvents(); tsProgressBar1.PerformStep(); dispTenKH.Value = tenKH; pTenKH.Name = "pTenKH"; pTenKH.CurrentValues.Add(dispTenKH); pfields.Add(pTenKH); Application.DoEvents(); tsProgressBar1.PerformStep(); dispDienThoai.Value = DT; pDienThoai.Name = "pDienThoai"; pDienThoai.CurrentValues.Add(dispDienThoai); pfields.Add(pDienThoai); Application.DoEvents(); tsProgressBar1.PerformStep(); dispNgayXuat.Value = ngayXuat; pNgayXuat.Name = "pNgayXuat"; pNgayXuat.CurrentValues.Add(dispNgayXuat); pfields.Add(pNgayXuat); Application.DoEvents(); tsProgressBar1.PerformStep(); dispNoCu.Value = noCu; pNoCu.Name = "pNoCu"; pNoCu.CurrentValues.Add(dispNoCu); pfields.Add(pNoCu); Application.DoEvents(); tsProgressBar1.PerformStep(); dispTienDaTT.Value = tienTT; pTienDaTT.Name = "pTienDaTT"; pTienDaTT.CurrentValues.Add(dispTienDaTT); pfields.Add(pTienDaTT); Application.DoEvents(); tsProgressBar1.PerformStep(); disGhiChu.Value = ghiChu; pGhiChu.Name = "pGhiChu"; pGhiChu.CurrentValues.Add(disGhiChu); pfields.Add(pGhiChu); Application.DoEvents(); tsProgressBar1.PerformStep(); disChietKhau.Value = chietKhau; pChietKhau.Name = "pChietKhau"; pChietKhau.CurrentValues.Add(disChietKhau); pfields.Add(pChietKhau); #endregion Application.DoEvents(); tsProgressBar1.PerformStep(); frm.crystalReportViewer1.ParameterFieldInfo = pfields; Application.DoEvents(); tsProgressBar1.PerformStep(); frm.crystalReportViewer1.ReportSource = _rptHoaDonBan; Application.DoEvents(); tsProgressBar1.PerformStep(); _rptHoaDonBan.SetDataSource(dt); Application.DoEvents(); tsProgressBar1.Value = tsProgressBar1.Maximum; frm.ShowDialog(); Application.DoEvents(); tsProgressBar1.Value = 0; tsProgressBar1.Visible = false; } }
private void frmBC_InHDPhieu_Load(object sender, EventArgs e) { string strCaption = ""; string ReportFile = Declare.AppPath; string sql = ""; cnn = ConnectionUtil.Instance.GetConnection(); switch (ReportType) { case "PT": { strCaption = "In phiếu thu"; sql = " SELECT SoPhieu, NgayLap, HoTen, DiaChi, SoTien, SoTaiKhoan, NoiDungThuChi, TyGia, SoTienChu, SoChungTuKem, ChungTuGoc, Ngay, Thang, Nam FROM vPhieuThu "; sql = sql + " WHERE SoPhieu = '" + SoHD_Phieu.Trim() + "'"; ReportFile = ReportFile + "Reports\\rptPhieuThu.rpt"; break; } case "THPT": { strCaption = "Tổng hợp phiếu thu"; sql = " SELECT * FROM vBCThu "; ReportFile = ReportFile + "Reports\\rptBC_Thu.rpt"; break; } case "PC": { strCaption = "In phiếu chi"; sql = " SELECT SoPhieuChi, NgayChi, SoTaiKhoan, SoTKDoiUng, LyDoChi, TienChi, TyGia, TongTienVN, TongTien_Chu, ChungTuGoc, HoTen, QuyenSo, TenTienTe, TenNhaCungCap, DiaChi, SL_ChungTuKem, ngay_chi, thang_chi, nam_chi, ngay, thang, nam FROM vPhieuChi "; sql = sql + " WHERE SoPhieuChi = '" + SoHD_Phieu.Trim() + "' and QuyenSo='" + this.QuyenSo + "'"; ReportFile = ReportFile + "Reports\\rptPhieuChi.rpt"; break; } case "HDM": { this.Text = "In hóa đơn mua"; sql = " select * from vThongTinNhaThuoc;select * from vHoaDonMua where SoHoaDonMua=N'" + SoHD_Phieu + "';select * from vChiTiet_HoaDonMua where SoHoaDonMua=N'" + SoHD_Phieu + "'"; da = new GtidDataAdapter(sql, cnn); da.Fill(ds); ds.Tables[0].TableName = "vThongTinNhaThuoc"; ds.Tables[1].TableName = "vHoaDonMua"; ds.Tables[2].TableName = "vChiTiet_HoaDonMua"; ReportFile = ReportFile + "Reports\\rptHoaDonMua.rpt"; if (ds.Tables[1].Rows.Count > 0) { rptHoaDonMua rpt = new rptHoaDonMua(); rpt.SetDataSource(ds); rptViewer.ReportSource = rpt; rptViewer.RefreshReport(); return; } break; } case "HDB": { this.Text = "In hóa đơn bán"; sql = " select * from vThongTinNhaThuoc;select * from vHoaDonBan where SoHoaDonBan=N'" + SoHD_Phieu + "';select * from vChiTiet_HoaDonBan where SoHoaDonBan=N'" + SoHD_Phieu + "'"; da = new GtidDataAdapter(sql, cnn); da.Fill(ds); ds.Tables[0].TableName = "vThongTinNhaThuoc"; ds.Tables[1].TableName = "vHoaDonBan"; ds.Tables[2].TableName = "vChiTiet_HoaDonBan"; ReportFile = ReportFile + "Reports\\rptHoaDonBan.rpt"; if (ds.Tables[1].Rows.Count > 0) { rptHoaDonBan rpt = new rptHoaDonBan(); rpt.SetDataSource(ds); rptViewer.ReportSource = rpt; rptViewer.RefreshReport(); return; } break; } } this.Text = strCaption; if (!DBTools.ExistData(sql)) { MessageBox.Show("Không có dữ liệu. Chọn số phiếu khác để in!", Declare.titleWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { DBTools.LoadReportFile(ReportFile, sql, rptViewer); this.rptViewer.RefreshReport(); } }