Ejemplo n.º 1
0
 public DisciplineNotificationRecord(StudentRecord student, DisciplineNotificationConfig config)
 {
     mstudent = student;
     mconfig  = config;
 }
Ejemplo n.º 2
0
 public DisciplineNotificationDocument(StudentRecord student, DisciplineNotificationConfig config, DisciplineNotificationTemplate template)
 {
     mstudent  = student;
     mconfig   = config;
     mtemplate = template;
 }
Ejemplo n.º 3
0
        public void ProcessButtonClick()
        {
            DemeritNotificatForm DateRangeForm = new DemeritNotificatForm();

            if (DateRangeForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                mPreference = DisciplineNotificationPreference.GetInstance();
                mconfig     = new DisciplineNotificationConfig(mPreference);
                ProcessDocument();
                try
                {
                    #region 儲存並開啟檔案

                    string reportName = "懲戒通知單";
                    string path       = Path.Combine(Application.StartupPath, "Reports");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    path = Path.Combine(path, reportName + ".doc");

                    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
                    {
                        Document.Save(path, SaveFormat.Doc);
                        System.Diagnostics.Process.Start(path);
                    }
                    catch
                    {
                        SaveFileDialog sd = new SaveFileDialog();
                        sd.Title    = "另存新檔";
                        sd.FileName = reportName + ".doc";
                        sd.Filter   = "Word檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*";
                        if (sd.ShowDialog() == DialogResult.OK)
                        {
                            try
                            {
                                Document.Save(sd.FileName, SaveFormat.AsposePdf);
                            }
                            catch
                            {
                                MessageBox.Show("指定路徑無法存取。", "建立檔案失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                    }
                    #endregion
                }
                catch
                {
                    System.Windows.Forms.MessageBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
            }
        }