数据库原理及应用课程设计报告.docx
《数据库原理及应用课程设计报告.docx》由会员分享,可在线阅读,更多相关《数据库原理及应用课程设计报告.docx(26页珍藏版)》请在冰豆网上搜索。
![数据库原理及应用课程设计报告.docx](https://file1.bdocx.com/fileroot1/2023-1/8/bec2b465-a416-46f8-9955-14aae37e4222/bec2b465-a416-46f8-9955-14aae37e42221.gif)
数据库原理及应用课程设计报告
成绩
《数据库原理及应用》课程设计报告
商品销售管理系统
学 院:
信息工程学院
班 级:
学 号:
姓 名:
完成时间:
201
课程设计的任务
数据库原理及应用是计算机及其相关学科的一门重要的学科基础课程,也是计算机软件科学与技术、信息科学与技术的重要学科分支。
本课程设计旨在通过对一个小型数据库管理系统(DBMS)的综合设计过程,强化学生对计算机系统软件的设计能力,提高学生的综合素质,并通过课程设计进一步加强学生对所学知识的理解,以及对数据库的全面、深刻认识。
具体要求如下:
1)了解DBMS的设计过程;
2)掌握关系型DBMS的结构及实现;
3)掌握系统程序设计的基础知识;
4)深化理解并掌握《数据库原理及应用》课程的相关内容;
5)强化软件开发的团队意识,提高合作能力。
系统需求分析与设计
数据流图
E-R图
数据结构描述
商品数据结构:
Shanid
Char
6
Shanname
Char
8
Shancount
Smailint
2
Shanprice
Smailint
2
Factorid
char
6
公司数据结构:
Factorid
Char
6
Factorname
varChar
24
Factoraddr
varChar
24
Factorphone
Char
11
销售数据结构:
Shanid
Char
6
Factorid
Char
6
Salsecount
Smailint
2
销售管理系统
软件设计流程图和功能模块图
商品信息查询
商品信息录入
销售信息查询
销售信息录入
公司信息查询
公司信息录入
程序模块汇总
商品信息录入;
商品信息查询;
公司信息录入;
公司信息查询;
销售信息录入;
销售信息查询;
源程序清单
主目录:
usingSystem;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Xml.Linq;
publicpartialclass_Default:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default2.aspx");
}
protectedvoidButton3_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default3.aspx");
}
protectedvoidButton2_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default4.aspx");
}
protectedvoidButton4_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default6.aspx");
}
protectedvoidButton5_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default4.aspx");
}
protectedvoidButton6_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default5.aspx");
}
protectedvoidButton7_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default7.aspx");
}
}
○1商品信息录入;
usingSystem;
usingSystem.Collections;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Xml.Linq;
usingSystem.Data.SqlClient;
publicpartialclassDefault2:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidButton3_Click(objectsender,EventArgse)
{
if((ShangID.Text.Trim()).Length<1)
{
Response.Write("");
return;
}
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringselect="selectcount(*)astotalfromSwhereShanID="+"'"+ShangID.Text.Trim()+"'";
SqlCommandcmdsel=newSqlCommand(select,con);
SqlDataReaderdr=cmdsel.ExecuteReader();
if(dr.Read())
{
if(int.Parse(dr["total"].ToString())==0)
{
Response.Write("");
return;
}
}
dr.Close();
stringstr="deletefromSwhereShanID="+"'"+ShangID.Text.Trim()+"'";
SqlCommandcmd=newSqlCommand(str,con);
cmd.ExecuteNonQuery();
con.Close();
}
protectedvoidExit_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default.aspx");
}
protectedvoidInsert_Click(objectsender,EventArgse)
{
SqlConnectioncon=newSqlConnection("server=localhost;uid=sa;pwd=123456;database=studb");
con.Open();
stringinsert="insertintoS(ShanID,ShanName,ShanCount,ShanPrice,FactoryID)values("
+"'"+ShangID.Text.Trim()+"'"+","+"'"+ShangName.Text.Trim()+
"'"+","+ShangCount.Text.Trim()+","+"'"+ShangPrice.Text.Trim()+
"'"+","+"'"+ShangAddr.Text.Trim()+"'"+")";
Response.Write(insert);
SqlCommandcmd1=newSqlCommand(insert,con);
cmd1.ExecuteNonQuery();
con.Close();
}
}
○2商品信息查询;
usingSystem;
usingSystem.Collections;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Xml.Linq;
usingSystem.Data.SqlClient;
publicpartialclassDefault3:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidMoveToFirst_Click(objectsender,EventArgse)
{
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringstr="selectShanIDfromSorderbyShanIDasc";
SqlCommandcmd=newSqlCommand(str,con);
SqlDataReadersr=cmd.ExecuteReader();
if(sr.Read())
{
stringStudent=sr["ShanID"].ToString();
Refresh(Student);
}
sr.Close();
}
privatevoidRefresh(stringshangId)
{
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringstr="select*fromSwhereShanID="+"'"+shangId.ToString()+"'";
SqlCommandcmd=newSqlCommand(str,con);
SqlDataReadersr=cmd.ExecuteReader();
if(sr.Read())
{
ShangID.Text=shangId.ToString();
ShangName.Text=sr["ShanName"].ToString();
ShangCount.Text=sr["ShanCount"].ToString();
ShangPrice.Text=sr["ShanPrice"].ToString();
ShangAddr.Text=sr["FactoryID"].ToString();
}
}
protectedvoidMoveToPre_Click(objectsender,EventArgse)
{
if((ShangID.Text.Trim()).Length<1)
{
Response.Write("");
return;
}
stringshangid="";
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringstr="selectShanIDfromSorderbyShanIDasc";
SqlCommandcmd=newSqlCommand(str,con);
SqlDataReadersr=cmd.ExecuteReader();
if(sr.Read())
{
shangid=sr["ShanID"].ToString();
}
sr.Close();
if(shangid==ShangID.Text.Trim())
{
Response.Write("");
return;
}
else
{
stringtempstr="selectmax(ShanID)asmaxidfromSwhereShanID<"+"'"+ShangID.Text.Trim()+"'";
cmd.CommandText=tempstr;
SqlDataReaderdr=cmd.ExecuteReader();
if(dr.Read())
{
stringshId=dr["maxid"].ToString();
Refresh(shId);
}
}
con.Close();
}
protectedvoidMoveToNext_Click(objectsender,EventArgse)
{
if((ShangID.Text.Trim()).Length<1)
{
Response.Write("");
return;
}
stringshangid="";
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringstr="selectShanIDfromSorderbyShanIDdesc";
SqlCommandcmd=newSqlCommand(str,con);
SqlDataReadersr=cmd.ExecuteReader();
if(sr.Read())
{
shangid=sr["ShanID"].ToString();
}
sr.Close();
if(shangid==ShangID.Text.Trim())
{
Response.Write("");
return;
}
else
{
stringtempstr="selectmin(ShanID)asmaxidfromSwhereShanID>"+"'"+ShangID.Text.Trim()+"'";
cmd.CommandText=tempstr;
SqlDataReaderdr=cmd.ExecuteReader();
if(dr.Read())
{
stringshId=dr["maxid"].ToString();
Refresh(shId);
}
}
con.Close();
}
protectedvoidMoveToLast_Click(objectsender,EventArgse)
{
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringstr="selectShanIDfromSorderbyShanIDdesc";
SqlCommandcmd=newSqlCommand(str,con);
SqlDataReadersr=cmd.ExecuteReader();
if(sr.Read())
{
stringShang=sr["ShanID"].ToString();
Refresh(Shang);
}
sr.Close();
con.Close();
}
protectedvoidKeySelect_Click(objectsender,EventArgse)
{
boolfind=false;
SqlConnectioncon=newSqlConnection("server=localhost;userid=sa;pwd=123456;database=studb");
con.Open();
stringcmdstr="select*fromS";
SqlDataAdapterda=newSqlDataAdapter(cmdstr,con);
DataSetds=newDataSet();
da.Fill(ds);
for(inti=0;i{
for(intj=0;j{
stringdata=(ds.Tables[0].Rows[i][j].ToString()).Trim();
if(data==Select.Text.Trim())
{
ShangID.Text=ds.Tables[0].Rows[i]["ShanID"].ToString();
ShangName.Text=ds.Tables[0].Rows[i]["ShanName"].ToString();
ShangCount.Text=ds.Tables[0].Rows[i]["ShanCount"].ToString();
ShangPrice.Text=ds.Tables[0].Rows[i]["ShanPrice"].ToString();
ShangAddr.Text=ds.Tables[0].Rows[i]["FactoryID"].ToString();
find=true;
}
}
}
if(find==false)
{
Response.Write("");
}
con.Close();
}
protectedvoidExit_Click(objectsender,EventArgse)
{
Response.Redirect("~/Default.aspx");
}
}
○3公司信息录入;
usingSystem;
usingSystem.Collections;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Xml.Linq;
usingSystem.Data.SqlClient;
publicpartialclassDefault4:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidInsert_Click(objectsender,EventArgse)
{
SqlConnectioncon=newSqlConnection("server=localhost;uid=sa;pwd=123456;database=studb");
con.Open();
stringinsert="insertintoFactory(FactorID,FactorName,FactorAddr,FactorPhone)values("
+"'"+FactoryID.Text.Trim()+"'"+","+"'"+FactoryName.Text.Trim()+
"'"+","+"'"+FactoryAddr.Text.Trim()+"'"+","+"'"+FactoryPhone.Text.Trim()+
"'"+")";
Response.Write(insert);
SqlComm