資源簡介
北大青鳥S1題庫
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Data.SqlClient;
namespace?TestOfzhaopm
{
????public?partial?class?AddGoodsForm?:?Form
????{
????????public?AddGoodsForm()
????????{
????????????InitializeComponent();
????????}
????????///?
????????///?清除按鈕,清除所有數據
????????///?
????????///?
????????///?
????????private?void?btnClear_Click(object?sender?EventArgs?e)
????????{
????????????//所有文本框的text屬性都清空
????????????txtname.Text?=?““;
????????????txtstyle.Text?=?““;
????????????txtPower.Text?=?““;
????????????txtMadein.Text?=?““;
????????????txtPrice.Text?=?““;
????????????txtAmount.Text?=?““;
????????}
????????///?
????????///?保存按鈕,單擊保存至數據庫
????????///?
????????///?
????????///?
????????///?
????????private?void?btnSave_Click(object?sender?EventArgs?e)
????????{
????????????if?(validateInput())//驗證非空
????????????{
????????????????string?sql?=?string.Format(“insert?into?applianceinfo?values(‘{0}‘‘{1}‘‘{2}‘‘{3}‘‘{4}‘{5})“?Convert.ToString(txtname.Text.Trim())?Convert.ToString(txtstyle.Text.Trim())?Convert.ToString(txtPower.Text.Trim())?Convert.ToString(txtMadein.Text.Trim())?Convert.ToInt32(txtPrice.Text.Trim())?Convert.ToInt32(txtAmount.Text.Trim()));//插入語句
????????????????try
????????????????{
????????????????????DBHelper.connection.Open();
????????????????????SqlCommand?command?=?new?SqlCommand(sql?DBHelper.connection);
????????????????????int?result?=?command.ExecuteNonQuery();
????????????????????if?(result?==?1)//如果添加數據庫成功
????????????????????{
????????????????????????MessageBox.Show(“保存成功!“?“系統提示“?MessageBoxButtons.OK?MessageBoxIcon.Information);
????????????????????????this.Close();
????????????????????}
????????????????????else
????????????????????{
????????????????????????MessageBox.Show(“數據庫出現異常,請稍后重試“?“系統提示“?MessageBoxButtons.OK?MessageBoxIcon.Information);
????????????????????????this.Close();
????????????????????}
????????????????}
????????????????catch?(Exception?ex)//異常處理塊
????????????????{
????????????????????Console.WriteLine(ex.Message);
????????????????}
????????????????finally
????????????????{
????????????????????DBHelper.connection.Close();
????????????????}
????????????}
????????}
????????///?
????????///?非空驗證方法
????????///?
????????///?
????????private?bool?validateInput()
????????{
????????????if?(txtname.Text?==?““||txtstyle.Text==““||txtPower.Text==““||txtPrice.Text==““||txtMadein.Text==““||txtAmount.Text==““)//任意一個文本框為空
????????????{
????????????????MessageBox.Show(“請輸入所有商品信息!“?“系統提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return?false;
????????????}
????????????//else?if?(Convert.ToInt32(txt
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......????154112??2010-04-17?00:00??S1題庫\10月份測試\S1筆試\10月題.DOC
????.......????477696??2010-03-06?00:00??S1題庫\11月筆試題.doc
????.......?????90112??2010-03-06?00:00??S1題庫\2009-1-10機試試卷.doc
????.......?????94720??2010-03-06?00:00??S1題庫\2009-1-10考試理論試卷.doc
????.......????119808??2010-04-17?00:00??S1題庫\200901\s1-2009-1筆試\2009-1.doc
????.......????304620??2010-04-17?00:00??S1題庫\200901\S1機試\200901S101.jpg
????.......????304152??2010-04-17?00:00??S1題庫\200901\S1機試\200901S102.jpg
????.......????251371??2010-04-17?00:00??S1題庫\200901\S1機試\200901S103.jpg
????.......??????9728??2010-04-17?00:00??S1題庫\200901\S1機試\Thumbs.db
????.......????275479??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B01.jpg
????.......????273929??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B02.jpg
????.......????274410??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B03.jpg
????.......????278078??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B04.jpg
????.......????266602??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B05.jpg
????.......????259541??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B06.jpg
????.......????277889??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B07.jpg
????.......????271979??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B08.jpg
????.......????282352??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B09.jpg
????.......????259123??2010-04-17?00:00??S1題庫\200901\S1筆試\200901S1B10.jpg
????.......?????27136??2010-04-17?00:00??S1題庫\200901\S1筆試\Thumbs.db
????.......????324064??2010-04-17?00:00??S1題庫\200908(機試)\8月機試\1.jpg
????.......????336778??2010-04-17?00:00??S1題庫\200908(機試)\8月機試\2.jpg
????.......????286978??2010-04-17?00:00??S1題庫\200908(機試)\8月機試\3.jpg
????.......?????14848??2010-04-17?00:00??S1題庫\200908(機試)\8月機試\Thumbs.db
????.......????314431??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\1.jpg
????.......????322898??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\2.jpg
????.......????282026??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\3.jpg
????.......????302942??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\4.jpg
????.......????208300??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\5.jpg
????.......?????18944??2010-04-17?00:00??S1題庫\200909(機試)\9月機試\Thumbs.db
............此處省略763個文件信息
評論
共有 條評論