/// <returns>Trả về dataset với tên bảng mặc định</returns> protected void FillToDataTable(DataTable dataTable, string commandText, params object[] paramValues) { try { CreateCommand(commandText, paramValues); var da = new GtidDataAdapter(CurrentCommand); if (dataTable == null) { dataTable = new DataTable(); } da.Fill(dataTable); da.Dispose(); //da = null; //GC.Collect(); //if (!String.IsNullOrEmpty(Convert.ToString(da))) // File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + String.Format("\\{0}.log", Path.GetRandomFileName()), // Convert.ToString(da)); } catch (Exception ex) { throw new ManagedException(ex.Message, false, dataTable, commandText, paramValues); } }
/// <returns>Trả về dataset với tên bảng mặc định</returns> protected DataTable GetDataTableCommand(string commandText) { try { CreateCommand(commandText); GtidDataAdapter da = new GtidDataAdapter(CurrentCommand); DataTable dtResult = new DataTable(); da.Fill(dtResult); da.Dispose(); //da = null; //GC.Collect(); //if (!String.IsNullOrEmpty(Convert.ToString(da))) // File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + String.Format("\\{0}.log", Path.GetRandomFileName()), // Convert.ToString(da)); return(dtResult); } catch (Exception ex) { throw new ManagedException(ex.Message, false, commandText); } }
public static DataSet getData(GtidCommand sql, string TableName) { GtidDataAdapter adap = new GtidDataAdapter(); adap.SelectCommand = sql; DataSet ds; ds = new DataSet(); try { adap.Fill(ds, TableName); } catch (Exception ex) { throw ex; } return(ds); }
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(); } }
private void frmBC_InHDPhieu_Load(object sender, EventArgs e) { string strCaption = ""; string ReportFile = Declare.AppPath; string sql = ""; cnn = ConnectionUtil.Instance.GetConnection(); switch (ReportType) { case "PN": { this.Text = "In phiếu nhập kho"; sql = " select * from vThongTinNhaThuoc;select * from vPhieuNhap where SoPhieuNhap=N'" + SoHD_Phieu + "';select * from vChiTiet_PhieuNhap where SoPhieuNhap=N'" + SoHD_Phieu + "'"; ReportFile = ReportFile + "Reports\\rptPhieuNhapKho.rpt"; da = new GtidDataAdapter(sql, cnn); da.Fill(ds); ds.Tables[0].TableName = "vThongTinNhaThuoc"; ds.Tables[1].TableName = "vPhieuNhap"; ds.Tables[2].TableName = "vChiTiet_PhieuNhap"; if (ds.Tables[1].Rows.Count > 0) { rptPhieuNhapKho rpt = new rptPhieuNhapKho(); rpt.SetDataSource(ds); rptViewer.ReportSource = rpt; rptViewer.RefreshReport(); return; } break; } case "PX": { this.Text = "In phiếu xuất kho"; sql = " select * from vThongTinNhaThuoc;select * from vPhieuXuat where SoPhieuXuat=N'" + SoHD_Phieu + "';select * from vChiTiet_PhieuXuat where SoPhieuXuat=N'" + SoHD_Phieu + "'"; ReportFile = ReportFile + "Reports\\rptPhieuXuatKho.rpt"; da = new GtidDataAdapter(sql, cnn); da.Fill(ds); ds.Tables[0].TableName = "vThongTinNhaThuoc"; ds.Tables[1].TableName = "vPhieuXuat"; ds.Tables[2].TableName = "vChiTiet_PhieuXuat"; if (ds.Tables[1].Rows.Count > 0) { rptPhieuXuatKho rpt = new rptPhieuXuatKho(); rpt.SetDataSource(ds); rptViewer.ReportSource = rpt; rptViewer.RefreshReport(); return; } break; } case "PDC": { strCaption = "In phiếu điều chuyển hàng"; sql = " SELECT SoLuong, GhiChu, NVNhap, TenThuoc, TenNhaSanXuat, KhoXuat, SoPhieuDC, NgayLap, TenDonViTinh, IdKho, IdThuoc, KhoNhap, NVXuat, HanDung FROM vPhieuDieuChuyen"; sql = sql + " WHERE SoPhieuDC = '" + SoHD_Phieu.Trim() + "'"; ReportFile = ReportFile + "Reports\\rptPhieuDieuChuyen.rpt"; 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(); } }