




已阅读5页,还剩37页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
项目目的:实现数据的录入、存储。应用的软件:VS2010、SQL首先界面设计:然后在SQL中建立自己的数据库,并添加一个表进去,代码如下create database SC_YFTest03on( name=sc_yftest02, filename=C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAsc_yftest03.mdf, size=10, maxsize=50, filegrowth=5)log on (name=sctest03, filename=C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAsctest03.ldf, size=10, maxsize=50, filegrowth=5 )create table Table_Employee3( num int not null, name nvarchar(10) not null, usedname nvarchar(10) null, sex nvarchar(5) null, state_ nvarchar(6) null, entrytime datetime null, gotime datetime null, retirement datetime null, birthday datetime null, nation nvarchar(5) null, IDnum nvarchar(29) null, phonenum nvarchar(11) null, phone nvarchar(11) null, political nvarchar(10) null, marriage nvarchar(10) null, health nvarchar(10) null, faddress nvarchar(80) null, naddress nvarchar(80) null, postnum nvarchar(10) null, Email nvarchar(50) null, effective nvarchar(10) null, remakers text null, gettime datetime null )在datagridview控件中添加进去的数据可以在数据库中查询,结果如下select *from Table_Employee3代码部分:首先建立一个类,放置人员的一些共有的性质。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace mod public class cls_Employee private string _num; private string _name; private string _usedname; private string _sex; private string _programID; private string _postID; private string _state; private string _entrytime; private string _gotime; private string _retirement; private string _birthday; private string _nation; private string _IDnum; private string _phonenum; private string _phone; private string _political; private string _marriage; private string _health; private string _faddress; private string _naddress; private string _postnum; private string _Email; private string _effective; private string _remakers; public cls_Employee() public string num get return _num; set _num = value; public string name get return _name; set _name = value; public string usedname get return _usedname; set _usedname = value; public string sex get return _sex; set _sex = value; public string programID get return _programID; set _programID = value; public string postID get return _postID; set _postID = value; public string states get return _state; set _state = value; public string entrytime get return _entrytime; set _entrytime = value; public string gotime get return _gotime; set _gotime = value; public string retirement get return _retirement; set _retirement = value; public string birthday get return _birthday; set _birthday = value; public string nation get return _nation; set _nation = value; public string IDnum get return _IDnum; set _IDnum = value; public string phonenum get return _phonenum; set _phonenum = value; public string phone get return _phone; set _phone = value; public string political get return _political; set _political = value; public string marriage get return _marriage; set _marriage = value; public string health get return _health; set _health = value; public string faddress get return _faddress; set _faddress = value; public string naddress get return _naddress; set _naddress = value; public string postnum get return _postnum; set _postnum = value; public string Email get return _Email; set _Email = value; public string effective get return _effective; set _effective = value; public string remakers get return _remakers; set _remakers = value; 然后是窗体部分的代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using mod;namespace WindowsFormsApplication5 public partial class Form1 : Form cls_Employee r = new cls_Employee(); int i; public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) /添加信?息按钮 this.panel2.Visible = true; i = 0; /点?击面?板?2显?示? private void button2_Click(object sender, EventArgs e) /修T改?信?息按钮,显?示?面?板?2 this.panel2.Visible = true; i+; /判D断?点?击的?是?修T改?按钮吗e private void button3_Click(object sender, EventArgs e) /删?除y信?息按钮 if (MessageBox.Show(是?否?删?除y当nr前选?择?的?数y据Y??, 提示?, MessageBoxButtons.YesNo,MessageBoxIcon.Warning) = DialogResult.Yes) string sSQL = delete from Table_Employee3 where num= + + r.num + + and name= + + + + and usedname= + + r.usedname + + and sex= + + r.sex + + and states= + + r.states + + and entrytime= + + r.entrytime + + and gotime= + + r.gotime + + and retirement= + + r.retirement + + and birthday= + + r.birthday + + and nation= + + r.nation + + and IDnum= + + r.IDnum + + and phonenum= + + r.phonenum + + and phone= + + r.phone + + and political= + + r.political + + and marriage= + + r.marriage + + and health= + + r.health + + and faddress= + + r.faddress + + and naddress= + + r.naddress + + and Email= + + r.Email + + and effective= + + r.effective + +and remakers like + + r.remakers + + and postnum= + + r.postnum + ; sHelper.SQLHelper Heper = new sHelper.SQLHelper(); int jj=Heper.ExecuteNonQuery(sSQL); if (jj 0) MessageBox.Show(删?除y成功|); else MessageBox.Show(删?除y失败); this.dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index); /删?除y选?定的?行D private void button4_Click(object sender, EventArgs e) /确定添加信?息按钮 r.num = textBox1.Text; = textBox2.Text; r.usedname = textBox3.Text; r.sex = comboBox1.Text; gramID = comboBox2.Text; r.postID = comboBox3.Text; r.states=comboBox4.Text; r.entrytime=dateTimePicker1.Value.ToString(); r.gotime = dateTimePicker2.Value.ToString(); r.retirement = dateTimePicker4.Value.ToString(); r.birthday = dateTimePicker5.Value.ToString(); r.nation = comboBox9.Text; r.IDnum = textBox5.Text; r.phonenum = textBox6.Text; r.phone = textBox7.Text; r.political=comboBox8.Text; r.marriage=comboBox5.Text; r.health=comboBox6.Text; r.faddress=textBox10.Text; r.naddress=textBox11.Text; r.postnum=textBox12.Text; r.Email=textBox13.Text; r.effective=comboBox7.Text; r.remakers= textBox9.Text; if (i = 0) /用?确定添加信?息的?那?个?按钮加行D DataGridViewRow row = new DataGridViewRow(); this.dataGridView1.Rows.Add( r.num, , r.usedname, r.sex, gramID, r.postID, r.states, r.entrytime, r.gotime, r.retirement, r.birthday, r.nation, r.IDnum, r.phonenum, r.phone, r.political, r.marriage, r.health, r.faddress, r.naddress, r.postnum, r.Email, r.effective, r.remakers); string sSQL = insert into Table_Employee3 /向数y据Y库a中D增?加一?行D + (num,name,usedname,sex,states,entrytime,gotime,retirement + ,birthday,nation,IDnum ,phonenum,phone,political,marriage,health + ,faddress, naddress,postnum,Email,effective,remakers,gettime) + values( + r.num + , + + , + r.usedname + , + r.sex + , + r.states + , + r.entrytime + , + r.gotime + , + r.retirement + , + r.birthday + , + r.nation + , + r.IDnum + , + r.phonenum + , + r.phone + , + r.political + , + r.marriage + , + r.health + , + r.faddress + , + r.naddress + , + r.postnum + , + r.Email + , + r.effective + , + r.remakers + ,GETDATE(); sHelper.SQLHelper Heper = new sHelper.SQLHelper();/注意a此?处|怎?么写的? int jj = Heper.ExecuteNonQuery(sSQL); if (jj 0) MessageBox.Show(添加成功|); else MessageBox.Show(添加失败); if (i 0) / 修T改?信?息 if (MessageBox.Show(是?否?修T改?当nr前选?择?的?数y据Y??, 提示?, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes) this.dataGridView1.CurrentRow.SetValues ( r.num, , r.usedname, r.sex, gramID, r.postID, r.states, r.entrytime, r.gotime, r.retirement, r.birthday, r.nation, r.IDnum, r.phonenum, r.phone, r.political, r.marriage, r.health, r.faddress, r.naddress, r.postnum, r.Email, r.effective, r.remakers ); string sSQL = update Table_Employee3 set num= + + r.num + /修T改?表中D的?某3个?数y据Y + , + name= + + + + , + usedname= + + r.usedname + + , + sex= + + r.sex + + , + states= + + r.states + + , + entrytime= + + r.entrytime + + , + gotime= + + r.gotime + + , + retirement= + + r.retirement + + , + birthday= + + r.birthday + + , + nation= + + r.nation + + , + IDnum= + + r.IDnum + + , + phonenum= + + r.phonenum + + , + phone= + + r.phone + + , + political= + + r.political + + , + marriage= + + r.marriage + + , + health= + + r.health + + , + faddress= + + r.faddress + + , + naddress= + + r.naddress + + , + postnum= + + r.postnum + + , + Email= + + r.Email + + , + effective= + + r.effective + + , + remakers= + + r.remakers + + where num= + + r.num + ; /* + and name= + + + ; +and usedname= + + r.usedname + + and sex= + + r.sex + + and states= + + r.states + + and entrytime= + + r.entrytime + + and gotime= + + r.gotime + + and retirement= + + r.retirement + + and birthday= + + r.birthday + + and nation= + + r.nation + + and IDnum= + + r.IDnum + + and phonenum= + + r.phonenum + + and phone= + + r.phone + + and political= + + r.political + + and marriage= + + r.marriage + + and health= + + r.health + + and faddress= + + r.faddress + + and naddress= + + r.naddress + + and Email= + + r.Email + + and effective= + + r.effective + + and remakers like + + r.remakers + + and postnum= + + r.postnum + ;*/ sHelper.SQLHelper Heper = new sHelper.SQLHelper(); int j = Heper.ExecuteNonQuery(sSQL); if (j 0) MessageBox.Show(修T改?成功|,提示?); else MessageBox.Show(修T改?失败); i = 0; private void button5_Click(object sender, EventArgs e) /取?消?面?板?2按钮,并清?空?;? = r.usedname = r.sex = r.states =r.entrytime =r.phone = r.gotime = r.retirement=r.Email = r.effective = r.remakers = r.birthday= r.nation = r.naddress =r.political = r.marriage = r.health = r.faddress =r.IDnum=r.postnum = ; gramID = r.postID =r.num = r.phonenum = ; this.textBox1.Text = this.textBox2.Text = this.textBox3.Text = this.textBox5.Text = this.textBox6.Text =
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO/IEC 29110-3-2:2018/AMD1:2025 EN Systems and software engineering - Lifecycle profiles for Very Small Entities (VSEs) - Part 3-2: Conformity certification scheme - Amendm
- 课件模板人物高清
- 综合材料手工培训大纲
- 高考成语教学课件
- 保险新人培训会
- 沃尔玛防损培训
- 广东会计制度自考试题及答案
- 广东国贸自考试题及答案
- 兰州法院考试题及答案
- 课二考试题及答案
- ECE-R90-欧盟第3版-中文版(R090r3e-01)
- 2023学年武汉市武昌区九年级语文上学期期中检测试卷附答案
- 渠道衬砌施工方案(渠道预制混凝土块)
- 不交社保劳动合同模板
- 2024年云南省中考数学试题(含答案)
- GB 14102.1-2024防火卷帘第1部分:通用技术条件
- 越野跑策划方案
- 《光学含沙量测量仪率定规范》
- 产值计算方案
- 冬季抢工措施方案
- 运用PDCA循环降低急诊科医护人员职业暴露发生率
评论
0/150
提交评论