コード例 #1
0
        //private void GenerateViewReports()
        //{
        //    frmReportViewer frmReports = new frmReportViewer();
        //    frmReportViewer frmViewWaste = new frmReportViewer();
        //    bool isReports = false;
        //    int nViewWaste = 0;
        //    pf.Visible = true;
        //    pf.Value = 0;
        //    //get the count of selected rows and drop each starting at the dropIndex
        //    if (ultraGrid1.Selected.Rows.Count > 0)
        //    {
        //        pf.Maximum = ultraGrid1.Selected.Rows.Count;
        //        foreach (UltraGridRow aRow in ultraGrid1.Selected.Rows)
        //        {

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

        //            pf.PerformStep();
        //        }
        //    }
        //    else
        //    {
        //        pf.Maximum = ultraGrid1.Rows.Count;
        //        foreach (UltraGridRow aRow in ultraGrid1.Rows)
        //        {

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

        //            pf.PerformStep();
        //        }
        //    }
        //    if (isReports)
        //    {
        //        frmReports.SetTitle(ultraGrid1.Rows[0].Cells["SerieName"].Value.ToString());
        //        frmReports.View();
        //        frmReports.Show();
        //    }
        //    if (nViewWaste > 0)
        //    {
        //        if (nViewWaste > 1)
        //        {
        //            DialogResult result = ShowSavePDF();
        //            if (result == DialogResult.Cancel)
        //                return;
        //            string fileName = this.saveFileDialog1.FileName;
        //            frmViewWaste.ShowPDF(fileName);
        //        }
        //        else
        //        {
        //            frmViewWaste.View();
        //            frmViewWaste.Show();
        //        }
        //    }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //}

        private void btnViewReportSet_Click(object sender, EventArgs e)
        {
            VWA4Common.GlobalSettings.PrintViewReportsProgressCancelled = false;
            try
            {
                //pf = new VWA4Common.ProgressForm();
                //pf.SetupAndShow(this.ParentForm, "Showing 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();
                int             nRows = 0, nReports = 1;

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


                btnViewReportSet.Enabled = false;


                VWA4Common.ProgressDialog.SetLeadin("Report List created");

                VWA4Common.ProgressDialog.SetLeadin("Report List created");
                bool isReports  = false;
                int  nViewWaste = 0;

                double progressTick = (nRows > 0 ? 100 / nRows : 1);
                VWA4Common.ProgressDialog.SetLeadin("Generating Reports");
                try
                {
                    VWA4Common.ProgressDialog.SetStatus("Generating report " + nReports + " of " + nRows, (int)(nReports * progressTick));
                    //get the count of selected rows and drop each starting at the dropIndex
                    if (ultraGrid1.Selected.Rows.Count > 0)
                    {
                        foreach (UltraGridRow aRow in ultraGrid1.Selected.Rows)
                        {
                            if (_progressCancelled)
                            {
                                btnViewReportSet.Enabled = true;
                                return;
                            }
                            VWA4Common.ProgressDialog.SetStatus("Generating report " + nReports + " of " + nRows, (int)(nReports * progressTick));
                            int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                            if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                            {
                                frmViewWaste.AddPDF(id);
                                nViewWaste++;
                            }
                            else
                            {
                                frmReports.AddLoadParameters(id, true);
                                isReports = true;
                            }
                            nReports++;
                        }
                    }
                    else
                    {
                        foreach (UltraGridRow aRow in ultraGrid1.Rows)
                        {
                            if (_progressCancelled)
                            {
                                btnViewReportSet.Enabled = true;
                                return;
                            }
                            VWA4Common.ProgressDialog.SetStatus("Generating report " + nReports + " of " + nRows, (int)(nReports * progressTick));
                            int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                            if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                            {
                                frmViewWaste.AddPDF(id);
                                nViewWaste++;
                            }
                            else
                            {
                                frmReports.AddLoadParameters(id, true);
                                isReports = true;
                            }
                            nReports++;
                        }
                    }
                }
                finally
                {
                    FinishProgress();
                    btnViewReportSet.Enabled = true;
                }
                //FinishProgress();

                //btnViewReportSet.Enabled = true;

                if (isReports)
                {
                    frmReports.SetTitle(ultraGrid1.Rows[0].Cells["SerieName"].Value.ToString());
                    frmReports.View();
                    frmReports.Show();
                }
                if (nViewWaste > 0)
                {
                    if (nViewWaste > 1)
                    {
                        DialogResult result = ShowSavePDF();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                        string fileName = this.saveFileDialog1.FileName;
                        frmViewWaste.ShowPDF(fileName);
                    }
                    else
                    {
                        frmViewWaste.View();
                        frmViewWaste.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (!_IsWeekly)
            {
                //set checkbox in task
                VWA4Common.UtilitiesInstance utils = new VWA4Common.UtilitiesInstance();
                utils.setTaskCheck(DateTime.Parse(VWA4Common.GlobalSettings.StartDateOfSelectedWeek), true, "reviewreports");
            }
        }
コード例 #2
0
ファイル: UCReportSerie.cs プロジェクト: klimkina/CSharp
        private void btnViewReportSet_Click(object sender, EventArgs e)
        {
            SetReportOrder();
            frmReportViewer frmReports   = new frmReportViewer();
            frmReportViewer frmViewWaste = new frmReportViewer();
            bool            isReports    = false;
            int             nViewWaste   = 0;

            this.Cursor = Cursors.WaitCursor;

            bool isWeekly = false;

            //get the count of selected rows and drop each starting at the dropIndex
            foreach (UltraGridRow aRow in ultraGrid1.Selected.Rows)
            {
                isWeekly = Regex.IsMatch(aRow.Cells["SerieName"].Value.ToString(), "weekly", RegexOptions.IgnoreCase);
                if (aRow.Band.Key == "ReportSet")
                {
                    int id = int.Parse(aRow.Cells["ReportMemorized.ID"].Value.ToString());
                    if (aRow.Cells["ReportType"].Value.ToString() == "View Waste")
                    {
                        frmViewWaste.AddPDF(id);
                        nViewWaste++;
                    }
                    else
                    {
                        frmReports.AddLoadParameters(id, isWeekly);
                        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)
                    {
                        if (viewRow["ReportMemorized.ID"].ToString() != "")
                        {
                            int id = int.Parse(viewRow["ReportMemorized.ID"].ToString());
                            if (viewRow["ReportType"].ToString() == "View Waste")
                            {
                                frmViewWaste.AddPDF(id);
                                nViewWaste++;
                            }
                            else
                            {
                                frmReports.AddLoadParameters(id, isWeekly);
                                isReports = true;
                            }
                        }
                    }
                }
            }
            this.Cursor = Cursors.Default;
            if (isReports)
            {
                frmReports.SetTitle(ultraGrid1.Rows[0].Cells["SerieName"].Value.ToString());
                frmReports.View();
                frmReports.Show();
            }
            if (nViewWaste > 0)
            {
                if (nViewWaste > 1)
                {
                    DialogResult result = ShowSavePDF();
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    string fileName = this.saveFileDialog1.FileName;
                    frmViewWaste.ShowPDF(fileName);
                }
                else
                {
                    frmViewWaste.View();
                    frmViewWaste.Show();
                }
            }

            // set task checkboxes
            VWA4Common.UtilitiesInstance utils = new VWA4Common.UtilitiesInstance();
            utils.setTaskCheck(DateTime.Parse(VWA4Common.GlobalSettings.StartDateOfSelectedWeek), true, "reviewreports");
        }