源代码(C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
/// <summary>
/// condb 的摘要说明
/// </summary>
///
public partial class Form1 : Form
{
public DataTable table=new DataTable();
public string str = "";
public int flag = 0;
public int b5_flag = 1;
public int b5_show = 0;
public string last_str="a";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
String conectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb";
OleDbConnection con = new OleDbConnection(conectionString);//"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb");
string strcmd="select * from words";
DataSet myDataset=new DataSet();
con.Open();
OleDbDataAdapter myConmand = new OleDbDataAdapter(strcmd, conectionString);//"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb");
myConmand.Fill(myDataset,"words");
//DataTable table = new DataTable();
table = myDataset.Tables["words"];
//table.Rows.Count.ToString();
//DataRow dr = myDataset.Tables["words"].NewRow();
//dr["En"] = "hello";
//dr["Ch"] = "测试ai";
//myDataset.Tables["words"].Rows.Add(dr);
//DataTable tbl = new DataTable("newTables");
//myDataset.Tables.Add(tbl);
OleDbCommandBuilder cb = new OleDbCommandBuilder(myConmand);//这一句很伤人!!!
myConmand.Update(myDataset,"words");
///////////MessageBox.Show("success");
string flag = textBox2.Text;
//int len = Convert.ToInt16(flag);
if (flag == "")
{
MessageBox.Show("please input.....");
flag = textBox2.Text;
// len = Convert.ToInt16(flag);
}
//textBox1.Paste();
int sum = Int32.Parse(table.Rows.Count.ToString());
str = "";
for (int i = 0; i < sum; i++)
if (table.Rows[i]["En"].ToString()==flag)
str += table.Rows[i]["En"].ToString() + " " + table.Rows[i]["Ch"].ToString() + '\r' + '\n';
//textBox1.Text = str;
//textBox1.Clear();
if (str == "")
//textBox1.Text = table.Rows.Count.ToString();
textBox1.Text = "对不起,没有您找的单词";
else
textBox1.Text = str;
con.Close();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//***************************************下一个(背单词)*********************************/
private void button3_Click(object sender, EventArgs e)
{
String conectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb";
OleDbConnection con = new OleDbConnection(conectionString);
con.Open();
// string s = "update backup set tags=" + 1;
// OleDbCommand c = new OleDbCommand(s, con);
// c.ExecuteNonQuery();
while (comboBox1.Text.ToString() == "请选择...")
{
MessageBox.Show("请选择...");
comboBox1.Text="a";
}
if (comboBox1.Text.ToString() == "go on")
{
comboBox1.Text = "selected";
string cmd = "select * from jilu";
DataSet myDaset = new DataSet();
OleDbDataAdapter myCnd = new OleDbDataAdapter(cmd, conectionString);//"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb");
myCnd.Fill(myDaset, "jilu");
//DataTable table = new DataTable();
table = myDaset.Tables["jilu"];
flag = Int32.Parse(table.Rows[0]["orange"].ToString());
}
if((comboBox1.Text.ToString() == "restart"))
{
comboBox1.Text = "selected";
flag=0;
}
string strcmd = "select * from backup";
DataSet myDataset = new DataSet();
OleDbDataAdapter myConmand = new OleDbDataAdapter(strcmd, conectionString);//
myConmand.Fill(myDataset, "backup");
table = myDataset.Tables["backup"];
int f=Int32.Parse(table.Rows.Count.ToString());
OleDbCommandBuilder cb = new OleDbCommandBuilder(myConmand);//这一句很伤人!!!
myConmand.Update(myDataset, "backup");
if (comboBox1.Text != "selected")
{
int i;
for (i = 0; i < f-1; i++)
{
str=table.Rows[i]["En"].ToString();
if (comboBox1.Text.ToString() == str[0].ToString())
break;
}
if (i < f)
flag = i;
else
flag = 0;
comboBox1.Text = "selected";
}
str = "";
if (flag >=f)
flag = 0;
int flag_sub = 0;
//////////**************************删除********************************************/////////////////////////////////////
if (flag >= 1 && Int32.Parse(table.Rows[flag - 1]["tags"].ToString())>=1)
{
string update = "update backup set tags=" + (Int32.Parse(table.Rows[flag - 1]["tags"].ToString())-1)+" where En='"+last_str+"'";
OleDbCommand update_cmd = new OleDbCommand(update, con);
update_cmd.ExecuteNonQuery();
}
if (flag >= 1 && table.Rows[flag - 1]["tags"].Equals(0))
{
string del = "delete from backup where En='" + table.Rows[flag - 1]["En"].ToString() + "'";
OleDbCommand del_command = new OleDbCommand(del, con);
del_command.ExecuteNonQuery();
//flag--;
flag_sub = 1;
}
//////////**************************删除********************************************/////////////////////////////////////
str += table.Rows[flag]["En"].ToString();
if (flag_sub == 1)
flag--;
flag++;
last_str = str;
bdc.Text = str;
con.Close();
}
private void bdc_TextChanged(object sender, EventArgs e)
{
}
private void review_TextChanged(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
// ********************************************忘了*********************************************************************
private void button5_Click(object sender, EventArgs e)
{
String conectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb";
OleDbConnection con = new OleDbConnection(conectionString);//"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb");
string strcmd_forget = "select *from backup";//forget
string strcmd = "select * from review";
DataSet myDataset = new DataSet();
con.Open();
DataSet myDataset_forget = new DataSet();
OleDbDataAdapter myConmand_forget = new OleDbDataAdapter(strcmd_forget, conectionString);
myConmand_forget.Fill(myDataset_forget, "backup");
int sum = Int32.Parse(myDataset_forget.Tables["backup"].Rows.Count.ToString()) ;
string flag = "";
string str="";
flag += bdc.Text.ToString();
for (int i = 0; i < sum; i++)
if (myDataset_forget.Tables["backup"].Rows[i]["En"].ToString() == flag)
{
str += myDataset_forget.Tables["backup"].Rows[i]["En"].ToString() + " " + myDataset_forget.Tables["backup"].Rows[i]["Ch"].ToString() + '\r' + '\n';
///////////////////////////////////改变tags
string tags = bdc.Text.ToString();
int test=2;
//(Int32.Parse(myDataset_forget.Tables["words"].Rows[i]["tags"].ToString())+1)
string update = "update backup set tags=" + (Int32.Parse(myDataset_forget.Tables["backup"].Rows[i]["tags"].ToString()) + 2) + " where En='" + tags + "'";
OleDbCommand add = new OleDbCommand(update, con);
add.ExecuteNonQuery();
///////////////////////////////////改变tags
bdc.Text = str;
break;
}
OleDbDataAdapter myConmand = new OleDbDataAdapter(strcmd, conectionString);//在review中显示刚才不记得的单词;
myConmand.Fill(myDataset, "review");
DataTable table = new DataTable();
table = myDataset.Tables["review"];
review.Text = "还认识吗?\n" + table.Rows[0]["En"].ToString(); //在review中显示刚才不记得的单词;
strcmd = "";
strcmd += "update review set En='" + bdc.Text + "'";
OleDbCommand command = new OleDbCommand(strcmd, con);
command.ExecuteNonQuery();
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_FormClosing_1(object sender, FormClosingEventArgs e)
{
String conectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb";
OleDbConnection con = new OleDbConnection(conectionString);
con.Open();
string http = flag.ToString();
string before="5";
string cmd = "update jilu set orange='"+ http+"'where htt='"+before+"'";
OleDbCommand mycnd = new OleDbCommand(cmd,con);//, conectionString);
mycnd.ExecuteNonQuery();
con.Close();
MessageBox.Show("您确定要关闭窗口", "关闭窗口", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("");
}
//********************************************************上一个**********************************************************
private void button2_Click_1(object sender, EventArgs e)
{
String conectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Database31.accdb";
OleDbConnection con = new OleDbConnection(conectionString);
con.Open();
//string http = flag.ToString();
//string before = "5";
string cmd = "select * from backup";
DataSet data=new DataSet();
OleDbDataAdapter mycnd = new OleDbDataAdapter(cmd, conectionString);//, conectionString);
mycnd.Fill(data, "backup");
flag-=2;
bdc.Text = data.Tables["backup"].Rows[flag]["En"].ToString();
con.Close();
}
}
}