这是当年老师给的例题
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemWindowsForms;
using SystemDataOleDb;
namespace ex12_2
{
public partial class Form1 : Form
{
OleDbConnection myCon ;
OleDbDataAdapter myDA;
DataSet myDS ;
DataTable tab1 = new DataTable();
int n; //当前记录的索引值
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
myCon=new OleDbConnection("Provider=MicrosoftJetOLEDB40; Data Source=学生mdb");
myConOpen();
string s = "select from 成绩";
myDA = new OleDbDataAdapter(s,myCon );
//自动生成SQL命令,以便更新数据源
OleDbCommandBuilder builder = new OleDbCommandBuilder(myDA);
myDS = new DataSet();
myDAFill(myDS, "成绩表");
tab1 = myDSTables["成绩表"];
//MessageBoxShow(tab1RowsCountToString());
if (tab1RowsCount > 0)
{
n = 0;
textBox1Text = tab1Rows[0]["学号"]ToString();
textBox2Text = tab1Rows[0]["姓名"]ToString();
textBox3Text = tab1Rows[0]["成绩"]ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
//单击"后一条"按钮
if (n < tab1RowsCount - 1)
{
n++;
textBox1Text = tab1Rows[n]["学号"]ToString();
textBox2Text = tab1Rows[n]["姓名"]ToString();
textBox3Text = tab1Rows[n]["成绩"]ToString();
}
else
MessageBoxShow("当前记录是最后一条记录");
}
private void button1_Click(object sender, EventArgs e)
{
//单击"前一条"按钮
if (n > 0)
{
n--;
textBox1Text = tab1Rows[n]["学号"]ToString();
textBox2Text = tab1Rows[n]["姓名"]ToString();
textBox3Text = tab1Rows[n]["成绩"]ToString();
}
else
MessageBoxShow("当前记录是第一条记录");
}
private void button3_Click(object sender, EventArgs e)
{
//单击"插入记录"
DataRow dr=tab1NewRow(); //使用tab1的结构生成一个新行
dr["学号"] = textBox5Text;
dr["姓名"] = textBox6Text;
dr["成绩"] = textBox4Text;
tab1RowsAdd(dr); //将新行追加到tab1表的末尾
myDAUpdate(myDS, "成绩表");
n = tab1RowsCount - 1;
textBox1Text = textBox5Text;
textBox2Text = textBox6Text;
textBox3Text = textBox4Text;
}
private void button6_Click(object sender, EventArgs e)
{
//退出
Close();
}
private void button4_Click(object sender, EventArgs e)
{
//删除记录
if(MessageBoxShow("确实要删除当前记录么?","提示",MessageBoxButtonsYesNo)==DialogResultYes)
{
tab1Rows[n]Delete();
myDAUpdate(myDS, "成绩表");
//删除记录后,显示被删记录的下一条记录
if (n < tab1RowsCount - 1)
n++;
else if (n > 0)
n--;
else
{
MessageBoxShow("表中已无记录");
return;
}
textBox1Text = tab1Rows[n]["学号"]ToString();
textBox2Text = tab1Rows[n]["姓名"]ToString();
textBox3Text = tab1Rows[n]["成绩"]ToString();
}
}
private void button5_Click(object sender, EventArgs e)
{
//更新记录
tab1Rows[n]["学号"] = textBox1Text;
tab1Rows[n]["姓名"] = textBox2Text;
tab1Rows[n]["成绩"] = textBox3Text;
myDAUpdate(myDS, "成绩表");
}
private void button7_Click(object sender, EventArgs e)
{
//按姓名查找
myDSClear();
OleDbCommand com1=new OleDbCommand();
com1CommandText= "select from 成绩 where 姓名='" + textBox7Text + "'";
com1Connection = myCon;
myDASelectCommand = com1;
myDAFill(myDS, "成绩表");
tab1 = myDSTables["成绩表"];
if (tab1RowsCount > 0)
{
n = 0;
textBox1Text = tab1Rows[0]["学号"]ToString();
textBox2Text = tab1Rows[0]["姓名"]ToString();
textBox3Text = tab1Rows[0]["成绩"]ToString();
}
else
MessageBoxShow("查无此人");
}
private void button8_Click(object sender, EventArgs e)
{
//重新显示
myDSClear();
OleDbCommand com1 = new OleDbCommand();
com1CommandText = "select from 成绩";
com1Connection = myCon ;
myDASelectCommand = com1;
myDAFill(myDS, "成绩表");
tab1 = myDSTables["成绩表"];
if (tab1RowsCount > 0)
{
n = 0;
textBox1Text = tab1Rows[0]["学号"]ToString();
textBox2Text = tab1Rows[0]["姓名"]ToString();
textBox3Text = tab1Rows[0]["成绩"]ToString();
}
}
}
}
这个简单:
网上有免费的天气接口:WebService
写个程序,调用WebService ,给你返回一个数组,数组里面就是你需要的结果。
>
以上就是关于求一个c#做的winform 小程序全部的内容,包括:求一个c#做的winform 小程序、winform本人小白 这两天需要一个能获取天气的小程序,难求啊 各种求人 问度娘、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)