Example #1
0
        private void btnPrintReportSet_Click(object sender, EventArgs e)
        {
            SetReportOrder();
            //get the count of selected rows and drop each starting at the dropIndex
            this.Cursor = Cursors.WaitCursor;
            frmReportViewer frmReports = new frmReportViewer();
            frmReportViewer frmViewWaste = new frmReportViewer();
            bool            isViewWaste = false, isReports = false;

            foreach (UltraGridRow aRow in ultraGrid1.Selected.Rows)
            {
                if (aRow.Band.Key == "ReportSet")
                {
                    int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                    if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                    {
                        frmViewWaste.AddPrint(id);
                        isViewWaste = true;
                    }
                    else
                    {
                        frmReports.AddPrint(id);
                        isReports = true;
                    }
                }
                else
                {
                    DataView view = _ReportSeries.Tables["ReportSet"].DefaultView;
                    view.RowFilter = "ReportSeries.ID = " + aRow.Cells["ID"].Value;
                    view.Sort      = "Order";
                    foreach (DataRowView viewRow in view)
                    {
                        int id = int.Parse(viewRow["ReportMemorized.ID"].ToString());
                        if (viewRow["ReportType"].ToString() == "View Waste")
                        {
                            frmViewWaste.AddPrint(id);
                            isViewWaste = true;
                        }
                        else
                        {
                            frmReports.AddPrint(id);
                            isReports = true;
                        }
                    }
                }
            }
            this.Cursor = Cursors.Default;
            if (isReports)
            {
                frmReports.Print();
            }
            if (isViewWaste)
            {
                frmViewWaste.Print();
            }
        }
Example #2
0
        private void btnPrintReportSet_Click(object sender, EventArgs e)
        {
            VWA4Common.GlobalSettings.PrintViewReportsProgressCancelled = false;
            //get the count of selected rows and drop each starting at the dropIndex
            //this.Cursor = Cursors.WaitCursor;
            try
            {
                //pf = new VWA4Common.ProgressForm();
                //pf.SetupAndShow(this.ParentForm, "Printing Reports", "Creating Report List...", true, true);
                int pd_left = (this.Left + ParentForm.Left) + this.Width / 2;
                int pd_top  = (this.Top + ParentForm.Top) + this.Height / 2;



                VWA4Common.ProgressDialog.ShowProgressDialog("Looking for Reports' Names.", "", "", pd_left, pd_top);

                frmReportViewer frmReports   = new frmReportViewer();
                frmReportViewer frmViewWaste = new frmReportViewer();

                VWA4Common.ProgressDialog.SetLeadin("Report List created");
                VWA4Common.ProgressDialog.SetLeadin("Report List inited");
                bool isViewWaste = false, isReports = false;

                btnPrintReportSet.Enabled = false;

                int nRows = 0, nReports = 1;

                if (ultraGrid1.Selected.Rows.Count > 0)
                {
                    nRows = ultraGrid1.Selected.Rows.Count;
                }
                else
                {
                    nRows = ultraGrid1.Rows.Count;
                }

                double progressTick = (nRows > 0 ? 100 / nRows : 1);
                VWA4Common.ProgressDialog.SetLeadin("Generating Reports");
                try
                {
                    if (ultraGrid1.Selected.Rows.Count > 0)
                    {
                        foreach (UltraGridRow aRow in ultraGrid1.Selected.Rows)
                        {
                            VWA4Common.ProgressDialog.SetStatus("Generating report " + nReports + " of " + nRows, (int)(nReports * progressTick));
                            if (VWA4Common.ProgressDialog.CancelPressed)
                            {
                                VWA4Common.ProgressDialog.CancelPressed = false;

                                btnPrintReportSet.Enabled = true;
                                return;
                            }

                            int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                            if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                            {
                                frmViewWaste.AddPrint(id);
                                isViewWaste = true;
                            }
                            else
                            {
                                frmReports.AddPrint(id, true);
                                isReports = true;
                            }
                            nReports++;
                        }
                    }
                    else
                    {
                        foreach (UltraGridRow aRow in ultraGrid1.Rows)
                        {
                            VWA4Common.ProgressDialog.SetStatus("Generating report " + nReports + " of " + nRows, (int)(nReports * progressTick));

                            if (VWA4Common.ProgressDialog.CancelPressed)
                            {
                                VWA4Common.ProgressDialog.CancelPressed = false;

                                btnPrintReportSet.Enabled = true;
                                return;
                            }

                            int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                            if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                            {
                                frmViewWaste.AddPrint(id);
                                isViewWaste = true;
                            }
                            else
                            {
                                frmReports.AddPrint(id, true);
                                isReports = true;
                            }
                            nReports++;
                        }
                    }

                    //FinishProgress();
                }
                finally
                {
                    FinishProgress();
                    btnPrintReportSet.Enabled = true;
                }

                //this.Cursor = Cursors.Default;
                if (isReports)
                {
                    frmReports.Print();
                }
                if (isViewWaste)
                {
                    frmViewWaste.Print();
                }
                if (_IsWeekly)
                {
                    //set checkbox in task
                    VWA4Common.UtilitiesInstance utils = new VWA4Common.UtilitiesInstance();
                    utils.setTaskCheck(DateTime.Parse(VWA4Common.GlobalSettings.StartDateOfSelectedWeek), true, "printweeklyreports");
                }
            }
            catch (Exception ex)
            {
                //Note cancellation throws an exception
                MessageBox.Show(ex.Message);
            }
        }