Exemple #1
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime UpToDate = Convert.ToDateTime(dateTimePicker1.Text);
                MCKJ.Reports.Accounts.BalanceSummary.frmReportViewer frm = new frmReportViewer();

                MCKJ.Reports.Accounts.BalanceSummary.rptBalanceSummary rpt = new MCKJ.Reports.Accounts.BalanceSummary.rptBalanceSummary();

                DataTable dt = DBLayer.getTrialBalance(UpToDate);

                for (int i = dt.Rows.Count; i > 0; i--)
                {
                    double balance = Convert.ToDouble(dt.Rows[i - 1].ItemArray.GetValue(4).ToString());
                    if (balance == 0)
                    {
                        dt.Rows.RemoveAt(i - 1);
                    }
                }

                rpt.SetDataSource(dt);

                frm.crystalReportViewer1.ReportSource = rpt;

                rpt.SetParameterValue(0, UpToDate);

                frm.Show();
            }
            catch (FormatException)
            {
                MessageBox.Show("Please enter a valid Date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An unknown error occured!\n\nError Description: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }