private void btnPrintList_Click(object sender, EventArgs e)
        {
            dbSchemaAsDataSet ds = new dbSchemaAsDataSet();                                                      // object of the database schema typical as the source of the report
            SqlDataAdapter    da = new SqlDataAdapter();                                                         // dataadapter used to fill the dataset

            stockStatusReports.rpt_productsAboutToFinish r = new stockStatusReports.rpt_productsAboutToFinish(); // object of the report
            Reports.frm_crRpt f = new Reports.frm_crRpt();                                                       // object of the report viewer form


            // to change the text report headline according to the formsate
            CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader;
            txtReportHeader = r.ReportDefinition.ReportObjects["txtHeadLine"] as TextObject;


            if (fState == formState.productsAboutToFinish)
            {
                DialogResult dr = MessageBox.Show("هل تريد ارفاق المنتجات المنتهية من المخزن ضمن التقرير ؟", "ارفاق المنتجات المنتهية ايضا", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    da = _reportsAndInfo.getLstProductsAboutToFinish(true);
                }
                else if (dr == DialogResult.No)                // did't use if..else bcz the user might press cancel
                {
                    da = _reportsAndInfo.getLstProductsAboutToFinish();
                }

                f.Text = "تقرير المنتجات التي قاربت علي الانتهاء من المخزن";                //change the form title
            }
            else if (fState == formState.outOfStockProducts)
            {
                da     = _reportsAndInfo.getLstOutOfStockProducts();
                f.Text = "تقرير بالمنتجات المنتهية من المخزن";
                txtReportHeader.Text = "تقرير بالمنتجات المنتهية من المخزن";
            }
            else if (fState == formState.inStockProducts)
            {
                da     = _reportsAndInfo.getLstInOfStockProducts();
                f.Text = "تقرير جرد المنتجات الموجودة بالمخزن";
                txtReportHeader.Text = "تقرير جرد المنتجات الموجودة في المخزن";
            }

            da.Fill(ds, "v_get_products_with_details");
            r.Refresh();
            r.SetDataSource(ds);
            f.crystalReportViewer1.ReportSource = r;
            f.Show();
        }
コード例 #2
0
        private void bntPrintBill_Click(object sender, EventArgs e)
        {
            // TODO:
            //
            //جرب تغير الكونكشن بتاعة الداتا بيز


            if (formState == e_formStatus.outProducts)
            {
                Cursor = Cursors.WaitCursor;
                dbSchemaAsDataSet ds = new Emad_Store.dbSchemaAsDataSet();                                         // object of the database schema typical as the source of the report
                SqlDataAdapter    da = new SqlDataAdapter();                                                       // dataadapter used to fill the dataset
                Reports.inOutStockBills.rpt_printSingleBill r = new Reports.inOutStockBills.rpt_printSingleBill(); // object of the report

                da = productsController.getBillReport(Convert.ToInt32(txtNewBillNum.Text));
                da.Fill(ds, "sv_get_all_bills_with_units");
                r.Refresh();
                r.SetDataSource(ds);
                Reports.frm_crRpt f = new Reports.frm_crRpt();                // object of the report viewer form
                f.crystalReportViewer1.ReportSource = r;
                f.Show();
                Cursor = Cursors.Default;


                /*
                 * Cursor = Cursors.WaitCursor;
                 * // instanciate on object of the crystal report (report for printing all products stored in db "stored proc called get all products")
                 * Reports.rpt_printSingleBill rptSingleBill = new Reports.rpt_printSingleBill();
                 * // obj from the form of reports
                 * Views.frm_reports reportsFrm = new Views.frm_reports();
                 *
                 * // refresh the sub report
                 * new Reports.rpt_printSingleBill().Refresh();
                 *
                 * // refresh the report in case if a change has made in the database
                 * rptSingleBill.Refresh();
                 *
                 * rptSingleBill.SetParameterValue("@bill_id", Convert.ToInt32(txtNewBillNum.Text));
                 *
                 * //bind the crystal report to the crystal report viewer on the reports form
                 * reportsFrm.crystalReportViewer1.ReportSource = rptSingleBill;
                 * Cursor = Cursors.Default;
                 * reportsFrm.ShowDialog();
                 */
            }
        }