版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、这个是添加的代码using System;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;namespace 学生成绩管理系统public partial class studentluru : Form/ CurrencyManager cmAmend;/ SqlConnection sqlConnection1 = new SqlConnection();public studentluru()InitializeComponent();private void stu
2、dentluru_Load(object sender, EventArgs e)/ 录入private void button5_Click(object sender, EventArgs e)string sno = textBox1.Text;string sname = textBox2.Text;string ssex = textBox3.Text;string sage = textBox4.Text;string sclass = textBox5.Text;string sdept = textBox6.Text;string saddress = textBox7.Tex
3、t;string sphone = textBox8.Text;string sqq = textBox9.Text;if (textBox1.Text = | textBox2.Text = | textBox5.Text = ) if (textBox1.Text = )MessageBox.Show( 学 号 不 能 为 空 , 警 告 提 示 , MessageBoxButtons.OKCancel, MessageBoxIcon.Error);textBox1.Focus();return;if (textBox2.Text = )MessageBox.Show( 姓 名 不 能 为
4、 空 , 警 告 提 示 , MessageBoxButtons.OKCancel, MessageBoxIcon.Error); textBox2.Focus();return;if (textBox5.Text = )MessageBox.Show( 班 级 不 能 为 空 , 警 告 提 示 , MessageBoxButtons.OKCancel, MessageBoxIcon.Error);textBox5.Focus();return;elsestring connstr = server=IT32;uid=sa;pwd=sa;database=sc;trySqlConnectio
5、n conn = new SqlConnection(connstr); conn.Open();string sqlinsert = insert into studentinfo values( + sno + , + sname+ ,+ ssex + , + sage + , + sclass + , + sdept + , + saddress + ,+ sphone + , + sqq + );SqlCommand sc = new SqlCommand(sqlinsert, conn); sc.ExecuteNonQuery();textBox1.Text = ;textBox2.
6、Text = ;textBox3.Text = ;textBox4.Text = ;textBox5.Text = ;textBox6.Text = ;textBox7.Text = ;textBox8.Text = ;textBox9.Text = ;MessageBox.Show(数据已经添加成功,温馨提示”);conn.Close();catch (Exception ex)MessageBox.Show(ex.ToString();private void button8_Click(object sender, EventArgs e)this.Dispose();这个是查询界面的代
7、码 :using System;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;namespace 学生成绩管理系统public partial class studentchaxun : FormDataTable dt = new DataTable();string per;string sno;CurrencyManager cmAmend;public studentchaxun()InitializeComponent();public studentchaxu
8、n(string k, string s)InitializeComponent();per = k;sno = s;private void studentchaxun_Load(object sender, EventArgs e)/ TODO: 这行代码将数据加载到表“ studentDataSet.studentinfo ”中。您可以根据需 要移动或移除它。/ 数据绑定if (per = 超级用户 )string sqlsel = select * from studentinfo ;DataTable dt = bangding(sqlsel);cmAmend = (Currency
9、Manager)BindingContextdt;if (per = 普通用户 )string sqlsel = select * from studentinfo where sno= + sno + ;DataTable dt = bangding(sqlsel);cmAmend = (CurrencyManager)BindingContextdt;DataTable bangding(string sqlsel)string connstr = server=.;uid=sa;pwd=sa;database=sc;using (SqlConnection conn = new SqlC
10、onnection(connstr)conn.Open();DataSet ds = new DataSet();SqlDataAdapter da = new SqlDataAdapter(sqlsel, conn);da.Fill(ds, coust);DataTable dt = ds.Tablescoust;conn.Close();return dt;private void button1_Click(object sender, EventArgs e)string xuehao = comboBox1.Text;string sqlsel = select * from stu
11、dentinfo where sno= + xuehao + ;elsestring xingming = comboBox2.Text;string sqlsel = select * from studentinfo where sname= + xingming + ; private void radioButton1_CheckedChanged(object sender, EventArgs e)elseprivate void checkstate(int pos)if (pos = 0)toolStripButton1.Enabled = false;toolStripBut
12、ton2.Enabled = false;toolStripButton3.Enabled = true;toolStripButton4.Enabled = true;elsetoolStripButton1.Enabled = true;toolStripButton2.Enabled = true;toolStripButton3.Enabled = true;toolStripButton4.Enabled = true;/ 首记录private void toolStripButton1_Click(object sender, EventArgs e) cmAmend.Positi
13、on = 0;/ 设置为 0. 回到首记录 checkstate(cmAmend.Position);/ 上一条private void toolStripButton2_Click(object sender, EventArgs e) cmAmend.Position-; checkstate(cmAmend.Position);/ 下一条private void toolStripButton3_Click(object sender, EventArgs e) cmAmend.Position+; checkstate(cmAmend.Position);/ 末记录private vo
14、id toolStripButton4_Click(object sender, EventArgs e) cmAmend.Position = cmAmend.Count - 1; checkstate(cmAmend.Position); 删除的代码 : using System;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;namespace 学生成绩管理系统public partial class studentshanchu : FormCurrencyMana
15、ger cmAmend; public studentshanchu()InitializeComponent();private void studentshanchu_Load(object sender, EventArgs e)/ TODO: 这行代码将数据加载到表“ studentDataSet.studentinfo ”中。您可以根据需 要移动或移除它。/ 数据绑定string sqlsel = select * from studentinfo ;DataTable dt = bangding(sqlsel);cmAmend = (CurrencyManager)BindingC
16、ontextdt;DataTable bangding(string sqlsel)string connstr = server=.;uid=sa;pwd=sa;database=sc;using (SqlConnection conn = new SqlConnection(connstr)conn.Open();DataSet ds = new DataSet();SqlDataAdapter da = new SqlDataAdapter(sqlsel, conn);da.Fill(ds, coust);DataTable dt = ds.Tablescoust;conn.Close(
17、);return dt;private void checkBox1_CheckedChanged(object sender, EventArgs e)if (checkBox1.Checked = true) this.Height = 450; else this.Height = 250; private void button1_Click(object sender, EventArgs e)if (MessageBox.Show(”你确定要删除该记录吗,询问, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Dialo
18、gResult.OK)string connstr = server=.;uid=sa;pwd=sa;database=sc;using (SqlConnection conn = new SqlConnection(connstr)conn.Open();DataSet ds = new DataSet();string sqlset = select * from studentinfo;/ 数据集SqlDataAdapter da = new SqlDataAdapter(sqlset, conn);da.Fill(ds, coust); DataTable dt = ds.Tables
19、coust; SqlCommandBuilder cb = new SqlCommandBuilder(da); dt.Rowspos.Delete();da.Update(ds, coust); textBox1.Text = ; textBox2.Text = ; textBox3.Text = ; textBox4.Text = ; textBox5.Text = ; textBox6.Text = ; textBox7.Text = ; textBox8.Text = ; textBox9.Text = ;MessageBox.Show(恭喜你已成功删除,温馨提示); conn.Clo
20、se(); 修改的代码 : using System; using System.ComponentModel; using System.Data;using System.Drawing; using System.Text;namespace 学生成绩管理系统 public partial class studentxiugai : Form string connstr = server=.;uid=sa;pwd=sa;database=sc; string per;string sno;CurrencyManager cmAmend; public studentxiugai() I
21、nitializeComponent(); public studentxiugai(string k,string s) InitializeComponent(); per = k; sno = s;private void checkBox1_CheckedChanged(object sender, EventArgs e) if (checkBox1.Checked = true) /this.Height = 450; comboBox1.Enabled = false; textBox1.Enabled = false;else /this.Height = 250; combo
22、Box1.Enabled = true; textBox1.Enabled = true;private void studentxiugai_Load(object sender, EventArgs e)/ 数据绑定if (per = 超级用户 )string sqlsel = select * from studentinfo order by sno asc ; DataTable dt = bangding(sqlsel);cmAmend = (CurrencyManager)BindingContextdt;if (per = 普通用户 )string sqlsel = selec
23、t *from studentinfo where sno= + sno + ; DataTable dt = bangding(sqlsel);DataTable bangding(string sqlsel)/ string connstr = server=.;uid=sa;pwd=sa;database=sc; using (SqlConnection conn = new SqlConnection(connstr) conn.Open();DataSet ds = new DataSet();SqlDataAdapter da = new SqlDataAdapter(sqlsel
24、, conn); da.Fill(ds, coust);DataTable dt = ds.Tablescoust; conn.Close();return dt;private void button1_Click(object sender, EventArgs e)if (checkBox1.Checked = true)string sno = comboBox1.Text;string sname = textBox1.Text;string sex = textBox2.Text;string age = textBox3.Text;string sclass = textBox4
25、.Text;string sdept = textBox5.Text;string saddress = textBox6.Text;string sphone = textBox7.Text;string sqq = textBox8.Text;if (textBox2.Text = | textBox3.Text = textBox5.Text = )if (textBox2.Text = )MessageBox.Show(性别不能为空,温馨提示 MessageBoxIcon.Error);textBox2.Focus();return;if (textBox3.Text = )MessageBox.Show(年龄不能为空,温馨提示 MessageBoxIcon.Error);textBox3.Focus();return;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年江苏省南通市八校联考初三物理试题下学期期中物理试题含解析
- 云南省红河州弥勒市2026年初三下学期第二次质量调研考试数学试题试卷含解析
- 2026年大学大一(经济学原理)博弈论与策略行为阶段测试试题及答案
- 杨天真谈就业指导
- 急危重症护理学
- 护理课件制作中的技术支持
- 护理实践中的护理计划
- 护理微课堂:护理领导力培养
- 护理学导论教学案例集锦
- 2026五年级数学下册 长方体正方体综合能力训练
- 企业信息咨询服务合同
- 保护性约束课件
- 《消防排烟通风天窗》
- 海南省定安富文金矿矿区污染治理修复项目(修编) 环评报告
- 人教版六年级数学下册全册分层作业设计含答案
- c90温控表说明书
- 肝修补术后的护理查房课件
- 幼儿行为观察概述(一)
- 第二章-临床康复工程学基础
- 文物科技保护简史-潘路课件
- 网络安全外文翻译文献
评论
0/150
提交评论