public frmFAQ_SingleForm(UDT.CSFaq CSFaq)
 {
     InitializeComponent();
     this.CSFaq = CSFaq;
     Access = new AccessHelper();
     this.ErrorProvider = new ErrorProvider();
     this.Load += new EventHandler(frmFAQ_SingleForm_Load);
 }
        private void Save_Click(object sender, EventArgs e)
        {
            if (!this.Validated())
            {
                MessageBox.Show("請修正錯誤再儲存。");
                return;
            }
            if (this.CSFaq == null)
                this.CSFaq = new UDT.CSFaq();

            List<UDT.CSFaq> CSFaqs = Access.Select<UDT.CSFaq>();

            if (string.IsNullOrEmpty(this.CSFaq.UID))
            {
                if (CSFaqs.Where(x => (x.Title.Trim() == this.txtTitle.Text.Trim())).Count() > 0)
                {
                    MessageBox.Show("相同標題之注意事項或問答已存在。");
                    return;
                }
                if (CSFaqs.Where(x => (x.Item.ToString() == this.txtItem.Text.Trim() && x.Category == this.cboCategory.Items[this.cboCategory.SelectedIndex].ToString())).Count() > 0)
                {
                    MessageBox.Show("相同題號之注意事項或問答已存在。");
                    return;
                }
            }
            else
            {
                if (CSFaqs.Where(x => (x.Title.Trim() == this.txtTitle.Text.Trim() && x.UID != this.CSFaq.UID)).Count() > 0)
                {
                    MessageBox.Show("相同標題之注意事項或問答已存在。");
                    return;
                }
                if (CSFaqs.Where(x => (x.Item.ToString() == this.txtItem.Text.Trim() && x.Category == this.cboCategory.Items[this.cboCategory.SelectedIndex].ToString() && x.UID != this.CSFaq.UID)).Count() > 0)
                {
                    MessageBox.Show("相同題號之注意事項或問答已存在。");
                    return;
                }
            }
            this.CSFaq.Category = (this.cboCategory.SelectedIndex == 1 ? "選課注意事項" : "選課問答");
            this.CSFaq.Item = int.Parse(this.txtItem.Text.Trim());
            this.CSFaq.Title = this.txtTitle.Text.Trim();
            this.CSFaq.Content = this.txtContent.Text.Trim();

            this.CSFaq.Save();
            UDT.DeliverCSFaqEventArgs ee = new UDT.DeliverCSFaqEventArgs(new List<UDT.CSFaq>(){ this.CSFaq });
            UDT.CSFaq.RaiseAfterUpdateEvent(this, ee);
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }