/*
 * Function:    Play_Perst_SelectByName
 * Function ID:	TTMS_SCU_Play_Perst_SelByName
 * Description: 按照剧目名称查找剧目的信息
 * Input:       list为查找到的剧目信息链表,condt为模糊查询的关键字
 * Output:      提示建立链表时,申请空间失败
 * Return:      返回查找到的记录数目
 */
int Play_Perst_SelectByName(play_list_t list, char condt[]) {
    play_t      data;
    play_node_t *newNode;
    int         iCount = 0;
    FILE        *fp;
    fp = fopen(PLAY_DATA_FILE,"rb");
    if(fp == NULL)
    {
        printf("Failed to open file %s!\n[Enter] to return!",PLAY_DATA_FILE);
        getchar();
        return 0;
    }
    
    List_Free(list,play_node_t);
    
    while (!feof(fp))
    {
        if (fread( &data, sizeof(play_t), 1, fp))
        {
            if (strcmp(condt,data.name) == 0)
            {
                newNode->data = data;
                List_AddTail(list,newNode);
                iCount++;
            }
        }
    }
    return iCount;
}
Example #2
0
//结合剧目Play.dat,统计销售数据,构建销售分析salesanalysis_list_t list链表,返回list链表长度
int Salesanalysis_Srv_StaticSale(salesanalysis_list_t list) {
	
	int count=0;
	int sold;	//已售票数 
	int total;	//总票数 
	assert(NULL!=list) ;
	play_list_t playList,pos;
	
	salesanalysis_node_t *newNode;
	

	List_Free(list,salesanalysis_node_t);//释放所有数据结点 
	List_Init(playList,play_node_t);//初始化 
	Play_Srv_FetchAll(playList);//载入剧目信息,构建链表
	
	List_ForEach(playList,pos){ 
		 
		newNode=(salesanalysis_node_t *)malloc(sizeof(salesanalysis_node_t));
		if(!newNode){
			break;
		}
		newNode->data.play_id=pos->data.id;	//剧目信息 
		newNode->data.start_date=pos->data.start_date;
		newNode->data.end_date=pos->data.end_date;
		
		newNode->data.sales=Schedule_Srv_StatRevByPlay(pos->data.id,&sold,&total);
		newNode->data.totaltickets=sold;
		List_AddTail(list,newNode);
		count++;
	}
Example #3
0
//根据行、列数初始化演出厅的座位
int Seat_Srv_RoomInit(seat_list_t list, int roomID, int rowsCount,
		int colsCount) {
	int i, j;

	seat_node_t *p;

	//批量获取主键
	long seatID=EntKey_Srv_CompNewKeys("Seat", rowsCount*colsCount);

	//先按行列数生成默认座位,形成链表
	for (i = 1; i <= rowsCount; i++){
		for (j = 1; j <= colsCount; j++) {
			p = (seat_node_t *) malloc(sizeof(seat_node_t));
			p->data.id = seatID;
			p->data.roomID = roomID;
			p->data.row = i;
			p->data.column = j;
			p->data.status = SEAT_NONE;
			seatID++;
			List_AddTail(list, p);
		}
	}

	return Seat_Perst_InsertBatch(list);
}
Example #4
0
int Play_Perst_SelectAll(play_list_t list) {
	// Çë²¹³äÍêÕû
	play_node_t *newNode;
	play_t data;
	int recCount = 0;

	assert (NULL != list);
		
	List_Free (list, play_node_t);
		
	FILE *fp = fopen (PLAY_DATA_FILE, "rb");
	if (NULL == fp)
	{
		return 0;
	}

	while (!feof (fp))
	{	
		if(fread (&data, sizeof (play_t), 1, fp))
		{
			newNode = (play_node_t *) malloc (sizeof (play_node_t));
			if (!newNode)
			{
				printf ("Memory Load fail!\n");
				break;
			}
			newNode->data = data;
			List_AddTail (list, newNode);
			recCount ++;
		}
	}
	fclose (fp);
	return recCount;	
}
Example #5
0
int Ticket_Perst_SelectBySchID(ticket_list_t list, int schedule_id) {
	
	ticket_node_t *newNode;
	ticket_t data;
	int recCount = 0;

	assert(NULL !=list);

	FILE *fp = fopen(TICKET_DATA_FILE,"rb");
	if(NULL == fp){
		printf ("Cannot open file %s!\n", TICKET_DATA_FILE);
		return 0;
	}	

	while(!feof(fp)){
		if(fread(&data, sizeof(ticket_t), 1, fp)){
			if(schedule_id == data.schedule_id){
				newNode = (ticket_node_t*) malloc(sizeof(ticket_node_t));
				if(!newNode){
					printf ("Cannot Load Memory!\n");
					exit (1);
				}
				newNode->data=data;
				List_AddTail(list, newNode);
				recCount++;
			}
		}
	}
	fclose(fp);
	return recCount;
}
Example #6
0
File: Arch.c Project: SzAllen/Arch
void Arch_MsgIfAdd(MsgIf* pMsgIf)
{
	if(Null == g_pArch->m_pMsgIfList)
	{
		g_pArch->m_pMsgIfList = (List *)pMsgIf;
	}
	else
	{
		List_AddTail(g_pArch->m_pMsgIfList, (List *)pMsgIf);
	}
}
Example #7
0
//将主键key保存到主键链表keyList中
inline void EntKey_Srv_Add2List(entkey_list_t keyList, long key) {
	assert(NULL != keyList);
	if (!EntKey_Srv_CheckExist(keyList, key)) {
		entkey_node_t *newNode = (entkey_node_t *) malloc(
				sizeof(entkey_node_t));
		if (NULL == newNode) {
			printf("Memory overflow!\n");
			return;
		} else {

			newNode->data.key = key;
			List_AddTail(keyList, newNode);
		}
	}
}
Example #8
0
int Ticket_Srv_AddBatch(int schedule_id, int studio_id){
	int rtn,i,key;
	ticket_node_t *p;
	seat_node_t  *q;
	ticket_list_t ticket_list;
	seat_list_t   seat_list;
	
	schedule_t scd;
	play_t pld;
	
	Schedule_Srv_FetchByID(schedule_id, &scd);
	Play_Srv_FetchByID( scd.play_id,  &pld);
	
	
	//Seat_Number_Count(studio_id);
	 List_Init(ticket_list, ticket_node_t);
	 
	 List_Init(seat_list,seat_node_t);
	 
	 rtn=Seat_Srv_FetchValidByRoomID(seat_list, studio_id);
	 key=EntKey_Srv_CompNewKeys("ticket",rtn);
	 //Seat_Srv_FetchByRoomID(seat_list,studio_id);
	  
	
	 q=seat_list->next;
	for(i=1;i<=rtn;i++)
	{
	   
	   p=(ticket_node_t *)malloc(sizeof(ticket_node_t));
	   p->data.id=key;
	   p->data.schedule_id=schedule_id;
	  	p->data.seat_id=q->data.id;
	   	p->data.price=pld.price;
	   	p->data.status=TICKET_AVL;
	   	List_AddTail(ticket_list,p);
	   	key++;
	   	q=q->next;
	   
	 }
	 
	
	   Ticket_Perst_Insert(ticket_list);
       	   return 1;
}
Example #9
0
//将结点node加入到已排序链表list中
void Seat_Srv_AddToSoftedList(seat_list_t list, seat_node_t *node) {

	seat_node_t *p;

	assert(list!=NULL && node!=NULL);

	if(List_IsEmpty(list))	{
		List_AddTail(list, node);
	}else{
		//寻找插入位置
		p=list->next;

		while(p!=list && (p->data.row<node->data.row ||
                    (p->data.row==node->data.row && p->data.column<node->data.column))){
			p=p->next;
		}
		//将结点node加入到p之前
		List_InsertBefore(p, node);
	}
}
/*
 * Function:    Play_Perst_SelectAll
 * Function ID:	TTMS_SCU_Play_Perst_SelAll
 * Description: 将所有剧目信息建立成一条链表
 * Input:       list剧目信息链表的头指针
 * Output:      提示建立链表时,申请空间失败
 * Return:      返回查找到的记录数目
 */
int Play_Perst_SelectAll(play_list_t list) {
   play_t          data;
    play_node_t     *newNode;
    int             recCount = 0;
    FILE            *fp;
    fp = fopen(PLAY_DATA_FILE,"rb");
    if(fp == NULL)
    {
        //printf("Failed to open file %s!\n[Enter] to return!",STUDIO_FILE);
        //getchar();
        return 0;
    }
    
    List_Free(list,play_node_t);
    
    while(!feof(fp))
    {
        if(fread( &data, sizeof(play_t), 1, fp))
        {
            newNode = (play_node_t *)malloc(sizeof(play_node_t));
            if(newNode)
            {
                newNode->data = data;
                List_AddTail(list,newNode);
                recCount++;
            }
            else
            {
                printf("Memory application failure!!\n[Enter] to continue!");
                getchar();
                break;
            }
        }
    }
    fclose(fp);
    return recCount;
}
Example #11
0
//根据给定时间区间内的销售记录
int Sale_Perst_SelectByDate(sale_list_t list, user_date_t stDate,user_date_t endDate) 
{
	FILE *fp;
	int i,j;
	int recCount;
	fp=fopen(SALE_DATA_FILE,"rb");
	sale_t saleRec;
	sale_list_t newNode;
	if(fp==NULL)
	{
		printf("文件打开失败!\n");
	}
	else
	{
		while(fread(&saleRec,sizeof(sale_t),1,fp)==1)
		{
			i=DateCmp( saleRec.date,stDate);    //          1
			j=DateCmp(  endDate,saleRec.date);     //   1 
			if( i !=-1 && j !=-1)
			{
				newNode=(sale_node_t *)malloc(sizeof(sale_node_t ));
				newNode->data.id=saleRec.id;
				newNode->data.user_id=saleRec.user_id;
				newNode->data.ticket_id=saleRec.ticket_id;
				newNode->data.date=saleRec.date;
				newNode->data.time=saleRec.time;
				newNode->data.value=saleRec.value;
				newNode->data.type=saleRec.type;
				List_AddTail(list,newNode);
				recCount++;
				break;
			}
		}
	}
	return recCount;
}
Example #12
0
/**
 * List_MoveTail - delete from one list and add as another's tail
 * @list: the entry to move
 * @head: the head that will follow our entry
 */
static MV_INLINE void List_MoveTail(List_Head *list,
				  List_Head *head)
{
        __List_Del(list->prev, list->next);
        List_AddTail(list, head);
}