教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 政务民生 >

PROJECT2实习报告(5)

来源:网络收集 时间:2026-01-13
导读: 淮阴工学院PROJECT2实习报告 页 到='\ + comboBox1.Text + \工号=\ + textBox1.Text; SqlCommand cmd = new SqlCommand(Myupdate, con); try { cmd.ExecuteNonQuery(); con.Close(); 第 17 页 共27 textBox3.Text +

淮阴工学院PROJECT2实习报告

到='\ + comboBox1.Text + \工号=\ + textBox1.Text; SqlCommand cmd = new SqlCommand(Myupdate, con); try {

cmd.ExecuteNonQuery(); con.Close();

第 17 页 共27

textBox3.Text + \联系方式 = '\ + textBox5.Text + \性别='\ + radioButton1.Text + \是否签

MessageBox.Show(\修改成功\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch {

MessageBox.Show(\修改错误\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Error); } }

if (radioButton2.Checked == true) {

string Myupdate = \姓名='\ + textBox2.Text + \部门='\ + textBox3.Text + \联系方式 = '\ + textBox5.Text + \性别='\ + radioButton2.Text + \是否签到='\ + comboBox1.Text + \工号=\ + textBox1.Text; SqlCommand cmd = new SqlCommand(Myupdate, con); try {

cmd.ExecuteNonQuery(); con.Close();

MessageBox.Show(\修改成功\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch {

MessageBox.Show(\修改错误\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }

6.5 删除员工数据的实现

通过点击表格中员工数据,点击删除,系统会删除员工,,如图6-7:

淮阴工学院PROJECT2实习报告

第 18 页 共27

图6-7 删除员工界面

部分删除员工的程序代码:

private void shanchu_Click(object sender, EventArgs e)

{

string cnnstr = \; SqlConnection cnn = new SqlConnection(cnnstr); cnn.Open();

int n = dataGridView1.SelectedRows.Count; if (n > 0) {

for (int i = 0; i < n; i++) {

string str = dataGridView1.SelectedRows[i].Cells[0].Value.ToString(); string deletestr = \工号='\ + str + \; SqlCommand delete = new SqlCommand(deletestr, cnn); delete.ExecuteNonQuery(); }

string selectstr = \;

SqlCommand select = new SqlCommand(selectstr, cnn); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = select; DataSet ds = new DataSet(); adapter.Fill(ds);

dataGridView1.DataSource = ds.Tables[0]; adapter.Dispose();

淮阴工学院PROJECT2实习报告

cnn.Close();

MessageBox.Show(\删除成功\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } else {

第 19 页 共27

MessageBox.Show(\请选中要删除的单元\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Error); } }

6.6 查询模块实现

查询模块由3块部分组成,分别是按部门查询部门情况,按工号查询个人,按签到情况查询

通过点击菜单栏中“数据查询”、“考勤情况”,系统会自动弹查询界面。 如图6-8,6-9,6-10:

图6-8 按部门查询部门情况

淮阴工学院PROJECT2实习报告

第 20 页 共27

部分查询的代码如下:

private void button3_Click(object sender, EventArgs e) {

if (bumenchaxun.Text == \) {

MessageBox.Show(\工号不能为空\); } else {

string str = \窦洁颖;Initial Catalog=shuju;Integrated Security=True\;

SqlConnection conn = new SqlConnection(str);

string a = \部门='\ + bumenchaxun.Text + \; SqlDataAdapter sda = new SqlDataAdapter(a, str); DataSet dt = new DataSet();

sda.Fill(dt, \); dataGridView3.DataSource = dt;

dataGridView3.DataSource = dt.Tables[\]; conn.Close(); dt.Dispose(); sda.Dispose(); }

}

淮阴工学院PROJECT2实习报告

第 21 页 共27

图6-9 按工号查询个人情况

部分查询的代码如下:

private void button1_Click(object sender, EventArgs e) {

if (chaxun.Text==\) {

MessageBox.Show(\工号不能为空\); } else {

string str = \窦洁颖;Initial Catalog=shuju;Integrated Security=True\;

SqlConnection conn = new SqlConnection(str);

string a = \工号='\ + chaxun.Text + \; SqlDataAdapter sda = new SqlDataAdapter(a, str); DataSet dt = new DataSet();

sda.Fill(dt, \); dataGridView2.DataSource = dt;

dataGridView2.DataSource = dt.Tables[\]; conn.Close(); dt.Dispose();

…… 此处隐藏:1047字,全部文档内容请下载后查看。喜欢就下载吧 ……
PROJECT2实习报告(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/447062.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)