功能模块图;
- 楼盘销售系统.c
//function_1包含:实现菜单,输入函数,输出函数,读文件函数,存文件函数
//function_2包含:增删减除,排序函数,统计函数
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include"function_1.h"
#include"function_2.h"
int main()
{
int f_0 = 9;//选择登录
int f_00 = 9;//选择创建账号(录入客户信息或员工信息)
int f_10 = 9;//用户选择服务
int f_t = 0;//每次的退出
int f_13 = 0;//选择预约与直接购买
int f_2 = 0;//进入员工页面选择
int f_3 = 0;//经理页面选择
int f_38 = 0;//选择查找方式
int ret = 0;//确认账号密码是否正确
// char f_12_m[20] = "12";//
int price_s = 0;//价格筛选
char Type_s[20] = { 0 };//按楼盘类型筛选
char Estate_n[25] = { 0 };//删除指定楼盘
char Type_i[20] = { 0 };//删除指定楼盘的户型
char inclu_s[20] = { 0 };//按楼盘查找
char Account[20] = "12";//账号初始化
char password[20] = "12";//密码的初始化
while (1)
{
loop_0:menu_0();
scanf("%d", &f_0);
system("cls");
if (f_0 > 0 && f_0 < 4)
{
menu_0_0();
}
if (f_0 == 4)
{
printf("感谢使用本系统!");
break;
}
else if (f_0 == 0)
{
menu01();
}
else if (f_0 == 1)//用户登录
{
scanf("%s %s", &Account, &password);
system("cls");
ret = pass_u(Account, password);
if (ret == 0)
goto loop_0;
}
else if (f_0 == 2)//销售人员登录
{
scanf("%s %s", &Account, &password);
system("cls");
ret = pass_e(Account, password);
if (ret == 0)
goto loop_0;
}
else if (f_0 == 3)//经理登录
{
scanf("%s %s", &Account, &password);
system("cls");
ret = pass_m(Account, password);
if (ret == 0)
goto loop_0;
}
else
{
printf("*** 输入错误请重新输入 ***");
continue;
}
switch (f_0)
{
case 0:
scanf("%d", &f_00);
if (f_00 == 0)
{
u_input();//用户创建
u_output();
}
else if (f_00 == 1)
{
e_input();//员工创建
}
else if (f_00 == 2)
{
system("cls");
goto loop_0;
}
break;
case 1:
loop_1:menu_1();
scanf("%d", &f_10);
system("cls");
if (f_10 == 0)//查看户型
{
//读所有的楼盘和户型
printf("以下是所有的楼盘:\n");
E_output();
printf("以下是所有的户型:\n");
t_output();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_1;
}
else if (f_10 == 1)//查看活动
{
system("cls");
menu_11();
Sleep(1000);
goto loop_1;
}
else if (f_10 == 2)//选择进行人工咨询
{
//读取员工信息
e_output();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_1;
}
else if (f_10 == 3)//在线预约和购买
{
menu13();
scanf("%d", &f_13);
system("cls");
if (f_13 == 2)//进行购买
{
printf("感谢购买。\n");
}
else if (f_13 == 3)//退出预约购买页面
{
goto loop_1;
}
else if (f_13 == 1)//进行预约
{
booking();
}
}
else if (f_10 == 4)//退出登录
break;
else if (f_10 == 5)//用户信息录入
{
u_input();
goto loop_1;
}
break;
case 2:
loop_2:menu2_m();//员工主页
scanf("%s", f_2);
{
if (f_2 == 0)
{
lookup_e();//员工个人信息查看
scanf("%d", &f_t);
system("cls");
goto loop_2;
}
else if (f_2 == 1)
{
//查看用户信息
u_output();
scanf("%d", &f_t);
system("cls");
goto loop_1;
}
else if (f_2 == 2)
{
//查看楼盘信息和户型信息
printf("以下是所有的楼盘:\n");
E_output();
printf("以下是所有的户型:\n");
t_output();
scanf("%d", &f_t);
system("cls");
goto loop_1;
}
else if (f_2 == 3)
{
goto loop_0;
}
}
break;
case 3:
loop_3:menu3();
scanf("%d", &f_3);
system("cls");
if (f_3 == 0)//增添楼盘
{
E_input();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 1)//增添户型
{
t_input();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 2)//查看楼盘信息
{
E_output();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 3)//查看户型信息
{
t_output();
menu_t();
scanf("%d", &f_t);
system("cls");
}
else if (f_3 == 4)//查看客户信息
{
u_output();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 5)//查看员工信息
{
e_output();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 6)//删除楼盘信息
{
//删除指定楼盘
scanf("%s", Estate_n);
system("cls");
delete_E(Estate_n);
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 7)//删除户型信息
{
//删除户型信息
scanf("%s", Type_i);
system("cls");
delete_t(Type_i);
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 8)//查找户型信息
{
scanf("%d", &f_38);
if(f_38==0)//价格
{
scanf("%d", &price_s);
system("cls");
lookup_p(price_s);
}
else if (f_38==1)//楼盘类型
{
scanf("%s", Type_s);
system("cls");
lookup_E(Type_s);
}
else if (f_38==2)//户型
{
scanf("%s", inclu_s);
system("cls");
lookup_t(inclu_s);
}
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 10)
{
sort_p();
menu_t();
scanf("%d", &f_t);
system("cls");
goto loop_3;
}
else if (f_3 == 9);
else
{
printf("输入错误请重新选择。\n");
goto loop_3;
}
break;
}
if(f_0==4)
break;
}
return 0;
}
- function_1.h
#include<stdio.h>
#include<string.h>
void menu_0();//选择登录方式
void menu01();//创建账号页面
void menu_0_0();//登录显示
void menu_1();//用户主页
void menu_t();//返回主页
void menu_10();//选择查看的楼盘
void menu_10_m();//选择查看的楼盘的信息
void menu_11();//活动
void menu13();//选择预约或购买
void menu2_m();//员工主页
void menu3();//经理主页
void menu_38();//选择查询方式
- function_1.c
#include<stdio.h>
#include<string.h>
void menu_0()//选择登录方式
{
printf("\t********************\n");
printf("\t****请选择登录页面****\n");
printf("\t*** 0.创建登录账号 ***\n");
printf("\t*** 1.用户登录页面 ***\n");
printf("\t*** 2.销售登录页面 ***\n");
printf("\t*** 3.经理登录页面 ***\n");
printf("\t*** 4.退出楼盘系统 ***\n");
printf("\t********************\n");
}
void menu01()//创建账号页面
{
printf("\t********************\n");
printf("\t*** 0.创建用户账号 ***\n");
printf("\t*** 1.创建员工账号 ***\n");
printf("\t*** 2.返回登录页面 ***\n");
printf("\t********************\n");
}
void menu_0_0()//登录显示
{
printf("\t**************************\n");
printf("\t*** 请输入账号和密码: ***\n");
printf("\t**************************\n");
}
void menu_1()//用户主页
{
printf("\t*****************************\n");
printf("\t*** 0.查看楼盘和户型 ***\n");
printf("\t*** 1.查看活动 ***\n");
printf("\t*** 2.选择进行人工询问的销售 ***\n");
printf("\t*** 3.在线预约和购买 ***\n");
printf("\t*** 4.退出 ***\n");
printf("\t*** 5.用户信息录入 ***\n");
}
void menu_10_m()//选择查看的楼盘
{
printf("\t**************************\n");
printf("\t*** 请选择要查看楼盘的编码 ***\n");
printf("\t*** (编码范围:0~9) ***\n");
printf("\t**************************\n");
}
void menu_10()//选择查看的楼盘的信息
{
printf("\t*****************************\n");//输出指定楼盘名称
printf("\t*** 请选择想要查看的楼盘信息 ***\n");
printf("\t*** 0.楼盘信息(名称,类型,特点)***\n");
printf("\t*** 1.开发商信息 ***\n");
printf("\t*** 2.返回上一级 ***\n");
printf("\t*** 3.直接退出 ***\n");
printf("\t*****************************\n");
}
void menu_t()//返回主页
{
printf("\t*****************************\n");
printf("\t*** 按任意数字键返回主页 ***\n");
printf("\t*****************************\n");
}
void menu_11()//活动
{
printf("\t*****************************\n");
printf("\t*** 暂时没有优惠活动*******\n");
printf("\t*** 一秒后自动返回上一级***********\n");
printf("\t*****************************\n");
}
void menu13()//选择预约或购买
{
printf("\t*********************************\n");
printf("\t*** 1.进行预约 ***\n");//预约时间,楼盘
printf("\t*** 2.进行购买 ***\n");//支付
printf("\t*** 3.返回用户主页面 ***\n");
printf("\t*********************************\n");
}
void menu2_m()//员工主页
{
printf("\t*********************************\n");
printf("\t*** 请完善个人信息 ***\n");
printf("\t*** 0.个人信息查看 ***\n");
printf("\t*** 1.查看用户信息 ***\n");
printf("\t*** 2.查看楼盘和户型信息 ***\n");
printf("\t*** 3.退出登录 ***\n");
printf("\t*********************************\n");
}
void menu3()//经理主页
{
printf("\t*********************************\n");
printf("\t*** 0.添加楼盘信息 ***\n");
printf("\t*** 1.添加户型信息 ***\n");
printf("\t*** 2.查看楼盘信息 ***\n");
printf("\t*** 3.查看户型信息 ***\n");
printf("\t*** 4.查看客户信息 ***\n");
printf("\t*** 5.查看员工信息 ***\n");
printf("\t*** 6.删除楼盘信息 ***\n");
printf("\t*** 7.删除户型信息 ***\n");
printf("\t*** 8.查找户型信息 ***\n");
printf("\t*** 9.退出登录 ***\n");
printf("\t*** 10.按价格降序查看 ***\n");
printf("\t*********************************\n");
}
void menu_38()//选择查询方式
{
printf("\t*********************************\n");
printf("\t*** 0.按户型价格查询 ***\n");
printf("\t*** 1.按楼盘类型查询 ***\n");
printf("\t*** 2.按户型属于的楼盘查询 ***\n");
printf("\t*********************************\n");
}
- function_2.h
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
struct developers//开发商信息
{
char Compang_name[50];//公司名称
char Phone_number[13];//联系电话
char compang_address[50];//公司地址
};
struct estate//楼盘
{
char name[25];//楼盘名称
char address[50];//楼盘地址
char Type_e[20];//楼盘类型
char peculiarity[500];//楼盘特点
}Estate[100];
struct Type_h //户型
{
char inclu[20];//属于那个楼盘
int h_count;//套数
int area;//面积
int unit_price;//单价
int price;//价值
//公共面积
//单价
}Type_H[9];
struct user //用户
{
char u_name[15];//姓名
char u_Account[20];//账号
char u_passwoed[20];//密码
char u_number[15];//联系方式
char u_type[20];//所需楼盘类型
int u_budget;//预算
char time[20];//预约时间
}User[1000];
struct employee //员工
{
char e_name[15];//姓名
char e_Account[20];//账号
char e_password[20];//密码
char e_number[15];//联系方式
}Employee[100];
struct manger //经理
{
char m_name[20];//姓名
char m_Account[20];//账号
char m_password[20];//密码
};
extern int count_u ;
extern int count_e ;
extern int count_E ;
extern int count_t ;
extern const char* u_path ;
extern const char* e_path ;
extern const char* E_path ;
extern const char* t_path ;
extern const char* d_path ;
void u_input();//用户的录入
void e_input();//员工的录入
void E_input();//楼盘的录入
void t_input();//户型的录入
void booking();//预约
void u_output();//用户的输出
void e_output();//员工的输出
void E_output();//所有楼盘的输出
void t_output();//所有户型的输出
int pass_e(char* x, char* y);//检查员工账号密码是否正确
int pass_u(char* x, char* y);//检查用户的账号密码是否正确
int pass_m(char* x, char* y);//经理登录
void lookup(char* x, char* y);//员工个人信息查看
void lookup_p(int x);//查找所需户型信息预算
void lookup_e(x, y);//员工个人信息查看
void lookup_E(char* x);//按楼盘类型查找
void lookup_t(char* x);//按户型所在楼盘查找
void delete_E(char* x);//删除指定的楼盘
void delete_t(char* x);//删除指定的楼盘的户型
void sort_p();//按售价排序
- function_2.c
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include"function_1.h"
#include"function_2.h"
struct developers Developers = {
"超级楼盘",
"1122334",
"某国某省某市"
};
struct manger Manger = {
"ling",
"153",
"166"
};
int count_u = 0;
int count_e = 0;
int count_E = 0;
int count_t = 0;
const char* u_path = "C:\\Users\\16623\\Desktop\\mayun\\test_c1\\c_Real estate sales management system\\user1.txt.txt";
const char* e_path = "C:\\Users\\16623\\Desktop\\mayun\\test_c1\\c_Real estate sales management system\\employee.txt.txt";
const char* E_path = "C:\\Users\\16623\\Desktop\\mayun\\test_c1\\c_Real estate sales management system\\estate.txt.txt";
const char* t_path = "C:\\Users\\16623\\Desktop\\mayun\\test_c1\\c_Real estate sales management system\\Type1.h.txt";
const char* d_path = "C:\\Users\\16623\\Desktop\mayun\\test_c1\\c_Real estate sales management system\\developers1.txt.txt";
void booking()//预约
{
char times[20] = "12";
char u_types[20] = "12";
scanf("%s%s", ×, &u_types);
strcpy(User[count_u].time, times);
strcpy(User[count_u].u_type, u_types);
FILE* fp_u;
fp_u = fopen(u_path, "a");
fprintf(fp_u, "%s%s", User[count_u].time, User[count_u].u_type);
fclose(fp_u);
}
void u_input()//用户的录入
{
FILE* fp_u;
fp_u = fopen(u_path, "a");
if (fp_u == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
printf("请输入您的姓名:");
scanf("%s", &User[count_u].u_name);
printf("请输入您的联系方式:");
scanf("%s", &User[count_u].u_number);
printf("请输入您预期楼盘类型:");
scanf("%s", &User[count_u].u_type);
printf("请输入您的购买预算:");
scanf("%d", &User[count_u].u_budget);
printf("请输入您的密码:");
scanf("%s", &User[count_u].u_passwoed);
printf("请输入您近期的预约时间:");
scanf("%s", &User[count_u].time);
printf("账号为您的联系方式:%s\n", User[count_u].u_number);
strcpy(User[count_u].u_Account, User[count_u].u_number);
fprintf(fp_u, "%s %s %s %s %s %d %s\n", User[count_u].u_name, User[count_u].u_Account, User[count_u].u_passwoed, User[count_u].u_number, User[count_u].u_type, User[count_u].u_budget, User[count_u].time);
fclose(fp_u);
}
void u_output()//所有用户的输出
{
printf("所有用户的信息。\n");
FILE* fp_u1;
fp_u1 = fopen(u_path, "r");
if (fp_u1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_u1, "%s %s %s %s %s %d %s", User[count_u].u_name, User[count_u].u_Account, User[count_u].u_passwoed, User[count_u].u_number, User[count_u].u_type, &User[count_u].u_budget, User[count_u].time) != EOF)
{
printf("用户的个人信息为:\n");
printf("\t姓名\t账号\t密码\t联系方式\t所需楼盘类型\t预算\t预约时间\n");
printf("\t%s\t%s\t%s\t%s\t\t%s\t\t%d\t%s\n", User[count_u].u_name, User[count_u].u_Account, User[count_u].u_passwoed, User[count_u].u_number, User[count_u].u_type, User[count_u].u_budget, User[count_u].time);
}
fclose(fp_u1);
}
void e_input()//员工录入
{
FILE* fp_e;
fp_e = fopen(e_path, "a");
if (fp_e == NULL)
{
printf("\n不能打开员工文件。");
getch();
exit(1);
}
printf("请输入您的姓名:");
scanf("%s", &Employee[count_e].e_name);
printf("请输入您的联系方式:");
scanf("%s", &Employee[count_e].e_number);
printf("请输入您的密码:");
scanf("%s", &Employee[count_e].e_password);
printf("您的账号为您的电话:%s\n", Employee[count_e].e_number);
strcpy(Employee[count_e].e_Account, Employee[count_e].e_number);
fprintf(fp_e, "%s %s %s %s", Employee[count_e].e_name, Employee[count_e].e_Account, Employee[count_e].e_password, Employee[count_e].e_number);
count_e++;
fclose(fp_e);
}
void e_output()//所有员工的输出
{
printf("所有员工的信息。\n");
FILE* fp_e1;
fp_e1 = fopen(e_path, "r");
if (fp_e1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_e1, "%s %s %s %s", Employee[count_u].e_name, Employee[count_u].e_Account, Employee[count_u].e_password, Employee[count_u].e_number) != EOF)
{
printf("员工的个人信息为:\n");
printf("\t姓名\t账号\t密码\t联系方式\n");
printf("\t%s\t%s\t%s\t%s\n", Employee[count_u].e_name, Employee[count_u].e_Account, Employee[count_u].e_password, Employee[count_u].e_number);
}
fclose(fp_e1);
}
void E_input()//楼盘的读入
{
FILE* fp_E;
fp_E = fopen(E_path, "a");
if (fp_E == NULL)
{
printf("\n不能打开楼盘文件。");
getch();
exit(1);
}
printf("请输入楼盘名称:");
scanf("%s", &Estate[count_E].name);
printf("请输入楼盘的地址:");
scanf("%s", &Estate[count_E].address);
printf("请输入楼盘类型:");
scanf("%s", &Estate[count_E].Type_e);
printf("请输入楼盘的特点:");
scanf("%s", &Estate[count_E].peculiarity);
fprintf(fp_E, "%s %s %s %s %s", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity);
fclose(fp_E);
}
void E_output()//所有楼盘的输出
{
printf("所有楼盘的信息。");
FILE* fp_E1;
fp_E1 = fopen(E_path, "a");
if (fp_E1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_E1, "%s %s %s %s", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity) != EOF)
{
printf("楼盘的信息为:\n");
printf("\t楼盘名称\t楼盘地址\t楼怕类型\t楼盘特点\n");
printf("\t%s\t%s\t%s\t%s\n", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity);
}
fclose(fp_E1);
}
void t_input()//户型文件录入
{
FILE* fp_t;
fp_t = fopen(t_path, "a");
if (fp_t == NULL)
{
printf("\n不能打开户型文件。\n");
getch();
exit(1);
}
printf("这个户型属于那个楼盘:");
scanf("%s", &Type_H[count_t].inclu);
printf("这个户型的剩余套数是:");
scanf("%d", &Type_H[count_t].h_count);
printf("这个户型的面积是:");
scanf("%d", &Type_H[count_t].area);
printf("这个户型的面积单价是多少:");
scanf("%d", &Type_H[count_t].unit_price);
printf("这个户型的价格是:");
scanf("%d", &Type_H[count_t].price);
fprintf(fp_t, "%s %d %d %d %d\n", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price);
fclose(fp_t);
}
void t_output()//所有户型的输出
{
printf("所有户型的信息。\n");
FILE* fp_t1;
fp_t1 = fopen(t_path, "r");
if (fp_t1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_t1, "%s %d %d %d %d", Type_H[count_t].inclu, &Type_H[count_t].h_count, &Type_H[count_t].area, &Type_H[count_t].unit_price, &Type_H[count_t].price) != EOF)
{
printf("户型的信息为:\n");
printf("\t户型属于的楼盘\t剩余套数\t户型面积\t单位面积价格\t价格\n");
printf("\t%s\t\t%d\t\t%d\t\t%d\t\t%d\n", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price);
}
fclose(fp_t1);
}
int pass_u(char* x, char* y)//检查用户账号密码是否正确
{
FILE* fp_p;
fp_p = fopen(u_path, "r");
if (fp_p == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
int c = 0;
while (fscanf(fp_p, "%s %s %s %s %s %d %s", User[count_u].u_name, User[count_u].u_Account, User[count_u].u_passwoed, User[count_u].u_number, User[count_u].u_type, &User[count_u].u_budget, User[count_u].time) != EOF)
{
if (strcmp(User[count_u].u_Account, x) == 0 && strcmp(User[count_u].u_passwoed, y) == 0)
{
//成功进入
printf("登录成功。\n");
c=1;
break;
}
else if (strcmp(User[count_u].u_Account, x) == 0 && strcmp(User[count_u].u_passwoed, y) != 0)
{
//密码错误
printf("密码错误\n");
break;
}
else if (strcmp(User[count_u].u_Account, x) != 0)
{
printf("系统内不存在该账号。\n");
break;
}
count_u++;
}
fclose(fp_p);
return c;
}
int pass_e(char* x, char* y)//检查员工账号密码是否正确
{
FILE* fp_p;
fp_p = fopen(e_path, "r");
if (fp_p == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
int c = 0;
while (fscanf(fp_p, "%s %s %s %s", Employee[count_u].e_name, Employee[count_u].e_Account, Employee[count_u].e_password, Employee[count_u].e_number) != EOF)
{
if (strcmp(Employee[count_e].e_Account, x) == 0 && strcmp(Employee[count_e].e_password, y) == 0)
{
//成功进入
printf("登录成功。\n");
c = 1;
break;
}
else if (strcmp(Employee[count_e].e_Account, x) == 0 && strcmp(Employee[count_e].e_password, y) != 0)
{
//密码错误
printf("密码错误\n");
break;
}
else if (strcmp(Employee[count_e].e_Account, x) != 0)
{
printf("系统内不存在该账号。\n");
break;
}
count_e++;
}
fclose(fp_p);
return c;
}
int pass_m(char* x, char* y)//经理登录
{
if (strcmp(Manger.m_Account, x) == 0 && strcmp(Manger.m_password, y) == 0)
{
printf("登录成功。\n");
return 1;
}
else if (strcmp(Manger.m_Account, x) == 0 && strcmp(Manger.m_password, y) != 0)
{
printf("密码错误。\n");
return 0;
}
else if (strcmp(Manger.m_Account, x) != 0)
{
printf("系统中不存在该账号。\n");
return 0;
}
}
void lookup_e(x, y)//员工个人信息查看
{
FILE* fp_p;
fp_p = fopen(e_path, "r");
if (fp_p == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_p, "%s %s %s %s", Employee[count_u].e_name, Employee[count_u].e_Account, Employee[count_u].e_password, Employee[count_u].e_number) != EOF)
{
if (strcmp(Employee[count_e].e_Account, x) == 0 && strcmp(Employee[count_e].e_password, y) == 0)
{
printf("员工姓名为:%s\n", Employee[count_e].e_name);
printf("员工账号为:%s\n", Employee[count_e].e_Account);
printf("员工密码为:%s\n", Employee[count_e].e_password);
printf("员工联系方式为:%s\n", Employee[count_e].e_number);
}
count_e++;
}
fclose(fp_p);
}
void lookup_p(int x) {
FILE* fp_t1;
fp_t1 = fopen(t_path, "r");
if (fp_t1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_t1, "%s %d %d %d %d", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price) != EOF)
{
if (x == Type_H[count_t].price)
{
printf("\t户型属于的楼盘\t剩余套数\t户型面积\t单位面积价格\n");
printf("\t%s\t%d\t%d\t%d\t%d\n", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price);
}
}
}
void lookup_E(char* x)//按楼盘类型查找
{
FILE* fp_E1;
fp_E1 = fopen(E_path, "a");
if (fp_E1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_E1, "%s %s %s %s", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity) != EOF)
{
if (strcmp(Estate[count_E].Type_e, x) == 0)
{
printf("\t楼盘名称\t楼盘地址\t楼怕类型\t楼盘特点\n");
printf("\t%s\t%s\t%s\t%s\n", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity);
}
count_E++;
}
fclose(fp_E1);
}
void lookup_t(char* x)//按户型所属楼盘查找
{
FILE* fp_t1;
fp_t1 = fopen(t_path, "a");
if (fp_t1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_t1, "%s %d %d %d %d", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price) != EOF)
{
if (strcmp(Type_H[count_t].inclu, x))
{
printf("\t户型属于的楼盘\t剩余套数\t户型面积\t单位面积价格\n");
printf("\t%s\t%d\t%d\t%d\t%d\n", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price);
}
count_t;
}
fclose(fp_t1);
}
void delete_E(char* x)//删除指定的楼盘
{
int a = 0;
FILE* fp_E1;
fp_E1 = fopen(E_path, "r");
if (fp_E1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_E1, "%s %s %s %s", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity) != EOF)
{
if (strcmp(Estate[count_E].name, x) == 0)
{
a = count_E;
printf("删除的楼盘信息为:\n");
printf("\t楼盘名称\t楼盘地址\t楼怕类型\t楼盘特点\n");
printf("\t%s\t%s\t%s\t%s\n", Estate[count_E].name, Estate[count_E].address, Estate[count_E].Type_e, Estate[count_E].peculiarity);
}
count_E++;
}
fclose(fp_E1);
fp_E1 = fopen(E_path, "a");
for (int i = 0; i < count_E - 1; i++)
{
if (i != a)
{
fprintf(fp_E1, "%s %s %s %s %s", Estate[i].name, Estate[i].address, Estate[i].Type_e, Estate[i].peculiarity);
}
}
fclose(fp_E1);
}
void delete_t(char* x)//删除指定楼盘的户型
{
int a = 0;
FILE* fp_t1;
fp_t1 = fopen(t_path, "r");
if (fp_t1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_t1, "%s %d %d %d %d", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price) != EOF)
{
if (strcmp(Type_H[count_t].inclu, x) == 0)
{
printf("删除的户型的信息为:\n");
printf("\t户型属于的楼盘\t剩余套数\t户型面积\t单位面积价格\n");
printf("\t%s\t%d\t%d\t%d\t%d\n", Type_H[count_t].inclu, Type_H[count_t].h_count, Type_H[count_t].area, Type_H[count_t].unit_price, Type_H[count_t].price);
}
count_t++;
}
fclose(fp_t1);
fp_t1 = fopen(t_path, "a");
for (int i = 0; i < count_t - 1; i++)
{
if (count_t != a)
{
fprintf(fp_t1, "%s %d %d %d %d", Type_H[i].inclu, Type_H[i].h_count, Type_H[i].area, Type_H[i].unit_price, Type_H[i].price);
}
}
fclose(fp_t1);
}
void sort_p()//按售价排序_从高到底
{
FILE* fp_t1;
fp_t1 = fopen(t_path, "r");
if (fp_t1 == NULL)
{
printf("\n不能打开用户文件。");
getch();
exit(1);
}
while (fscanf(fp_t1, "%s %d %d %d %d", Type_H[count_t].inclu, &Type_H[count_t].h_count, &Type_H[count_t].area, &Type_H[count_t].unit_price, &Type_H[count_t].price) != EOF)
{
count_t++;
}
for (int i = 0; i < count_t; i++)
{
for (int j = 0; j < count_t-i-1; j++)
{
struct Type_h t = {"12",1,1,1,1};
if (Type_H[j].price > Type_H[j + 1].price)
{
t = Type_H[j];
Type_H[j] = Type_H[j + 1];
Type_H[j + 1] = t;
}
}
}
for(int i=0;i<count_t;i++)
{
printf("户型的信息为:\n");
printf("\t户型属于的楼盘\t剩余套数\t户型面积\t单位面积价格\t价格\n");
printf("\t%s\t\t%d\t\t%d\t\t%d\t\t%d\n", Type_H[i].inclu, Type_H[i].h_count, Type_H[i].area, Type_H[i].unit_price, Type_H[i].price);
}
fclose(fp_t1);
}```