c常用增删改查源码Word格式文档下载.docx

上传人:b****2 文档编号:799997 上传时间:2023-04-29 格式:DOCX 页数:17 大小:16.45KB
下载 相关 举报
c常用增删改查源码Word格式文档下载.docx_第1页
第1页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第2页
第2页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第3页
第3页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第4页
第4页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第5页
第5页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第6页
第6页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第7页
第7页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第8页
第8页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第9页
第9页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第10页
第10页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第11页
第11页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第12页
第12页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第13页
第13页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第14页
第14页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第15页
第15页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第16页
第16页 / 共17页
c常用增删改查源码Word格式文档下载.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

c常用增删改查源码Word格式文档下载.docx

《c常用增删改查源码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《c常用增删改查源码Word格式文档下载.docx(17页珍藏版)》请在冰点文库上搜索。

c常用增删改查源码Word格式文档下载.docx

stringssex=textBox3.Text;

stringsage=textBox4.Text;

stringsclass=textBox5.Text;

stringsdept=textBox6.Text;

stringsaddress=textBox7.Text;

stringsphone=textBox8.Text;

stringsqq=textBox9.Text;

if(textBox1.Text=="

"

||textBox2.Text=="

||textBox5.Text=="

MessageBox.Show("

学号不能为空"

"

警告提示"

MessageBoxButtons.OKCancel,MessageBoxIcon.Error);

textBox1.Focus();

return;

if(textBox2.Text=="

姓名不能为空"

textBox2.Focus();

if(textBox5.Text=="

班级不能为空"

textBox5.Focus();

else

stringconnstr="

server=IT32;

uid=sa;

pwd='

sa'

;

database=sc;

try

SqlConnectionconn=newSqlConnection(connstr);

conn.Open();

stringsqlinsert="

insertintostudentinfovalues('

+sno+"

'

'

+sname+"

+ssex+"

+sage+"

+sclass+"

+sdept+"

+saddress+"

+sphone+"

+sqq+"

)"

SqlCommandsc=newSqlCommand(sqlinsert,conn);

sc.ExecuteNonQuery();

textBox1.Text="

textBox2.Text="

textBox3.Text="

textBox4.Text="

textBox5.Text="

textBox6.Text="

textBox7.Text="

textBox8.Text="

textBox9.Text="

数据已经添加成功"

温馨提示"

);

conn.Close();

catch(Exceptionex)

MessageBox.Show(ex.ToString());

privatevoidbutton8_Click(objectsender,EventArgse)

this.Dispose();

这个是查询界面的代码:

usingSystem.Collections.Generic;

publicpartialclassstudentchaxun:

DataTabledt=newDataTable();

stringper;

stringsno;

CurrencyManagercmAmend;

publicstudentchaxun()

publicstudentchaxun(stringk,strings)

per=k;

sno=s;

privatevoidstudentchaxun_Load(objectsender,EventArgse)

//TODO:

这行代码将数据加载到表“studentDataSet.studentinfo”中。

您可以根据需要移动或移除它。

//数据绑定

if(per=="

超级用户"

stringsqlsel="

select*fromstudentinfo"

DataTabledt=bangding(sqlsel);

cmAmend=(CurrencyManager)BindingContext[dt];

普通用户"

select*fromstudentinfowheresno='

"

DataTablebangding(stringsqlsel)

server=.;

pwd=sa;

database=sc"

using(SqlConnectionconn=newSqlConnection(connstr))

DataSetds=newDataSet();

SqlDataAdapterda=newSqlDataAdapter(sqlsel,conn);

da.Fill(ds,"

coust"

DataTabledt=ds.Tables["

];

returndt;

privatevoidbutton1_Click(objectsender,EventArgse)

stringxuehao=comboBox1.Text;

+xuehao+"

stringxingming=comboBox2.Text;

select*fromstudentinfowheresname='

+xingming+"

privatevoidradioButton1_CheckedChanged(objectsender,EventArgse)

privatevoidcheckstate(intpos)

if(pos==0)

toolStripButton1.Enabled=false;

toolStripButton2.Enabled=false;

toolStripButton3.Enabled=true;

toolStripButton4.Enabled=true;

toolStripButton1.Enabled=true;

toolStripButton2.Enabled=true;

//首记录

privatevoidtoolStripButton1_Click(objectsender,EventArgse)

cmAmend.Position=0;

//设置为0.回到首记录

checkstate(cmAmend.Position);

//上一条

privatevoidtoolStripButton2_Click(objectsender,EventArgse)

cmAmend.Position--;

//下一条

privatevoidtoolStripButton3_Click(objectsender,EventArgse)

cmAmend.Position++;

//末记录

privatevoidtoolStripButton4_Click(objectsender,EventArgse)

cmAmend.Position=cmAmend.Count-1;

删除的代码:

publicpartialclassstudentshanchu:

publicstudentshanchu()

privatevoidstudentshanchu_Load(objectsender,EventArgse)

privatevoidcheckBox1_CheckedChanged(objectsender,EventArgse)

if(checkBox1.Checked==true)

{this.Height=450;

}

{this.Height=250;

if(MessageBox.Show("

你确定要删除该记录吗"

询问"

MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)

stringsqlset="

select*fromstudentinfo"

//数据集

SqlDataAdapterda=newSqlDataAdapter(sqlset,conn);

SqlCommandBuildercb=newSqlCommandBuilder(da);

dt.Rows[pos].Delete();

da.Update(ds,"

恭喜你已成功删除"

"

修改的代码:

usingSystem.Data.SqlClient;

publicpartialclassstudentxiugai:

publicstudentxiugai()

publicstudentxiugai(stringk,strings)

{//this.Height=450;

comboBox1.Enabled=false;

textBox1.Enabled=false;

{//this.Height=250;

comboBox1.Enabled=true;

textBox1.Enabled=true;

privatevoidstudentxiugai_Load(objectsender,EventArgse)

select*fromstudentinfoorderbysnoasc"

select*fromstudentinfowheresno='

//stringconnstr="

stringsno=comboBox1.Text;

stringsname=textBox1.Text;

stringsex=textBox2.Text;

stringage=textBox3.Text;

stringsclass=textBox4.Text;

stringsdept=textBox5.Text;

stringsaddress=textBox6.Text;

stringsphone=textBox7.Text;

stringsqq=textBox8.Text;

||textBox3.Text=="

||textBox4.Text=="

性别不能为空"

if(textBox3.Text=="

年龄不能为空"

textBox3.Focus();

if(textBox4.Text=="

textBox4.Focus();

系别不能为空"

stringsqlupdate="

updatestudentinfosetssex='

+sex+"

sage='

+age+"

sclass='

sdept='

saddress='

sphone='

sqq='

wheresno='

SqlCommandsc=newSqlCommand(sqlupdate,conn);

数据已经修改成功"

MessageBox.Show

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2