Пример #1
0
        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());
                    }
                }
            }
        }
Пример #2
0
        public UpFile Retrieveq(string num)
        {
            DBConnect dbconn = new DBConnect();

            dbconn.ConnectDB();
            UpFile objq = new UpFile();

            try
            {
                dbconn.getCmd().CommandText = "SELECT * from FileData WHERE FileNumber = '" + num + "'";
                dbconn.getCmd().CommandType = System.Data.CommandType.Text;
                dbconn.getConn().Open();

                OleDbDataReader reader = dbconn.getCmd().ExecuteReader();
                while (reader.Read())
                {
                    objq.SetFileNumber(reader["FileNumber"].ToString());
                    objq.SetFileTitle(reader["Title"].ToString());
                    objq.SetFileContent(reader["Content"].ToString());
                    objq.SetFileStatus(reader["Status"].ToString());
                    objq.SetFFixContent(reader["FixContent"].ToString());
                    objq.SetUpD(reader["FileDate"].ToString());
                    objq.SetUpT(reader["UpTime"].ToString());
                }
            }

            catch (Exception e)
            {
                System.Console.WriteLine("Error message :" + e.ToString());
            }
            finally
            {
                if (dbconn.getConn() != null)
                {
                    dbconn.getConn().Close();
                }
            }
            return(objq);
        }