-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_goods.cpp
More file actions
executable file
·759 lines (657 loc) · 22.4 KB
/
Copy pathadd_goods.cpp
File metadata and controls
executable file
·759 lines (657 loc) · 22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
#include "add_goods.h"
#include "database.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 检查菜品ID
char *check_goods_name(char *temp_goods_name) {
do {
scanf("%s", temp_goods_name);
int i = 0, k, check_num = 1;
for (i = 0; temp_goods_name[i] != '\0'; i++) {
k = isdigit(temp_goods_name[i]);
if (i == 0 || i == 1) {
if (temp_goods_name[i] < 'A' || temp_goods_name[i] > 'Z')
check_num = 0;
} else if (i >= 2 && i <= 5) {
if (!k)
check_num = 0;
} else
check_num = 0;
}
if (i == 6 && check_num == 1)
break;
else {
printf("您的输入格式错误, 请检查后重新输入:\n");
printf("请输入商品ID(2位大写字母+4位数字): \n");
}
} while (1);
return temp_goods_name;
}
// 检查单价
float check_unit_price() {
float price = 0;
do {
char price_str[10];
scanf("%s", price_str);
int i, j, k = 0, dot_num = 0; // 检测是否出现非数字字符以及小数点的规范
for (i = 0; price_str[i] != '\0'; i++) {
j = isdigit(price_str[i]);
if (price_str[0] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入单价: \n");
break;
}
if (price_str[i + 1] == '\0' && price_str[i] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入单价: \n");
break;
}
if (price_str[i] == '.')
dot_num = dot_num + 1;
if (dot_num == 2) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入单价: \n");
break;
}
if (!j && price_str[i] != '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入单价: \n");
break;
}
}
if (k == 1)
continue;
price = 0;
price = atof(price_str); // 字符串转浮点型
if ((int(price * 100) != (price * 100)) || price == 0) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入单价: \n");
continue;
} else if (strlen(price_str) > 8 || atof(price_str) > 50000) {
printf("\n售价不得超过50000, 请检查后重新输入!\n");
printf("请输入单价: \n");
continue;
}
break;
} while (1);
return price;
}
// 检查进价
float check_in_price() {
float price = 0;
do {
char price_str[10];
scanf("%s", price_str);
int i, j, k = 0, dot_num = 0; // 检测是否出现非数字字符以及小数点的规范
for (i = 0; price_str[i] != '\0'; i++) {
j = isdigit(price_str[i]);
if (price_str[0] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入进价: \n");
break;
}
if (price_str[i + 1] == '\0' && price_str[i] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入进价: \n");
break;
}
if (price_str[i] == '.')
dot_num = dot_num + 1;
if (dot_num == 2) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入进价: \n");
break;
}
if (!j && price_str[i] != '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入进价: \n");
break;
}
}
if (k == 1)
continue;
price = 0;
price = atof(price_str); // 字符串转浮点型
if ((int(price * 100) != (price * 100)) || price == 0) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入进价: \n");
continue;
} else if (strlen(price_str) > 8 || atof(price_str) > 50000) {
printf("\n进价不得超过50000, 请检查后重新输入!\n");
printf("请输入进价: \n");
continue;
}
break;
} while (1);
return price;
}
// 检查库存
int check_goods_in_stock() {
int goods_in_stock;
do {
char goods_in_stock_str[10];
scanf("%s", goods_in_stock_str);
int i, j, k = 0; // 检测是否出现非数字字符
for (i = 0; goods_in_stock_str[i] != '\0'; i++) {
j = isdigit(goods_in_stock_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入库存: \n");
break;
}
}
if (k == 1)
continue;
goods_in_stock = atoi(goods_in_stock_str);
if (goods_in_stock <= 0 && k == 0) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入库存: \n");
continue;
}
break;
} while (1);
return goods_in_stock;
}
// 检查折扣价格
float check_discount_price() {
float price = 0;
do {
char price_str[10];
scanf("%s", price_str);
int i, j, k = 0, dot_num = 0; // 检测是否出现非数字字符以及小数点的规范
for (i = 0; price_str[i] != '\0'; i++) {
j = isdigit(price_str[i]);
if (price_str[0] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入折扣价格: \n");
break;
}
if (price_str[i + 1] == '\0' && price_str[i] == '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入折扣价格: \n");
break;
}
if (price_str[i] == '.')
dot_num = dot_num + 1;
if (dot_num == 2) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
k = k + 1;
printf("请输入折扣价格: \n");
break;
}
if (!j && price_str[i] != '.') {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入折扣价格: \n");
break;
}
}
if (k == 1)
continue;
price = atof(price_str); // 字符串转浮点型
if ((int(price * 100) != (price * 100)) || price == 0) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
printf("请输入折扣价格: \n");
continue;
} else if (strlen(price_str) > 8 || atof(price_str) > 50000) {
printf("\n折扣价不得超过50000, 请检查后重新输入!\n");
printf("请输入折扣价格: \n");
continue;
}
break;
} while (1);
return price;
}
// 检查时间
int *check_time() {
int i, j, k;
static int temp_time[6];
int time_temp = 0;
do {
printf("年份: ");
char time_str[10];
scanf("%s", time_str);
i = 0;
k = 0; // 检测是否出现非数字字符
for (i = 0; time_str[i] != '\0'; i++) {
j = isdigit(time_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入: \n");
break;
}
}
if (k == 1)
continue;
time_temp = atoi(time_str);
if (time_temp < 1000 || time_temp > 9999) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
continue;
}
break;
} while (1);
temp_time[1] = time_temp;
time_temp = 0;
do {
printf("月份: ");
char time_str[10];
scanf("%s", time_str);
i = 0;
k = 0; // 检测是��出现非数字字符
for (i = 0; time_str[i] != '\0'; i++) {
j = isdigit(time_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
break;
}
}
if (k == 1)
continue;
time_temp = atoi(time_str);
if (time_temp < 1 || time_temp > 12) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
continue;
}
break;
} while (1);
temp_time[2] = time_temp;
time_temp = 0;
do {
printf("日期: ");
char time_str[10];
scanf("%s", time_str);
i = 0;
k = 0; // 检测是否出现非数字字符
for (i = 0; time_str[i] != '\0'; i++) {
j = isdigit(time_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
break;
}
}
if (k == 1)
continue;
time_temp = atoi(time_str);
if (time_temp < 1 || time_temp > 31) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
continue;
}
break;
} while (1);
temp_time[3] = time_temp;
time_temp = 0;
do {
printf("小时: ");
char time_str[10];
scanf("%s", time_str);
i = 0;
k = 0; // 检测是否出现非数字字符
for (i = 0; time_str[i] != '\0'; i++) {
j = isdigit(time_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
break;
}
}
if (k == 1)
continue;
time_temp = atoi(time_str);
if (time_temp < 0 || time_temp > 24) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
continue;
}
break;
} while (1);
temp_time[4] = time_temp;
time_temp = 0;
do {
printf("分钟: ");
char time_str[10];
scanf("%s", time_str);
i = 0;
k = 0; // 检测是否出现非数字字符
for (i = 0; time_str[i] != '\0'; i++) {
j = isdigit(time_str[i]);
if (!j) {
k = k + 1;
printf("\n您的输入格式错误, 请检查后重新输入:\n");
break;
}
}
if (k == 1)
continue;
time_temp = atoi(time_str);
if (time_temp < 0 || time_temp > 60) {
printf("\n您的输入格式错误, 请检查后重新输入:\n");
continue;
}
break;
} while (1);
temp_time[5] = time_temp;
return temp_time;
}
/************************************************/
int add_goods_choose_2() {
char choose[10]; // 记录管理员操作时的选择
int choose_num;
// 用户界面
printf("\n---------------您要修改哪一项?--------------\n\n");
printf("1. 单价.\n2. 折扣价.\n3. 进价\n4. 库存.\n5. "
"折扣开始时间.\n6. 折扣结束时间.\n");
printf("\n------------------------------------------\n");
printf("请按数字键选择要执行的操作:\n");
scanf("%s", choose);
// 容错判断
if (strcmp(choose, "1") != 0 && strcmp(choose, "2") != 0 &&
strcmp(choose, "3") != 0 && strcmp(choose, "4") != 0 &&
strcmp(choose, "5") != 0 && strcmp(choose, "6") != 0) {
printf("\n您的输入有误, 请按照操作选项再次输入:\n\n");
choose_num = add_goods_choose_2();
} else
choose_num = atoi(choose);
return choose_num;
}
int add_goods_choose() {
char choose[10]; // 记录管理员操作时的选择
int choose_num;
// 用户界面
printf("\n---------------操作选项---------------\n\n");
printf("1. 确认发布.\n2. 修改信息.\n0. 取消发布.\n");
printf("\n-------------------------------------\n");
printf("请按数字键选择要执行的操作:\n");
scanf("%s", choose);
// 容错判断
if (strcmp(choose, "1") != 0 && strcmp(choose, "2") != 0 &&
strcmp(choose, "0") != 0) {
printf("\n您的输入有误, 请按照操作选项再次输入:\n\n");
choose_num = add_goods_choose();
} else
choose_num = atoi(choose);
return choose_num;
}
void add_goods(char user_id[30]) {
// 输入信息并进行检查
printf("请依次输入商品信息: \n");
// 读取商店ID
database_admin_information(user_id, 0);
char temp_shop_id[30];
strcpy(temp_shop_id, admin_information.shop_id);
// 输入商品ID并检查
printf("请输入商品ID(2位大写字母+4位数字): \n");
char temp_goods_id[30];
char goods_id[30];
strcpy(goods_id, check_goods_name(temp_goods_id));
char temp_goods_name[30];
char goods_name[30];
printf("请输入商品名: \n");
scanf("%s", temp_goods_name);
strcpy(goods_name, temp_goods_name);
if (!database_name_to_id(goods_name, 0))
database_name_to_id(goods_name, 1);
strcpy(name_to_id_goods_id, goods_id);
database_name_to_id(goods_name, 1);
// 输入单价并检查
printf("请输入单价: \n");
float temp_unit_price = check_unit_price();
// 输入进价并检查
printf("请输入进价: \n");
float temp_in_price = check_in_price();
// 输入销量,因为是新货, 销量默认为0
int temp_sales_volume = 0;
// 输入库存并检查
printf("请输入库存: \n");
int temp_goods_in_stock = check_goods_in_stock();
// 输入折扣价格��检查
printf("请输入折扣价格: \n");
float temp_discount_price = check_discount_price();
int *point; // 接收返回指针
int i; // 循环变量
// 输入折扣开始时间并检查
printf("请输入折扣开始时间: \n");
point = check_time();
int temp_time_begin[6];
for (i = 1; i <= 5; i++)
temp_time_begin[i] = *(point + i);
// 输入折扣结束时间并检��
printf("请输入折扣结束时间: \n");
point = check_time();
int temp_time_end[6];
for (i = 1; i <= 5; i++)
temp_time_end[i] = *(point + i);
// 打印
database_name_to_id(temp_goods_name, 1);
printf("您要发布的商品信息如下, 请确认:\n");
printf("商品ID\t商品名\t单价\t折扣价\t进价\t库存\t销量\t折扣"
"开始时间\t\t折扣结束时间\n");
database_name_to_id(temp_goods_name, 1);
printf("%s\t%-8s\t%0.2f\t%0.2f\t%0.2f\t%d\t%d\t%04d:%02d:%02d:%02d"
":%02d\t%04d:%02d:%02d:%02d:%02d\n",
name_to_id_goods_id, //
temp_goods_name, //
temp_unit_price, //
temp_discount_price, //
temp_in_price, //
temp_goods_in_stock, //
temp_sales_volume, //
temp_time_begin[1], //
temp_time_begin[2], //
temp_time_begin[3], //
temp_time_begin[4], //
temp_time_begin[5], //
temp_time_end[1], //
temp_time_end[2], //
temp_time_end[3], //
temp_time_end[4], //
temp_time_end[5] //
);
printf("\n请输入任意字符并按回车键以继续...\n");
char screen[10];
scanf("%s", screen); // 延长屏幕显示时间
int choose = 0;
// 进一步操作
do {
printf("您要发布的商品信息如下, 请确认:\n");
printf("商品ID\t商品名\t单价\t折扣价\t进价\t库存\t销量\t折扣"
"开始时间\t\t折扣结束时间\n");
database_name_to_id(temp_goods_name, 1);
printf("%s\t%-8s\t%0.2f\t%0.2f\t%0.2f\t%d\t%d\t%04d:%02d:%02d:%02d"
":%02d\t%04d:%02d:%02d:%02d:%02d\n",
name_to_id_goods_id, //
temp_goods_name, //
temp_unit_price, //
temp_discount_price, //
temp_in_price, //
temp_goods_in_stock, //
temp_sales_volume, //
temp_time_begin[1], //
temp_time_begin[2], //
temp_time_begin[3], //
temp_time_begin[4], //
temp_time_begin[5], //
temp_time_end[1], //
temp_time_end[2], //
temp_time_end[3], //
temp_time_end[4], //
temp_time_end[5] //
);
choose = add_goods_choose();
if (choose == 2) {
// 打印
printf("您要发布的商品信息如下, 请确认:\n");
printf("商品ID\t商品名\t单价\t折扣价\t进价\t库存\t销量\t折扣"
"开始时间\t\t折扣结束时间\n");
database_name_to_id(temp_goods_name, 1);
printf("%s\t%-8s\t%0.2f\t%0.2f\t%0.2f\t%d\t%d\t%04d:%02d:%02d:%02d"
":%02d\t%04d:%02d:%02d:%02d:%02d\n",
name_to_id_goods_id, //
temp_goods_name, //
temp_unit_price, //
temp_discount_price, //
temp_in_price, //
temp_goods_in_stock, //
temp_sales_volume, //
temp_time_begin[1], //
temp_time_begin[2], //
temp_time_begin[3], //
temp_time_begin[4], //
temp_time_begin[5], //
temp_time_end[1], //
temp_time_end[2], //
temp_time_end[3], //
temp_time_end[4], //
temp_time_end[5] //
);
int choose_2 = add_goods_choose_2();
switch (choose_2) {
case 1: {
// 输入单价并检查
printf("请输入单价: \n");
temp_unit_price = check_unit_price();
break;
}
case 2: {
printf("请输入折扣价格: \n");
temp_discount_price = check_discount_price();
break;
}
case 3: {
// 输入进价并检查
printf("请输入进价: \n");
temp_in_price = check_in_price();
break;
}
case 4: {
// 输入库存并检查
printf("请输入库存: \n");
temp_goods_in_stock = check_goods_in_stock();
break;
}
case 5: {
// 输入折扣开始时间并检查
printf("请输入折扣开始时间: \n");
point = check_time();
for (i = 1; i <= 5; i++)
temp_time_begin[i] = *(point + i);
break;
}
case 6: {
// 输入折扣结束时间并检��
printf("请输入折扣结束时间: \n");
point = check_time();
for (i = 1; i <= 5; i++)
temp_time_end[i] = *(point + i);
break;
}
}
} else
break;
} while (1);
switch (choose) {
// 选项1: 确认发布
case 1: {
int i_shop = 1, i_goods; // 深度测量
int i; // 循环变量
// 打开或建立新数据库
if (!database_shop_index(temp_shop_id, 0)) {
shop_index[0].unit_price = 0;
database_shop_index(temp_shop_id, 1);
i_shop = 0;
}
if (i_shop) {
i = 0;
while (shop_index[i].unit_price != 0)
i++;
i_shop = i;
}
strcpy(shop_index[i_shop].goods_name, temp_goods_name); // 商品名
shop_index[i_shop].unit_price = temp_unit_price; // 零售价格
shop_index[i_shop].in_price = temp_in_price; // 进货价格
shop_index[i_shop].sales_volume = temp_sales_volume; // 销量
shop_index[i_shop].goods_in_stock = temp_goods_in_stock; // 存货
shop_index[i_shop].discount_price = temp_discount_price; // 折扣价
shop_index[i_shop].time_begin.tm_year = temp_time_begin[1]; // 开始时间
shop_index[i_shop].time_begin.tm_mon = temp_time_begin[2]; // ...
shop_index[i_shop].time_begin.tm_mday = temp_time_begin[3]; // ...
shop_index[i_shop].time_begin.tm_hour = temp_time_begin[4]; // ...
shop_index[i_shop].time_begin.tm_min = temp_time_begin[5]; // ...
shop_index[i_shop].time_end.tm_year = temp_time_end[1]; // 结束时间
shop_index[i_shop].time_end.tm_mon = temp_time_end[2]; // ...
shop_index[i_shop].time_end.tm_mday = temp_time_end[3]; // ...
shop_index[i_shop].time_end.tm_hour = temp_time_end[4]; // ...
shop_index[i_shop].time_end.tm_min = temp_time_end[5]; // ...
database_shop_index(temp_shop_id, 1);
// 打开或建立新数据库
if (!database_goods_index(temp_goods_name, 0)) {
// 清���结构体
for (i = 0; i < 100; i++) {
strcpy(goods_index[i].shop_id, ""); // 饭店ID
goods_index[i].unit_price = 0; // 单价
goods_index[i].in_price = 0; // 进价
goods_index[i].sales_volume = 0; // 销量
goods_index[i].goods_in_stock = 0; // 库存
goods_index[i].discount_price = 0; // 折扣价格
goods_index[i].time_begin.tm_year = 0; // 折扣开始时间
goods_index[i].time_begin.tm_mon = 0; // ...
goods_index[i].time_begin.tm_mday = 0; // ...
goods_index[i].time_begin.tm_hour = 0; // ...
goods_index[i].time_begin.tm_min = 0; // ...
goods_index[i].time_end.tm_year = 0; // 折扣结束时间
goods_index[i].time_end.tm_mon = 0; // ...
goods_index[i].time_end.tm_mday = 0; // ...
goods_index[i].time_end.tm_hour = 0; // ...
goods_index[i].time_end.tm_min = 0; // ...}
}
database_goods_index(temp_goods_name, 1);
}
i = 0;
while (goods_index[i].unit_price != 0)
i++;
i_goods = i;
strcpy(goods_index[i_goods].shop_id, temp_shop_id); // 饭店编号
goods_index[i_goods].unit_price = temp_unit_price; // 零售价格
goods_index[i_goods].in_price = temp_in_price; // 进货价格
goods_index[i_goods].sales_volume = temp_sales_volume; // 销量
goods_index[i_goods].goods_in_stock = temp_goods_in_stock; // 存货
goods_index[i_goods].discount_price = temp_discount_price; // 折扣价
goods_index[i_goods].time_begin.tm_year = temp_time_begin[1]; // 开始���间
goods_index[i_goods].time_begin.tm_mon = temp_time_begin[2]; // ...
goods_index[i_goods].time_begin.tm_mday = temp_time_begin[3]; // ...
goods_index[i_goods].time_begin.tm_hour = temp_time_begin[4]; // ...
goods_index[i_goods].time_begin.tm_min = temp_time_begin[5]; // ...
goods_index[i_goods].time_end.tm_year = temp_time_end[1]; // 结束时间
goods_index[i_goods].time_end.tm_mon = temp_time_end[2]; // ...
goods_index[i_goods].time_end.tm_mday = temp_time_end[3]; // ...
goods_index[i_goods].time_end.tm_hour = temp_time_end[4]; // ...
goods_index[i_goods].time_end.tm_min = temp_time_end[5]; // ...
database_goods_index(temp_goods_name, 1);
database_all_index(1, temp_goods_name, temp_shop_id);
break;
}
// 选项3: 取消发布
case 0: {
break;
}
return;
}
}
// 主程序, 负责读取数据库以及传入下一层.
int add_goods_main(char user_id[30]) {
add_goods(user_id);
return 1; // 程序运行成功返回"1"
}