private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("標題或內容不可為空", "錯誤"); } else { DialogResult result = MessageBox.Show("請仔細檢查內容決定是否送出", "送出確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { UpFile objfile = new UpFile(); objfile.SetFileTitle(textBox1.Text); objfile.SetFileContent(textBox2.Text); objfile.SetUpD(Convert.ToString(DateTime.Today)); objfile.SetUpT(DateTime.Now.ToString("HH:mm ss tt")); if (objfile.InsertUpFile(objfile)) { MessageBox.Show("已成功送出公文:" + textBox1.Text + "\n" + "送出時間:" + Convert.ToString(DateTime.Now), "送出結果" ); textBox1.Text = ""; textBox2.Text = ""; } else { MessageBox.Show("送出公文:" + textBox1.Text + "失敗"); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }