/// <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); } }
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(); } }