private void GetInvoiceReportData(DateTime date, int customer) { string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value; using (var dailydb = new OrderEntities()) { //var ds1 = (from x in dailydb.vwCustomerDetail // where x.CustomerID == customer // select x).ToList(); List <GetOrderCustomer_Result> ds1 = null; List <GetOrderbyDay_Result> ds2 = null; ds1 = dailydb.GetOrderCustomer(date, customer, "INV").ToList(); ds2 = dailydb.GetOrderbyDay(date, customer).ToList(); if (ds1.Count() > 0 && ds2.Count() > 0) { string docid = (from c in ds1 select(string) c.DocumentID).FirstOrDefault(); string datestring = HelperCS.DateTextThai(date, "TH", "dd MMM yyyy"); ReportParameter p1 = new ReportParameter("ReportType", ReportName); //ReportParameter p2 = new ReportParameter("Date", RptDatePicker.Value.ToLongDateString()); ReportParameter p2 = new ReportParameter("Date", datestring); ReportParameter p3 = new ReportParameter("BahtText", BahtToText(ds2.Sum(item => item.OrderTotal))); ReportParameter p4 = new ReportParameter("DocumentID", docid); reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 }); CustomerBindingSource.DataSource = null; OrderBindingSource.DataSource = null; CustomerBindingSource.DataSource = HelperCS.ToDataTable(ds1); OrderBindingSource.DataSource = HelperCS.ToDataTable(ds2); ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", CustomerBindingSource); ReportDataSource rtpsource2 = new ReportDataSource("DataSet2", OrderBindingSource); reportViewer1.LocalReport.DataSources.Add(rtpsource1); reportViewer1.LocalReport.DataSources.Add(rtpsource2); } else { CustomerBindingSource.DataSource = null; OrderBindingSource.DataSource = null; } } }
private void GetReceiveWeeklyReportData(DateTime date, int customer, bool showprice) { string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value; using (var dailydb = new OrderEntities()) { List <GetOrderCustomer_Result> ds1 = null; List <GetReceiveWeeklyPrice_Result> ds2 = null; List <GetReceiveWeekly_Result> ds3 = null; ds1 = dailydb.GetOrderCustomer(date, customer, "RCD").ToList(); bool rowno = false; string bahttext = ""; DataTable dtorder; if (showprice) { ds2 = dailydb.GetReceiveWeeklyPrice(date, customer).ToList(); rowno = ds2.Count() > 0 ? true : false; bahttext = rowno ? BahtToText(ds2.Sum(item => item.total)) : ""; dtorder = HelperCS.ToDataTable(ds2); } else { ds3 = dailydb.GetReceiveWeekly(date, customer).ToList(); rowno = ds3.Count() > 0 ? true : false; bahttext = rowno ? BahtToText(ds3.Sum(item => item.total)) : ""; dtorder = HelperCS.ToDataTable(ds3); } //string datestring = HelperCS.DateTextThai(RptDatePicker.Value,"TH","dd MMM yyyy"); string datestring = HelperCS.DateTextThai(DateTime.Now, "TH", "dd MMM yyyy"); if (ds1.Count() > 0 && rowno) { CustomerBindingSource.DataSource = HelperCS.ToDataTable(ds1); OrderBindingSource.DataSource = dtorder; //string sunday = dt.Rows[i].Field<int>(j); DateTime startdate = (from c in ds1 select(DateTime) c.OrderStartDate).FirstOrDefault(); string docid = (from c in ds1 select(string) c.DocumentID).FirstOrDefault(); ReportParameter p1 = new ReportParameter("ReportType", ReportName); ReportParameter p2 = new ReportParameter("Date", datestring); ReportParameter p3 = new ReportParameter("BahtText", bahttext); ReportParameter p4 = new ReportParameter("suntext", HelperCS.DateTextThai(startdate, "TH", "dd-MMM")); ReportParameter p5 = new ReportParameter("montext", HelperCS.DateTextThai(startdate.AddDays(1), "TH", "dd-MMM")); ReportParameter p6 = new ReportParameter("tuetext", HelperCS.DateTextThai(startdate.AddDays(2), "TH", "dd-MMM")); ReportParameter p7 = new ReportParameter("wedtext", HelperCS.DateTextThai(startdate.AddDays(3), "TH", "dd-MMM")); ReportParameter p8 = new ReportParameter("thrtext", HelperCS.DateTextThai(startdate.AddDays(4), "TH", "dd-MMM")); ReportParameter p9 = new ReportParameter("fritext", HelperCS.DateTextThai(startdate.AddDays(5), "TH", "dd-MMM")); ReportParameter p10 = new ReportParameter("sattext", HelperCS.DateTextThai(startdate.AddDays(6), "TH", "dd-MMM")); ReportParameter p11 = new ReportParameter("DocumentID", docid); reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 }); ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", CustomerBindingSource); ReportDataSource rtpsource2 = new ReportDataSource("DataSet2", OrderBindingSource); reportViewer1.LocalReport.DataSources.Add(rtpsource1); reportViewer1.LocalReport.DataSources.Add(rtpsource2); } else { CustomerBindingSource.DataSource = null; OrderBindingSource.DataSource = null; } } }