在【对象资源管理器】窗口中展开服务器,然后选择【数据库】节点
右键单击【数据库】节点,从d出来的快捷菜单中选择【新建数据库】命令。
执行上述 *** 作后,会d出【新建数据库】对话框。在对话框、左侧有3个选项,分别是【常规】、【选项】和【文件组】。完成这三个选项中的设置会后,就完成了数据库的创建工作,
在【数据库名称】文本框中输入要新建数据库的名称。例如,这里以“新建的数据库”。
在【所有者】文本框中输入新建数据库的所有者,如sa。根据数据库的使用情况,选择启用或者禁用【使用全文索引】复选框。
在【数据库文件】列表中包括两行,一行是数据库文件,而另一行是日记文件。通过单击下面的【添加】、【删除】按钮添加或删除数据库文件。
切换到【选项页】、在这里可以设置数据库的排序规则、恢复模式、兼容级别和其他属性。
切换到【文件组】页,在这里可以添加或删除文件组。
完成以上 *** 作后,单击【确定】按钮关闭【新建数据库】对话框。至此“新建的数据”数据库创建成功。新建的数据库可以再【对象资源管理器】窗口看到。
这个是我自己做的管理系统,里面的汉字什么的你改下就OK了,比如把单价改成工资```总价改成总工资````数量改成月底百分比提成什么的```其他的不用改的。毕竟只有30分,我只能说把我自己做过的复制下给你,汉字我就不给你改了。看着行你就给分,好的话追加,感觉垃圾就骂我。#include<stdio.h>
struct material
{int num
char name[20]
char leibie[20]
char shijian[20]
int shuliang
int price
int total
int delet }
work[50]
static n=1int f,g=1,e
FILE *fp1
char fname[20]
jianli() /*创建新文件*/
{
int i,x=0FILE *fp
system("cls")
menu1()
menu2()
printf("\t\t\t 请输入文件名!")
scanf("%s",fname)
fp=fopen(fname,"rb")
for(i=0i<50i++)
{fread(&work[i],sizeof(struct material),1,fp)
if(work[i].total!=0)x++
}
fclose(fp)n=x
}
r()
{
int iFILE *fp
if((fp=fopen(fname,"rb"))==NULL)
{
printf("\n\n\t\tcannot open file!\n")}
printf("编号 名称 类别 登记时间数量 单价总价\n")
for(i=0i<ni++)
{
fread(&work[i],sizeof(struct material),1,fp)
if(work[i].delet==0)
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",
work[i].num,work[i].name,work[i].leibie,work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
}
fclose(fp)
}
r1()
{
int iFILE *fp
if((fp=fopen(fname,"rb"))==NULL)
{
printf("\n\n\t\tcannot open file!\n")}
printf("编号 名称 类别 登记时间数量 单价总价\n")
for(i=0i<ni++)
{
fread(&work[i],sizeof(struct material),1,fp)
if(work[i].delet==1)
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
}
fclose(fp)
}
display2() /*显示所有信息*/
{
int i,d=0FILE *fp
fp=fopen(fname,"rb")
system("cls")menu1()
printf("以下是所有材料信息!\n")
for(i=0i<ni++)
fread(&work[i],sizeof(struct material),1,fp)
printf("编号 名称 类别 登记时间数量 单价总价\n")
for(i=0i<ni++)
if(work[i].delet==0)
{d++
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
}
if(d==0)printf("没找着,想好了再找!\n")
scanf("%d",&i)
}
display1() /*显示信息*/
{int iint d=0
printf("以下是排序后的信息 :\n")
printf("编号 名称 类别 登记时间数量 单价总价\n")
for(i=0i<ni++)
if(work[i].delet==0)
{d++
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
}
if(d==0){printf("没找着,想好了再找!\n")system("pause")}
}
save() /*保存函数*/
{FILE *fpint i
system("cls")menu1()
printf("保存在原文件请按 1 另存为请按 2\n")
scanf("%d",&e)
while(1)
{
if(e==1)
{
if((fp=fopen(fname,"w"))==0)
{printf("cannot open\n")return}
for(i=0i<ni++)
if(fwrite(&work[i],sizeof(struct material), 1,fp)!=1)
printf("error!\n")break
}
else if(e==2)
{
printf("input jianli file name!\n")
scanf("%s",fname)
if((fp=fopen(fname,"w"))==0)
{printf("cannot open\n")return}
for(i=0i<ni++)
if(fwrite(&work[i],sizeof(struct material), 1,fp)!=1)
printf("error!error!\n")break
}
else printf("error!\n")
}
fclose(fp)
system("cls")menu1()
printf("OK了!\n\n")system("pause")
}
slect()
{
int d,isystem("cls")menu1()menu2()scanf("%d",&d)
if(d==1){add()slect()}
else if(d==2){display2()slect()}
else if(d==3){cha()slect()}
else if(d==4){delet()slect()}
else if(d==5){modify()slect()}
else if(d==6){order()slect()}
else if(d==7){recy()slect()}
else if(d==8){tongji()slect()}
else if(d==9){jianli()slect()}
else if(d==0){printf("exit!\n\n")exit()}
else{printf("error!\n")slect()}
}
cha() /*查询*/
{
int i,num,c,suc=0,suc1char name[20]FILE *fp
fp=fopen(fname,"rb")
for(i=0i<ni++)
fread(&work[i],sizeof(struct material),1,fp)
while(1)
{
system("cls")menu1()
printf("您有两种方式查询:\n")
printf("输入名称请按 1 输入材料号请按 2\n")
scanf("%d",&c)
system("cls")menu1()
if(c==1)
{printf("输入名称\n")
scanf("%s",name)break}
else if(c==2)
{printf("输入材料号\n")
scanf("%d",&num)break}
else while(1)
{ system("cls")menu1()printf("输入出错啦!!!!\n")
printf("重输请按 0退出请按 1\n ")
scanf("%d",&suc)
if(suc==0||suc==1)
break
else continue
}
if(suc==1)break
}
if(suc!=1)
{
for(i=0i<ni++)
if((strcmp(name,work[i].name)==0||num==work[i].num)&&work[i].delet==0)break
if(i<n)
{ system("cls")menu1()
printf("编号 名称 类别 登记时间数量 单价总价\n")
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
printf("请按任意数字键继续!\n")
scanf("%d",&i)
}
else {system("cls")menu1()
printf(" I’m sorry!我都快死机了也没找到....!\n\n",i)
printf("继续请按任意数字键!\n")
scanf("%d",&i)}
while(1)
{ system("cls")menu1()
printf("继续请按 0退出请按 1\n ")
scanf("%d",&suc1)
if(suc1==0||suc1==1)
break
else printf(" error!\n\n",i)
printf("继续请按任意数字键!\n")
scanf("%d",&i)
}
if(suc1==0) cha()
if(suc1==1) {printf("bye!\n")
system("pause")
}
}
else printf("bye!\n")
}
add() /*添加*/
{
int e,i,num,c,h,suc=0,suc1char name[20]int a
while(suc==0)
{if(n<50){a=nn++work[a].delet=0}
else
{for(i=0i<ni++)
if(work[i].delet==2)break
{a=iwork[a].delet=0}
}
while(1)
{printf("文件已经存有以下信息:\n\n")
system("cls")menu1()r()
printf("请输入编号:\n")
scanf("%d",&work[a].num)
for(h=0h<nh++)
{if(h==a)h++
if((work[a].num==work[h].num)&&work[h].delet==0)break
}
if(h<n)
{system("cls")menu1()
printf("编号重复!想好了再写!\n")printf("请按任意数字键继续!\n")
scanf("%d",&i)
}
else break
}
system("cls")menu1()r()
while(1)
{
printf("请输入名称:name\n")
scanf("%s",&work[a].name)
for(h=0h<nh++)
{if(h==a)h++
if(strcmp(work[a].name,work[h].name)==0&&work[h].delet==0)break
}
if(h<n)
{system("cls")menu1()printf("名称重复!想好了写!\n")
printf("请按任意数字键继续!\n")
scanf("%d",&i)}
else break
}
system("cls")menu1()r()
printf("请输入类别:\n")
scanf("%s",&work[a].leibie)system("cls")menu1()r()
printf("请输入登记时间:\n")
scanf("%s",&work[a].shijian)system("cls")menu1()r()
printf("请输入数量:\n")
scanf("%d",&work[a].shuliang)system("cls")menu1()r()
printf("请输入单价:\n")
scanf("%d",&work[a].price)system("cls")menu1()r()
work[a].total=work[a].shuliang*work[a].price
work[a].delet=0system("cls")menu1()r()
while(1)
{
printf("\n")
printf(" 保存请按 1 重输请按 2\n")
scanf("%d",&e)
if(e==1){save()suc=1break}
else if(e==2){n--break}
else {system("cls")menu1()printf("写错啦!想好了写!!\n")}
}
while(e==1)
{system("cls")menu1()
printf("继续请按 0 退出请按 1\n")
scanf("%d",&suc)
if(suc==0||suc==1)break
else {system("cls")menu1()printf("输入有误!想好了写!\n\n")}
}
if(suc==1)break
}
}
delet() /*删除*/
{
char jint e,i,num,c,suc=0
char name[20]
system("cls")menu1()r()
while(1)
{
printf("请输入您要删除的材料的信息:名称 或 材料号\n")
printf("\n")
printf("输入名称请按 1 输入材料号请按2\n")
scanf("%d",&c)
system("cls")menu1()r()
if(c==1)
{printf("输入名称\n")
scanf("%s",name)break}
else if(c==2)
{printf("输入材料号\n")
scanf("%d",&num)break}
else while(1)
{printf("输入出错啦!!!!\n")
printf("重输请按 0确认请按 1\n ")
scanf("%d",&suc)
if(suc==0||suc==1)
break
else continue
}
if(suc==1)break
}
if(suc!=1)
{
for(i=0i<ni++)
if((strcmp(name,work[i].name)==0||num==work[i].num)&&work[i].delet==0)break
if(i<n)
while(1)
{ system("cls")menu1()r()
printf("您要删除 %s 的信息!\n ",work[i].name)
printf("\n")
printf("暂时删除请按 1 永久删除请按 2\n")
scanf("%d",&e)
if(e==1)
{work[i].delet=1system("cls")menu1()printf("deleted sucessfully!\n\n")save()break}
if(e==2)
{work[i].delet=2system("cls")menu1()printf("deleted sucessfully!\n\n")save()break}
else {system("cls")menu1()printf(" 输入出错啦!!!!\n\n",i)
printf("继续请按任意数字键!\n") scanf("%d",&i)}
}
if(i>=n){system("cls")menu1()printf(" I’m sorry!我都快死机了也没找到....!\n\n",i)
printf("继续请按任意数字键!\n") scanf("%d",&i)}
while(1)
{system("cls")menu1()
printf("继续请按 0 退出请按 1\n")scanf("%d",&e)
if(e==0||e==1)break
else {system("cls")menu1()printf(" 输入出错啦!!!!\n\n",i)
printf("继续请按任意数字键!\n")scanf("%d",&i)}
}
if(e==0)delet()
else printf("bye!\n")
}
}
modify() /*修改*/
{ char name[20]int i,e=1,a,h
system("cls")menu1()
r()
printf("请输入您要修改的材料的名称!\n")
scanf("%s",name)
for(i=0i<ni++)
if(strcmp(work[i].name,name)==0&&work[i].delet==0)break
if(i<n)
{system("cls")menu1()
printf("您要修改的材料的编号为num: %d, 修改 0 放弃修改 1\n",work[i].num)
scanf("%d",&e)
if(e==0)
while(1)
{ printf("请输入编号:\n")
scanf("%d",&work[i].num)
for(h=0h<nh++)
{if(h==i)h++
if((work[i].num==work[h].num)&&work[h].delet==0)break
}
if(h<n) printf("编号重复!想好了写!\n")
else break
}
system("cls")menu1()
printf("您要修改的材料的名称为:%s, 修改 0 放弃修改 1\n",work[i].name)
scanf("%d",&e)
if(e==0)
while(1)
{ printf("请输入名称:\n")
scanf("%s",&work[i].name)
for(h=0h<nh++)
{if(h==i)h++
if(strcmp(work[i].name,work[h].name)==0&&work[h].delet==0)break
}
if(h<n) printf("名称重复!想好了写!s\n")
else break
}
system("cls")menu1()
printf("您要修改的材料的类别为 %s, 修改 0 放弃修改 1\n",work[i].leibie)
scanf("%d",&e)
if(e==0)
{printf("请输入类别:\n")
scanf("%s",&work[i].leibie)}
system("cls")menu1()
printf("您要修改的材料的登记时间为:%s, 修改 0 放弃修改 1\n",work[i].shijian)
scanf("%d",&e)
if(e==0)
{printf("请输入登记时间:\n")
scanf("%s",&work[i].shijian)}
system("cls")menu1()
printf("您要修改的材料的数量为%d, 修改 0 放弃修改 1\n", work[i].shuliang)
scanf("%d",&e)
if(e==0)
{printf("请输入数量:\n")
scanf("%d",&work[i].shuliang)}
system("cls")menu1()
printf("您要修改的材料的单价为%d, 修改 0 放弃修改 1\n",work[i].price)
scanf("%d",&e)
if(e==0)
{printf("请输入单价:\n")
scanf("%d",&work[i].price)}
work[i].total=work[i].shuliang*work[i].price
system("cls")menu1()
printf("搞定! \n")
printf("新信息为:\n")
printf("编号 名称 类别 登记时间数量 单价总价\n")
printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
while(1)
{
printf(" 保存请按 1 取消请按 2\n")
scanf("%d",&e)
if(e==1){save()break}
else if(e==2)break
else {system("cls")menu1()printf("写错啦!想好了写!!\n")}
}
}
if(i==n) {system("cls")menu1()printf("no such a material!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
while(e==1)
{system("cls")menu1()
printf("继续请按 0 退出请按 1\n")
scanf("%d",&e)
if(e==0||e==1)break
else {system("cls")menu1()printf("输入有误!想好了写!\n\n")
printf("继续请按任意数字键!\n")scanf("%d",&i)}
}
if(e==0)modify()
if(e==1)printf("exit!\n")
}
er() /*冒泡排序*/
{int tchar dai[20]
t=work[f].pricework[f].price=work[f+1].pricework[f+1].price=t
t=work[f].numwork[f].num=work[f+1].numwork[f+1].num=t
t=work[f].shuliangwork[f].shuliang=work[f+1].shuliangwork[f+1].shuliang=t
t=work[f].totalwork[f].total=work[f+1].totalwork[f+1].total=t
strcpy(dai,work[f].name)
strcpy(work[f].name,work[f+1].name)
strcpy(work[f+1].name,dai)
strcpy(dai,work[f].leibie)
strcpy(work[f].leibie,work[f+1].leibie)
strcpy(work[f+1].leibie,dai)
strcpy(dai,work[f].shijian)
strcpy(work[f].shijian,work[f+1].shijian)
strcpy(work[f+1].shijian,dai)
}
order1() /*按数量排序*/
{ int i,j,e
system("cls")menu1()
for(j=0j<n-1j++)
for(i=0i<n-1-ji++)
if((work[i].shuliang>work[i+1].shuliang)&&work[i].delet==0)
{f=ier()}
while(1)
{ system("cls")menu1()display1()
printf(" 保存请按 1 取消请按 2\n")
scanf("%d",&e)
if(e==1){save()break}
else if(e==2)break
else {system("cls")menu1()printf("写错啦!想好了写!!\n")
printf("继续请按任意数字键!\n")scanf("%d",&i)}
}
}
order2() /*按单价排序*/
{ int i,j
system("cls")menu1()
for(j=0j<n-1j++)
for(i=0i<n-1-ji++)
if((work[i].price>work[i+1].price)&&work[i].delet==0)
{f=ier()}
while(1)
{ system("cls")menu1()display1()
printf(" 保存请按 1 取消请按 2\n")
scanf("%d",&e)
if(e==1){save()break}
else if(e==2)break
else {system("cls")menu1()printf("写错啦!想好了写!!\n")
printf("继续请按任意数字键!\n")scanf("%d",&i)}
}
}
order3() /*按总价排序*/
{ int i,j
system("cls")menu1()
for(j=0j<n-1j++)
for(i=0i<n-1-ji++)
if((work[i].total>work[i+1].total)&&work[i].delet==0)
{f=ier()}
while(1)
{ system("cls")menu1()display1()
printf(" 保存请按 1 取消请按 2\n")
scanf("%d",&e)
if(e==1){save()break}
else if(e==2)break
else {system("cls")menu1()printf("写错啦!想好了写!!\n")
printf("继续请按任意数字键!\n")scanf("%d",&i)}
}
}
deci() /*退出继续选择*/
{ int e,i
while(1)
{ system("cls")menu1()
printf(" 继续按 1 退出按 2 \n")
scanf("%d",&e)
if(e==1){g=1break}
if(e==2){g=2break}
else {printf("error!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
}
}
order() /*排序函数*/
{ int e,i
while(g==1)
{system("cls")menu1()
printf("按数量排序请按 1 \n")
printf("按单价排序请按 2 \n")
printf("按总价排序请按3 \n")
scanf("%d",&e)
if(e==1){order1()deci()}
else if(e==2){order2()deci()}
else if(e==3){order3()deci()}
else {system("cls")menu1()printf("写错啦!想好了写!!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
}
g=1
}
recy() /*恢复函数*/
{
int i,e,numFILE *fp
system("cls")menu1()
fp=fopen(fname,"rb")
for(i=0i<ni++)
fread(&work[i],sizeof(struct material),1,fp)
printf("编号 名称 类别 登记时间数量 单价总价\n")
for(i=0i<ni++)
if(work[i].delet==1)
{ printf("%-5d %-10s %-10s %-10s %-6d %-6d %-6d \n",work[i].num,work[i].name,work[i].leibie,
work[i].shijian,work[i].shuliang,work[i].price,work[i].total)
}
else if(i==n){printf("没找着,想好了再找!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
while(1)
{ system("cls")menu1()r1()
printf("全部死刑(清空)0 宣判无罪(恢复)1 大赦天下(全部恢复)2 打道回府(退出)3 \n")
scanf("%d",&e)
if(e==0)
{for(i=0i<ni++)
if(work[i].delet==1)work[i].delet=2break
}
else if(e==1)
{ system("cls")menu1()r1()
printf("请输入要恢复的材料的编号:\n")
scanf("%d",&num)
for(i=0i<ni++)
if(num==work[i].num&&work[i].delet==1) break
if(i<n) {work[i].delet=0break}
else if(i==n) {printf("没找着,想好了再找!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)break}
}
else if(e==2)
{for(i=0i<ni++)
if(work[i].delet==1)work[i].delet=0break
}
else if(e==3)break
else {printf("写错啦!想好了写!!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
}
system("cls")menu1()printf("搞定!\n")
printf("按任意数字键退出!\n")scanf("%d",&i)save()
}
tongji() /*统计函数*/
{int i,e,n1=0,n2=0,n3=0,n4=0,n5=0,z=0,c=0FILE *fp
system("cls")menu1()
fp=fopen(fname,"rb")
for(i=0i<ni++)
fread(&work[i],sizeof(struct material),1,fp)
for(i=0i<ni++)
{if(work[i].delet==0){z=z+work[i].totalc++}
if(work[i].total<3000&&work[i].delet==0)n1++
if(work[i].total>=3000&&work[i].total<4000&&work[i].delet==0)n2++
if(work[i].total>=4000&&work[i].total<5000&&work[i].delet==0)n3++
if(work[i].total>=5000&&work[i].delet==0)n4++
}
n5=z/c
printf(" 总价 材料种类数 \n",n1)
printf(" 3000以下: %d\n",n1)
printf(" 3000 --- 4000: %d\n",n2)
printf(" 4000 --- 5000: %d\n",n3)
printf(" 5000以下: %d\n",n4)
printf("平均价格: %d\n",n5)
printf("\n\n")
system("pause")
while(1)
{ system("cls")menu1()
printf(" 保存请按 1 取消请按 2\n")
scanf("%d",&e)
if(e==1){save()break}
else if(e==2)break
else {printf("写错啦!想好了写!!\n")printf("继续请按任意数字键!\n")
scanf("%d",&i)}
}
printf("按任意数字键退出!\n")
scanf("%d",&i)
}
menu1() /*欢迎界面*/
{
printf("\t \n")
printf("\t 课 程 设 计\n")
printf("\t \n")
printf("\t 材料管理系统 \n")
printf("\t \n")
printf("\t 自动化 \n")
printf("\t王璇\n")
printf("\t \n")
printf("\t \n")
printf("\t\n")
printf("\t\n")
printf("\t \n")
printf("\t\n")
}
menu2() /*菜单函数*/
{
printf("\t1.添加材料信息\n")
printf("\t2.查看全部材料信息\n")
printf("\t3.查找材料资料\n")
printf("\t4.删除材料资料\n")
printf("\t5.修改材料数据\n")
printf("\t6.材料信息排序\n")
printf("\t7.已经删除的材料档案\n")
printf("\t8.材料信息记录统计\n")
printf("\t9.文件管理\n")
printf("\t0.退出\n")
}
main() /*主函数*/
{
system("cls")
menu1()
jianli()
slect()
}
按照规范的设计方法,一个完整的数据库设计一般分为以下六个阶段:⑴ 需求分析:分析用户的需求,包括数据、功能和性能需求;
⑵ 概念结构设计:主要采用E-R模型进行设计,包括画E-R图;
⑶ 逻辑结构设计:通过将E-R图转换成表,实现从E-R模型到关系模型的转换;
⑷ 数据库物理设计:主要是为所设计的数据库选择合适的存储结构和存取路径;
⑸ 数据库的实施:包括编程、测试和试运行;
⑹ 数据库运行与维护:系统的运行与数据库的日常维护。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)