Пример #1
0
        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();
                var ds2 = dailydb.GetOrderbyDay(date, customer).ToList();
                if (ds1.Count() > 0 && ds2.Count() > 0)
                {
                    ReportParameter p1 = new ReportParameter("ReportType", ReportName);
                    ReportParameter p2 = new ReportParameter("Date", RptDatePicker.Value.ToLongDateString());
                    ReportParameter p3 = new ReportParameter("DocumentNo", "INV");
                    ReportParameter p4 = new ReportParameter("BahtText", BahtToText(ds2));

                    reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 });

                    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
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Пример #2
0
        //private void LoadReport()
        //{
        //    reportViewer1.ProcessingMode = ProcessingMode.Local;

        //    //string date = "16/11/2017";
        //    //DateTime dt = Convert.ToDateTime(date);

        //    //GetSalesOrderData(dt,  3);
        //}

        #region GET REPORT DATA
        private void GetSalesOrderData(DateTime date, int customer)
        {
            using (var dailydb = new OrderEntities())
            {
                // Get result from Stored Procedure
                var ds = dailydb.GetOrderbyDay(date, customer).ToList();
                //OrderUC orderUC = new OrderUC();
                if (ds.Count() > 0)
                {
                    OrderBindingSource.DataSource = HelperCS.ToDataTable(ds);
                    ReportDataSource rtpsource = new ReportDataSource("DataSet1", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource);
                }
                else
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Пример #3
0
        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;
                }
            }
        }