C#课程设计个人单词簿软件设计.docx
- 文档编号:30509086
- 上传时间:2023-08-16
- 格式:DOCX
- 页数:25
- 大小:662.22KB
C#课程设计个人单词簿软件设计.docx
《C#课程设计个人单词簿软件设计.docx》由会员分享,可在线阅读,更多相关《C#课程设计个人单词簿软件设计.docx(25页珍藏版)》请在冰豆网上搜索。
C#课程设计个人单词簿软件设计
课程设计说明书
(2012/2013学年第一学期)
**学院
课程名称:
软件程序设计
题目:
个人单词簿软件设计
专业班级:
学生姓名:
放羊娃
学号:
指导教师:
设计周数:
2周
设计成绩:
2013年1月18日
个人单词簿的设计
1、课程设计目的
本课程设计是信息工程专业的一门软件实践专业基础课,旨在提高学生的软件编程能力。
本设计将进一步加强学生对面向对象程序设计思想的理解,增强对C#程序语言的灵活运用。
要求学生能结合数据库知识,网络通信技术,实现基本的应用软件,为以后从事相关行业打下软件编程基础。
编写一个单词簿软件,便于个人记忆单词,并且能够进行小测试,知道自己的错误,导出单词表,进行更深刻的记忆。
2、课程设计正文
2.1设计分析
实现对于生单词的记录,对单词的测试,了解自己的掌握状况。
框架图
2.2程序设计
主界面的设计
主界面部分代码:
privatevoidForm1_Load(objectsender,EventArgse)
{
maxnum=getmaxnum();
}
publicintgetmaxnum()
{
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="SELECT*FROMremember";
sdr=cmd.ExecuteReader();
if(sdr.Read())
{
returnsdr.GetInt32(0);
}
else
{
return-1;
}
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
if(std==null)
{
std=newStudy(this);
std.Show();
}
else
{
if(std.IsDisposed)
{
std=newStudy(this);
std.Show();
}
else
{
std.WindowState=FormWindowState.Normal;
std.Activate();
}
}
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
if(inw==null)
新单词录入界面:
录入新词界面代码:
privateboolgettext()//判断输入十分为空
{
if(textBox1.Text!
=""&&textBox2.Text!
="")
{
returntrue;
}
else
{
returnfalse;
}
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
if(gettext())
{
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="SELECT*FROMWordWHEREword='"+textBox1.Text.Trim()+"'";
sdr=cmd.ExecuteReader();
if(!
sdr.Read())
{
sdr.Close();
cmd.CommandText="INSERTINTOwordVALUES('"+textBox1.Text.Trim()+"','"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"','0')";
cmd.ExecuteNonQuery();
cmd.CommandText="UPDATErememberSETmaxnum='"+(++f.maxnum)+"'";
cmd.ExecuteNonQuery();
}
else
{
MessageBox.Show("你已经保存了这个单词了亲");
}
sql.closeAll(conn,cmd,sdr);
}
else
{
MessageBox.Show("要把单词和词义填上啊亲");
测试成果界面:
测试成果界面代码:
privatevoidTest_Load(objectsender,EventArgse)
{
getword();
next();
}
privatevoidgetword()
{
word=newstring[maxnum];
meaning=newstring[maxnum];
inti=0;
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
Conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="SELECT*FROMWord";
sdr=cmd.ExecuteReader();
while(sdr.Read())
{
word[i]=sdr.GetString(0);
meaning[i]=sdr.GetString
(1);
i++;
}
sql.closeAll(conn,cmd,sdr);
}
privatevoidnext()
{
if(t>=maxnum)
{
if(MessageBox.Show("测试结束","",MessageBoxButtons.OK)==DialogResult.OK)
{
this.Close();
}
}
else
{
label1.Text=word[t];
intnum1=0,num2=0,num3=0,num4=0;
Randomrd=newRandom();
num1=rd.Next(1,4);
switch(num1)
{
case1:
{
A.Text=meaning[t];
a=t;
num2=getnum(t,0,0,0);
B.Text=meaning[num2];
b=num2;
num3=getnum(t,num2,0,0);
C.Text=meaning[num3];
c=num3;
num4=getnum(t,num2,num3,0);
D.Text=meaning[num4];
d=num4;
break;
}
case2:
{
B.Text=meaning[t];
b=t;
num2=getnum(t,0,0,0);
A.Text=meaning[num2];
a=num2;
num3=getnum(t,num2,0,0);
C.Text=meaning[num3];
c=num3;
num4=getnum(t,num2,num3,0);
D.Text=meaning[num4];
d=num4;
break;
}
case3:
{
C.Text=meaning[t];
c=t;
num2=getnum(t,0,0,0);
B.Text=meaning[num2];
b=num2;
num3=getnum(t,num2,0,0);
A.Text=meaning[num3];
a=num3;
num4=getnum(t,num2,num3,0);
D.Text=meaning[num4];
d=num4;
break;
}
case4:
{
D.Text=meaning[t];
d=t;
num2=getnum(t,0,0,0);
B.Text=meaning[num2];
b=num2;
num3=getnum(t,num2,0,0);
C.Text=meaning[num3];
c=num3;
num4=getnum(t,num2,num3,0);
A.Text=meaning[num4];
a=num4;
break;
}
}
t++;
}
}
privateintgetnum(intn1,intn2,intn3,intn4)
{
Randomrd=newRandom();
intcnum=0;
while(true)
{
cnum=rd.Next(0,maxnum);
if(cnum!
=n1&&cnum!
=n2&&cnum!
=n3&&cnum!
=n4)
{
break;
}
}
returncnum;
}
privatevoidA_Click(objectsender,EventArgse)
{
intj=t-1;
if(a==j)
{
pictureBox1.Visible=true;
pictureBox2.Visible=false;
}
else
{
adderr(j);
pictureBox1.Visible=false;
pictureBox2.Visible=true;
}
}
privatevoidB_Click(objectsender,EventArgse)
{
intj=t-1;
if(b==j)
{
pictureBox1.Visible=true;
pictureBox2.Visible=false;
}
else
{
adderr(j);
pictureBox1.Visible=false;
pictureBox2.Visible=true;
}
}
privatevoidC_Click(objectsender,EventArgse)
{
intj=t-1;
if(c==j)
{
pictureBox1.Visible=true;
pictureBox2.Visible=false;
}
else
{
adderr(j);
pictureBox1.Visible=false;
pictureBox2.Visible=true;
}
}
privatevoidD_Click(objectsender,EventArgse)
{
intj=t-1;
if(d==j)
{
pictureBox1.Visible=true;
pictureBox2.Visible=false;
}
else
{
adderr(j);
pictureBox1.Visible=false;
pictureBox2.Visible=true;
}
}
privatevoidadderr(intq)
{
intdfc=0;
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="SELECTdifficultyFROMWordWHEREword='"+word[q]+"'";
sdr=cmd.ExecuteReader();
if(sdr.Read())
{
dfc=sdr.GetInt32(0);
dfc++;
sdr.Close();
cmd.CommandText="UPDATEWordSETdifficulty='"+dfc+"'WHEREword='"+word[q]+"'";
cmd.ExecuteNonQuery();
}
sql.closeAll(conn,cmd,sdr);
}
privatevoidpictureBox1_Click(objectsender,EventArgse)
{
pictureBox1.Visible=false;
pictureBox2.Visible=false;
next();
}
privatevoidpictureBox2_Click(objectsender,EventArgse)
}
pictureBox1.Visible=false;
pictureBox2.Visible=false;
next();
}
privatevoidlabel1_Click(objectsender,EventArgse)
{
}
快乐学习界面:
快乐学习界面代码:
privatevoidStudy_Load(objectsender,EventArgse)
{
//TODO:
这行代码将数据加载到表“database1DataSet.Word”中。
您可以根据需要移动或删除它。
this.wordTableAdapter.Fill(this.database1DataSet.Word);
}
privatevoiddataGridView1_CurrentCellChanged(objectsender,EventArgse)
{
label1.Text=this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
label4.Text="出错次数:
"+this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
this.textBox1.Text=this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
this.textBox2.Text=this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
}
privatevoidtoolStripButton1_Click(objectsender,EventArgse)
{
if(f.maxnum>5)
{
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="DELETEFROMwordWHEREWord='"+label1.Text+"'";
cmd.ExecuteNonQuery();
cmd.CommandText="UPDATErememberSETmaxnum='"+(--f.maxnum)+"'";
cmd.ExecuteNonQuery();
sql.closeAll(conn,cmd,sdr);
MessageBox.Show("删除的单词在从新打开后不再显示");
}
else
{
MessageBox.Show("必须保留5个单词以维持系统稳定")
}
privatevoidtoolStripButton2_Click(objectsender,EventArgse)
{
StreamWritersw=newStreamWriter("Word.txt");
stringword,meaning,phrase,df;
stringdataDir=AppDomain.CurrentDomain.BaseDirectory;
if(dataDir.EndsWith(@"\bin\Debug\")||dataDir.EndsWith(@"\bin\Release\"))
{
dataDir=System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DataDirectory",dataDir);
}
conn=newSqlConnection(@"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;IntegratedSecurity=True;UserInstance=True");
conn.Open();
cmd=conn.CreateCommand();
cmd.CommandText="SELECT*FROMWord";
sdr=cmd.ExecuteReader();
while(sdr.Read())
{
word=sdr.GetString(0);
meaning=sdr.GetString
(1);
phrase=sdr.GetString
(2);
df=sdr.GetInt32(3).ToString();
sw.WriteLine(word);
sw.WriteLine(meaning);
sw.WriteLine(phrase);
sw.Writ
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 课程设计 个人 单词 软件设计