资源简介
北大青鸟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个文件信息
评论
共有 条评论