public void GetRequisition() { try { int POId = Convert.ToInt32(Request.QueryString["Id"]); DSdtls = obj_RequisitionCafeteria.BindForReport(POId, out StrError); ViewState["ImportExel"] = DSdtls.Tables[1]; if (DSdtls.Tables.Count > 0) { if (DSdtls.Tables[0].Rows.Count > 0) { lblReqNo.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["RequisitionNo"].ToString()); lblReqDate.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["RequisitionDate"].ToString()); lblEmp.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["UserName"].ToString()); } if (DSdtls.Tables[1].Rows.Count > 0) { ReqGrid.DataSource = DSdtls.Tables[1]; ReqGrid.DataBind(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void CALLPDF() { DMRequisitionCafeteria obj_RequisitionCafeteria = new DMRequisitionCafeteria(); DataSet dslogin = new DataSet(); int POId = Convert.ToInt32(Request.QueryString["Id"]); string StrError = string.Empty; dslogin = obj_RequisitionCafeteria.BindForReport(POId, out StrError); dslogin.Tables[0].TableName = "REQUESTMASTER"; dslogin.Tables[1].TableName = "REQUESTDETAILS"; dslogin.Tables[2].TableName = "COMPANY"; //----------------------------Image Print--------------------------------------------------------------- string Image = dslogin.Tables[2].Rows[0]["CLogo"].ToString(); string ImageSign = dslogin.Tables[2].Rows[0]["DigitalSignature"].ToString(); string ImageSign1 = dslogin.Tables[2].Rows[0]["DigitalSignature1"].ToString(); string ImageSign2 = dslogin.Tables[2].Rows[0]["DigitalSignature2"].ToString(); dslogin.Tables[2].Columns.Add("CompanyLogo", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign1", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign2", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign3", System.Type.GetType("System.Byte[]")); Image = Image.Replace("~", ""); Image = Image.Replace("/", "\\"); ImageSign = ImageSign.Replace("~", ""); ImageSign = ImageSign.Replace("/", "\\"); ImageSign1 = ImageSign1.Replace("~", ""); ImageSign1 = ImageSign1.Replace("/", "\\"); ImageSign2 = ImageSign2.Replace("~", ""); ImageSign2 = ImageSign2.Replace("/", "\\"); FileStream fs; BinaryReader br; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + Image)) { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + Image, FileMode.Open); br = new BinaryReader(fs); byte[] imgbyte = new byte[fs.Length + 1]; imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); dslogin.Tables[2].Rows[0]["CompanyLogo"] = imgbyte; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["CompanyLogo"] = imgbyte; br.Close(); fs.Close(); } FileStream fss1; BinaryReader brs1; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign)) { fss1 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign, FileMode.Open); brs1 = new BinaryReader(fss1); byte[] imgbyte1 = new byte[fss1.Length + 1]; imgbyte1 = brs1.ReadBytes(Convert.ToInt32((fss1.Length))); dslogin.Tables[2].Rows[0]["Sign1"] = imgbyte1; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign1"] = imgbyte1; brs1.Close(); fss1.Close(); } FileStream fss2; BinaryReader brs2; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign1)) { fss2 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign1, FileMode.Open); brs2 = new BinaryReader(fss2); byte[] imgbyte2 = new byte[fss2.Length + 1]; imgbyte2 = brs2.ReadBytes(Convert.ToInt32((fss2.Length))); dslogin.Tables[2].Rows[0]["Sign2"] = imgbyte2; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign2"] = imgbyte2; brs2.Close(); fss2.Close(); } FileStream fss3; BinaryReader brs3; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign2)) { fss3 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign2, FileMode.Open); brs3 = new BinaryReader(fss3); byte[] imgbyte3 = new byte[fss3.Length + 1]; imgbyte3 = brs3.ReadBytes(Convert.ToInt32((fss3.Length))); dslogin.Tables[2].Rows[0]["Sign3"] = imgbyte3; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign3"] = imgbyte3; brs3.Close(); fss3.Close(); } //------------------------------------------------------------------------------------------- CRpt.Load(Server.MapPath("~/CrystalPrint/REQUEST.rpt")); CRpt.SetDataSource(dslogin); string PDFMaster = Server.MapPath(@"~/TempFiles/" + "PREREQUISITION - " + (DateTime.Now).ToString("dd-MMM-yyyy") + ".pdf"); CRpt.ExportToDisk(ExportFormatType.PortableDocFormat, PDFMaster); WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(PDFMaster); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); } }
public string GETPDF(int reqid) { DMRequisitionCafeteria obj_RequisitionCafeteria = new DMRequisitionCafeteria(); string StrError = string.Empty; string PDFMaster = string.Empty; ReportDocument CRpt = new ReportDocument(); DataSet dslogin = new DataSet(); dslogin = obj_RequisitionCafeteria.BindForReport(reqid, out StrError); dslogin.Tables[0].TableName = "REQUESTMASTER"; DataTable dt0 = new DataTable(); dt0 = dslogin.Tables[0]; dslogin.Tables[1].TableName = "REQUESTDETAILS"; DataTable dt1 = new DataTable(); dt1 = dslogin.Tables[1]; dslogin.Tables[2].TableName = "COMPANY"; DataTable dt2 = new DataTable(); dt2 = dslogin.Tables[2]; //----------------------------Image Print--------------------------------------------------------------- string Image = dslogin.Tables[2].Rows[0]["CLogo"].ToString(); string ImageSign = dslogin.Tables[2].Rows[0]["DigitalSignature"].ToString(); string ImageSign1 = dslogin.Tables[2].Rows[0]["DigitalSignature1"].ToString(); string ImageSign2 = dslogin.Tables[2].Rows[0]["DigitalSignature2"].ToString(); dslogin.Tables[2].Columns.Add("CompanyLogo", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign1", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign2", System.Type.GetType("System.Byte[]")); dslogin.Tables[2].Columns.Add("Sign3", System.Type.GetType("System.Byte[]")); Image = Image.Replace("~", ""); Image = Image.Replace("/", "\\"); ImageSign = ImageSign.Replace("~", ""); ImageSign = ImageSign.Replace("/", "\\"); ImageSign1 = ImageSign1.Replace("~", ""); ImageSign1 = ImageSign1.Replace("/", "\\"); ImageSign2 = ImageSign2.Replace("~", ""); ImageSign2 = ImageSign2.Replace("/", "\\"); FileStream fs; BinaryReader br; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + Image)) { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + Image, FileMode.Open); br = new BinaryReader(fs); byte[] imgbyte = new byte[fs.Length + 1]; imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); dslogin.Tables[2].Rows[0]["CompanyLogo"] = imgbyte; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["CompanyLogo"] = imgbyte; br.Close(); fs.Close(); } FileStream fss1; BinaryReader brs1; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign)) { fss1 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign, FileMode.Open); brs1 = new BinaryReader(fss1); byte[] imgbyte1 = new byte[fss1.Length + 1]; imgbyte1 = brs1.ReadBytes(Convert.ToInt32((fss1.Length))); dslogin.Tables[2].Rows[0]["Sign1"] = imgbyte1; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign1"] = imgbyte1; brs1.Close(); fss1.Close(); } FileStream fss2; BinaryReader brs2; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign1)) { fss2 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign1, FileMode.Open); brs2 = new BinaryReader(fss2); byte[] imgbyte2 = new byte[fss2.Length + 1]; imgbyte2 = brs2.ReadBytes(Convert.ToInt32((fss2.Length))); dslogin.Tables[2].Rows[0]["Sign2"] = imgbyte2; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign2"] = imgbyte2; brs2.Close(); fss2.Close(); } FileStream fss3; BinaryReader brs3; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign2)) { fss3 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign2, FileMode.Open); brs3 = new BinaryReader(fss3); byte[] imgbyte3 = new byte[fss3.Length + 1]; imgbyte3 = brs3.ReadBytes(Convert.ToInt32((fss3.Length))); dslogin.Tables[2].Rows[0]["Sign3"] = imgbyte3; dslogin.Tables[2].Rows[dslogin.Tables[2].Rows.Count - 1]["Sign3"] = imgbyte3; brs3.Close(); fss3.Close(); } //------------------------------------------------------------------------------------------- CRpt.Load(Server.MapPath("~/CrystalPrint/REQUEST.rpt")); CRpt.SetDataSource(dslogin); string DATE = DateTime.Now.ToString("dd-MMM-yyyy ss"); PDFMaster = Server.MapPath(@"~/TempFiles/" + "REQUISITION - " + DATE + ".pdf"); CRpt.ExportToDisk(ExportFormatType.PortableDocFormat, PDFMaster); CHKATTACHBROUCHER.Checked = true; CHKATTACHBROUCHER.Text = "Indent Details"; CHKATTACHBROUCHER.ToolTip = PDFMaster; iframepdf.Attributes.Add("src", "../TempFiles/" + "REQUISITION - " + (DATE) + ".pdf"); return(PDFMaster); }