傻大方


首页 > 学习 >

常用|C常用增删改查源码



按关键词阅读: 常用 源码 增删

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(姓名不能为空,警告提示, MessageBoxB 。

4、uttons.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;
trySqlConnection conn = new SqlConnection(connstr);
conn. 。

5、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.Text = ;
textBox3.Text = ;
textBox4.Text = ;
t 。

6、extBox5.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();
这个是查询界面的代码:using System;
using System.ComponentModel;
u 。

7、sing 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 studentchaxun(string k, string s)InitializeComponent();
p 。

8、er = 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 = (CurrencyManager)BindingContextdt;
if (per = 普通用户 )str 。

9、ing 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 SqlConnection(connstr) conn.Open();
DataSet ds = 。

10、 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 studentinfo where sno= + xuehao + elsestring 。

11、 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;
toolStripButton2.Enabled = false;
toolStripButton3.Enabled 。

12、 = true;
toolStripButton4.Enabled = true;
else toolStripButton1.Enabled = true;
toolStripButton2.Enabled = true;
toolStripButton3.Enabled = true;
toolStripButton4.Enabled = true;
/ 首记录private void toolStripButton1_Click(object sender, EventArgs e)cmAmend.Position = 0;
/ 设置为 0. 回到首记录checkstate(cmAmend.Posit 。

13、ion);
/ 上一条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 void toolStripButton4_Click(object sender, EventArgs 。

14、 e)cmAmend.Position = cmAmend.Count - 1;
checkstate(cmAmend.Position);
删除的代码:using System;


稿源:(未知)

【傻大方】网址:/a/2021/0905/0024106971.html

标题:常用|C常用增删改查源码


上一篇:中学生|中学生成长演讲稿

下一篇:幼儿园|幼儿园新年晚会演讲稿