2015年7月1日 软件1404 赵毅 课设日志
昨天晚上都说好了,今天,不多说废话。现在直接开始,演出计划界面层
void Schedule_UI_ListAll(void) {
schedule_list_t list;
int id;
char c;
if ( Schedule_Srv_FetchAll(list) )
{
printf("Which ID do you want to look ? \n");
scanf("%d",&id);
while ( Schedule_UI_Query(id) )
{
printf("Query succeed!Do you want continue or quit?Y or N\n");
scanf("%c",&c);
if ( strcmp(c,'Y')==0 )
{
scanf("%d",&id);
continue;
else
{
printf("Bye!\n");
break;
}
}
}
else
{
printf("Fail!\n");
break;
}
}
以上这个是显示所有的演出计划信息,并进入查询界面
int Schedule_UI_Modify(int id){
int rtn=0;
schedule_t *temp;
schedule_list_t new;
if ( Schedule_Srv_FetchByID(id,temp) )
{
printf("This is its old infomation : \n");
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
printf("Input the new infomation : \n");
scanf("%d%d%d%d",&new->data.paly_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
if ( Schedule_Srv_Modify(new) )
{
rtn=1;
printf("Modify succeed!\n");
}
else
printf("Modify fail!\n");
return rtn;
}
else
{
printf("No found!\n");
break;
}
}
以上是修改演出计划界面。
int Schedule_UI_Add(int play_id) {
schedule_list_t new;
while (1)
{
printf("Input the new play infomation : \n");
scanf("%d%d%d%d%d",&new->data.play_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
new->data.play_id=play_id;;
if ( Schedule_Srv_Add(new) )
{
printf("Add succeed!\n");
n++;
}
else
printf("Add faid!\n");
printf("Do you want to continue : \n ");
scanf("%c",&choice);
if ( strcmp(choice,'a')!=0 || strcmp(choice,'A')!=0 )
{
return n;
break;
}
}
}
添加演出计划界面层。
int Schedule_UI_Delete(int id){
int rtn;
schedule_list_t n;
if ( n->data.id==id && Schedule_Srv_DeleteByID(id) )
{
printf("Delete succeed!\n");
rtn=1;
return rtn;
}
else
{
printf("Delete fail!\n");
break;
}
}
删除演出计划界面层。
int Schedule_UI_Query(int id){
schedule_list_t now;
int rtn=0;
if ( Schedule_Srv_FetchByID(id,now) )
{
printf("Here it is : \n");
rtn=1;
return rtn;
}
else
{
printf("Show fail!\n");
break;
}
}
这是啥,以主键为id的演出计划查询。
void Schedule_UI_MgtEntry(int play_id){
int i, id;
char choice;
schedule_list_t head;
schedule_node_t *pos;
Pagination_t paging;
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("cls");*/
printf("\n==================================================================\n");
printf(
"********************** Projection Room List **********************\n");
printf("%5d %18d %10d %10d %10d %10d\n", "ID", "Play_id", "Stduio_id",
"Date_tdate", "My_ttime","Seat_count");
printf(
"------------------------------------------------------------------\n");
//显示数据
Paging_ViewPage_ForEach(head, paging, studio_node_t, pos, i){
printf("%5d %18d %10d %10d %10d %10d\n", pos->data.id,
pos->data.play_id, pos->data.studio_t, pos->data.data_ttime,
pos->data.mytime_ttime);
}
printf("------- Total Records:%2d ----------------------- Page %2d/%2d ----\n",
paging.totalRecords, Pageing_CurPage(paging),
Pageing_TotalPages(paging));
printf("******************************************************************\n");
printf("[P]revPage|[N]extPage | [A]dd|[D]elete|[U]pdate | [S]eat | [R]eturn");
printf("\n==================================================================\n");
printf("Your Choice:");
fflush(stdin);
scanf("%c", &choice);
fflush(stdin);
switch (choice) {
case 'a':
case 'A':
if (Schedule_UI_Add()) //新添加成功,跳到最后一页显示
{
paging.totalRecords = Schedule_Srv_FetchAll(head);
Paging_Locate_LastPage(head, paging, schedule_node_t);
}
break;
case 'd':
case 'D':
printf("Input the ID:");
scanf("%d", &id);
if (Schedule_UI_Delete(id)) { //从新载入数据
paging.totalRecords = Schedule_Srv_FetchAll(head);
List_Paging(head, paging, schedule_node_t);
}
break;
case 'u':
case 'U':
printf("Input the ID:");
scanf("%d", &id);
if (Schedule_UI_Modify(id)) { //从新载入数据
paging.totalRecords = Schedule_Srv_FetchAll(head);
List_Paging(head, paging, schedule_node_t);
}
break;
case 'q':
case 'q':
printf("Input the room ID:");
scanf("%d", &id);
if ( Schedule_UI_Query(id) )
{
paging.totalRecords = Schedule_Srv_FetchAll(head);
List_Paging(head, paging, schedule_node_t);
}
break;
case 'p':
case 'P':
if (!Pageing_IsFirstPage(paging)) {
Paging_Locate_OffsetPage(head, paging, -1, schedule_node_t);
}
break;
case 'n':
case 'N':
if (!Pageing_IsLastPage(paging)) {
Paging_Locate_OffsetPage(head, paging, 1, schedule_node_t);
}
break;
}
} while (choice != 'r' && choice != 'R');
//释放链表空间
List_Destroy(head, schedule_node_t);
}
好吧,今天早上感觉还是颇多的。以上写的时候没有和之前写的一样,写一个复制一个过来,然后解释说明。一直就在编译器里写啊写的,最后,和松松片了会,然后再把代码全复制过来,结果,完全没有HP写每一个函数的解释什么了。1,还是需要全身心的投入,就目前的水平,写一个,在日志里解释一个;刚才在写void Schedule_UI_MgtEntry(int play_id)这个的时候,后来才发现一个事实,那个studio是已经写好了,老师让参考,而我刚才才第一次参考,到底是好事还是坏事。自己都想笑,这几天是按自己的分析,看模块写啊写的,刚才写界面层也一直是自己写写的,最后就复制了这个studio里的mgtentry,自己把里面需要修改的修改了一下。
其实,我本来的目的也就是锻炼自己,这样好,达到目的了的。
然后,组长过来又和我谈论了下关于课设的,我表示全是我的错,然后,准备继续安静的找事干,我要做的事,为了锻炼自己。
现在是11:34,至今呢,三个层我基本都写了一遍,感受了一下。如今肯定也存在其他问题,例如:链表到底在哪里用,结构体链表的两种形式定义,何时只需要结构体,这一个整体的流程到底是什么来的,当前我需要解决的问题(我的问题)到底是什么。
过去了半小时,然而放松了下,准备看我还能干什么。
现在是16:11,可以说已经进入下午的时间段了,开始编会吧,也不想管太多了。
我本来想把我写的演出计划合一块看看,结果发现,Ticket.h 是什么鬼啊。。。
好吧,现在是16:52,为什么感觉好迷茫,好像到了一个瓶颈处。突然不想做什么也不知道怎么做。
现在是23:46,过去的半小时多的时间里,自己把自己写的演出计划持久化层编译的看是否有错误,以下是错误:
Schedule_Persist.c: In function ‘Schedule_Perst_SelectAll’:
Schedule_Persist.c:127:3: error: incompatible type for argument 1 of ‘fread’
if ( fread(*temp,sizeof(schedule_list_t),1,fp) && temp->data.id==temp->data.play_id )
^
In file included from Schedule_Persist.c:7:0:
/usr/include/stdio.h:709:15: note: expected ‘void * __restrict__’ but argument is of type ‘struct schedule_node’
extern size_t fread (void *__restrict __ptr, size_t __size,
^
zy-dream@ubuntu:~/src/Persistence$ vim Schedule_Persist.c
zy-dream@ubuntu:~/src/Persistence$ gcc Schedule_Persist.c
Schedule_Persist.c: In function ‘Schedule_Perst_Update’:
Schedule_Persist.c:44:35: error: ‘tp’ undeclared (first use in this function)
fread(&buf,sizeof(schedule_t),1,tp);
^
Schedule_Persist.c:44:35: note: each undeclared identifier is reported only once for each function it appears in
Schedule_Persist.c: In function ‘Schedule_Perst_DeleteByID’:
Schedule_Persist.c:80:3: error: expected ‘;’ before ‘if’
if ( buf->id==ID )
^
Schedule_Persist.c: In function ‘Schedule_Perst_SelectAll’:
Schedule_Persist.c:128:3: error: incompatible type for argument 1 of ‘fread’
if ( fread(*temp,sizeof(schedule_list_t),1,fp) && temp->data.id==temp->data.play_id )
^
In file included from Schedule_Persist.c:7:0:
/usr/include/stdio.h:709:15: note: expected ‘void * __restrict__’ but argument is of type ‘struct schedule_node’
extern size_t fread (void *__restrict __ptr, size_t __size,
^
zy-dream@ubuntu:~/src/Persistence$ vim Schedule_Persist.c
zy-dream@ubuntu:~/src/Persistence$ gcc Schedule_Persist.c
Schedule_Persist.c: In function ‘Schedule_Perst_SelectAll’:
Schedule_Persist.c:129:11: error: ‘data’ undeclared (first use in this function)
fread(&data,sizeof(schedule_t),1,fp);
^
然后,现在基本都一一解决了,编译后出来的东西已经没有错误了,估计就是函数调用问题了。回头看,
有fread的正确使用,结构体的正确调用,以及小细节的错误。有时间,还是好好学习下文件啊。
现在是演出计划业务逻辑层的编译:
zy-dream@ubuntu:~/src/Service$ gcc Schedule.c
Schedule.c: In function ‘Schedule_Srv_Add’:
Schedule.c:12:2: warning: passing argument 1 of ‘Ticket_Srv_AddBatch’ makes integer from pointer without a cast [enabled by default]
if ( Ticket_Srv_AddBatch(data) )
^
In file included from Schedule.c:4:0:
Ticket.h:24:5: note: expected ‘int’ but argument is of type ‘const struct schedule_t *’
int Ticket_Srv_AddBatch(int schedule_id, int studio_id);
^
Schedule.c:12:2: error: too few arguments to function ‘Ticket_Srv_AddBatch’
if ( Ticket_Srv_AddBatch(data) )
^
In file included from Schedule.c:4:0:
Ticket.h:24:5: note: declared here
int Ticket_Srv_AddBatch(int schedule_id, int studio_id);
^
Schedule.c: In function ‘Schedule_Srv_Modify’:
Schedule.c:21:2: error: too few arguments to function ‘Ticket_Srv_DeleteBatch’
if ( Ticket_Srv_DeleteBatch() && Tickes_Srv_Addbatch(data) )
^
In file included from Schedule.c:4:0:
Ticket.h:26:5: note: declared here
int Ticket_Srv_DeleteBatch(int schedule_id);
^
Schedule.c: In function ‘Schedule_Srv_DeleteByID’:
Schedule.c:31:2: error: too few arguments to function ‘Ticket_Srv_DeleteBatch’
if ( Ticket_Srv_DeleteBatch() )
^
In file included from Schedule.c:4:0:
Ticket.h:26:5: note: declared here
int Ticket_Srv_DeleteBatch(int schedule_id);
^
如此看来,是没有错误的,所有提示都是票的函数。票都还没写好呢。
最后就是,今天写了很多的演出计划界面层:
Schedule_UI.c: In function ‘Schedule_UI_ListAll’:
Schedule_UI.c:30:4: error: expected ‘}’ before ‘else’
else
^Schedule_UI.c:40:3: error: break statement not within loop or switch
break;
^
Schedule_UI.c: In function ‘Schedule_UI_Add’:
Schedule_UI.c:50:72: error: ‘schedule_t’ has no member named ‘date_tdate’
scanf("%d%d%d%d%d",&new->data.play_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
^
Schedule_UI.c:50:94: error: ‘schedule_t’ has no member named ‘mytime_ttime’
scanf("%d%d%d%d%d",&new->data.play_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
^
Schedule_UI.c:56:3: warning: passing argument 1 of ‘Schedule_Srv_Add’ from incompatible pointer type [enabled by default]
if ( Schedule_Srv_Add(new) )
^
In file included from Schedule_UI.h:4:0,
from Schedule_UI.c:1:
../Service/Schedule.h:21:12: note: expected ‘const struct schedule_t *’ but argument is of type ‘schedule_list_t’
inline int Schedule_Srv_Add(const schedule_t *data);
^
Schedule_UI.c:59:4: error: ‘n’ undeclared (first use in this function)
n++;
^
Schedule_UI.c:59:4: note: each undeclared identifier is reported only once for each function it appears in
Schedule_UI.c:64:15: error: ‘choice’ undeclared (first use in this function)
scanf("%c",&choice);
^
Schedule_UI.c: In function ‘Schedule_UI_Modify’:
Schedule_UI.c:83:29: error: request for member ‘id’ in something not a structure or union
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:83:37: error: request for member ‘play_id’ in something not a structure or union
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:83:50: error: request for member ‘studio_id’ in something not a structure or union
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:83:65: error: request for member ‘date_tdate’ in something not a structure or union
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:83:81: error: request for member ‘mytime_ttime’ in something not a structure or union
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:83:95: error: ‘data’ undeclared (first use in this function)
printf("%d%d%d%d%d%d",temp.id,temp.play_id,temp.studio_id,temp.date_tdate,temp.mytime_ttime,data.seat_count);
^
Schedule_UI.c:85:30: error: ‘schedule_t’ has no member named ‘paly_id’
scanf("%d%d%d%d",&new->data.paly_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
^
Schedule_UI.c:85:70: error: ‘schedule_t’ has no member named ‘date_tdate’
scanf("%d%d%d%d",&new->data.paly_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
^
Schedule_UI.c:85:92: error: ‘schedule_t’ has no member named ‘mytime_ttime’
scanf("%d%d%d%d",&new->data.paly_id,&new->data.studio_id,&new->data.date_tdate,&new->data.mytime_ttime,&new->data.seat_count);
^
Schedule_UI.c:88:3: warning: passing argument 1 of ‘Schedule_Srv_Modify’ from incompatible pointer type [enabled by default]
if ( Schedule_Srv_Modify(new) )
^
In file included from Schedule_UI.h:4:0,
from Schedule_UI.c:1:
../Service/Schedule.h:23:12: note: expected ‘const struct schedule_t *’ but argument is of type ‘schedule_list_t’
inline int Schedule_Srv_Modify(const schedule_t *data);
^
Schedule_UI.c:100:3: error: break statement not within loop or switch
break;
^
Schedule_UI.c: In function ‘Schedule_UI_Delete’:
Schedule_UI.c:117:3: error: break statement not within loop or switch
break;
^
Schedule_UI.c: In function ‘Schedule_UI_Query’:
Schedule_UI.c:124:2: warning: passing argument 2 of ‘Schedule_Srv_FetchByID’ from incompatible pointer type [enabled by default]
if ( Schedule_Srv_FetchByID(id,now) )
^
In file included from Schedule_UI.h:4:0,
from Schedule_UI.c:1:
../Service/Schedule.h:27:12: note: expected ‘struct schedule_t *’ but argument is of type ‘schedule_list_t’
inline int Schedule_Srv_FetchByID(int ID, schedule_t *buf);
^
Schedule_UI.c:133:3: error: break statement not within loop or switch
break;
^
Schedule_UI.c: In function ‘Schedule_UI_MgtEntry’:
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
"Date_tdate", "My_ttime","Seat_count");
^
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘char *’ [-Wformat=]
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘char *’ [-Wformat=]
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘char *’ [-Wformat=]
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘char *’ [-Wformat=]
Schedule_UI.c:159:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘char *’ [-Wformat=]
In file included from Schedule_UI.h:3:0,
from Schedule_UI.c:1:
../Common/List.h:143:16: warning: assignment from incompatible pointer type [enabled by default]
for (i=0, pos = (list_node_t *) (paging.curPos); \
^
Schedule_UI.c:163:3: note: in expansion of macro ‘Paging_ViewPage_ForEach’
Paging_ViewPage_ForEach(head, paging, studio_node_t, pos, i){
^
Schedule_UI.c:165:34: error: ‘schedule_t’ has no member named ‘studio_t’
pos->data.play_id, pos->data.studio_t, pos->data.data_ttime,
^
Schedule_UI.c:165:54: error: ‘schedule_t’ has no member named ‘data_ttime’
pos->data.play_id, pos->data.studio_t, pos->data.data_ttime,
^
Schedule_UI.c:166:15: error: ‘schedule_t’ has no member named ‘mytime_ttime’
pos->data.mytime_ttime);
^
Schedule_UI.c:183:4: error: too few arguments to function ‘Schedule_UI_Add’
if (Schedule_UI_Add()) //��������������
^
Schedule_UI.c:44:5: note: declared here
int Schedule_UI_Add(int play_id) {
^
Schedule_UI.c:208:3: error: duplicate case value
case 'q':
^
Schedule_UI.c:207:3: error: previously used here
case 'q':
^错误简直不能看啊,所以我还是调到最小,就意思一下吧。
然后,这要解决的话,好好好,我先去看看都是哪些错误呢。
我发现有一个问题是,对何时是用结构体,何时是用结构体链表。
基本都是我自己写的,不错,是要好好分析下到底是哪里不对。
现在是0:08。
嗯,课设还剩下明天最后一天了,而且明天的任务也很明确了,演出计划界面层的错误。
毕竟这演出计划是我一个人写的模块。
本来还想感慨下的,结果呢,不急,反正就快结束了
等结束了,好好写一下课设总结吧。。。。。。。。。。。。。。。。。。。。。。。。。