public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptBinCard rpt = new rptBinCard(); rpt.Site = this.Site; return(rpt); }
private void dgwStockSummary_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dgwStockSummary.Columns["BinCard"].Index) { int storeid = Convert.ToInt32(ddlStore.SelectedValue.ToString()); int itemid = Convert.ToInt32(dgwStockSummary.Rows[e.RowIndex].Cells["ItemId"].Value.ToString()); DateTime dateFrom = Convert.ToDateTime(dtpFrom.Value.ToString("yyyy-MM-dd")); DateTime dateTo = Convert.ToDateTime(dtpTo.Value.ToString("yyyy-MM-dd")); ReportDocument objRptDoc = new ReportDocument(); DataSet theDS = GetBINCard(storeid, itemid, dateFrom, dateTo); //////////////////////////////////////////////////////////////// //Image Streaming DataTable dtFacility = new DataTable(); // object of data row DataRow drow = null; // add the column in table to store the image of Byte array type dtFacility.Columns.Add("FacilityImage", System.Type.GetType("System.Byte[]")); drow = dtFacility.NewRow(); // define the filestream object to read the image FileStream fs = default(FileStream); // define te binary reader to read the bytes of image BinaryReader br = default(BinaryReader); int ImageFlag = 0; // check the existance of image if (File.Exists(GblIQCare.PresentationImagePath() + theDS.Tables[3].Rows[0]["FacilityLogo"].ToString())) { // open image in file stream fs = new FileStream(GblIQCare.PresentationImagePath() + theDS.Tables[3].Rows[0]["FacilityLogo"].ToString(), FileMode.Open); // initialise the binary reader from file streamobject br = new BinaryReader(fs); // define the byte array of filelength byte[] imgbyte = new byte[fs.Length + 1]; // read the bytes from the binary reader imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); drow[0] = imgbyte; // add the image in bytearray dtFacility.Rows.Add(drow); ImageFlag = 1; // add row into the datatable br.Close(); // close the binary reader fs.Close(); // close the file stream } theDS.Tables.Add(dtFacility); //////////////////////////////////////// theDS.WriteXmlSchema(GblIQCare.GetXMLPath() + "\\BinCard.xml"); rptBinCard rep = new rptBinCard(); rep.SetDataSource(theDS); // rep.ParameterFields["FormDate","1"]; rep.SetParameterValue("facilityname", GblIQCare.AppLocation); frmReportViewer theRepViewer = new frmReportViewer(); theRepViewer.MdiParent = this.MdiParent; theRepViewer.Location = new Point(0, 0); theRepViewer.crViewer.ReportSource = rep; theRepViewer.Show(); this.Close(); } }