예제 #1
0
        static public DisciplineNotificationPreference GetInstance()
        {
            if (mDisciplineNotificationPreference == null)
            {
                mDisciplineNotificationPreference = new DisciplineNotificationPreference();
            }


            return(mDisciplineNotificationPreference);
        }
예제 #2
0
 public DisciplineNotificationConfig(DisciplineNotificationPreference Preference)
 {
     mMinReward           = Preference.MinReward;
     mMinRewardCount      = Preference.Mincount;
     mReceiverType        = Preference.ReceiveName;
     mReceiverAddressType = Preference.ReceiveAddress;
     mStartDate           = Preference.StartDate;
     mEndDate             = Preference.EndDate;
     mPreference          = Preference;
 }
예제 #3
0
        public DemeritNotificatForm()
        {
            InitializeComponent();

            _startDate     = DateTime.Today;
            _endDate       = DateTime.Today;
            textBoxX1.Text = _startDate.ToShortDateString();
            textBoxX2.Text = _endDate.ToShortDateString();

            mDisciplineNotificationPreference = DisciplineNotificationPreference.GetInstance();

            //textBoxX2.Enabled = (mDisciplineNotificationPreference.DateModeRangeMode == DateRangeMode.Custom) ? true : false;

            InitialDateRange();

            textBoxX1.Text = DateTime.Today.ToShortDateString();
            textBoxX2.Text = textBoxX1.Text;
        }
예제 #4
0
        private void SetPreference()
        {
            mDisciplineNotificationPreference = DisciplineNotificationPreference.GetInstance();

            numericUpDown1.Value = mDisciplineNotificationPreference.Mincount;

            //設定是否使用自訂樣版
            if (mDisciplineNotificationPreference.UseDefaultTemplate)
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }

            //設定是否只列印有缺曠記錄學生
            checkBoxX1.Checked = mDisciplineNotificationPreference.PrintHasRecordOnly;

            //設定日期區間
            switch (mDisciplineNotificationPreference.DateModeRangeMode)
            {
            case DateRangeMode.Month:
                radioButton3.Checked = true;
                break;

            case DateRangeMode.Week:
                radioButton4.Checked = true;
                break;

            case DateRangeMode.Custom:
                radioButton5.Checked = true;
                break;

            default:
                throw new Exception("Date Range Mode Error.");
            }

            comboBoxEx1.SelectedIndex = 0;
            comboBoxEx2.SelectedIndex = 0;
            comboBoxEx3.SelectedIndex = 0;

            foreach (DevComponents.Editors.ComboItem var in comboBoxEx3.Items)
            {
                if (var.Text.Equals(mDisciplineNotificationPreference.MinReward))
                {
                    comboBoxEx3.SelectedIndex = comboBoxEx3.Items.IndexOf(var);
                    break;
                }
            }


            //設定收件人姓名
            foreach (DevComponents.Editors.ComboItem var in comboBoxEx1.Items)
            {
                if (var.Text.Equals(mDisciplineNotificationPreference.ReceiveName))
                {
                    comboBoxEx1.SelectedIndex = comboBoxEx1.Items.IndexOf(var);
                    break;
                }
            }

            //設定收件人地址
            foreach (DevComponents.Editors.ComboItem var in comboBoxEx2.Items)
            {
                if (var.Text.Equals(mDisciplineNotificationPreference.ReceiveAddress))
                {
                    comboBoxEx2.SelectedIndex = comboBoxEx2.Items.IndexOf(var);
                    break;
                }
            }
        }
예제 #5
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);
                }
            }
        }