private void EnableAllButton(FrontForm form)
 {
     foreach (Control ctl in form.Controls)
     {
         ctl.Enabled = true;
     }
 }
        private void PrepairData(FrontForm form)
        {
            int templateNumber = form.TemplateNumber;

            MemoryStream selectedTemplate = form.Template;

            string text1 = form.Text1;
            string text2 = form.Text2;
            string text3 = form.Text3;

            int custodian = form.Custodian;
            int address   = form.Address;
            int phone     = form.Phone;

            string coreSubjectSign      = form.SignCoreSubject;
            string coreCourseSign       = form.SignCoreCourse;
            string resitSign            = form.SignResit;
            string retakeSign           = form.SignRetake;
            string failedSign           = form.SignFailed;
            string schoolYearAdjustSign = form.SignSchoolYearAdjust;
            string manualAdjustSign     = form.SignManualAdjust;

            string dataType = string.Empty;

            int moralScoreType = form.MoralScoreOption;
            int saveFileType   = form.SaveFileType;

            bgwObject = new object[] {
                selectedTemplate,
                templateNumber,
                text1,
                text2,
                text3,
                custodian,
                address,
                phone,
                coreSubjectSign,
                coreCourseSign,
                resitSign,
                retakeSign,
                failedSign,
                schoolYearAdjustSign,
                manualAdjustSign,
                dataPool,
                saveFileType,
                moralScoreType,
                students
            };
        }
        private void Clicked()
        {
            FrontForm form = new FrontForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                MotherForm.RibbonBarItems["學生", reportPath]["報表"]["成績相關報表"][reportName].Enable = false;
                MotherForm.RibbonBarItems["班級", reportPath]["報表"]["成績相關報表"][reportName].Enable = false;
                DisableAllButton(form);
                //ThreadPool.QueueUserWorkItem(arg =>
                //{
                //    SyncEvent.WaitOne();
                try
                {
                    PrepairData(form);

                    _BGWStudentRecord = new BackgroundWorker();
                    _BGWStudentRecord.WorkerReportsProgress      = true;
                    _BGWStudentRecord.WorkerSupportsCancellation = true;
                    _BGWStudentRecord.DoWork             += new DoWorkEventHandler(_BGWStudentRecord_DoWork);
                    _BGWStudentRecord.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_BGWStudentRecord_RunWorkerCompleted);
                    _BGWStudentRecord.ProgressChanged    += new ProgressChangedEventHandler(_BGWStudentRecord_ProgressChanged);
                    MotherForm.SetStatusBarMessage("學籍表(97學年度入學適用)產生中...");
                    _BGWStudentRecord.RunWorkerAsync();

                    //
                    //SyncEvent = null;
                }
                catch (Exception ex)
                {
                    MsgBox.Show(ex.Message);
                }
                finally
                {
                    _BGWStudentRecord.Dispose();
                    EnableAllButton(form);
                    form.Dispose();
                }
                //});
            }
            //else
            //    _BGWStudentRecord.CancelAsync();
        }
        private void Clicked()
        {
            FrontForm form = new FrontForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                MotherForm.RibbonBarItems["學生", reportPath]["報表"]["成績相關報表"][reportName].Enable = false;
                MotherForm.RibbonBarItems["班級", reportPath]["報表"]["成績相關報表"][reportName].Enable = false;
                DisableAllButton(form);
                //ThreadPool.QueueUserWorkItem(arg =>
                //{
                //    SyncEvent.WaitOne();
                try
                {
                    PrepairData(form);

                    _BGWStudentRecord = new BackgroundWorker();
                    _BGWStudentRecord.WorkerReportsProgress = true;
                    _BGWStudentRecord.WorkerSupportsCancellation = true;
                    _BGWStudentRecord.DoWork += new DoWorkEventHandler(_BGWStudentRecord_DoWork);
                    _BGWStudentRecord.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_BGWStudentRecord_RunWorkerCompleted);
                    _BGWStudentRecord.ProgressChanged += new ProgressChangedEventHandler(_BGWStudentRecord_ProgressChanged);
                    MotherForm.SetStatusBarMessage("學籍表(97學年度入學適用)產生中...");
                    _BGWStudentRecord.RunWorkerAsync();

                    //
                    //SyncEvent = null;

                }
                catch (Exception ex)
                {
                    MsgBox.Show(ex.Message);
                }
                finally
                {
                    _BGWStudentRecord.Dispose();
                    EnableAllButton(form);
                    form.Dispose();
                }
                //});
            }
            //else
            //    _BGWStudentRecord.CancelAsync();
        }
        private void PrepairData(FrontForm form)
        {
            int templateNumber = form.TemplateNumber;

            MemoryStream selectedTemplate = form.Template;

            string text1 = form.Text1;
            string text2 = form.Text2;
            string text3 = form.Text3;

            int custodian = form.Custodian;
            int address = form.Address;
            int phone = form.Phone;

            string coreSubjectSign = form.SignCoreSubject;
            string coreCourseSign = form.SignCoreCourse;
            string resitSign = form.SignResit;
            string retakeSign = form.SignRetake;
            string failedSign = form.SignFailed;
            string schoolYearAdjustSign = form.SignSchoolYearAdjust;
            string manualAdjustSign = form.SignManualAdjust;

            string dataType = string.Empty;

            int moralScoreType = form.MoralScoreOption;
            int saveFileType = form.SaveFileType;

            bgwObject = new object[] {
                selectedTemplate,
                templateNumber,
                text1,
                text2,
                text3,
                custodian,
                address,
                phone,
                coreSubjectSign,
                coreCourseSign,
                resitSign,
                retakeSign,
                failedSign,
                schoolYearAdjustSign,
                manualAdjustSign,
                dataPool,
                saveFileType,
                moralScoreType,
                students
            };
        }
 private void EnableAllButton(FrontForm form)
 {
     foreach (Control ctl in form.Controls)
         ctl.Enabled = true;
 }
 private void DisableAllButton(FrontForm form)
 {
     foreach (Control ctl in form.Controls)
         ctl.Enabled = false;
 }