资源描述:
《常用增删改查源码.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、这个是添加的代码usingSystem;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;namespace学生成绩管理系统{publicpartialclassstudentluru:Form{//CurrencyManagercmAmend;//SqlConnectionsqlConnection1=newSqlConnection();publicstudentluru(){InitializeComponent();}privatevoids
2、tudentluru_Load(objectsender,EventArgse){}//录入privatevoidbutton5_Click(objectsender,EventArgse){stringsno=textBox1.Text;stringsname=textBox2.Text;stringssex=textBox3.Text;stringsage=textBox4.Text;stringsclass=textBox5.Text;stringsdept=textBox6.Text;stringsaddress=textBox7.Text;strin
3、gsphone=textBox8.Text;stringsqq=textBox9.Text;if(textBox1.Text==""
4、
5、textBox2.Text==""
6、
7、textBox5.Text==""){if(textBox1.Text==""){MessageBox.Show("学号不能为空","警告提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);textBox1.Focus();return;}if(textBox2.Text==""){MessageBox.Show("姓名不能为空","警
8、告提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);textBox2.Focus();return;}if(textBox5.Text==""){MessageBox.Show("班级不能为空","警告提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);textBox5.Focus();return;}}else{stringconnstr="server=IT32;uid=sa;pwd='sa';database=sc;";try{SqlConnec
9、tionconn=newSqlConnection(connstr);conn.Open();stringsqlinsert="insertintostudentinfovalues('"+sno+"','"+sname+"','"+ssex+"','"+sage+"','"+sclass+"','"+sdept+"','"+saddress+"','"+sphone+"','"+sqq+"')";SqlCommandsc=newSqlCommand(sqlinsert,conn);sc.ExecuteNonQuery();textBox1.Text="";t
10、extBox2.Text="";textBox3.Text="";textBox4.Text="";textBox5.Text="";textBox6.Text="";textBox7.Text="";textBox8.Text="";textBox9.Text="";MessageBox.Show("数据已经添加成功","温馨提示");conn.Close();}catch(Exceptionex){MessageBox.Show(ex.ToString());}}}privatevoidbutton8_Click(objectsender,EventArg
11、se){this.Dispose();}}}这个是查询界面的代码:usingSystem;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;namespace学生成绩管理系统{publicpartialclassstudentchaxun:Form{DataTabledt=newDataTable();stringper;stringsno;CurrencyManagercmAmend;publicstudentchaxun(){Initialize
12、Component();}public