Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (allCheck.Checked)
            {
                try
                {
                    //int chkresult = ChkNotes.CheckState == CheckState.Checked ? 1 : 0;

                    DataTable dt = new DataTable();
                    //BoughtLeafBusinessLayer.Reports myReports = new BoughtLeafBusinessLayer.Reports();
                    //myReports.Note = Convert.ToInt32(ChkNotes.CheckState == CheckState.Checked ? 1 : 0).ToString();
                    dt           = myReports.getCashAmountAll(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), ChkNotes.CheckState == CheckState.Checked ? 1 : 0);
                    dt.TableName = "Coin";
                    dt.WriteXml("CoinAnalysis.xml");
                    CoinAnalysisRPT myaclist = new CoinAnalysisRPT();
                    myaclist.SetDataSource(dt);
                    ReportViewer myReportViewer = new ReportViewer();
                    myaclist.SetParameterValue("Company", BoughtLeafBusinessLayer.BLUser.getCompanyName());
                    myaclist.SetParameterValue("Period", "Period : " + cmbYear.Text + " / " + cmbMonth.Text);
                    myaclist.SetParameterValue("Route", "ALL");
                    myReportViewer.crystalReportViewer1.ReportSource = myaclist;
                    myReportViewer.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    DataTable dt = new DataTable();
                    BoughtLeafBusinessLayer.Reports myReports = new BoughtLeafBusinessLayer.Reports();
                    dt = myReports.getCashAmount(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), (cmbRoute.SelectedValue.ToString()), ChkNotes.CheckState == CheckState.Checked ? 1 : 0);
                    //dt.Columns.Add(cmbRoute.Text.ToString());
                    dt.TableName = "Coin";
                    dt.WriteXml("CoinAnalysis.xml");
                    CoinAnalysisRPT myaclist = new CoinAnalysisRPT();
                    myaclist.SetDataSource(dt);
                    ReportViewer myReportViewer = new ReportViewer();
                    myaclist.SetParameterValue("Company", BoughtLeafBusinessLayer.BLUser.getCompanyName());
                    myaclist.SetParameterValue("Period", "Period : " + cmbYear.Text + " / " + cmbMonth.Text);
                    myaclist.SetParameterValue("Route", cmbRoute.Text.ToString());
                    myReportViewer.crystalReportViewer1.ReportSource = myaclist;
                    myReportViewer.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void cmdDisplay_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet dataSetReport = new DataSet();

                if (allCheck.Checked)
                {                     
                    BoughtLeafBusinessLayer.Reports myReports = new BoughtLeafBusinessLayer.Reports();
                    dataSetReport = myReports.getCashPaymentAllList(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()));
                    dataSetReport.WriteXml("CashPaymentAllList.xml");
                    CashPaymentAllListRPT myaclist = new CashPaymentAllListRPT();
                    myaclist.SetDataSource(dataSetReport);
                    ReportViewer myReportViewer = new ReportViewer();
                    myaclist.SetParameterValue("Company", BoughtLeafBusinessLayer.BLUser.getCompanyName());
                    myaclist.SetParameterValue("Period", "Period : " + cmbYear.Text + " / " + cmbMonth.Text);
                    myReportViewer.crystalReportViewer1.ReportSource = myaclist;
                    myReportViewer.Show();

                }
                else
                {
                    BoughtLeafBusinessLayer.Reports myReports = new BoughtLeafBusinessLayer.Reports();
                    dataSetReport = myReports.getCashPaymentList(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), (cmbRoute.SelectedValue.ToString()));
                    dataSetReport.WriteXml("CashPaymentAllList.xml");
                    CashPaymentAllListRPT myaclist = new CashPaymentAllListRPT();
                    myaclist.SetDataSource(dataSetReport);
                    ReportViewer myReportViewer = new ReportViewer();
                    myaclist.SetParameterValue("Company", BoughtLeafBusinessLayer.BLUser.getCompanyName());
                    myaclist.SetParameterValue("Period", "Period : " + cmbYear.Text + " / " + cmbMonth.Text);
                    myReportViewer.crystalReportViewer1.ReportSource = myaclist;
                    myReportViewer.Show();
                }
              

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }