傻大方


首页 > 学习 >

常用|C常用增删改查源码( 二 )



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


using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
namespace 学生成绩管理系统public partial class studentshanchu : FormCurrencyManager cmAmend;
public studentshanchu()InitializeComponent( 。

15、);
private void studentshanchu_Load(object sender, EventArgs e)/ TODO: 这行代码将数据加载到表“ studentDataSet.studentinfo ”中 。
您可以根据需要移动或移除它 。
/ 数据绑定string sqlsel = select * from studentinfo ;
DataTable dt = bangding(sqlsel);
cmAmend = (CurrencyManager)BindingContextdt;
DataTable bangding(string sqlsel)string connstr。

16、= 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();
return dt;
private void checkBox1_CheckedChanged(object。

17、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) = DialogResult.OK) string connstr = server=.;
uid=sa;
pw 。

18、d=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.Tablescoust;
SqlCommandBuilder cb = new SqlCommandBui 。

19、lder(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.Close();
修改的代码:using System;
using System.ComponentModel;
using。

20、System.Data;
using System.Drawing;
using System.Text;
namespace 学生成绩管理系统public partial class studentxiugai : Formstring connstr = server=.;
uid=sa;
pwd=sa;
database=sc;
string per;
string sno;
CurrencyManager cmAmend;
public studentxiugai()InitializeComponent();
public studentxiugai(string k,string s)Initiali 。

21、zeComponent();
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;
comboBox1.Enabled = true;
textBox1.Enabled = true;
private void studentxiugai_Load( 。

22、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 = select *from studentinfo where sno= + sno +DataTable dt = bangding(sqlsel);
DataTabl 。

23、e 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();
return dt;
pri 。

24、vate 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.Text;
string sdept = textBox5.Text;
string saddress = textBox6.Text;
string sphone = te 。

25、xtBox7.Text;
string sqq = textBox8.Text;
if (textBox2.Text = | textBox3.Text = | textBox4.Text = |textBox5.Text = )if (textBox2.Text = ) MessageBox.Show(性另U不能为空,温馨提示, MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
textBox2.Focus();
return;
if (textBox3.Text = )MessageBox.Show(年龄不能为空,温馨提示, MessageBoxBu 。

26、ttons.OKCancel,MessageBoxIcon.Error);
textBox3.Focus();
return;
if (textBox4.Text = )MessageBox.Show(班级不能为空,温馨提示, MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
textBox4.Focus();
return;
if (textBox5.Text = )MessageBox.Show( 系别不能为空, 温馨提示 , MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
textBox5.Focus 。

【常用|C常用增删改查源码】27、();
return;
elsestring connstr = server=IT32;
uid=sa;
pwd=sa;
database=sc;


稿源:(未知)

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

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


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

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