数据库与webWord格式.docx
- 文档编号:959806
- 上传时间:2023-04-29
- 格式:DOCX
- 页数:12
- 大小:192.53KB
数据库与webWord格式.docx
《数据库与webWord格式.docx》由会员分享,可在线阅读,更多相关《数据库与webWord格式.docx(12页珍藏版)》请在冰点文库上搜索。
(6)删除一汽工程及其使用零件的情况。
deletefromspjwherespj.jno=(selectjnofromjwherej.jname='
一汽'
)
deletefromjwherej.jname='
5、在数据库test1中进行下列查询操作,将查询语句写入实验报告。
(1)查询所有供应商情况,先按城市升序排列,城市相同按供应商名称降序排列。
select*fromjorderbycityasc,jnamedesc
(1)查询零件名中含有“螺”字的零件信息。
select*frompwherepnamelike'
%螺%'
(3)查询零件中的最大、最小、平均重量。
selectmax(weight)fromp
selectmin(weight)fromp
selectavg(weight)fromp
(4)查询供应商S1所供应的各种零件的名称和数量。
selectdistinctp.pname,sum(spj.qty)fromspjjoinponspj.pno=p.pnowherespj.sno='
groupbypname
(5)查询使用红色螺丝刀的工程名称。
selectjnamefromjwherejno=(selectjnofromspjwherepno=(selectpnofrompwherep.pname='
螺丝刀'
andp.color='
红色'
))
(6)查询供应情况,显示内容为供应商名称、零件名、工程名称、数量。
selects.sname,p.pname,j.jname,spj.qtyfromsinnerjoin(pinnerjoin(jinnerjoinspjonj.jno=spj.jno)onp.pno=spj.pno)ons.sno=spj.sno
(7)查询工程J1所使用的全部零件和零件来源。
selects.sname,p.pnamefromsinnerjoin(spjinnerjoinponp.pno=spj.pno)ons.sno=spj.snowherespj.jno='
6、请为机车厂工程项目建立一个供应情况的视图,包括供应商代码,零件代码,供应数量。
针对该视图完成如下查询并将SQL语句写入实验报告。
createviewv1asselectsno,pno,qtyfromspj
(1)查询机车厂工程项目使用的各种零件代码及其数量。
selectdistinctpno,sum(qty)fromv1wheresno=(selectsnofromspjwherejno=(selectjnofromjwherejname='
机车厂'
))groupbypno
(2)查询供应商S2的供应情况。
select*fromv1wheresno='
s2'
二.Web应用系统:
人事管理系统
2.1、系统功能分析:
人事管理系统主要有以下几项功能要求:
1)新员工资料的输入;
2)自动分配员工号,并且设置初始的用户密码;
3)人事变动的详细记录,包括岗位和部门的调整;
4)员工信息的查询和修改,包括员工个人信息和密码等。
2.2、系统功能模块设计
根据系统功能的要求,可以将系统分解成几个功能模块来分别设计,功能模块如图1所示。
2.3、数据流程图
系统的数据流程图如图2所示,所有数据由人事管理人员输入。
2.4、数据库需求分析
根据数据流程图,可以列出以下数据项和数据结构:
1)员工信息:
基本信息,学历信息,婚配信息,工作信息
2)人事变动:
新员工信息录入,员工信息修改,员工信息删除
所需的外部数据支持:
1)部门设置:
部门编号、名称……
2.5、数据库概念结构设计
图3是人事管理系统的E-R图。
2.6、数据库逻辑结构设计与实现
员工基本信息表
员工学历信息表
员工婚姻状况表
员工工作信息表
2.7、主要代码实现
//公共类(数据操作类)DataClass
publicclassDataClass{
privateSqlConnectionsqlConn;
publicDataClass(){}
publicSqlConnectionGetSqlSeverConn(){
SqlConnectionsqlConn;
stringstrConn=WebConfigurationManager.ConnectionStrings["
ApplicationServices"
].ConnectionString;
sqlConn=newSqlConnection(strConn);
sqlConn.Open();
returnsqlConn;
}
publicvoidCloseSqlSeverConn(SqlConnectionsqlConn){
if(sqlConn.State==ConnectionState.Open){sqlConn.Close();
}}
publicboolIsUserRegist(stringstrUserName){returntrue;
}
privatestringGetMD5(stringstrPwd){MD5md5=newMD5CryptoServiceProvider();
byte[]bPwd=Encoding.Default.GetBytes(strPwd);
byte[]bMD5=md5.ComputeHash(bPwd);
StringBuildersbMD5Pwd=newStringBuilder();
for(inti=0;
i<
bMD5.Length;
i++){sbMD5Pwd.Append(bMD5[i].ToString());
returnsbMD5Pwd.ToString();
publicboolSaveUserInfo(stringstrUserName,stringstrPwd,intiQx){returntrue;
publicboolIsUserExist(stringstrUserName,stringstrPwd){
stringstrConn="
selectcount(*)from
用户信息表where用户名=@用户名and用户密码=@用户密码"
;
SqlConnectionsqlConn=this.GetSqlSeverConn();
SqlCommandsqlComm=newSqlCommand();
try{sqlComm.CommandText=strConn;
sqlComm.Connection=sqlConn;
sqlComm.Parameters.AddWithValue("
@用户名"
strUserName);
@用户密码"
strPwd);
objectobj=sqlComm.ExecuteScalar();
if(int.Parse(obj.ToString())>
0){returntrue;
else{returnfalse;
catch(Exceptionex){
returnfalse;
}finally{this.CloseSqlSeverConn(sqlConn);
publicboolIsAddJBInfomation(stringYGID,stringYGName,stringYGSex,intYGAge,stringYGBirth){try{
insertinto员工基本信息表
values('
"
+YGID+"
+YGName+"
+YGSex+"
"
+YGAge+"
+YGBirth+"
)"
SqlCommandsqlComm=newSqlCommand(strConn,sqlConn);
sqlComm.ExecuteNonQuery();
returntrue;
catch(Exceptionex){
}finally{}}
publicboolIsAddXLInfomation(stringYGID,stringYGXl,stringYGZy,stringYGByTime,stringYGScool,stringYGEnglish)
{try{stringstrConn=@"
insertinto员工学历信息表values('
+YGID+"
+YGXl+"
+YGZy+"
+YGByTime+"
+YGScool+"
+YGEnglish+"
SqlConnectionsqlConn=this.GetSqlSeverConn();
SqlCommandsqlComm=newSqlCommand(strConn,sqlConn);
publicboolIsAddHYInfomation(stringYGID,stringYGHy,stringYGPName,intYGPAge,stringYGPSex,stringYGPBirth){try{stringstrConn=@"
insertinto员工婚姻状况表
+YGHy+"
+YGPName+"
+YGPAge+"
+YGPSex+"
+YGPBirth+"
}finally}}
publicboolIsAddGzInfomation(stringYGID,stringYGBID,stringYGGWName,stringYGGwZz,stringYGBz){try{stringstrConn
=@"
insertinto企业工作岗位表values('
+YGBID+"
+YGGWName+"
+YGGwZz+"
+YGBz+"
SqlCommandsqlComm=newSqlCommand(strConn,sqlConn);
}catch(Exceptionex){
return
false;
finally{}}
(1)登录模块
protectedvoidBtnSubmit_Click(objectsender,EventArgse){if(TextBox3.Text.ToUpper().Equals(Session["
ValidCode"
].ToString().ToUpper())){
boolbFlag=newDataClass().IsUserExist(TextBox1.Text,TextBox2.Text);
if(bFlag){Session["
]=his.TextBox1.Text.ToString();
Response.Write("
<
Script>
alert('
欢?
迎®
-"
+TextBox1.Text+"
Ì
?
录?
!
);
window.navigate('
Main.aspx'
/Script>
}else{Response.Write("
用户名或密码输错误,请重新输入);
Login1.aspx'
}}elseResponse.Write("
验证码输入错误请重新输入!
(2)员工信息录入
protectedvoidBtnSubmit_Click(objectsender,EventArgse){stringYGID=this.TbID.Text.ToString();
stringYGName=this.TbName.Text.ToString();
stringYGSex=this.DropDownList1.Text.ToString();
intYGAge=Convert.ToInt32(this.TbAge.Text.ToString());
stringYGTime=this.TbYtime.Text.ToString();
stringYGXL=this.DropDownList2.Text.ToString();
stringYGZz=this.TBBz.Text.ToString();
stringYGBTime=this.TbBtime.Text.ToString();
stringYGScool=this.TbScool.Text.ToString();
stringYGEnglish=this.TbEnglish.Text.ToString();
stringYGHY=this.DropDownList3.Text.ToString();
stringYGPName=this.TbPname.Text.ToString();
intYGPAge=Convert.ToInt32(this.TbPage.Text.ToString());
stringYGPSex=this.DropDownList4.Text.ToString();
stringYGPBtime=this.TbBbtime.Text.ToString();
stringYGBID=this.TbBID.Text.ToString();
stringYGGname=this.TbGname.Text.ToString();
stringYGGZz=this.TBZz.Text.ToString();
stringYGBZ=this.TBBz.Text.ToString();
DataClassd1=newDataClass();
if(YGHY=="
已婚"
){if(d1.IsAddJBInfomation(YGID,YGName,YGSex,YGAge,YGTime)==true&
&
d1.IsAddXLInfomation(YGID,YGXL,YGZz,YGBTime,YGScool,YGEnglish)==true&
d1.IsAddHYInfomation(YGID,YGHY,YGPName,YGPAge,YGPSex,YGPBtime)==true&
d1.IsAddGzInfomation(YGID,YGBID,YGGname,YGGZz,YGBZ)==true){Response.Write("
script>
插入成功'
)<
/script>
else{Response.Write("
插入失ì
败'
else{stringYGPName1="
intYGPAge1=0;
stringYGPSex1="
stringYGPBtime1="
if(d1.IsAddJBInfomation(YGID,YGName,YGSex,YGAge,YGTime)==true&
d1.IsAddHYInfomation(YGID,YGHY,YGPName1,YGPAge1,YGPSex1,YGPBtime1)==true&
d1.IsAddGzInfomation(YGID,YGBID,YGGname,YGGZz,YGBZ)==true){
Response.Write("
添加成功);
AddInfo.aspx'
}else{Response.Write("
添加失败);
}}}
(3)员工信息的修改
=17;
i++){if(QJXI[i]!
=QJXIG[i]){if(i==0)
{DataClassd2=newDataClass();
stringtempYGID1=this.DropDownList4.Text.ToString();
stringstrConn=@"
update员工基本信息表.员工姓名='
+QJXIG[0]+"
where员工.ID='
+tempYGID1+"
SqlConnectionsqlConn=d2.GetSqlSeverConn();
sqlConn.Close();
Response.Write
("
修改成功'
UpdataInfo.aspx'
}elseif(i==1){DataClassd2=newDataClass();
stringtempYGID1this.DropDownList4.Text.ToString();
update员工基本信息表.员工性别='
+QJXIG[1]+"
where员¡
À
工¡
è
ID='
+tempYGID1+"
(4)员工信息查询
//四种查询条件不同,代码类似
stringTempTb=this.TextBox2.Text.ToString();
if(TempTb==null||TempTb=="
){Response.Write
请输入要查询的员工号'
SelectInfo.aspx'
}else{
DataClassd2=newDataClass();
SqlConnectionstrconn=d2.GetSqlSeverConn();
stringcmd="
SELECT*FROM员工基本信息表WHERE员工ID='
+TempTb+"
SqlDataAdaptersda=newSqlDataAdapter(cmd,strconn);
DataSetds=newDataSet();
sda.Fill(ds,"
emp"
GridView1.DataSource=ds.Tables["
];
GridView1.DataKeyNames=newstring[]{"
员工.ID"
};
GridView1.DataBind();
strconn.Close();
this.TextBox2.Text="
(5)员工信息删除
stringTempTb=this.TextBox1.Text.ToString();
){
Del.aspx'
SqlConnection
strconn=d2.GetSqlSeverC
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 web