private void show_report() { ReportViewer2.Reset(); DataTable dt = Queries2.flybuygoa(TextBox1.Text, TextBox2.Text, TextBox3.Text); DataTable dt2 = Queries2.Seapdate(TextBox1.Text); ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportDataSource rds2 = new ReportDataSource("DataSet2", dt2); ReportViewer2.LocalReport.DataSources.Add(rds); ReportViewer2.LocalReport.DataSources.Add(rds2); ReportViewer2.LocalReport.ReportPath = "reports/flybuygoa.rdlc"; ReportParameter[] rptParam = new ReportParameter[] { new ReportParameter("input", TextBox1.Text), new ReportParameter("venue", TextBox2.Text), new ReportParameter("gvenue", TextBox3.Text), }; ReportViewer2.LocalReport.SetParameters(rptParam); ReportViewer2.LocalReport.Refresh(); }
public override void Abas_AntesDeTrocarAba(AbaBeforeChangedCancelEventArgs e) { base.Abas_AntesDeTrocarAba(e); if (e.IndiceDaAba == 3) { TelerikReport.Report1 dd = new TelerikReport.Report1(); using (ContatoEstadoBLL bll = new ContatoEstadoBLL()) { bll.Filters = GetFilters(); dd.DataSource = bll.listaRelatorio(); ReportViewer1.Report = dd; ReportViewer1.DataBind(); } } if (e.IndiceDaAba == 4) { TelerikReport.Report3 dd = new TelerikReport.Report3(); using (ContatoEstadoBLL bll = new ContatoEstadoBLL()) { bll.Filters = GetFilters(); dd.DataSource = bll.listaRelatorio(); ReportViewer2.Report = dd; ReportViewer2.DataBind(); } } }
protected void btnbuscar_Click2(object sender, EventArgs e) { string company, fechaini, fechafin; company = ""; //usuario = ""; fechafin = ""; fechafin = ""; company = txtcompany3.Text.ToString(); //usuario = txtUsuario.Text.ToString(); fechaini = txtfechaini3.Text.ToString(); fechafin = txtfechafin3.Text.ToString(); ObtenerIndicadorNivelCumplimiento2(company, fechaini, fechafin); DataTable table = ConvertListToDataTable2(Indicadores2); ReportViewer2.Reset(); ReportViewer2.LocalReport.ReportPath = Server.MapPath("~/Content/Report/Report2.rdlc"); ReportDataSource rds = new ReportDataSource("DataSet1", table); ReportViewer2.LocalReport.DataSources.Clear(); ReportViewer2.LocalReport.DataSources.Add(rds); ReportViewer2.DataBind(); ReportViewer2.LocalReport.Refresh(); }
public void ShowErrorMessage() { ReportViewer2.LocalReport.DataSources.Clear(); ReportViewer2.LocalReport.DataSources.Add(new ReportDataSource("", new DataTable())); ReportViewer2.LocalReport.ReportPath = Server.MapPath("~/" + "Report//rpt//blank.rdlc"); ReportViewer2.DataBind(); ReportViewer2.LocalReport.Refresh(); }
protected void ShowReport() { DataTable dt = GetData(); ReportViewer1.Reset(); ReportViewer1.AsyncRendering = AsyncMode.Checked; ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.ReportPath = "Reports/Report1.rdlc"; ReportViewer1.LocalReport.DisplayName = "Report1"; ReportViewer1.LocalReport.Refresh(); ReportViewer1.ShowFindControls = false; ReportViewer1.ShowPrintButton = false; ReportViewer1.ShowFindControls = false; ReportViewer1.ShowZoomControl = false; ReportViewer1.ShowRefreshButton = false; ReportViewer1.ShowBackButton = false; ReportViewer1.Visible = Show1.Checked; ReportViewer2.Reset(); ReportViewer2.AsyncRendering = AsyncMode.Checked; ReportDataSource rds2 = new ReportDataSource("DataSet1", dt); ReportViewer2.LocalReport.DataSources.Add(rds2); ReportViewer2.LocalReport.ReportPath = "Reports/Report2.rdlc"; ReportViewer2.LocalReport.DisplayName = "Report2"; ReportViewer2.LocalReport.Refresh(); ReportViewer2.ShowFindControls = false; ReportViewer2.ShowPrintButton = false; ReportViewer2.ShowFindControls = false; ReportViewer2.ShowZoomControl = false; ReportViewer2.ShowRefreshButton = false; ReportViewer2.ShowBackButton = false; ReportViewer2.Visible = Show2.Checked; ReportViewer2.Visible = true; ReportViewer3.Reset(); ReportViewer3.AsyncRendering = AsyncMode.Checked; ReportDataSource rds3 = new ReportDataSource("DataSet1", dt); ReportViewer3.LocalReport.DataSources.Add(rds2); ReportViewer3.LocalReport.ReportPath = "Reports/Report3.rdlc"; ReportViewer3.LocalReport.DisplayName = "Report3"; ReportViewer3.LocalReport.Refresh(); ReportViewer3.ShowFindControls = false; ReportViewer3.ShowPrintButton = false; ReportViewer3.ShowFindControls = false; ReportViewer3.ShowZoomControl = false; ReportViewer3.ShowRefreshButton = false; ReportViewer3.ShowBackButton = false; ReportViewer3.Visible = Show3.Checked; }
private void ShowReportDailyDueStatement(int pMemberCaregoryID, string pMemberCode) { ReportViewer2.Reset(); DataTable dt = GetDailyDueStatement(pMemberCaregoryID, pMemberCode); ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportViewer2.LocalReport.DataSources.Add(rds); this.ReportViewer2.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; if (!string.IsNullOrEmpty(pMemberCode)) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberAllDueStatement.rdlc"; } else { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "DailyDueStatement.rdlc"; } ReportViewer2.LocalReport.Refresh(); string PDFPath = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")) + "PDF\\"; Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; String mimeType = null; String encoding = null; String extension = null; Byte[] bytes = null; if (!string.IsNullOrEmpty(pMemberCode)) { fileName = "MemberDueStatement" + DateTime.Now.ToFileTime() + ".pdf"; } else { fileName = "DailyDueStatement" + DateTime.Now.ToFileTime() + ".pdf"; } bytes = ReportViewer2.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamids, out warnings); bool IsExitsPDF = File.Exists(PDFPath + fileName); FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); byte[] data = new byte[fs.Length]; fs.Write(bytes, 0, bytes.Length); fs.Close(); PdfLocation = PDFPath + fileName; //report.Attributes.Add("src", "../PDF/" + fileName); report.Attributes.Add("src", "../PDF/" + fileName); //return_BalancheRptForm.Visible = true; }
public void GenerateReportDocument(dynamic reportParam, string reportType, DataTable data) { string dsName = reportParam.DataSetName; ReportViewer2.LocalReport.DataSources.Clear(); ReportViewer2.LocalReport.DataSources.Add(new ReportDataSource(dsName, data)); ReportViewer2.LocalReport.ReportPath = Server.MapPath("~/" + "Report//rpt//" + reportParam.RptFileName); ReportViewer2.DataBind(); ReportViewer2.LocalReport.Refresh(); }
private void showreport() { ReportViewer2.Reset(); DataTable dt = GetData(Int32.Parse(txtid.Text)); ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportViewer2.LocalReport.DataSources.Add(rds); ReportViewer2.LocalReport.ReportPath = "Report1.rdlc"; ReportParameter[] param = new ReportParameter[] { new ReportParameter("id", txtid.Text), new ReportParameter("Dates", txtdt.Text) }; ReportViewer2.LocalReport.SetParameters(param); ReportViewer2.LocalReport.Refresh(); }
private void ShowReportDailyRegistrationStatement(int pMemberID, int pPayTypeID, DateTime frDate, DateTime toDate) { ReportViewer2.Reset(); DataTable dt = GetDailyRegistrationStatement(pMemberID, pPayTypeID, frDate, toDate); ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportViewer2.LocalReport.DataSources.Add(rds); this.ReportViewer2.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "DailyRegistrationStatement.rdlc"; ReportParameter[] parameter = new ReportParameter[] { new ReportParameter("FromDate", frDate.ToString()), new ReportParameter("ToDate", toDate.ToString()) }; ReportViewer2.LocalReport.SetParameters(parameter); ReportViewer2.LocalReport.Refresh(); string PDFPath = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")) + "PDF\\"; Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; String mimeType = null; String encoding = null; String extension = null; Byte[] bytes = null; fileName = "DailyRegistrationStatement" + DateTime.Now.ToFileTime() + ".pdf"; bytes = ReportViewer2.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamids, out warnings); bool IsExitsPDF = File.Exists(PDFPath + fileName); FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); byte[] data = new byte[fs.Length]; fs.Write(bytes, 0, bytes.Length); fs.Close(); PdfLocation = PDFPath + fileName; //report.Attributes.Add("src", "../PDF/" + fileName); report.Attributes.Add("src", "../PDF/" + fileName); //return_BalancheRptForm.Visible = true; }
private async void btnDateSearch_Click(object sender, RoutedEventArgs e) { ReportViewer2.Reset(); if (DPFrom != null && DPTo != null && DPFrom.SelectedDate != null && DPTo.SelectedDate != null) { DateTime beginningDate = DPFrom.SelectedDate.Value.Date; DateTime endingDate = DPTo.SelectedDate.Value.Date; DataTable dt = await Task.Run(() => reportDAL.getDetailedSalesByDate(beginningDate, endingDate)); ReportDataSource ds = new ReportDataSource("DetailedTransactionDataSet", dt); ReportViewer2.LocalReport.DataSources.Add(ds); ReportViewer2.LocalReport.ReportEmbeddedResource = "LoginUI.Report.DetailedTransactionReport.rdlc"; ReportViewer2.RefreshReport(); } else { MessageBox.Show("Please select the date."); } }
protected void ExportToPDF(object sender, EventArgs e) { try { if (DropDownList1.SelectedValue != "") { string fno = "010702"; string fname = "PENGESAHAN MAKLUMAT DIVIDEN"; DataTable dt = new DataTable(); dt = DBCon.Ora_Execute_table("select row_number() OVER (ORDER BY c.kavasan_name,c.Wilayah_Name,branch_desc,mem_centre,mem_new_icno) as Id,a.mem_new_icno,a.mem_name,a.mem_centre,a.mem_sahabat_no,a.mem_address, sum(a.div_debit_amt) div_debit_amt,sha_amt as jumlah,c.kavasan_name,c.Wilayah_Name,c.branch_desc as cawangan_name,a.div_bank_acc_no,c1.Bank_Name from (select mm.mem_new_icno,mm.mem_name,mm.mem_centre,mm.mem_member_no as mem_sahabat_no,mm.mem_address,sum(md.div_debit_amt) as div_debit_amt,sha_amt,mm.mem_region_cd,mm.mem_branch_cd,md.div_batch_name,div_bank_cd,div_bank_acc_no from mem_member mm inner join mem_divident md on md.div_new_icno=mm.mem_new_icno and md.Acc_sts ='Y' where mm.Acc_sts ='Y' group by mem_new_icno,mem_name,mem_centre,mem_member_no,sha_amt,mem_address,mm.mem_region_cd,mm.mem_branch_cd,md.div_batch_name,div_bank_cd,div_bank_acc_no) a left join (select kavasan_name,wilayah_name,cawangan_code branch_cd, cawangan_name branch_desc from Ref_Cawangan rw where Isnull(cawangan_code,'') !='')c on a.mem_branch_cd=c.branch_cd left join (select rnb.Bank_Code,rnb.Bank_Name from Ref_Nama_Bank rnb)c1 on a.div_bank_cd=c1.Bank_Code where a.div_batch_name='" + DropDownList1.SelectedItem.Text + "' group by a.mem_new_icno,a.mem_name,a.mem_centre,a.mem_sahabat_no,sha_amt,a.mem_address,c.kavasan_name,c.Wilayah_Name,c.branch_desc,a.div_bank_acc_no,c1.Bank_Name Order by c.kavasan_name,c.Wilayah_Name,branch_desc,mem_centre,mem_new_icno"); // Reset ReportViewer2.Reset(); List <DataRow> listResult = dt.AsEnumerable().ToList(); listResult.Count(); int countRow = 0; countRow = listResult.Count(); if (countRow != 0) { string Inssql = "insert into cmn_audit_trail(aud_crt_id,aud_crt_dt,aud_txn_cd,aud_txn_desc)values('" + Session["New"].ToString() + "','" + DateTime.Now.ToString() + "','" + fno + "','" + fname + "')"; Status = dbcon.Ora_Execute_CommamdText(Inssql); txtError.Text = ""; //Display Report ReportDataSource rds = new ReportDataSource("DIV_MAK", dt); ReportViewer2.LocalReport.DataSources.Add(rds); //Path ReportViewer2.LocalReport.ReportPath = "keanggotan/Mak_Div.rdlc"; //ToDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); //Parameters ReportParameter[] rptParams = new ReportParameter[] { new ReportParameter("Kelompok", DropDownList1.SelectedItem.Text), new ReportParameter("current_date", DateTime.Now.ToString()) //new ReportParameter("toDate",ToDate .Text ) //new ReportParameter("fromDate",dmula.ToShortDateString() ), //new ReportParameter("toDate",dakhir.ToShortDateString() ) }; ReportViewer2.LocalReport.SetParameters(rptParams); //Refresh ReportViewer2.LocalReport.Refresh(); string filename = string.Format("{0}.{1}", "PENGESAHAN_DIVIDEN_" + DateTime.Now.ToString("ddMMyyyy") + "", "pdf"); ReportViewer2.LocalReport.DisplayName = "PENGESAHAN_DIVIDEN_" + DateTime.Now.ToString("ddMMyyyy"); //} Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer2.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + filename); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } else if (countRow == 0) { txtError.Text = "Rekod tidak dijumpai. Sila pastikan semua maklumat dimasukkan dengan betul."; } } else { ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Sila Pilih Nama Kelompok.',{'type': 'warning','title': 'warning','auto_close': 2000});", true); } } catch (Exception ex) { } }
public void TestRVException() { IReportViewer reportViewer = new ReportViewer2(new FakeStubFileServiceReturnSize(), "TestException"); Assert.Throws <FileNotFoundException>(() => reportViewer.Clean()); }
private void ShowReportBillCollectionSummaryStatement(int pMemberID, DateTime frDate, DateTime toDate, int pPayTypeID) { ReportViewer2.Reset(); DataTable dt = GetMember_CollectionSummary(pMemberID, frDate, toDate, pPayTypeID); ReportDataSource rds = new ReportDataSource("DataSet1", dt); ReportViewer2.LocalReport.DataSources.Add(rds); this.ReportViewer2.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; if (pPayTypeID == 0) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryReport.rdlc"; } if (pPayTypeID == 1) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryCashReport.rdlc"; } if (pPayTypeID == 2) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryChequeReport.rdlc"; } if (pPayTypeID == 3) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryMemberCardReport.rdlc"; } if (pPayTypeID == 4) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryBankCardReport.rdlc"; } if (pPayTypeID == 5) { ReportViewer2.LocalReport.ReportPath = Server.MapPath("/Controls/") + "MemberCollectionSummaryDueReport.rdlc"; } ReportViewer2.LocalReport.Refresh(); string PDFPath = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")) + "PDF\\"; Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; String mimeType = null; String encoding = null; String extension = null; Byte[] bytes = null; fileName = "MemberCollectionSummaryReport" + DateTime.Now.ToFileTime() + ".pdf"; bytes = ReportViewer2.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamids, out warnings); bool IsExitsPDF = File.Exists(PDFPath + fileName); FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); byte[] data = new byte[fs.Length]; fs.Write(bytes, 0, bytes.Length); fs.Close(); PdfLocation = PDFPath + fileName; //report.Attributes.Add("src", "../PDF/" + fileName); report.Attributes.Add("src", "../PDF/" + fileName); //return_BalancheRptForm.Visible = true; }
private void UserControl_LoadedSalesOrder(object sender, RoutedEventArgs e) { SalesOrderForm sqf = _viewModel.PrintSalesOrder(); //this is for table grid DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("PandSCode", typeof(string))); dt.Columns.Add(new DataColumn("PandSName", typeof(string))); dt.Columns.Add(new DataColumn("SOQty", typeof(string))); dt.Columns.Add(new DataColumn("Price", typeof(string))); dt.Columns.Add(new DataColumn("SODiscount", typeof(string))); dt.Columns.Add(new DataColumn("SOAmount", typeof(string))); dt.Columns.Add(new DataColumn("GSTRate", typeof(string))); //ReportingDataset ds = new ReportingDataset(); foreach (var item in sqf.OrderDetails) { DataRow dr = dt.NewRow(); dr["PandSCode"] = item.PandSCode; dr["PandSName"] = item.PandSName; dr["SOQty"] = item.SOQty; dr["Price"] = item.Price.ToString(); dr["SODiscount"] = item.SODiscount; dr["SOAmount"] = item.SOAmount.ToString(); dr["GSTRate"] = item.GSTRate.ToString(); dt.Rows.Add(dr); } ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "SalesOrderDataSet"; // Name of the DataSet we set in .rdlc reportDataSource.Value = dt; // end of product grid code DataTable dt4 = new DataTable(); //for other than table dt4.Columns.Add(new DataColumn("TermsAndConditions", typeof(string))); dt4.Columns.Add(new DataColumn("TotalBeforeTax", typeof(string))); dt4.Columns.Add(new DataColumn("TotalTax", typeof(string))); dt4.Columns.Add(new DataColumn("TotalAfterTax", typeof(string))); dt4.Columns.Add(new DataColumn("SONo", typeof(string))); dt4.Columns.Add(new DataColumn("OrderDate", typeof(string))); dt4.Columns.Add(new DataColumn("CusPoNo", typeof(string))); dt4.Columns.Add(new DataColumn("DeliveryDate", typeof(string))); DataRow dr4 = dt4.NewRow(); dr4["TermsAndConditions"] = sqf.Order.TermsAndConditions; dr4["TotalBeforeTax"] = sqf.Order.TotalAfterTax; dr4["TotalTax"] = sqf.Order.TotalTax.ToString(); dr4["TotalAfterTax"] = sqf.Order.TotalAfterTax.ToString(); dr4["SONo"] = sqf.Order.OrderNo; dr4["OrderDate"] = sqf.Order.OrderDate.Date.ToString("dd/M/yyyy"); dr4["CusPoNo"] = sqf.Order.Cus_Po_No; dr4["DeliveryDate"] = sqf.Order.DeliveryDate.Date.ToString("dd/M/yyyy"); dt4.Rows.Add(dr4); ReportDataSource reportDataSource4 = new ReportDataSource(); reportDataSource4.Name = "SalesOrderUniqueRecordDataSet"; // Name of the DataSet we set in .rdlc reportDataSource4.Value = dt4; // company details /*****Define column*****/ DataTable dt1 = new DataTable(); dt1.Columns.Add(new DataColumn("CompanyName", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyLogo", typeof(byte[]))); dt1.Columns.Add(new DataColumn("CompanyRegNumber", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyGstNumber", typeof(string))); dt1.Columns.Add(new DataColumn("Telephone", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyFax", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyEmail", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine1", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine2", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToCity", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToState", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToCountary", typeof(string))); dt1.Columns.Add(new DataColumn("CompanyBillToPostCode", typeof(string))); /*****End column*****/ /*****data part*******/ DataRow dr1 = dt1.NewRow(); dr1["CompanyName"] = sqf.Order.CompanyName; dr1["CompanyLogo"] = sqf.Order.CompanyLogo; dr1["CompanyRegNumber"] = sqf.Order.CompanyRegNumber; dr1["CompanyGstNumber"] = sqf.Order.CompanyGstNumber; dr1["Telephone"] = sqf.Order.Telephone; dr1["CompanyFax"] = sqf.Order.CompanyFax; dr1["CompanyEmail"] = sqf.Order.CompanyEmail; dr1["CompanyBillToAddressLine1"] = sqf.Order.CompanyBillToAddressLine1; dr1["CompanyBillToAddressLine2"] = sqf.Order.CompanyBillToAddressLine2; dr1["CompanyBillToCity"] = sqf.Order.CompanyBillToCity; dr1["CompanyBillToState"] = sqf.Order.CompanyBillToState; dr1["CompanyBillToCountary"] = sqf.Order.CompanyBillToCountary; dr1["CompanyBillToPostCode"] = sqf.Order.CompanyBillToPostCode; dt1.Rows.Add(dr1); /*****data part*******/ ReportDataSource reportDataSource1 = new ReportDataSource(); reportDataSource1.Name = "CompanyDetailDataSet"; // Name of the DataSet we set in .rdlc reportDataSource1.Value = dt1; // end of company details //Customer Details /****column defn**/ DataTable dt2 = new DataTable(); dt2.Columns.Add(new DataColumn("CustomerName", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddress1", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddress2", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressCity", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressState", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressCountary", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillPostCode", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddress1", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddress2", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressCity", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressState", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressCountary", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipPostCode", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerTelephone", typeof(string))); /****end column defn**/ /**data****/ DataRow dr2 = dt2.NewRow(); dr2["CustomerName"] = sqf.Order.CustomerName; dr2["CustomerBillAddress1"] = sqf.Order.CustomerBillAddress1; dr2["CustomerBillAddress2"] = sqf.Order.CustomerBillAddress2; dr2["CustomerBillAddressCity"] = sqf.Order.CustomerBillAddressCity; dr2["CustomerBillAddressState"] = sqf.Order.CustomerBillAddressState; dr2["CustomerBillAddressCountary"] = sqf.Order.CustomerBillAddressCountary; dr2["CustomerBillPostCode"] = sqf.Order.CustomerBillPostCode; dr2["CustomerShipAddress1"] = sqf.Order.CustomerShipAddress1; dr2["CustomerShipAddress2"] = sqf.Order.CustomerShipAddress2; dr2["CustomerShipAddressCity"] = sqf.Order.CustomerShipAddressCity; dr2["CustomerShipAddressState"] = sqf.Order.CustomerShipAddressState; dr2["CustomerShipAddressCountary"] = sqf.Order.CustomerShipAddressCountary; dr2["CustomerShipPostCode"] = sqf.Order.CustomerShipPostCode; dr2["CustomerTelephone"] = sqf.Order.CustomerTelephone; /**end data****/ dt2.Rows.Add(dr2); ReportDataSource reportDataSource2 = new ReportDataSource(); reportDataSource2.Name = "CustomerDetailsDataSet"; // Name of the DataSet we set in .rdlc reportDataSource2.Value = dt2; //End Customer Details //option DataTable dt3 = new DataTable(); dt3.Columns.Add(new DataColumn("CurrencyCode", typeof(string))); DataRow dr3 = dt3.NewRow(); dr3["CurrencyCode"] = sqf.Order.CurrencyCode; dt3.Rows.Add(dr3); ReportDataSource reportDataSource3 = new ReportDataSource(); reportDataSource3.Name = "OptionsDataSet"; // Name of the DataSet we set in .rdlc reportDataSource3.Value = dt3; //end options string exefolder = System.Windows.Forms.Application.StartupPath; string reportPath = System.IO.Path.Combine(exefolder, @"SalesOrder.rdlc"); ReportViewer2.LocalReport.ReportPath = reportPath; // Path of the rdlc file ReportViewer2.LocalReport.DataSources.Clear(); ReportViewer2.LocalReport.DataSources.Add(reportDataSource); ReportViewer2.LocalReport.DataSources.Add(reportDataSource1); ReportViewer2.LocalReport.DataSources.Add(reportDataSource2); ReportViewer2.LocalReport.DataSources.Add(reportDataSource3); ReportViewer2.LocalReport.DataSources.Add(reportDataSource4); ReportViewer2.RefreshReport(); }
public void showreport() { try { //string fdate = TxtFdate.Text; string fmdate = TxtFdate.Text; DateTime ft = DateTime.ParseExact(fmdate, "dd/mm/yyyy", CultureInfo.InvariantCulture); String fdate = ft.ToString("yyyy-mm-dd"); string todate = TxtTdate.Text; DateTime td = DateTime.ParseExact(todate, "dd/mm/yyyy", CultureInfo.InvariantCulture); String tdate = td.ToString("yyyy-mm-dd"); DateTime dmula; DateTime dakhir; dmula = DateTime.ParseExact(fdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); dakhir = DateTime.ParseExact(tdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); string sts = ddadu.SelectedItem.Value; DateTime today = DateTime.Now; //DataSource DataTable dt = new DataTable(); dmula = today; dakhir = today; // DataTable dt = GetData(DateTime.Parse(datedari), DateTime.Parse(datehingga), nokp, pusat, Caw, Zon, Wil); if ((fdate == "") && (tdate == "")) { dmula = today; dakhir = today; //ToDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); //FromDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); TxtTdate.Text = today.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture); TxtFdate.Text = today.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture); dt = GetData(fdate, tdate, sts); } //date mula ada, date akhir ada else if ((fdate != "") && (tdate != "")) { // dmula = DateTime.ParseExact(datedari, "MM/dd/yyyy", CultureInfo.InvariantCulture); // dakhir = DateTime.ParseExact(datehingga, "MM/dd/yyyy", CultureInfo.InvariantCulture); dmula = DateTime.ParseExact(fdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); dakhir = DateTime.ParseExact(tdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); dt = GetData(fdate, tdate, sts); } //date mula ada, date akhir tiada else if ((fdate != "") && (tdate == "")) { // dmula = DateTime.ParseExact(datedari, "MM/dd/yyyy", CultureInfo.InvariantCulture); dmula = DateTime.ParseExact(fdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); dakhir = today; //ToDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); TxtTdate.Text = today.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture); //("MM/dd/yyyy HH:mm:ss.fff", // CultureInfo.InvariantCulture); dt = GetData(fdate, tdate, sts); } else if ((fdate == "") && (tdate != "")) { dmula = today; // dakhir = DateTime.ParseExact(datehingga, "MM/dd/yyyy", CultureInfo.InvariantCulture); // FromDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); dakhir = DateTime.ParseExact(tdate, "yyyy-mm-dd", CultureInfo.InvariantCulture); TxtFdate.Text = today.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture); //kena add exception error, date akhir tak boleh previous dr date mula dt = GetData(fdate, tdate, sts); } //Reset ReportViewer2.Reset(); List <DataRow> listResult = dt.AsEnumerable().ToList(); listResult.Count(); int countRow = 0; countRow = listResult.Count(); if (countRow != 0) { //txtError.Text = ""; ss1.Visible = true; //Display Report ReportDataSource rds = new ReportDataSource("ADU_CET", dt); ReportViewer2.LocalReport.DataSources.Add(rds); //Path ReportViewer2.LocalReport.ReportPath = "keanggotan/CET_ADU.rdlc"; //ToDate.Text = today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); //Parameters string status; if (ddadu.SelectedItem.Text == "--- PILIH ---") { status = "SEMUA"; } else { status = ddadu.SelectedItem.Text; } ReportParameter[] rptParams = new ReportParameter[] { new ReportParameter("fromDate", TxtFdate.Text), new ReportParameter("toDate", TxtTdate.Text), new ReportParameter("Status", status), new ReportParameter("current_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) }; ReportViewer2.LocalReport.SetParameters(rptParams); //Refresh ReportViewer2.LocalReport.Refresh(); string filename = string.Format("{0}.{1}", "Cetak_Aduan_" + DateTime.Now.ToString("ddMMyyyy") + "", "pdf"); ReportViewer2.LocalReport.DisplayName = "Cetak_Aduan_" + DateTime.Now.ToString("ddMMyyyy"); //} Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer2.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + filename); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } else if (countRow == 0) { ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Tiada Rekod Dijumpai Dalam Julat Tarikh Yang Dimasukkan.',{'type': 'warning','title': 'Warning','auto_close': 2000});", true); //txtError.Text = "Maklumat Carian Tidak Dijumpai"; } } catch (Exception ex) { //txtError.Text = ex.ToString(); } }