This repository was archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy.h
132 lines (130 loc) · 3.99 KB
/
destroy.h
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
#ifndef DESTROY_H
#define DESTROY_H
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include "ui.h"
#include "struct.h"
#include "ui_terminal.h"
#include "freightlib.h"
#include "cleartool.h"
#include "freighttool.h"
int destroy()
{
char *destroy_notice1 = "请您确认是否销毁此商品?";
char *destroy_notice2 = "请您最后确认销毁数量是否正确?";
char *choice1 = "[Y]是";
char *choice2 = "[N]否";
char *destroy_choice[2] = {choice1, choice2};
char *msg = (char *)malloc(sizeof(char) * 100);
int load_satus, length = 0, serch_id, ch1, ch2, x, num;
unsigned long long EAN;
freight *p = (freight *)malloc(sizeof(freight) * 1000);
load_satus = load_stock_data(p, &length);
if (load_satus == -1)
{
return -1;
}
while (1)
{
system("cls");
printf("请输入要销毁的货品的EAN码(输入0以退出)\n");
ShowConsoleCursor();
scanf("%llu", &EAN);
char buff = getchar();
while (buff != '\n' || (EAN > 0 && EAN < 1e12) || EAN >= 1e13 || EAN < 0)
{
printf("输入不合法,请重新输入\n");
fflush(stdin);
system("pause");
system("cls");
printf("请输入要销毁的货品的EAN码(输入0以退出)\n");
ShowConsoleCursor();
scanf("%llu", &EAN);
buff = getchar();
}
if (EAN == 0)
{
fflush(stdin);
x = silent_save_stock_data(p, &length);
return -1;
}
serch_id = locating(p, length, EAN);
if (serch_id == -1)
{
system("cls");
SetColor(4, 0);
printf("商品不存在,请重新输入!\n");
SetColor(15, 0);
fflush(stdin);
system("pause");
continue;
}
else
{
system("cls");
freight_msg(msg, p, serch_id);
printf("%s", msg);
system("pause");
ch1 = ui_choice(destroy_notice1, destroy_choice, 2);
if (ch1 == 0)
{
while (1)
{
printf("请问您要销毁多少个该种商品?\n");
ShowConsoleCursor();
scanf("%d", &num);
buff = getchar();
if (buff != '\n')
num = -1;
while (num < 0 || num > p[serch_id].stock)
{
if (num > p[serch_id].stock)
{
printf("库存不足,请重新输入\n");
}
else
{
printf("输入不合法,请重新输入\n");
}
fflush(stdin);
system("pause");
system("cls");
printf("请问您要销毁多少个该种商品?\n");
ShowConsoleCursor();
scanf("%d", &num);
char buff = getchar();
if (buff != '\n')
num = -1;
}
ch2 = ui_choice(destroy_notice2, destroy_choice, 2);
if (ch2 == 0)
{
dest_freight(p, serch_id, num);
system("cls");
SetColor(10, 0);
printf("销毁成功!\n");
SetColor(15, 0);
system("pause");
fflush(stdin);
break;
}
else
{
printf("已经取消此操作\n");
system("pause");
continue;
}
}
}
else
{
printf("已经取消此操作\n");
system("pause");
continue;
}
}
}
free(p);
}
#endif