Exemple #1
0
        /// <summary>
        /// 透過異動名冊ID取得異動名冊內學生異動資料List
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static List <StudUpdateRecDoc> StudUpdateRecDocListByID(string ID)
        {
            List <StudUpdateRecDoc> retVal = new List <StudUpdateRecDoc>();
            StudUpdateRecBatchRec   surbr  = DAL.DALTransfer.GetStudUpdateRecBatchRec(ID);

            retVal = surbr.StudUpdateRecDocList;
            return(retVal);
        }
        public ReportSelector(StudUpdateRecBatchRec BRec)
        {
            _BRec = BRec;

            if (_BRec == null)
            {
                return;
            }
        }
Exemple #3
0
        /// <summary>
        /// 產生報表
        /// </summary>
        public void Print()
        {
            // 取得異動名冊畫面上所選擇異動名冊ID
            _SelectBRecID = UpdateRecordModule_KHSH_N.BL.Get.UpdateBatchSelectID();
            // 透過異動名冊ID取得異動名冊
            _SelectBRec = UpdateRecordModule_KHSH_N.BL.Get.StudUpdateRecBatchRecByID(_SelectBRecID);

            try
            {
                ReportSelector rs      = new ReportSelector(_SelectBRec);
                IReportBuilder builder = rs.GetReport() as IReportBuilder;

                if (builder == null)
                {
                    progressBarX1.Value = 0;
                    pnlReport.Visible   = false;
                    FISCA.Presentation.Controls.MsgBox.Show("名冊格式不同,無法列印");
                    return;
                }
                progressBarX1.Value = 0;
                pnlReport.Visible   = true;

                builder.ProgressChanged += new ProgressChangedEventHandler(builder_ProgressChanged);
                builder.Completed       += new RunWorkerCompletedEventHandler(builder_Completed);
                path = Path.Combine(Application.StartupPath, "Reports");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path = Path.Combine(path, _SelectBRec.UpdateType + ".xls");

                if (File.Exists(path))
                {
                    int i = 1;
                    while (true)
                    {
                        string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path);
                        if (!File.Exists(newPath))
                        {
                            path = newPath;
                            break;
                        }
                    }
                }
                try
                {
                    File.Create(path).Close();
                }
                catch
                {
                    SaveFileDialog sd = new SaveFileDialog();
                    sd.Title    = "另存新檔";
                    sd.FileName = Path.GetFileNameWithoutExtension(path) + ".xls";
                    sd.Filter   = "Excel檔案 (*.xls)|*.xls|所有檔案 (*.*)|*.*";
                    if (sd.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            File.Create(sd.FileName);
                            path = sd.FileName;
                        }
                        catch
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }

                builder.BuildReport((XmlElement)_SelectBRec.Content.FirstChild, path);


                // 產生異動名冊的過程,系統佔用之記憶體,回收之
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
            catch (Exception ex)
            {
                FISCA.Presentation.Controls.MsgBox.Show("產生電子報表失敗." + ex.Message);
            }
        }