Ejemplo n.º 1
0
int Schedule_UI_Query(int id){
	int ret=0;
	schedule_t data;
	if(id==-1){
		while(1){
		printf("\n\t\t		|     请输入计划ID:");
			if(scanf("%d",&id)==1){ cl_stdin(); break;}
			else{ cl_stdin();printf("\n\t\t		                        **您的输入有误!请重新输入**     "); }
		}
	}
	
	if(Schedule_Srv_FetchByID(id, &data)){
		//while(1){ 

				system("clear");
				printf("\n\n\n\t\t		=================================================================");
        			printf("\n\t\t		*************************根据ID查询演出计划*************************");
          			printf("\n\t\t		=================================================================");
       				printf("\t\t\t\t %-4s %10s %-12s %-10s %-10s %-8s\n", "ID", "剧目编号", "演出厅编号",
				 "上映日期","上映时间","票价");
				printf("\n\t\t		-----------------------------------------------------------------");
				printf("\n\t\t\t\t %-3d 『%d』\t『%d』",data.id, data.play_id,data.studio_id);
				printf("%4d-%02d-%02d",data.date.year, data.date.month,data.date.day);
				printf(" %2d:%02d:00", data.time.hour, data.time.minute);
				printf(" %5d", data.price);
				
				printf("\n\t\t		=================================================================");
       				
		
	}else{
				printf("\n\t\t		                       **未找到ID『%d』!请重新输入**",id);
	}
    sleep(1);
       return ret;
}
Ejemplo n.º 2
0
inline int Sale_UI_SellTicket(ticket_list_t tickList, seat_list_t seatList){
	
	int id;
	ticket_list_t head;
	schedule_t sch;
	
	
    printf("\n		|     请输入演出计划ID:");
			
	while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n		                        **您的输入有误!请重新输入**     ");}
	}
	
	if(!Schedule_Srv_FetchByID(id, &sch)){
			printf("\n		                        **未找到ID『%d』!按任意键返回**     ",id);
			getchar();
			return 0;
	}
	
	Ticket_Srv_FetchBySchID(tickList, sch.id);
			
	Seat_Srv_FetchValidByRoomID(seatList, sch.studio_id);
	
	
	Ticket_UI_ListBySch(&sch,tickList,seatList);
	
	
    return 1;
}
Ejemplo n.º 3
0
//根据用户账号名删除一个已经存在的用户账号信息,如果不存在这个用户账号名,提示出错信息
int Account_UI_Delete(account_list_t head,char usrName[]) {

		int ret=0;
       		char choice;
		account_t data;	
		if( Account_Srv_FetchByUsrName(usrName,&data) ){
			if(gl_CurUser.id==data.id){
				printf("\n		----------------------------没有权限!------------------------------");
				cl_stdin();
				getchar();
				return 0;
			}
			while(1){
				system("clear");
				
				printf("\n\t\t==================================================================");
       			printf("\n\t\t***************************删除用户********************************");
        		printf("\n\t\t==================================================================");
       			printf("\n\t\t\t%s\t\t%s\t\t%s", "ID", "用户类型", "用户名");
				printf("\n\t\t------------------------------------------------------------------");
				printf("\n		          \033[31m**该功能涉及系统安全,请谨慎操作!**\033[0m\n");
				printf("\n\t\t------------------------------------------------------------------");
				printf("\n\t\t\t%d\t\t ", data.id);
			
				switch(data.type){
					case USR_CLERK:  printf("%s\t\t\t","CLERK"); 	break;
					case USR_MANG:	 printf("%s\t\t\t","MANG");  	break;
					case USR_ADMIN:  printf("%s\t\t\t","ADMIN"); 	break;
				}
				printf("%20s\n", data.username);
				printf("\n		-----------------------------------------------------------------");
				printf("\n		|          [D]elete          |               [R]eturn           |");
				printf("\n		******************************************************************");
       			 printf("\n		Input Your choice:");
				choice=l_getc();
				if('r'==choice || 'R'==choice) break;	
				
				if('d'==choice || 'D'==choice){
					
					if(Account_Srv_DeleteByID(data.id)){
						printf("\n		----------------------------删除成功!------------------------------");
						ret=1;
					}else{
						 printf("\n		----------------------------删除失败!------------------------------");
					}
				sleep(1);
				}
			}
		
		
       
       }else{
       		printf("\n		----------------------------未找到信息!------------------------------");
		cl_stdin();
		sleep(1);
       	}
       
       return ret;
}
Ejemplo n.º 4
0
int prom(char *msg,char a,char b){
	char ch;
	printf("\n%s [ %c / %c ] ",msg,a,b);
	cl_stdin();
	ch=l_getc();
	cl_stdin();
	if(ch==a||ch==a-32) return 1;
	if(ch==b||ch==a-32) return 0;
	return -1;
}
Ejemplo n.º 5
0
int SysLogin() {
	
	
	int i=MAX_TIMES;
	char uname[30],pwd[30];
	
	Account_Srv_InitSys();
	
	while(i--){
		system("clear");
        printf("\n\t\t==================================================================");
        printf("\n\t\t***************************用户登陆********************************");
        printf("\n\t\t==================================================================");
        printf("\n\n\n\t\t\t\t用户名:");
       	scanf("%s",&uname);
       	printf("\n\t\t\t\t密  码:");
       	cl_stdin();
       	getpwd(30,pwd); //input passwd	
		if(Account_Srv_Verify(uname,pwd)){ 
			printf("\n\n		------------------------登陆成功!--------------------------");sleep(1);
			return 1;
		}else{

			if(i>0){  
			printf("\n\n		------------用户名或密码错误!还可以输入%d次-------------",i);
				sleep(1);
			}
			   
		}
	}
		return 0;
       		
}
Ejemplo n.º 6
0
void Passwd(){
	char oldpwd[30],newpwd[30],newpwd1[30];
	account_t data=gl_CurUser;
	int i=MAX_TIMES,q=0;
	system("clear");
        printf("\n\t\t==================================================================");
        printf("\n\t\t***************************密码修改********************************");
        printf("\n\t\t==================================================================");
        printf("\n\t\t|	当前用户为:%s",gl_CurUser.username);
       	cl_stdin();      		
       		while(i--){
       	        printf("\n\t\t|	旧密码:");
	       		getpwd(30,oldpwd); //input passwd
	       		
	       		if( strcmp(oldpwd,gl_CurUser.password)==0 ){
	       			q=1;
	       			break;
	       		}else{
	       		
		       		if(i>0){  
					printf("\n\n		------------用户名或密码错误!还可以输入%d次-------------",i);
					sleep(1);
                    }
		        }
            }
		while(q){
				 	printf("\n\t\t|	新密码:");
				//cl_stdin();
				getpwd(30,newpwd);
				 	printf("\n\t\t|	再输一次:");
							
				getpwd(30,newpwd1);
				if( strcmp(newpwd,newpwd1)==0 ){
						strcpy(data.password,newpwd);
						
						if(Account_Srv_Modify(&data)){
							gl_CurUser=data;
							printf("\n		----------------------------修改成功!------------------------------");
			
						}else{

							printf("\n		----------------------------修改失败!------------------------------");
						}
						
						break;
				}else{
							
						printf("\n\n		-----------------两次新密码输入不一致!-------------------------");
					sleep(1);
				}
		}
		
		sleep(1);
	

}
Ejemplo n.º 7
0
//添加一个用户账号信息
int Account_UI_Add(void) {
	
	int er=0,newRecCount=0;
       		char choice;
		account_t data,buf;	
		do { 

				system("clear");
				printf("\n\t\t==================================================================");
       			printf("\n\t\t***************************添加用户********************************");
        		printf("\n\t\t==================================================================");
       				
                cl_stdin();
				while(1){
				printf("\n\t\t|	用户名:");
                    gets(data.username);
					if(Account_Srv_FetchByUsrName(data.username,&buf)){
						printf("\t\t           	          **用户已存在!**");
                        //cl_stdin();
					}else break;
				}
		        //cl_stdin();
				printf("\n\t\t|       密码:");
			gets(data.password);	
            printf("\n		-------[1].CLERK------------[2].MANG-------------[3].ADMAIN--------");
				while(1){
				printf("\n		|     请选择用户类型:");
					er=0;
					choice=l_getc();
					switch(choice){
						case '1': data.type= USR_CLERK;  	break;
						case '2': data.type= USR_MANG;   	break;
						case '3': data.type= USR_ADMIN; 	break;
						default : er=1; printf("\n\t\t         	           **输入有误!**   ");
					}
					if(er!=1) break;
				}
				data.id = EntKey_Srv_CompNewKey("User");
			
				
				if(Account_Srv_Add(&data)){
					newRecCount++;
					printf("\n		----------------------------添加成功!------------------------------");
				}else{
					printf("\n		----------------------------添加失败!------------------------------");
					
				}
				printf("\n		==================================================================");
       				printf("\n		|         [A]dd More               |             [R]eturn        |");
        			printf("\n		******************************************************************");
        			printf("\n		Input Your choice:");
				choice=l_getc();
        } while ('a' == choice || 'A' == choice);	
        return newRecCount;

}
Ejemplo n.º 8
0
//创建系统初始化账号admin
void Account_Srv_InitSys(){
	char entName[8];
	if(Account_Perst_CheckAccFile());
	else
		{
            system("clear");
			account_t data_admin;
			data_admin.id=EntKey_Srv_CompNewKey(entName);//调用函数获取用户id
			printf("\n\n\n\t\t\t\t   \033[31m为您创建系统初始化帐号ADMIN\033[0m");
            printf("\n\n\t\t\t\t请输入姓名:");
            scanf("%s",data_admin.username);//为ata_admin账号赋值成员信息 
			data_admin.type=9;
            cl_stdin();
            printf("\n\t\t\t\t请输入密码:");
			getpwd(30,data_admin.password);
            Account_Srv_Add(&data_admin);//将新建data_admin账号写入文件 
            printf("\n\t\t\t\t\t创建成功!");
            sleep(1);

}
}
Ejemplo n.º 9
0
int SysLogout() {
	
	
	int choice;
	    cl_stdin();
		system("clear");
       	printf("\n\n\n\t\t\t==================================================================");
       	printf("\n\t\t\t\t\t%s\t\t\t%s","用户名","用户身份");
		printf("\n\t\t\t------------------------------------------------------------------");
       	printf("\n\n\t\t\t\t\t%s",gl_CurUser.username);
		switch(gl_CurUser.type){
					case USR_CLERK:  printf("\t\t\t%s","CLERK"); 	break;
					case USR_MANG:	 printf("\t\t\t%s","MANG");  	break;
					case USR_ADMIN:  printf("\t\t\t%s","ADMIN"); 	break;
				}
		printf("\n\n\t		-----------------------------------------------------------------");
		printf("\n\t		|          [L]og Out          |               [R]eturn           |");
		printf("\n\t		******************************************************************");
        printf("\n\t		Input Your choice:");
        choice=getchar();
        if(choice=='l'||choice=='L'){
	       	if(Account_Perst_CheckAccFile()){

				printf("\n\n\t\t\t----------------------------注销成功!------------------------------");
				sleep(1);
                SysLogin();
				return 1;
		}else{
				  printf("\n\n\t\t\t----------------------------注销失败!------------------------------");
				
				sleep(1);
				return 0;
				   
			}
		}
		
}
Ejemplo n.º 10
0
//退票
void Sale_UI_ReturnTicket(){
	char choice;
	int id,t=0;
     while(1){
		system("clear");
       		printf("\n		=================================================================");
        		printf("\n		**************************剧目%s的演出计划************************");
          		printf("\n		=================================================================");
            printf("\n		|     请输入演出计划ID:");
		
		while(1){
				if(scanf("%d",&id)==1){ cl_stdin(); break;}
				else{ cl_stdin();printf("\n		                    **您的输入有误!**");}
		}
		
		
		ticket_t buf;
		schedule_t scd;
			
	   	Schedule_Srv_FetchByID(buf.schedule_id, &scd);
		if( Ticket_Srv_FetchByID(id,&buf) ){
			if(buf.status==TICKET_SOLD){
       				Ticket_UI_Print(id);
       				user_time_t nowtime=TimeNow();
       				if(DateCmp(DateNow(), scd.date)==-1 || (DateCmp(DateNow(), scd.date)==0 && scd.time.hour<nowtime.hour && scd.time.minute<nowtime.minute ) ){
       				t=1;
       				Ticket_UI_Print(id);
       				}else{
       					printf("\n		                **您的输入有误!按任意键继续**");
					getchar();
					break;
					
       				}
       			}else{
       			
       				printf("\n		                    **信息不存在!按任意键返回**");
       				
				getchar();
				break;
       			}
       		}
		
		
		if(t){
			printf("\n		-----------------------------------------------------------------");
			printf("\n		|         [Q]uik    	       |             [R]eturn              |");
			printf("\n		******************************************************************");
			printf("\n		==================================================================");
			printf("\n		Iput Your choice:");
			choice=l_getc();
			if('r'==choice || 'R'==choice) break;	
			if('q'==choice || 'Q'==choice) {
			
				
	       			buf.status=TICKET_AVL;
	       			sale_t data;
	       					
	       			data.id=EntKey_Srv_CompNewKey("sale");
	       			data.user_id=gl_CurUser.id;
	       			data.ticket_id=id;
	       			data.date=DateNow();
	       			data.time=TimeNow();
	       			data.value=buf.price;
	       			data.type=SALE_RETURN;
	       					
	       			Sale_Srv_Add(&data);
	       					
	       			Ticket_Srv_Modify(&buf);
       				printf("\n		----------------------------**退票成功! **---------------------------------");
					printf("\n		==================================================================");
				cl_stdin();
				getchar();
											
				break;
       			}
       					
       		}
     			
		
	}
	
}
Ejemplo n.º 11
0
void Sale_UI_MgtEntry() {
	int i, id;
	char choice;

	schedule_list_t head;
	//schedule_node_t *p;
	schedule_node_t *p;
	Pagination_t paging;

	List_Init(head, schedule_node_t);
	//List_Init(head,schedule_node_t);
	
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchAll(head);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n		=================================================================");
        	printf("\n		**************************剧目%s的演出计划*************************");
          	printf("\n		=================================================================");
		printf("\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s\n", "ID", "剧目编号", "演出厅编号",
		 "上映日期","上映时间","票价");
		printf("\n		-----------------------------------------------------------------");
		
		//显示数据
		
			for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
				printf("%5d  『%d』%20s  『%d』%2s ", p->data.id, p->data.play_id, p->data.play_name,p->data.studio_id, p->data.studio_name);
				printf("  %4d-%02d-%02d",p->data.date.year, p->data.date.month, p->data.date.day);
				printf("\t%2d:%02d:%02d ", p->data.time.hour, p->data.time.minute, p->data.time.second);
				printf("\t%5d\n", p->data.price);
				p=p->next;
		}

		printf("\n		==================================================================");
        	printf("\n		|----------总数%2d------------------------------%2d/%2d页---------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n		******************************************************************");
        	printf("\n		|        [P]revPage          |              [N]extPage          |");
		printf("\n		-----------------------------------------------------------------");
		printf("\n		|         [I]D List    	  |             [R]eturn              |");
		printf("\n		******************************************************************");
		printf("\n		==================================================================");
		printf("\n		Iput Your choice:");
		choice=l_getc();
	

		switch (choice) {
		case 'i':
		case 'D':
				
				printf("\n		|     请输入演出计划ID:");
				while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin(); printf("\n		                    **您的输入有误!**");}
				}
				Sale_UI_ShowScheduler(id);
			
				break;
		case 'p':
        case 'P':
			system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,schedule_node_t);
            }
			break;
		case 'n':
        case 'N':
		system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
		}

	
} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Ejemplo n.º 12
0
//根据计划ID显示所有票
void Ticket_UI_ListBySch(const schedule_t *sch,	ticket_list_t tickList, seat_list_t seatList) {
	
	int i,id;
	char choice;
	
	ticket_node_t *pos;
	Pagination_t paging;

	paging.offset = 0;
	paging.pageSize = TICKET_PAGE_SIZE;
	
	//演出计划schedule_id
	paging.totalRecords=Ticket_Srv_FetchBySchID(tickList, sch->id);
	Paging_Locate_FirstPage(tickList, paging);
	do {
		system("clear");
		printf("\t\t\t\033[32m=====================================================================================\n\n");
		printf("\t\t\t***************************************\033[0m\033[34m 票 \033[0m\033[32m******************************************\033[0m\n\n");
		printf("\t\t\t\033[33m%s\t\t%s\t\t%s\033[0m\t\t\033[36m%s\033[0m\t\t\033[31m%s\033[0m","票ID","演出计划ID","座位ID","票价","票状态");

		printf("\n\t\t\t\033[32m-------------------------------------------------------------------------------------\033[0m\n");
		Paging_ViewPage_ForEach(tickList, paging, ticket_node_t, pos, i){
			printf("\t\t\t\033[33m%2d\t\t%5d\t\t %11d\033[0m\t\033[36m%10d\033[0m\t\t", pos->data.id,
					pos->data.schedule_id, pos->data.seat_id, pos->data.price);
					
			switch(pos->data.status){
				case TICKET_AVL:  	printf("\033[31m%5s\033[0m\n","待售"); 	break;
				case TICKET_SOLD:	printf("\033[31m%5s\033[0m\n","已售");	break;
				case TICKET_RESV:   printf("\033[31m%5s\033[0m\n","预留"); 	break;
			}
		}
		
		printf("\n\t\t\t\033[32m----------------- 共 \033[0m\033[33m%d\033[0m\033[32m 条数据 -------------------------- 页码: %d\033[0m/\033[33m%d\033[0m\033[32m -----------------\033[0m\n\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("\t\t\t\033[32m======================================================================================\033[0m\n\n");
		printf("\n\t\t\t\033[33m------------------------ [A]售票 -------------- [B]预留票 ----------------------------\033[0m\n\n");
		printf("\t\t\t\033[32m---------------\033[0m[\033[32mP\033[0m]\033[32m上页---------------\033[0m[\033[33mR\033[0m]\033[33m返回\033[0m\033[32m---------------\033[0m[\033[36mN\033[0m]\033[36m下页\033[0m\033[32m--------------------\033[0m\n\n");
		printf("\t\t\t\033[32m======================================================================================\033[0m\n\n");
		printf("\t\t\t\033[33m请选择: \033[0m");
		choice=l_getc();
		switch(choice)
		{
		case 'p':
		case 'P':
			if (!Pageing_IsFirstPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, -1, ticket_node_t);

			}
			break;
		case 'n':
		case 'N':
			if (!Pageing_IsLastPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, 1, ticket_node_t);
			}
			break;
		case 'a':
		case 'A':
			{
				seat_node_t *p;
				int row,column,t=0;
				printf("\n\t\t\t\033[33m请输入座位的行号: \033[0m");

				while(1){
					if(scanf("%d", &(row))==1){ cl_stdin(); break;}
					else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
				}
					
				printf("\n\t\t\t\033[33m请输入座位的列号: \033[0m");

				while(1){
					if(scanf("%d", &(column))==1){ cl_stdin(); break;}
					else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
				}

				List_ForEach(seatList, p){

					if(row==p->data.row && column==p->data.column){

						ticket_node_t *td;
						td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
					
						if(QueryTicket(td->data.id)==1){
							if(UpdateTicket(td->data.id) ){
								
								sale_t sdata;
								sdata.id=EntKey_Srv_CompNewKey("sale");
								sdata.user_id=gl_CurUser.id;
								sdata.ticket_id=td->data.id;
								sdata.date=DateNow();
								sdata.time=TimeNow();
								sdata.value=td->data.price;
								sdata.type=SALE_SELL;

								Sale_Srv_Add(&sdata);
								system("echo '\n\t\t\t\033[36m售票成功!\t系统正在出票, 请稍候....\033[0m\n' | pv -qL 15");
								sleep(1);
								Ticket_UI_Print(td->data.id);
								printf("\n\n\t\t\t\033[33m按任意键继续....\033[0m\n");
								getchar();
								t=1;
								break;
							}else{
								printf("\n\t\t\t\033[31m售票失败! 请稍候重试! \033[0m\n\t\t\t\033[33m按任意键返回....\033[0m\n");
								getchar();
								t=0;
								break;
							}

						}else{
							printf("\n\t\t\t\033[31m该票已预留或售出!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
							getchar();
							t=1;
							break;
						}
					}
				}

				if(!t){
					printf("\n\t\t\t\033[31m未找到该座位!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
					getchar();
				}
				
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);
			}
			break;
			
		case 'b':
		case 'B':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
					printf("\n\t\t\t\033[33m请输入座位的行号: \033[0m");
				    	
					while(1){
						if(scanf("%d", &(row))==1){ cl_stdin(); break;}
						else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
					}
				    	
					printf("\n\t\t\t\033[33m请输入座位的列号: \033[0m");

					while(1){
						if(scanf("%d", &(column))==1){ cl_stdin(); break;}
						else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
					}
					
					List_ForEach(seatList, p){
					
						if(row==p->data.row && column==p->data.column){

							ticket_node_t *td;
							td= Ticket_Srv_FindBySeatID(tickList, p->data.id);

							if(QueryTicket(td->data.id)==1){
							
								ticket_t  data;
								data=td->data;
								data.status=TICKET_RESV;
								
								if(Ticket_Srv_Modify(&data) ){
									printf("\n\t\t\t\033[33m预留票成功!\033[0m\n");
									printf("\n\t\t\t\033[34m按任意键继续....\033[0m\n");
									getchar();
									t=1;
									break;
								}else{
									printf("\n\t\t\t\033[31m预留票失败! 请稍候重试! \033[0m\n\t\t\t\033[33m按任意键返回....\033[0m\n");
									getchar();
									t=0;
									break;
								}
							}else{
								printf("\n\t\t\t\033[31m该票已预留或售出!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
								getchar();
								t=1;
								break;
							}
						}
					}
					if(!t){	
						printf("\n\t\t\t\033[31m未找到该座位!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
						getchar();
					}
						
					paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
					List_Paging(tickList, paging, ticket_node_t);
				}
				break;
			}
	} while (choice != 'r' && choice != 'R');
Ejemplo n.º 13
0
int Schedule_UI_Add(int play_id) {
	int er=0,sid,newRecCount=0;
       	char choice;
	schedule_t data;
	studio_t sdata;	
	play_t pdata;
    cl_stdin();
		do { 

				system("clear");
				printf("\n\n\n\t\t		=================================================================");
        			printf("\n\t\t		***************************添加演出计划**************************");
          			printf("\n\t\t		=================================================================");
				data.id = EntKey_Srv_CompNewKey("schedule");
				data.play_id=play_id;
				while(1){
				printf("\n\t\t		|     请输入演出厅ID:");
					if(scanf("%d",&sid)==1){
					 cl_stdin(); 
					 
					 if(!Studio_Srv_FetchByID(sid, &sdata)){
					 	printf("\n\t\t\t\t                    **没有演出厅信息!请重新输入**        ");
					 	continue;
					 }
					 
					data.studio_id=sdata.id;
                    data.price=pdata.price;
					data.seat_count=Seat_Number_Count(data.studio_id);
					 
					 break;
					}
					else{ cl_stdin(); printf("\n\t\t\t您的输入有误!请重新输入**  "); }
				}
				while(1){
				printf("\n\t\t		|     请输入演出日期:");
					if(scanf("%d%d%d",&(data.date.year), &(data.date.month), &(data.date.day))==3){
						 cl_stdin();
						 if(data.date.month>12 || data.date.day>31){
						 	printf("\n\t\t		                      **您输入的日期有误!请重新输入**     ");
						 	continue;
						 }
						 if(DateCmp(data.date, DateNow())==-1){
						 	printf("\n\t\t		                      **您输入的日期太早!请重新输入**     ");
						 	continue;
						 
						 }
						 
						 break;
					}
					else{ cl_stdin();printf("\n\t		                        **您的输入有误!请重新输入**     "); }
				}
				
				

				while(1){ 
				printf("\n\t\t		|     请输入演出时间(h min):");
					if(scanf("%d %d",&(data.time.hour), &(data.time.minute))==2){
						data.time.second=0;
						cl_stdin();
						if(data.time.hour>24 || data.time.minute>60){
						 	printf("\n\t\t		                        **您的输入有误!请重新输入**     "); 
						 	continue;
						 }
						
						 break;
					}
					else{ cl_stdin(); printf("\n\t		                        **您的输入有误!请重新输入**     ");  }
				}
				
				
				printf("\n\t\t		==================================================================");		

				if(Schedule_Srv_Add(&data)){
					//Ticket_Srv_AddBatch(data.id, data.studio_id);
					newRecCount++;
					printf("\n\t\t		------------------------添加计划成功!--------------------------");
					printf("\n\t\t		******************************************************************");
				}else{
					
				}
				printf("\n\t\t		==================================================================");
       				printf("\n\t\t		|         [A]dd More               |             [R]eturn        |");
        			printf("\n\t\t		******************************************************************");
        			printf("\n\t\t		Iput Your choice:");
		
				choice=l_getc();
		} while ('a' == choice || 'A' == choice);
	return newRecCount;
			
     
}
Ejemplo n.º 14
0
void Schedule_UI_MgtEntry(int play_id){
     int i, id;
	char choice;
	play_t pdata;
	schedule_list_t head;
	schedule_node_t *p;
	Pagination_t paging;
	Play_Srv_FetchByID(play_id, &pdata);
	List_Init(head, schedule_node_t);
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;
	//载入数据
	paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
	Paging_Locate_FirstPage(head, paging);
	do {
		system("clear");
		printf("\n\n\n\t		=================================================================");
        	printf("\n\t		**************************剧目%d的演出计划*************************",play_id);
          	printf("\n\t		=================================================================");
		printf("\n\t\t\t    %-5s%-10s   %-12s   %-12s      %-12s   %-5s", "ID", "剧目", "演出厅",
		 "上映日期","上映时间","票价");
		    printf("\n\t		-----------------------------------------------------------------");
		//显示数据
		for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
			printf("\n\t\t\t    %-3d 『%d』 \t   『%d』 ", p->data.id, p->data.play_id,p->data.studio_id);
			printf("\t%4d-%02d-%02d\t",p->data.date.year, p->data.date.month, p->data.date.day);
			printf("%2d:%02d:00", p->data.time.hour, p->data.time.minute);
			printf("    %-5d\n", p->data.price);
			p=p->next;
		}
		printf("\n\t		==================================================================");
        printf("\n\t		|-------------总数%2d----------------------------%2d/%2d页-----------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n\t		******************************************************************");
        printf("\n\t		|       [P]revPage            |              [N]extPage           |");
		printf("\n\t		|     [A]dd   |   [D]elete    |     [U]udate      |   [V]iew All  |");         
		printf("\n\t		------------------------[R]eturn----------------------------------");	
  		printf("\n\t		==================================================================");
        	printf("\n\t		Iput Your choice:");
		
		choice=l_getc();
	

		switch (choice) {
		case 'a':
		case 'A':
			{
				studio_list_t slist;
				List_Init(slist, studio_node_t);
				Studio_Srv_FetchAll(slist);
				if(!List_IsEmpty(slist) ){
					if (Schedule_UI_Add(pdata.id)) //新添加成功,跳到最后一页显示
					{
						paging.totalRecords =Schedule_Srv_FetchByPlay(head,play_id);
						Paging_Locate_LastPage(head, paging, schedule_node_t);
					}
				}else{
					if(List_IsEmpty(slist)){
						printf("\n		               **没有演出厅信息,无法添加计划!**  /n");
					}
					printf("\n		-------------------------------按任意键返回-------------------------");
					getchar();
				}
			}
			break;
		case 'd':
		case 'D':
			printf("\n\t		|     请输入计划ID:");
			while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n\t		                        **您的输入有误!请重新输入**     ");}
				}
			
			if (Schedule_UI_Delete(id)) {	//从新载入数据
					paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
					List_Paging(head, paging, schedule_node_t);
			}
			break;
		case 'u':
		case 'U':
				printf("\n		|     请输入计划ID:");
				while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n\t		                        **您的输入有误!请重新输入**     "); }
				}
			
				if (Schedule_UI_Modify(id)) {	//从新载入数据
					paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
					List_Paging(head, paging, schedule_node_t);
				}
			break;
		case 'v':
		case 'V':
			Schedule_UI_ListAll();
			break;
		case 't':
		case 'T':
			//();
			break;
		case 24 :
	     if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, schedule_node_t);
			}
			break;
		case 25 :
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, schedule_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Ejemplo n.º 15
0
//根据用户账号名修改用户账号密码,不存在这个用户账号名,提示出错信息
int Account_UI_Modify(account_list_t head,char usrName[]) {
       		int er=0,ret=0,q=0;
       		char choice;
            void Passwd();
            
	Pagination_t paging;
	paging.totalRecords = Account_Srv_FetchAll(head);
		account_t data;	
		if( Account_Srv_FetchByUsrName(usrName,&data) ){
			if(gl_CurUser.id==data.id){
				printf("\n		----------------------------没有权限!------------------------------");
				cl_stdin();
				getchar();
				return 0;
			}
			while(1) { 

				system("clear");
				
				printf("\n\t\t==================================================================");
       			printf("\n\t\t***************************修改用户********************************");
        		printf("\n\t\t==================================================================");
       			printf("\n\t\t\t%s\t\t%s\t\t%s", "ID", "用户类型", "用户名");
				printf("\n\t\t------------------------------------------------------------------");
            	printf("\n		             \033[31m**该功能涉及系统安全,请谨慎操作!**\033[0m\n");
				printf("\n\t\t------------------------------------------------------------------");
				printf("\n\t\t\t%d\t\t ", data.id);
			
				switch(data.type){
					case USR_CLERK:  printf("%s\t\t\t","CLERK"); 	break;
					case USR_MANG:	 printf("%s\t\t\t","MANG");  	break;
					case USR_ADMIN:  printf("%s\t\t\t","ADMIN"); 	break;
				}
				printf("%-20s", data.username);
				printf("\n		==================================================================");
        		printf("\n		|---------总数%2d------------------------------%2d/%2d页----------|",paging.totalRecords ,Pageing_CurPage(paging),Pageing_TotalPages(paging));
        		printf("\n		==================================================================");;
				printf("\n		******************************************************************");
        		printf("\n\t\t|	  [T]ype	|	[P]asswd	|	[R]eturn	|");
        		printf("\n		******************************************************************");
        		printf("\n\t\tYour choice:");
				choice=l_getc();
				if('r'==choice || 'R'==choice) break;	
				switch(choice){
					
						
					case 'p':
					case 'P':
                        Passwd();
						/*{
						char fpwd[30]spwd[30];
						while(1){
							printf("\n\t\t|	新密码:");
							cl_stdin();
							getpwd(30,fpwd);
							printf("\n\t\t|请再次输入新密码:");
							
							getpwd(30spwd);
							if( strcmp(fpwdspwd)==0 ){
								strcpy(data.password,fpwd);
								q=1;
								break;
							}else{
							printf("\n\n		-----------------两次新密码输入不一致!-------------------------");
							}
						}
						}*/
						break;
						
					case 't':
					case 'T':
						printf("\n		-------[1].CLERK------------[2].MANG-------------[3].ADMAIN--------");
						printf("\n		|     请选择用户类型:");
						while(1){
							er=0;
							choice=l_getc();
							switch(choice){
								case '1': 
									
									if(data.type!= USR_CLERK){
										data.type= USR_CLERK;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
									} 	
									break;
									
								case '2': 
								
									if(data.type!= USR_MANG){
										data.type= USR_MANG;
										q=1;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
										q=0;
									} 	
									break;
								case '3': 
								
									if(data.type!= USR_ADMIN){
										data.type= USR_ADMIN;
										q=1;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
										q=0;
									} 	
									break;
								default : er=1; printf("\n\t\t        	           **输入有误!**   ");
							}
							if(er!=1) break;
						}
						break;
					}
			
				
				if(q && Account_Srv_Modify(&data)){
					printf("\n		----------------------------修改成功!------------------------------");
					ret=1;
				}else{
					if(q!=0) printf("\n		----------------------------修改成功!------------------------------");;
				}
				cl_stdin();
				sleep(1);
		
		}
       
       }else{
       		printf("\n		----------------------------未找到信息!------------------------------");
		cl_stdin();
		sleep(1);
       	}
       
       return ret;
}
Ejemplo n.º 16
0
int Schedule_UI_Modify(int id){
	int ret=0,sid;
       	char choice;
	schedule_t data;
	studio_t sdata;	
	
	if(Schedule_Perst_SelectByID(id, &data)){
		
		while(1){ 

				system("clear");
				printf("\n\n\n\t\t		=================================================================");
        			printf("\n\t\t		***************************修改演出计划*******************************");
          			printf("\n\t\t		=================================================================");
       				printf("\n\t\t\t  %-5s  %-10s  %-12s %-10s %-10s %-10s ", "ID", "剧目ID", "演出厅ID",
				 "放映日期","放映时间","座位数");
				printf("\n\t		-----------------------------------------------------------------");
				printf("\n\t\t\t%-3d 『%d』\t『%d』", data.id,data.play_id,data.studio_id);
				printf(" %4d-%2d-%2d",data.date.year, data.date.month,data.date.day);
				printf(" %2d:%2d:00 ", data.time.hour, data.time.minute);
				printf("  %5d", data.price);
		
				printf("\n\t\t		==================================================================");
       				printf("\n\t\t		|      [S]tudio       |       [T]ime        |       [R]eturn     |");
        			printf("\n\t\t		******************************************************************");
				printf("\n\t\t		Iput Your choice:");
				choice=l_getc();
				if('r'==choice || 'R'==choice) break;	
				switch(choice){
					
					case 's':
					case 'S':
						while(1){
						printf("\n\t\t\t\t|\t请输入演出厅ID:");
							if(scanf("%d",&sid)==1){
							 cl_stdin(); 
							 
							 if(!Studio_Srv_FetchByID(sid, &sdata)){
							 	printf("\n\t\t\t\t\t\t**没有演出厅信息!请重新输入**  ");
							 	continue;
							 }
							 
							data.studio_id=sdata.id;
							data.seat_count=Seat_Number_Count(data.studio_id);
							 
							 break;
							}
							else{ cl_stdin(); printf("\n\t\t\t\t		                        **您的输入有误!请重新输入**     ");  }
						}
						break;
		
					case 't':
					case 'T':
				
						while(1){
						printf("\n\t\t		|     请输入上映日期( 年 月 日):   ");
							if(scanf("%d %d %d",&(data.date.year), &(data.date.month), &(data.date.day))==3){
								 cl_stdin();
								 if(data.date.month>12 || data.date.day>31){
								 	printf("\n\t\t		                      **您输入的日期有误!请重新输入**     ");
								 	continue;
								 }
								 if(DateCmp(data.date, DateNow())==-1){
								 	printf("\n\t\t		                    **您输入的时间早于今天!请重新输入!**   ");
								 	continue;
								 
								 }
								 
								 break;
							}
							else{ cl_stdin(); printf("\n\t\t		                        **您的输入有误!请重新输入**     ");}
						}
						
				
				
						printf("\n\t\t		|     请输入上映时间(h min):");
						while(1){ 
							if(scanf("%d %d",&(data.time.hour), &(data.time.minute))==2){
								data.time.second=0;
								cl_stdin();
								if(data.time.hour>24 || data.time.minute>60){
								 	 printf("\n\t\t		                        **您的输入有误!请重新输入**  "); 
								 	continue;
								 }
						
								 break;
							}
							else{ cl_stdin();printf("\n\t\t		                        **您的输入有误!请重新输入**  ");  }
						}
						
						break;
				
				
				}//switch
				printf("\n\t\t		==================================================================");		

				if(Schedule_Srv_Modify(&data)){
					
					printf("\n\t\t		--------------------------修改计划成功!----------------------------");
					printf("\n\t\t		******************************************************************");
					ret=1;
				}else{
					printf("\n\t\t		--------------------------修改计划成功!----------------------------");
					printf("\n\t\t		******************************************************************");
				}
			sleep(1);
		}//while
	}else{
	    printf("\n\t\t                         **没有演出厅信息!** ");
		sleep(1);
        return 0;
	}
       return ret;
}
Ejemplo n.º 17
0
//根据计划ID显示所有票
void Ticket_UI_ListBySch(const schedule_t *sch,	ticket_list_t tickList, seat_list_t seatList) {
	
	int i,id;
	char choice;
	
	
	
	ticket_node_t *pos;
	Pagination_t paging;
	
	
	paging.offset = 0;
	paging.pageSize = TICKET_PAGE_SIZE;
	
	//演出计划schedule_id
	paging.totalRecords=Ticket_Srv_FetchBySchID(tickList, sch->id);
	Paging_Locate_FirstPage(tickList, paging);
	do {
		system("clear");
	        printf("\t\t\t=====================================================================================\n\n");
	        printf(
				"\t\t\t*************************************票******************************************\n\n");
		printf("\t\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s","票ID","演出计划ID","座位ID","票价","票状态");

		printf("\n\t\t\t---------------------------------------------------------------------------------------\n");
		Paging_ViewPage_ForEach(tickList, paging, ticket_node_t, pos, i){
			printf("\t\t\t%2d\t\t%5d\t\t %8d\t%10d\t\t", pos->data.id,
					pos->data.schedule_id, pos->data.seat_id, pos->data.price);
					
			switch(pos->data.status){
				case TICKET_AVL:  	printf("%5s\n","待售"); 	break;
				case TICKET_SOLD:	printf("%5s\n","已售");  	break;
				case TICKET_RESV:   	printf("%5s\n","预留"); 	break;
			}
		}
		
		printf("\n\t\t\t------- 总数:%2d ---------------------------------------------------- 页数 %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("\t\t\t***************************************************************************************\n");
		printf("\n\t\t\t===================================================================================\n\n");
		
		printf("\n\t\t\t=========[P]上一页====================================[N]下一页=====================\n");
		printf("\n\t\t\t=========[A]售票==============[B]预留票===============[R]返回=====================\n");
		
		printf("\n\t\t\t===================================================================================\n");
		printf("\t\t\t请选择:");
		choice=l_getc();
		switch(choice)
		{
		case 'p':
		case 'P':
			if (!Pageing_IsFirstPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, -1, ticket_node_t);

			}
			break;
		case 'n':
		case 'N':
			if (!Pageing_IsLastPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, 1, ticket_node_t);
			}
			break;
		case 'a':
		case 'A':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
				    	printf("\t\t\t请输入座位的行号:");
				    	
				    	while(1){
							if(scanf("%d", &(row))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
				    	
				    	printf("\t\t\t请输入座位的列号:");
				    	
				    	while(1){
							if(scanf("%d", &(column))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
					
					List_ForEach(seatList, p){
					
							if(row==p->data.row && column==p->data.column){
								
								ticket_node_t *td;
								
								td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
								
								
								
								if(QueryTicket(td->data.id)==1){
									if(UpdateTicket(td->data.id) ){
										sale_t sdata;
	       					
							       			sdata.id=EntKey_Srv_CompNewKey("sale");
							       			sdata.user_id=gl_CurUser.id;
							       			sdata.ticket_id=td->data.id;
							       			sdata.date=DateNow();
							       			sdata.time=TimeNow();
							       			sdata.value=td->data.price;
							       			sdata.type=SALE_SELL;
							       					
							       			Sale_Srv_Add(&sdata);
											printf("\n\t\t\t售票成功!\t系统正在出票,请稍候。。。\n");
											sleep(1);
											Ticket_UI_Print(td->data.id);
											printf("\n\n\t\t\t按任意键继续!。。。\n");
											getchar();
											t=1;
											break;
									}else{
											printf("\n\t\t\t售票失败!\t请稍候重试。\n\t\t\t按任意键返回。。。\n");
											getchar();
											t=1;
											break;
									}
									
									
								}else{
								
									printf("\n\t\t\t该票已预留或售出!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									break;
								}
							}
					}
						
						
					if(!t){
								
									printf("\n\t\t\t未找到该座位!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									
								
								
					}
				
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);	
			
				}
				break;
		case 'b':
		case 'B':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
				    	printf("\t\t\t请输入座位的行号:");
				    	
				    	while(1){
							if(scanf("%d", &(row))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
				    	
				    	printf("\t\t\t请输入座位的列号:");
				    	
				    	while(1){
							if(scanf("%d", &(column))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
					
					List_ForEach(seatList, p){
					
							if(row==p->data.row && column==p->data.column){
							
								ticket_node_t *td;
								
								td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
								
								
								
								if(QueryTicket(td->data.id)==1){
								
									ticket_t  data;
									data=td->data;
									data.status=TICKET_RESV;
									
									if(Ticket_Srv_Modify(&data) ){
											printf("\n\t\t\t预留票成功!\n");
											
											printf("\n\n\t\t\t按任意键继续!。。。\n");
											getchar();
											t=1;
											break;
									}else{
											printf("\n\t\t\t预留票失败!\t请稍候重试。\n\t\t\t按任意键返回。。。\n");
											getchar();
											t=1;
											break;
									}
								}else{
								
									printf("\n\t\t\t该票已预留或售出!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									break;
								}
							}
								
					
					}
						
						
						
					if(!t){	
									printf("\n\t\t\t未找到该座位!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
							
					}
						
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);		
					
			
				}
				break;
			
		
		
		}
	} while (choice != 'r' && choice != 'R');