Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            PDCManagementCR rpt = new PDCManagementCR();

            rpt.Site = this.Site;
            return(rpt);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            /*
             * Getting the min and max of date for parameter
             */

            var dateTimes = dataGridView1.Rows.Cast <DataGridViewRow>()
                            //.Select(x => (DateTime) x.Cells["ColumnName"].Value); //if column type datetime
                            //or
                            .Select(x => Convert.ToDateTime(x.Cells["ChequeDate"].Value));

            var minValue = dateTimes.Min();
            var maxValue = dateTimes.Max();

            //ATM REPORT
            CrystalDecisions.Shared.TableLogOnInfo li;

            //Print Purposes
            using (SqlConnection con = new SqlConnection(global.connectString()))
            {
                con.Open();
                string qry;
                if (str == "")
                {
                    qry = "SELECT TOP 50 * FROM vw_PDCManagementReportV2 ORDER BY ChequeDate,EmpName ASC";
                }
                else
                {
                    qry = str;
                }

                SqlDataAdapter adapter = new SqlDataAdapter(qry, con);

                DataTable dt = new DataTable();
                DataSet   ds = new DataSet();

                PDCFolder.PDCManagementCR cr  = new PDCFolder.PDCManagementCR();
                PDCFolder.PDCReport       rpt = new PDCFolder.PDCReport();

                li = new TableLogOnInfo();

                li.ConnectionInfo.IntegratedSecurity = false;

                adapter.Fill(ds, "vw_PDCManagementReportV2");
                dt = ds.Tables["vw_PDCManagementReportV2"];
                cr.SetDataSource(ds.Tables["vw_PDCManagementReportV2"]);

                if (str != "" && dtChequeDateFrom.Checked == true && dtChequeDateTO.Checked == true)
                {
                    cr.SetParameterValue("pdcDUe", "PDC Due From " + dtChequeDateFrom.Text + " To " + dtChequeDateTO.Text);
                }
                else
                {
                    cr.SetParameterValue("pdcDUe", "PDC Due From " + minValue.ToShortDateString() + " To " + maxValue.ToShortDateString());
                }

                //cr.SetParameterValue("printedBy", Classes.clsUser.Username);
                cr.SetParameterValue("printedBy", "Nikko");

                //cr.SetDatabaseLogon("sa", "SYSADMIN", "192.168.255.176", "PECCI-NEW");
                cr.SetDatabaseLogon(global.username, global.pass, global.datasource, global.initialCatalog);


                rpt.crystalReportViewer1.ReportSource = cr;
                rpt.ShowDialog();
            }
        }