From 58567a7fa417685a828e19c0f2ea1d29940c2847 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Mon, 13 Jul 2020 16:13:16 +0800
Subject: [PATCH 01/48] fangrui
---
"\350\257\276\350\256\276.sln" | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 "\350\257\276\350\256\276.sln"
diff --git "a/\350\257\276\350\256\276.sln" "b/\350\257\276\350\256\276.sln"
new file mode 100644
index 0000000..7e94b1b
--- /dev/null
+++ "b/\350\257\276\350\256\276.sln"
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30225.117
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "课设", "课设\课设.vcxproj", "{59EAE882-B918-4B92-B01F-91442C3D55D4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x64.ActiveCfg = Debug|x64
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x64.Build.0 = Debug|x64
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x86.ActiveCfg = Debug|Win32
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x86.Build.0 = Debug|Win32
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x64.ActiveCfg = Release|x64
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x64.Build.0 = Release|x64
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x86.ActiveCfg = Release|Win32
+ {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8A27AE5D-2BFE-49C4-91FE-495ACBEFED87}
+ EndGlobalSection
+EndGlobal
--
Gitee
From 0237a8d5a4feadb68fb016a3bfdaa629866ca512 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Mon, 13 Jul 2020 21:04:27 +0800
Subject: [PATCH 02/48] try1
---
"\350\257\276\350\256\276.vcxproj" | 147 +++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
create mode 100644 "\350\257\276\350\256\276.vcxproj"
diff --git "a/\350\257\276\350\256\276.vcxproj" "b/\350\257\276\350\256\276.vcxproj"
new file mode 100644
index 0000000..761b79b
--- /dev/null
+++ "b/\350\257\276\350\256\276.vcxproj"
@@ -0,0 +1,147 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {59eae882-b918-4b92-b01f-91442c3d55d4}
+ 课设
+ 10.0
+
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ false
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
Gitee
From dfdf55e4b12dec1d3aa088f83a6e54addf931e84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Tue, 14 Jul 2020 15:07:19 +0800
Subject: [PATCH 03/48] =?UTF-8?q?=E9=94=80=E5=94=AE=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=80=BB=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 344 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 344 insertions(+)
create mode 100644 "code/\346\272\220.cpp"
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
new file mode 100644
index 0000000..464e9c1
--- /dev/null
+++ "b/code/\346\272\220.cpp"
@@ -0,0 +1,344 @@
+#include
+#include
+#include
+#include
+//ʱṹ
+struct date
+{
+ int year;//
+ int month;//
+ int day;//
+};
+//Ʒṹ
+struct goods
+{
+ char id_Number[20];//Ʒ
+ char good_Name[20];//Ʒ
+ double buy_Price;//Ʒ
+ double sell_Price;//Ʒۼ
+ date produce_Date;//
+ date purchase_Date;//
+ int quality_Date;//
+ int remain_Number;//ʣ
+ char place[20];//λ
+ goods* next;
+};
+//Ļṹ
+struct soldGoods
+{
+ char id_Number[20];//Ʒ
+ char name[20];
+ int count;//
+ double price;//
+};
+//Աṹ
+struct salespersons
+{
+ char id_Number[20];//Ա
+ char salesperson_Name[20];//Ա
+ double money;//۶
+ salespersons* next;//ָ
+};
+//ۼ¼ṹ
+struct records
+{
+ char id[20];//id
+ char goodName[20];//
+ char people[20];//Ա
+ int count;//
+ double price;//۽
+ //ʱ
+ int year;
+ int mon;
+ int day;
+ int hour;
+ int min;
+ int sec;
+ records* next;
+};
+FILE* femployeeData = fopen("employeedata.txt", "r+");
+FILE* fgoodData = fopen("gooddata.txt", "r+");
+//Ʒ
+goods* createGoodList()
+{
+ goods* goodHead, * p, * goodEnd;
+ goodHead = (goods*)malloc(sizeof(goods));
+ goodHead->next = NULL;
+ goodEnd = goodHead;
+ int n = 0;
+ while(n<17)
+ {
+ p = (goods*)malloc(sizeof(goods));
+ fscanf(fgoodData,
+ "%s %s %lf %lf %d %d %d %d %d %d %d %d %s",
+ p->id_Number,
+ p->good_Name,
+ &p->buy_Price,
+ &p->sell_Price,
+ &p->produce_Date.year,
+ &p->produce_Date.month,
+ &p->produce_Date.day,
+ &p->purchase_Date.year,
+ &p->purchase_Date.month,
+ &p->purchase_Date.day,
+ &p->quality_Date,
+ &p->remain_Number,
+ p->place);
+ p->next = NULL;
+ goodEnd->next = p;
+ goodEnd = p;
+ n++;
+ }
+ return goodHead;
+}
+//Ա
+salespersons* createSalespersonList()
+{
+ salespersons* head, * p, * end;
+ head = (salespersons*)malloc(sizeof(salespersons));
+ head->next = NULL;
+ end = head;
+ for (int i = 0;i < 10;i++)
+ {
+ p = (salespersons*)malloc(sizeof(salespersons));
+ fscanf(femployeeData, "%s %s %lf", p->id_Number, p->salesperson_Name, &p->money);
+ p->next = NULL;
+ end->next = p;
+ end = p;
+ }
+ return head;
+}
+//ʵʱ¼
+records* createSingleRecordList()
+{
+ records* recordHead;
+ recordHead = (records*)malloc(sizeof(records));
+ recordHead->next = NULL;
+ return recordHead;
+}
+//Ƿ()
+goods* searchGood(char* id, goods* head)
+{
+ goods* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(id, p->id_Number) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ʵʱۼ¼
+void singleRecords(records* singleRecord, soldGoods soldGood,goods *good, salespersons* salesperson)
+{
+ records* p;
+ p = (records*)malloc(sizeof(records));
+ strcpy(p->id, good->id_Number);//
+ strcpy(p->goodName, good->good_Name);//
+ p->count = soldGood.count;//
+ strcpy(p->people, salesperson->salesperson_Name);//Ա
+ p->price = soldGood.count * good->sell_Price;//ۼ
+ time_t t;
+ struct tm* lt;
+ time(&t);
+ lt = localtime(&t);
+ p->year = lt->tm_year + 1900;//
+ p->mon = lt->tm_mon + 1;//
+ p->day = lt->tm_mday;//
+ p->hour = lt->tm_hour;//ʱ
+ p->min = lt->tm_min;//
+ p->sec = lt->tm_sec;//
+ p->next = NULL;
+ p->next = singleRecord->next;
+ singleRecord->next = p;
+}
+//ۼ¼
+records* allRecords(records* head)
+{
+ records* allHead, * p1, * p2, * p3, * allEnd;
+ allHead = (records*)malloc(sizeof(records));
+ allEnd = allHead;
+ p1 = head->next;
+ while (p1 != NULL)
+ {
+ p2 = (records*)malloc(sizeof(records));
+ p2->count = p1->count;
+ p2->day = p1->day;
+ strcpy(p2->goodName, p1->goodName);
+ p2->hour = p1->hour;
+ strcpy(p2->id, p1->id);
+ p2->min = p1->min;
+ p2->mon = p1->mon;
+ p2->price = p1->price;
+ p2->sec = p1->sec;
+ p2->year = p1->year;
+ p2->next = NULL;
+ allEnd->next = p2;
+ allEnd = p2;
+ p1 = p1->next;
+ }
+ p1 = allHead->next;
+ while (p1 != NULL)
+ {
+ p3 = p1;
+ p2 = p1->next;
+ while (p2!=NULL)
+ {
+ if (strcmp(p1->goodName, p2->goodName) == 0)
+ {
+ p1->count = p1->count + p2->count;
+ p1->price = p1->price + p2->price;
+ p3->next = p2->next;
+ free(p2);
+ }
+ else
+ p3 = p2;
+ p2 = p3->next;
+ }
+ p1 = p1->next;
+ }
+ return allHead;
+}
+//ʵʱ¼
+records* searchSingleRecord(records* head, char* id)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(id, p->id) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ܼ¼
+records* searchAllRecord(records* head, char* name)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(name, p->goodName) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ӡʵʱ¼
+void printSingleRecord(records* head)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ printf("%s %s %s %lf %d%d%d %d:%d:%d\n", p->id, p->goodName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ p = p->next;
+ }
+}
+//ӡܼ¼
+void printAllRecord(records* head)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ printf("%s %lf %d%d%d %d:%d:%d\n", p->goodName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ p = p->next;
+ }
+}
+//ʵʱۼ¼ɾģ¼
+void sell(salespersons* salespersonHead, goods* goodHead, records* singleRecord)
+{
+ salespersons* p;
+ p = salespersonHead->next;
+ soldGoods soldGood;
+ char id[20];
+ printf("Ա Ʒ ");
+ scanf("%s %s %d", id, soldGood.id_Number, &soldGood.count);
+ while (p != NULL)
+ {
+ if (!strcmp(p->id_Number, id) && searchGood(soldGood.id_Number, goodHead))
+ {
+ goods* n = searchGood(soldGood.id_Number, goodHead);
+ if (soldGood.count > n->remain_Number)
+ printf("Ʒ\n");
+ p->money = p->money + soldGood.count * n->sell_Price;//۶
+ n->remain_Number = n->remain_Number - soldGood.count;//¿
+ if (n->remain_Number == 0)
+ {
+ printf("%s %sû\n", n->id_Number, n->good_Name);//ɾҪ
+ }
+ //ۼ¼
+ singleRecords(singleRecord, soldGood,n, p);
+ break;
+ }
+ p = p->next;
+ }
+}
+int main()
+{
+ salespersons* salesperson;//Աͷָ
+ records* all;//ۼ¼ͷָ
+ records* single;//ʵʱۼ¼ͷָ
+ goods* good;//ͷָ
+ int n;
+ int a;
+ single = createSingleRecordList();
+ salesperson = createSalespersonList();
+ good = createGoodList();
+ while (1)
+ {
+ printf("˿밴1\n");
+ printf("ӡʵʱۼ¼밴2\n");
+ printf("ӡۼ¼3\n");
+ printf("˳밴0\n");
+ scanf("%d", &a);
+ if (a == 1)
+ {
+ printf("˿");
+ scanf("%d", &n);
+ printf("ʼɨ루û豸ֶ!\n");
+ while (n > 0)
+ {
+ sell(salesperson, good, single);
+ n--;
+ }
+ }
+ if (a == 2)
+ {
+ printSingleRecord(single);
+ }
+ if (a == 3)
+ {
+ all = allRecords(single);
+ printAllRecord(all);
+ }
+ if (a == 0)
+ {
+ printf("°ˣף!\n");
+ break;
+ }
+ }
+ //ԱͿû
+ /*good = good->next;
+ while (good != NULL)
+ {
+ printf("%s %d\n", good->good_Name, good->remain_Number);
+ good = good->next;
+ }
+ salesperson = salesperson->next;
+ while (salesperson != NULL)
+ {
+ printf("%s %.2f\n", salesperson->salesperson_Name, salesperson->money);
+ salesperson = salesperson->next;
+ }*/
+ return 0;
+}
\ No newline at end of file
--
Gitee
From a4dcf2979be8caefe4fd973ac33d9681f698966a Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Tue, 14 Jul 2020 16:13:16 +0800
Subject: [PATCH 04/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?=
=?UTF-8?q?=E8=AF=BE=E8=AE=BE.sln?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\350\257\276\350\256\276.sln" | 31 -------------------------------
1 file changed, 31 deletions(-)
delete mode 100644 "\350\257\276\350\256\276.sln"
diff --git "a/\350\257\276\350\256\276.sln" "b/\350\257\276\350\256\276.sln"
deleted file mode 100644
index 7e94b1b..0000000
--- "a/\350\257\276\350\256\276.sln"
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30225.117
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "课设", "课设\课设.vcxproj", "{59EAE882-B918-4B92-B01F-91442C3D55D4}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x64.ActiveCfg = Debug|x64
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x64.Build.0 = Debug|x64
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x86.ActiveCfg = Debug|Win32
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Debug|x86.Build.0 = Debug|Win32
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x64.ActiveCfg = Release|x64
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x64.Build.0 = Release|x64
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x86.ActiveCfg = Release|Win32
- {59EAE882-B918-4B92-B01F-91442C3D55D4}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {8A27AE5D-2BFE-49C4-91FE-495ACBEFED87}
- EndGlobalSection
-EndGlobal
--
Gitee
From 68e1f5f2f49533de635cca5483bbea5fb68f96fc Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Tue, 14 Jul 2020 16:13:22 +0800
Subject: [PATCH 05/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?=
=?UTF-8?q?=E8=AF=BE=E8=AE=BE.vcxproj?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"\350\257\276\350\256\276.vcxproj" | 147 -----------------------------
1 file changed, 147 deletions(-)
delete mode 100644 "\350\257\276\350\256\276.vcxproj"
diff --git "a/\350\257\276\350\256\276.vcxproj" "b/\350\257\276\350\256\276.vcxproj"
deleted file mode 100644
index 761b79b..0000000
--- "a/\350\257\276\350\256\276.vcxproj"
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- Win32Proj
- {59eae882-b918-4b92-b01f-91442c3d55d4}
- 课设
- 10.0
-
-
-
- Application
- true
- v142
- Unicode
-
-
- Application
- false
- v142
- true
- Unicode
-
-
- Application
- true
- v142
- Unicode
-
-
- Application
- false
- v142
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- false
-
-
-
- Level3
- false
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
\ No newline at end of file
--
Gitee
From 053411adefc5b649e4f7708fc629665bb521ee0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Wed, 15 Jul 2020 19:55:23 +0800
Subject: [PATCH 06/48] =?UTF-8?q?update=20code/=E6=BA=90.cpp.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 145 ++++++++++++++++++++--------------------
1 file changed, 73 insertions(+), 72 deletions(-)
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
index 464e9c1..06a5524 100644
--- "a/code/\346\272\220.cpp"
+++ "b/code/\346\272\220.cpp"
@@ -2,52 +2,53 @@
#include
#include
#include
-//ʱṹ
+//时间结构体
struct date
{
- int year;//
- int month;//
- int day;//
+ int year;//年
+ int month;//月
+ int day;//日
};
-//Ʒṹ
+//库存商品结构体
struct goods
{
- char id_Number[20];//Ʒ
- char good_Name[20];//Ʒ
- double buy_Price;//Ʒ
- double sell_Price;//Ʒۼ
- date produce_Date;//
- date purchase_Date;//
- int quality_Date;//
- int remain_Number;//ʣ
- char place[20];//λ
+ char id_Number[20];//商品编号
+ char good_Name[20];//商品名
+ double buy_Price;//商品进价
+ double sell_Price;//商品售价
+ date produce_Date;//生产日期
+ date purchase_Date;//进货日期
+ int quality_Date;//保质期
+ int remain_Number;//剩余数量
+ char place[20];//库存位置
+ goods* pre;
goods* next;
};
-//Ļṹ
+//卖的货结构体
struct soldGoods
{
- char id_Number[20];//Ʒ
+ char id_Number[20];//商品编号
char name[20];
- int count;//
- double price;//
+ int count;//数量
+ double price;//单价
};
-//Աṹ
+//销售员结构体
struct salespersons
{
- char id_Number[20];//Ա
- char salesperson_Name[20];//Ա
- double money;//۶
- salespersons* next;//ָ
+ char id_Number[20];//雇员编号
+ char salesperson_Name[20];//雇员名
+ double money;//销售额
+ salespersons* next;//后继指针
};
-//ۼ¼ṹ
+//销售记录结构体
struct records
{
- char id[20];//id
- char goodName[20];//
- char people[20];//Ա
- int count;//
- double price;//۽
- //ʱ
+ char id[20];//货物id
+ char goodName[20];//货物名
+ char people[20];//销售员
+ int count;//销售数量
+ double price;//销售金额
+ //销售时间
int year;
int mon;
int day;
@@ -58,7 +59,7 @@ struct records
};
FILE* femployeeData = fopen("employeedata.txt", "r+");
FILE* fgoodData = fopen("gooddata.txt", "r+");
-//Ʒ
+//创建商品链表
goods* createGoodList()
{
goods* goodHead, * p, * goodEnd;
@@ -91,7 +92,7 @@ goods* createGoodList()
}
return goodHead;
}
-//Ա
+//创建雇员链表
salespersons* createSalespersonList()
{
salespersons* head, * p, * end;
@@ -108,7 +109,7 @@ salespersons* createSalespersonList()
}
return head;
}
-//ʵʱ¼
+//创建实时记录链表
records* createSingleRecordList()
{
records* recordHead;
@@ -116,7 +117,7 @@ records* createSingleRecordList()
recordHead->next = NULL;
return recordHead;
}
-//Ƿ()
+//货物是否存在(货查)
goods* searchGood(char* id, goods* head)
{
goods* p;
@@ -131,31 +132,31 @@ goods* searchGood(char* id, goods* head)
}
return NULL;
}
-//ʵʱۼ¼
+//实时销售记录
void singleRecords(records* singleRecord, soldGoods soldGood,goods *good, salespersons* salesperson)
{
records* p;
p = (records*)malloc(sizeof(records));
- strcpy(p->id, good->id_Number);//
- strcpy(p->goodName, good->good_Name);//
- p->count = soldGood.count;//
- strcpy(p->people, salesperson->salesperson_Name);//Ա
- p->price = soldGood.count * good->sell_Price;//ۼ
+ strcpy(p->id, good->id_Number);//货物编号
+ strcpy(p->goodName, good->good_Name);//货名
+ p->count = soldGood.count;//数量
+ strcpy(p->people, salesperson->salesperson_Name);//销售员
+ p->price = soldGood.count * good->sell_Price;//售价
time_t t;
struct tm* lt;
time(&t);
lt = localtime(&t);
- p->year = lt->tm_year + 1900;//
- p->mon = lt->tm_mon + 1;//
- p->day = lt->tm_mday;//
- p->hour = lt->tm_hour;//ʱ
- p->min = lt->tm_min;//
- p->sec = lt->tm_sec;//
+ p->year = lt->tm_year + 1900;//年
+ p->mon = lt->tm_mon + 1;//月
+ p->day = lt->tm_mday;//日
+ p->hour = lt->tm_hour;//时
+ p->min = lt->tm_min;//分
+ p->sec = lt->tm_sec;//秒
p->next = NULL;
p->next = singleRecord->next;
singleRecord->next = p;
}
-//ۼ¼
+//总销售记录
records* allRecords(records* head)
{
records* allHead, * p1, * p2, * p3, * allEnd;
@@ -202,7 +203,7 @@ records* allRecords(records* head)
}
return allHead;
}
-//ʵʱ¼
+//查找实时记录
records* searchSingleRecord(records* head, char* id)
{
records* p;
@@ -217,7 +218,7 @@ records* searchSingleRecord(records* head, char* id)
}
return NULL;
}
-//ܼ¼
+//查找总记录
records* searchAllRecord(records* head, char* name)
{
records* p;
@@ -232,36 +233,36 @@ records* searchAllRecord(records* head, char* name)
}
return NULL;
}
-//ӡʵʱ¼
+//打印实时记录
void printSingleRecord(records* head)
{
records* p;
p = head->next;
while (p != NULL)
{
- printf("%s %s %s %lf %d%d%d %d:%d:%d\n", p->id, p->goodName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ printf("%s %s %s %lf %d年%d月%d日 %d:%d:%d\n", p->id, p->goodName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
p = p->next;
}
}
-//ӡܼ¼
+//打印总记录
void printAllRecord(records* head)
{
records* p;
p = head->next;
while (p != NULL)
{
- printf("%s %lf %d%d%d %d:%d:%d\n", p->goodName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ printf("%s %lf %d年%d月%d日 %d:%d:%d\n", p->goodName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
p = p->next;
}
}
-//ʵʱۼ¼ɾģ¼
+//卖货返回实时销售记录(货删和改,记录增)
void sell(salespersons* salespersonHead, goods* goodHead, records* singleRecord)
{
salespersons* p;
p = salespersonHead->next;
soldGoods soldGood;
char id[20];
- printf("Ա Ʒ ");
+ printf("请依次输入销售员编号 商品编号 购买数量");
scanf("%s %s %d", id, soldGood.id_Number, &soldGood.count);
while (p != NULL)
{
@@ -269,14 +270,14 @@ void sell(salespersons* salespersonHead, goods* goodHead, records* singleRecord)
{
goods* n = searchGood(soldGood.id_Number, goodHead);
if (soldGood.count > n->remain_Number)
- printf("Ʒ\n");
- p->money = p->money + soldGood.count * n->sell_Price;//۶
- n->remain_Number = n->remain_Number - soldGood.count;//¿
+ printf("计数错误,请重新请点商品数量\n");
+ p->money = p->money + soldGood.count * n->sell_Price;//更新销售额
+ n->remain_Number = n->remain_Number - soldGood.count;//更新库存
if (n->remain_Number == 0)
{
- printf("%s %sû\n", n->id_Number, n->good_Name);//ɾҪ
+ printf("%s %s正好卖没货了\n", n->id_Number, n->good_Name);//可以删除但还是要进货的
}
- //ۼ¼
+ //更新销售记录
singleRecords(singleRecord, soldGood,n, p);
break;
}
@@ -285,10 +286,10 @@ void sell(salespersons* salespersonHead, goods* goodHead, records* singleRecord)
}
int main()
{
- salespersons* salesperson;//Աͷָ
- records* all;//ۼ¼ͷָ
- records* single;//ʵʱۼ¼ͷָ
- goods* good;//ͷָ
+ salespersons* salesperson;//销售员头指针
+ records* all;//总销售记录头指针
+ records* single;//实时销售记录头指针
+ goods* good;//货物头指针
int n;
int a;
single = createSingleRecordList();
@@ -296,16 +297,16 @@ int main()
good = createGoodList();
while (1)
{
- printf("˿밴1\n");
- printf("ӡʵʱۼ¼밴2\n");
- printf("ӡۼ¼3\n");
- printf("˳밴0\n");
+ printf("来顾客了请按“1”\n");
+ printf("打印实时销售记录请按“2”\n");
+ printf("打印总销售记录“3”\n");
+ printf("退出程序请按“0”\n");
scanf("%d", &a);
if (a == 1)
{
- printf("˿");
+ printf("输入顾客所买东西的种类数:");
scanf("%d", &n);
- printf("ʼɨ루û豸ֶ!\n");
+ printf("开始扫码(没有设备手动输入吧亲!)\n");
while (n > 0)
{
sell(salesperson, good, single);
@@ -323,11 +324,11 @@ int main()
}
if (a == 0)
{
- printf("°ˣף!\n");
+ printf("下班了,祝你晚餐愉快!\n");
break;
}
}
- //ԱͿû
+ //看看员工和库存更没更新
/*good = good->next;
while (good != NULL)
{
--
Gitee
From c118f64800858ae30f82c3e5514a3c5babbdd743 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Wed, 15 Jul 2020 20:35:29 +0800
Subject: [PATCH 07/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/=E6=BA=90.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 345 ----------------------------------------
1 file changed, 345 deletions(-)
delete mode 100644 "code/\346\272\220.cpp"
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
deleted file mode 100644
index 06a5524..0000000
--- "a/code/\346\272\220.cpp"
+++ /dev/null
@@ -1,345 +0,0 @@
-#include
-#include
-#include
-#include
-//时间结构体
-struct date
-{
- int year;//年
- int month;//月
- int day;//日
-};
-//库存商品结构体
-struct goods
-{
- char id_Number[20];//商品编号
- char good_Name[20];//商品名
- double buy_Price;//商品进价
- double sell_Price;//商品售价
- date produce_Date;//生产日期
- date purchase_Date;//进货日期
- int quality_Date;//保质期
- int remain_Number;//剩余数量
- char place[20];//库存位置
- goods* pre;
- goods* next;
-};
-//卖的货结构体
-struct soldGoods
-{
- char id_Number[20];//商品编号
- char name[20];
- int count;//数量
- double price;//单价
-};
-//销售员结构体
-struct salespersons
-{
- char id_Number[20];//雇员编号
- char salesperson_Name[20];//雇员名
- double money;//销售额
- salespersons* next;//后继指针
-};
-//销售记录结构体
-struct records
-{
- char id[20];//货物id
- char goodName[20];//货物名
- char people[20];//销售员
- int count;//销售数量
- double price;//销售金额
- //销售时间
- int year;
- int mon;
- int day;
- int hour;
- int min;
- int sec;
- records* next;
-};
-FILE* femployeeData = fopen("employeedata.txt", "r+");
-FILE* fgoodData = fopen("gooddata.txt", "r+");
-//创建商品链表
-goods* createGoodList()
-{
- goods* goodHead, * p, * goodEnd;
- goodHead = (goods*)malloc(sizeof(goods));
- goodHead->next = NULL;
- goodEnd = goodHead;
- int n = 0;
- while(n<17)
- {
- p = (goods*)malloc(sizeof(goods));
- fscanf(fgoodData,
- "%s %s %lf %lf %d %d %d %d %d %d %d %d %s",
- p->id_Number,
- p->good_Name,
- &p->buy_Price,
- &p->sell_Price,
- &p->produce_Date.year,
- &p->produce_Date.month,
- &p->produce_Date.day,
- &p->purchase_Date.year,
- &p->purchase_Date.month,
- &p->purchase_Date.day,
- &p->quality_Date,
- &p->remain_Number,
- p->place);
- p->next = NULL;
- goodEnd->next = p;
- goodEnd = p;
- n++;
- }
- return goodHead;
-}
-//创建雇员链表
-salespersons* createSalespersonList()
-{
- salespersons* head, * p, * end;
- head = (salespersons*)malloc(sizeof(salespersons));
- head->next = NULL;
- end = head;
- for (int i = 0;i < 10;i++)
- {
- p = (salespersons*)malloc(sizeof(salespersons));
- fscanf(femployeeData, "%s %s %lf", p->id_Number, p->salesperson_Name, &p->money);
- p->next = NULL;
- end->next = p;
- end = p;
- }
- return head;
-}
-//创建实时记录链表
-records* createSingleRecordList()
-{
- records* recordHead;
- recordHead = (records*)malloc(sizeof(records));
- recordHead->next = NULL;
- return recordHead;
-}
-//货物是否存在(货查)
-goods* searchGood(char* id, goods* head)
-{
- goods* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(id, p->id_Number) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//实时销售记录
-void singleRecords(records* singleRecord, soldGoods soldGood,goods *good, salespersons* salesperson)
-{
- records* p;
- p = (records*)malloc(sizeof(records));
- strcpy(p->id, good->id_Number);//货物编号
- strcpy(p->goodName, good->good_Name);//货名
- p->count = soldGood.count;//数量
- strcpy(p->people, salesperson->salesperson_Name);//销售员
- p->price = soldGood.count * good->sell_Price;//售价
- time_t t;
- struct tm* lt;
- time(&t);
- lt = localtime(&t);
- p->year = lt->tm_year + 1900;//年
- p->mon = lt->tm_mon + 1;//月
- p->day = lt->tm_mday;//日
- p->hour = lt->tm_hour;//时
- p->min = lt->tm_min;//分
- p->sec = lt->tm_sec;//秒
- p->next = NULL;
- p->next = singleRecord->next;
- singleRecord->next = p;
-}
-//总销售记录
-records* allRecords(records* head)
-{
- records* allHead, * p1, * p2, * p3, * allEnd;
- allHead = (records*)malloc(sizeof(records));
- allEnd = allHead;
- p1 = head->next;
- while (p1 != NULL)
- {
- p2 = (records*)malloc(sizeof(records));
- p2->count = p1->count;
- p2->day = p1->day;
- strcpy(p2->goodName, p1->goodName);
- p2->hour = p1->hour;
- strcpy(p2->id, p1->id);
- p2->min = p1->min;
- p2->mon = p1->mon;
- p2->price = p1->price;
- p2->sec = p1->sec;
- p2->year = p1->year;
- p2->next = NULL;
- allEnd->next = p2;
- allEnd = p2;
- p1 = p1->next;
- }
- p1 = allHead->next;
- while (p1 != NULL)
- {
- p3 = p1;
- p2 = p1->next;
- while (p2!=NULL)
- {
- if (strcmp(p1->goodName, p2->goodName) == 0)
- {
- p1->count = p1->count + p2->count;
- p1->price = p1->price + p2->price;
- p3->next = p2->next;
- free(p2);
- }
- else
- p3 = p2;
- p2 = p3->next;
- }
- p1 = p1->next;
- }
- return allHead;
-}
-//查找实时记录
-records* searchSingleRecord(records* head, char* id)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(id, p->id) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//查找总记录
-records* searchAllRecord(records* head, char* name)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(name, p->goodName) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//打印实时记录
-void printSingleRecord(records* head)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- printf("%s %s %s %lf %d年%d月%d日 %d:%d:%d\n", p->id, p->goodName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
- p = p->next;
- }
-}
-//打印总记录
-void printAllRecord(records* head)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- printf("%s %lf %d年%d月%d日 %d:%d:%d\n", p->goodName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
- p = p->next;
- }
-}
-//卖货返回实时销售记录(货删和改,记录增)
-void sell(salespersons* salespersonHead, goods* goodHead, records* singleRecord)
-{
- salespersons* p;
- p = salespersonHead->next;
- soldGoods soldGood;
- char id[20];
- printf("请依次输入销售员编号 商品编号 购买数量");
- scanf("%s %s %d", id, soldGood.id_Number, &soldGood.count);
- while (p != NULL)
- {
- if (!strcmp(p->id_Number, id) && searchGood(soldGood.id_Number, goodHead))
- {
- goods* n = searchGood(soldGood.id_Number, goodHead);
- if (soldGood.count > n->remain_Number)
- printf("计数错误,请重新请点商品数量\n");
- p->money = p->money + soldGood.count * n->sell_Price;//更新销售额
- n->remain_Number = n->remain_Number - soldGood.count;//更新库存
- if (n->remain_Number == 0)
- {
- printf("%s %s正好卖没货了\n", n->id_Number, n->good_Name);//可以删除但还是要进货的
- }
- //更新销售记录
- singleRecords(singleRecord, soldGood,n, p);
- break;
- }
- p = p->next;
- }
-}
-int main()
-{
- salespersons* salesperson;//销售员头指针
- records* all;//总销售记录头指针
- records* single;//实时销售记录头指针
- goods* good;//货物头指针
- int n;
- int a;
- single = createSingleRecordList();
- salesperson = createSalespersonList();
- good = createGoodList();
- while (1)
- {
- printf("来顾客了请按“1”\n");
- printf("打印实时销售记录请按“2”\n");
- printf("打印总销售记录“3”\n");
- printf("退出程序请按“0”\n");
- scanf("%d", &a);
- if (a == 1)
- {
- printf("输入顾客所买东西的种类数:");
- scanf("%d", &n);
- printf("开始扫码(没有设备手动输入吧亲!)\n");
- while (n > 0)
- {
- sell(salesperson, good, single);
- n--;
- }
- }
- if (a == 2)
- {
- printSingleRecord(single);
- }
- if (a == 3)
- {
- all = allRecords(single);
- printAllRecord(all);
- }
- if (a == 0)
- {
- printf("下班了,祝你晚餐愉快!\n");
- break;
- }
- }
- //看看员工和库存更没更新
- /*good = good->next;
- while (good != NULL)
- {
- printf("%s %d\n", good->good_Name, good->remain_Number);
- good = good->next;
- }
- salesperson = salesperson->next;
- while (salesperson != NULL)
- {
- printf("%s %.2f\n", salesperson->salesperson_Name, salesperson->money);
- salesperson = salesperson->next;
- }*/
- return 0;
-}
\ No newline at end of file
--
Gitee
From c2390eac4c216e2e0ba9a5b693f24cdd2b12843f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Wed, 15 Jul 2020 20:36:57 +0800
Subject: [PATCH 08/48] =?UTF-8?q?=E9=94=80=E5=94=AE=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=8A=8Agood=E6=94=B9=E6=88=90?=
=?UTF-8?q?=E4=BA=86goods=E7=BE=8E=E5=8C=96=E4=BA=86=E4=B8=80=E4=B8=8B?=
=?UTF-8?q?=E9=94=80=E5=94=AE=E8=AE=B0=E5=BD=95=E7=9A=84=E8=BE=93=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 346 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 346 insertions(+)
create mode 100644 "code/\346\272\220.cpp"
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
new file mode 100644
index 0000000..ee229af
--- /dev/null
+++ "b/code/\346\272\220.cpp"
@@ -0,0 +1,346 @@
+#include
+#include
+#include
+#include
+//ʱṹ
+struct date
+{
+ int year;//
+ int month;//
+ int day;//
+};
+//Ʒṹ
+struct goods
+{
+ char id_Number[20];//Ʒ
+ char goods_Name[20];//Ʒ
+ double buy_Price;//Ʒ
+ double sell_Price;//Ʒۼ
+ date produce_Date;//
+ date purchase_Date;//
+ int quality_Date;//
+ int remain_Number;//ʣ
+ char place[20];//λ
+ goods* next;
+};
+//Ļṹ
+struct soldGoods
+{
+ char id_Number[20];//Ʒ
+ char name[20];
+ int count;//
+ double price;//
+};
+//Աṹ
+struct salespersons
+{
+ char id_Number[20];//Ա
+ char salesperson_Name[20];//Ա
+ double money;//۶
+ salespersons* next;//ָ
+};
+//ۼ¼ṹ
+struct records
+{
+ char id[20];//id
+ char goodsName[20];//
+ char people[20];//Ա
+ int count;//
+ double price;//۽
+ //ʱ
+ int year;
+ int mon;
+ int day;
+ int hour;
+ int min;
+ int sec;
+ records* next;
+};
+FILE* femployeeData = fopen("employeedata.txt", "r+");
+FILE* fgoodsData = fopen("goodsdata.txt", "r+");
+//Ʒ
+goods* createGoodsList()
+{
+ goods* goodsHead, * p, * goodsEnd;
+ goodsHead = (goods*)malloc(sizeof(goods));
+ goodsHead->next = NULL;
+ goodsEnd = goodsHead;
+ int n = 0;
+ while(n<17)
+ {
+ p = (goods*)malloc(sizeof(goods));
+ fscanf(fgoodsData,
+ "%s %s %lf %lf %d %d %d %d %d %d %d %d %s",
+ p->id_Number,
+ p->goods_Name,
+ &p->buy_Price,
+ &p->sell_Price,
+ &p->produce_Date.year,
+ &p->produce_Date.month,
+ &p->produce_Date.day,
+ &p->purchase_Date.year,
+ &p->purchase_Date.month,
+ &p->purchase_Date.day,
+ &p->quality_Date,
+ &p->remain_Number,
+ p->place);
+ p->next = NULL;
+ goodsEnd->next = p;
+ goodsEnd = p;
+ n++;
+ }
+ return goodsHead;
+}
+//Ա
+salespersons* createSalespersonList()
+{
+ salespersons* head, * p, * end;
+ head = (salespersons*)malloc(sizeof(salespersons));
+ head->next = NULL;
+ end = head;
+ for (int i = 0;i < 10;i++)
+ {
+ p = (salespersons*)malloc(sizeof(salespersons));
+ fscanf(femployeeData, "%s %s %lf", p->id_Number, p->salesperson_Name, &p->money);
+ p->next = NULL;
+ end->next = p;
+ end = p;
+ }
+ return head;
+}
+//ʵʱ¼
+records* createSingleRecordList()
+{
+ records* recordHead;
+ recordHead = (records*)malloc(sizeof(records));
+ recordHead->next = NULL;
+ return recordHead;
+}
+//Ƿ()
+goods* searchGoods(char* id, goods* head)
+{
+ goods* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(id, p->id_Number) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ʵʱۼ¼
+void singleRecords(records* singleRecord, soldGoods soldGoods,goods *goods, salespersons* salesperson)
+{
+ records* p;
+ p = (records*)malloc(sizeof(records));
+ strcpy(p->id, goods->id_Number);//
+ strcpy(p->goodsName, goods->goods_Name);//
+ p->count = soldGoods.count;//
+ strcpy(p->people, salesperson->salesperson_Name);//Ա
+ p->price = soldGoods.count * goods->sell_Price;//ۼ
+ time_t t;
+ struct tm* lt;
+ time(&t);
+ lt = localtime(&t);
+ p->year = lt->tm_year + 1900;//
+ p->mon = lt->tm_mon + 1;//
+ p->day = lt->tm_mday;//
+ p->hour = lt->tm_hour;//ʱ
+ p->min = lt->tm_min;//
+ p->sec = lt->tm_sec;//
+ p->next = NULL;
+ p->next = singleRecord->next;
+ singleRecord->next = p;
+}
+//ۼ¼
+records* allRecords(records* head)
+{
+ records* allHead, * p1, * p2, * p3, * allEnd;
+ allHead = (records*)malloc(sizeof(records));
+ allEnd = allHead;
+ p1 = head->next;
+ while (p1 != NULL)
+ {
+ p2 = (records*)malloc(sizeof(records));
+ p2->count = p1->count;
+ p2->day = p1->day;
+ strcpy(p2->goodsName, p1->goodsName);
+ p2->hour = p1->hour;
+ strcpy(p2->id, p1->id);
+ p2->min = p1->min;
+ p2->mon = p1->mon;
+ p2->price = p1->price;
+ p2->sec = p1->sec;
+ p2->year = p1->year;
+ p2->next = NULL;
+ allEnd->next = p2;
+ allEnd = p2;
+ p1 = p1->next;
+ }
+ p1 = allHead->next;
+ while (p1 != NULL)
+ {
+ p3 = p1;
+ p2 = p1->next;
+ while (p2!=NULL)
+ {
+ if (strcmp(p1->goodsName, p2->goodsName) == 0)
+ {
+ p1->count = p1->count + p2->count;
+ p1->price = p1->price + p2->price;
+ p3->next = p2->next;
+ free(p2);
+ }
+ else
+ p3 = p2;
+ p2 = p3->next;
+ }
+ p1 = p1->next;
+ }
+ return allHead;
+}
+//ʵʱ¼
+records* searchSingleRecord(records* head, char* id)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(id, p->id) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ܼ¼
+records* searchAllRecord(records* head, char* name)
+{
+ records* p;
+ p = head->next;
+ while (p != NULL)
+ {
+ if (strcmp(name, p->goodsName) == 0)
+ {
+ return p;
+ }
+ p = p->next;
+ }
+ return NULL;
+}
+//ӡʵʱ¼
+void printSingleRecord(records* head)
+{
+ records* p;
+ p = head->next;
+ printf("Ʒ Ʒ ۶ ʱ\n");
+ while (p != NULL)
+ {
+ printf("%s %s %s %lf %d%d%d %d:%d:%d\n", p->id, p->goodsName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ p = p->next;
+ }
+}
+//ӡܼ¼
+void printAllRecord(records* head)
+{
+ records* p;
+ p = head->next;
+ printf("Ʒ ۶ ʱ");
+ while (p != NULL)
+ {
+ printf("%s %lf %d%d%d %d:%d:%d\n", p->goodsName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ p = p->next;
+ }
+}
+//ʵʱۼ¼ɾģ¼
+void sell(salespersons* salespersonHead, goods* goodsHead, records* singleRecord)
+{
+ salespersons* p;
+ p = salespersonHead->next;
+ soldGoods soldGoods;
+ char id[20];
+ printf("Ա Ʒ \n");
+ scanf("%s %s %d", id, soldGoods.id_Number, &soldGoods.count);
+ while (p != NULL)
+ {
+ if (!strcmp(p->id_Number, id) && searchGoods(soldGoods.id_Number, goodsHead))
+ {
+ goods* n = searchGoods(soldGoods.id_Number, goodsHead);
+ if (soldGoods.count > n->remain_Number)
+ printf("Ʒ\n");
+ p->money = p->money + soldGoods.count * n->sell_Price;//۶
+ n->remain_Number = n->remain_Number - soldGoods.count;//¿
+ if (n->remain_Number == 0)
+ {
+ printf("%s %sû\n", n->id_Number, n->goods_Name);//ɾҪ
+ }
+ //ۼ¼
+ singleRecords(singleRecord, soldGoods,n, p);
+ break;
+ }
+ p = p->next;
+ }
+}
+int main()
+{
+ salespersons* salesperson;//Աͷָ
+ records* all;//ۼ¼ͷָ
+ records* single;//ʵʱۼ¼ͷָ
+ goods* goods;//ͷָ
+ int n;
+ int a;
+ single = createSingleRecordList();
+ salesperson = createSalespersonList();
+ goods = createGoodsList();
+ while (1)
+ {
+ printf("˿밴1\n");
+ printf("ӡʵʱۼ¼밴2\n");
+ printf("ӡۼ¼3\n");
+ printf("˳밴0\n");
+ scanf("%d", &a);
+ if (a == 1)
+ {
+ printf("˿");
+ scanf("%d", &n);
+ printf("ʼɨ루û豸ֶ!\n");
+ while (n > 0)
+ {
+ sell(salesperson, goods, single);
+ n--;
+ }
+ }
+ if (a == 2)
+ {
+ printSingleRecord(single);
+ }
+ if (a == 3)
+ {
+ all = allRecords(single);
+ printAllRecord(all);
+ }
+ if (a == 0)
+ {
+ printf("°ˣף!\n");
+ break;
+ }
+ }
+ //ԱͿû
+ /*goods = goods->next;
+ while (goods != NULL)
+ {
+ printf("%s %d\n", goods->goods_Name, goods->remain_Number);
+ goods = goods->next;
+ }
+ salesperson = salesperson->next;
+ while (salesperson != NULL)
+ {
+ printf("%s %.2f\n", salesperson->salesperson_Name, salesperson->money);
+ salesperson = salesperson->next;
+ }*/
+ return 0;
+}
\ No newline at end of file
--
Gitee
From ee305b675aceef70e61e5657bc27e455ceb1c3b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=96=87=E6=B4=8B?= <810503626@qq.com>
Date: Wed, 15 Jul 2020 22:45:04 +0800
Subject: [PATCH 09/48] =?UTF-8?q?update=20code/=E6=BA=90.cpp.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 171 ++++++++++++++++++++++------------------
1 file changed, 94 insertions(+), 77 deletions(-)
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
index ee229af..f2e4157 100644
--- "a/code/\346\272\220.cpp"
+++ "b/code/\346\272\220.cpp"
@@ -2,52 +2,52 @@
#include
#include
#include
-//ʱṹ
+//时间结构体
struct date
{
- int year;//
- int month;//
- int day;//
+ int year;//年
+ int month;//月
+ int day;//日
};
-//Ʒṹ
+//库存商品结构体
struct goods
{
- char id_Number[20];//Ʒ
- char goods_Name[20];//Ʒ
- double buy_Price;//Ʒ
- double sell_Price;//Ʒۼ
- date produce_Date;//
- date purchase_Date;//
- int quality_Date;//
- int remain_Number;//ʣ
- char place[20];//λ
+ char id_Number[20];//商品编号
+ char goods_Name[20];//商品名
+ double buy_Price;//商品进价
+ double sell_Price;//商品售价
+ date produce_Date;//生产日期
+ date purchase_Date;//进货日期
+ int quality_Date;//保质期
+ int remain_Number;//剩余数量
+ char place[20];//库存位置
goods* next;
};
-//Ļṹ
+//卖的货结构体
struct soldGoods
{
- char id_Number[20];//Ʒ
+ char id_Number[20];//商品编号
char name[20];
- int count;//
- double price;//
+ int count;//数量
+ double price;//单价
};
-//Աṹ
+//销售员结构体
struct salespersons
{
- char id_Number[20];//Ա
- char salesperson_Name[20];//Ա
- double money;//۶
- salespersons* next;//ָ
+ char id_Number[20];//雇员编号
+ char salesperson_Name[20];//雇员名
+ double money;//销售额
+ salespersons* next;//后继指针
};
-//ۼ¼ṹ
+//销售记录结构体
struct records
{
- char id[20];//id
- char goodsName[20];//
- char people[20];//Ա
- int count;//
- double price;//۽
- //ʱ
+ char id[20];//货物id
+ char goodsName[20];//货物名
+ char people[20];//销售员
+ int count;//销售数量
+ double price;//销售金额
+ //销售时间
int year;
int mon;
int day;
@@ -58,7 +58,7 @@ struct records
};
FILE* femployeeData = fopen("employeedata.txt", "r+");
FILE* fgoodsData = fopen("goodsdata.txt", "r+");
-//Ʒ
+//创建商品链表
goods* createGoodsList()
{
goods* goodsHead, * p, * goodsEnd;
@@ -91,7 +91,7 @@ goods* createGoodsList()
}
return goodsHead;
}
-//Ա
+//创建雇员链表
salespersons* createSalespersonList()
{
salespersons* head, * p, * end;
@@ -108,7 +108,7 @@ salespersons* createSalespersonList()
}
return head;
}
-//ʵʱ¼
+//创建实时记录链表
records* createSingleRecordList()
{
records* recordHead;
@@ -116,7 +116,7 @@ records* createSingleRecordList()
recordHead->next = NULL;
return recordHead;
}
-//Ƿ()
+//货物是否存在(货查)
goods* searchGoods(char* id, goods* head)
{
goods* p;
@@ -131,31 +131,31 @@ goods* searchGoods(char* id, goods* head)
}
return NULL;
}
-//ʵʱۼ¼
+//实时销售记录
void singleRecords(records* singleRecord, soldGoods soldGoods,goods *goods, salespersons* salesperson)
{
records* p;
p = (records*)malloc(sizeof(records));
- strcpy(p->id, goods->id_Number);//
- strcpy(p->goodsName, goods->goods_Name);//
- p->count = soldGoods.count;//
- strcpy(p->people, salesperson->salesperson_Name);//Ա
- p->price = soldGoods.count * goods->sell_Price;//ۼ
+ strcpy(p->id, goods->id_Number);//货物编号
+ strcpy(p->goodsName, goods->goods_Name);//货名
+ p->count = soldGoods.count;//数量
+ strcpy(p->people, salesperson->salesperson_Name);//销售员
+ p->price = soldGoods.count * goods->sell_Price;//售价
time_t t;
struct tm* lt;
time(&t);
lt = localtime(&t);
- p->year = lt->tm_year + 1900;//
- p->mon = lt->tm_mon + 1;//
- p->day = lt->tm_mday;//
- p->hour = lt->tm_hour;//ʱ
- p->min = lt->tm_min;//
- p->sec = lt->tm_sec;//
+ p->year = lt->tm_year + 1900;//年
+ p->mon = lt->tm_mon + 1;//月
+ p->day = lt->tm_mday;//日
+ p->hour = lt->tm_hour;//时
+ p->min = lt->tm_min;//分
+ p->sec = lt->tm_sec;//秒
p->next = NULL;
p->next = singleRecord->next;
singleRecord->next = p;
}
-//ۼ¼
+//总销售记录
records* allRecords(records* head)
{
records* allHead, * p1, * p2, * p3, * allEnd;
@@ -202,7 +202,7 @@ records* allRecords(records* head)
}
return allHead;
}
-//ʵʱ¼
+//查找实时记录
records* searchSingleRecord(records* head, char* id)
{
records* p;
@@ -217,7 +217,7 @@ records* searchSingleRecord(records* head, char* id)
}
return NULL;
}
-//ܼ¼
+//查找总记录
records* searchAllRecord(records* head, char* name)
{
records* p;
@@ -232,38 +232,39 @@ records* searchAllRecord(records* head, char* name)
}
return NULL;
}
-//ӡʵʱ¼
+//打印实时记录
void printSingleRecord(records* head)
{
records* p;
p = head->next;
- printf("Ʒ Ʒ ۶ ʱ\n");
+ printf("商品编号 商品名 卖货人 销售额 销售时间\n");
while (p != NULL)
{
- printf("%s %s %s %lf %d%d%d %d:%d:%d\n", p->id, p->goodsName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ printf("%s %s %s %lf %d年%d月%d日 %d:%d:%d\n", p->id, p->goodsName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
p = p->next;
}
}
-//ӡܼ¼
+//打印总记录
void printAllRecord(records* head)
{
records* p;
p = head->next;
- printf("Ʒ ۶ ʱ");
+ printf("商品名 销售额 销售时间\n");
while (p != NULL)
{
- printf("%s %lf %d%d%d %d:%d:%d\n", p->goodsName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
+ printf("%s %lf %d年%d月%d日 %d:%d:%d\n", p->goodsName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
p = p->next;
}
}
-//ʵʱۼ¼ɾģ¼
-void sell(salespersons* salespersonHead, goods* goodsHead, records* singleRecord)
+//卖货返回实时销售记录(货删和改,记录增)
+double sell(salespersons* salespersonHead, goods* goodsHead, records* singleRecord,int a)
{
salespersons* p;
p = salespersonHead->next;
soldGoods soldGoods;
+ double money;
char id[20];
- printf("Ա Ʒ \n");
+ printf("请依次输入销售员编号 商品编号 购买数量\n");
scanf("%s %s %d", id, soldGoods.id_Number, &soldGoods.count);
while (p != NULL)
{
@@ -271,26 +272,31 @@ void sell(salespersons* salespersonHead, goods* goodsHead, records* singleRecord
{
goods* n = searchGoods(soldGoods.id_Number, goodsHead);
if (soldGoods.count > n->remain_Number)
- printf("Ʒ\n");
- p->money = p->money + soldGoods.count * n->sell_Price;//۶
- n->remain_Number = n->remain_Number - soldGoods.count;//¿
+ {
+ printf("计数错误,请重新请点商品数量\n");
+ a = a + 1;//重新计数
+ return 0;
+ }
+ p->money = p->money + soldGoods.count * n->sell_Price;//更新销售额
+ n->remain_Number = n->remain_Number - soldGoods.count;//更新库存
if (n->remain_Number == 0)
{
- printf("%s %sû\n", n->id_Number, n->goods_Name);//ɾҪ
+ printf("%s %s正好卖没货了\n", n->id_Number, n->goods_Name);//可以删除但还是要进货的
}
- //ۼ¼
+ //更新销售记录
singleRecords(singleRecord, soldGoods,n, p);
- break;
+ return soldGoods.count * n->sell_Price;
}
p = p->next;
}
}
int main()
{
- salespersons* salesperson;//Աͷָ
- records* all;//ۼ¼ͷָ
- records* single;//ʵʱۼ¼ͷָ
- goods* goods;//ͷָ
+ salespersons* salesperson;//销售员头指针
+ records* all;//总销售记录头指针
+ records* single;//实时销售记录头指针
+ goods* goods;//货物头指针
+ double money1=0,money2=0,money3=0;
int n;
int a;
single = createSingleRecordList();
@@ -298,21 +304,32 @@ int main()
goods = createGoodsList();
while (1)
{
- printf("˿밴1\n");
- printf("ӡʵʱۼ¼밴2\n");
- printf("ӡۼ¼3\n");
- printf("˳밴0\n");
+ printf("来顾客了请按“1”\n");
+ printf("打印实时销售记录请按“2”\n");
+ printf("打印总销售记录“3”\n");
+ printf("退出程序请按“0”\n");
scanf("%d", &a);
if (a == 1)
{
- printf("˿");
+ printf("输入顾客所买东西的种类数:");
scanf("%d", &n);
- printf("ʼɨ루û豸ֶ!\n");
+ printf("开始扫码(没有设备手动输入吧亲!)\n");
while (n > 0)
{
- sell(salesperson, goods, single);
+ money2=money2+sell(salesperson, goods, single, n);
n--;
}
+ printf("输入顾客所付钱数:");
+ scanf("%lf", &money1);
+ if(money1>=money2)
+ printf("找零:%.2f\n", money1 - money2);
+ else
+ {
+ printf("所付金额不足,请继续付款");
+ scanf("%lf", &money3);
+ money1 = money1 + money3;
+ printf("找零:%.2f\n", money1 - money2);
+ }
}
if (a == 2)
{
@@ -325,11 +342,11 @@ int main()
}
if (a == 0)
{
- printf("°ˣף!\n");
+ printf("下班了,祝你晚餐愉快!\n");
break;
}
}
- //ԱͿû
+ //看看员工和库存更没更新
/*goods = goods->next;
while (goods != NULL)
{
--
Gitee
From 709ec64f002e819467a86c01315877f8a50aeec6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AB=98=E9=BE=99=E9=A3=9E?= <1011520207@qq.com>
Date: Wed, 15 Jul 2020 23:42:44 +0800
Subject: [PATCH 10/48] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E7=AE=A1=E7=90=86=E7=B3=BB=E7=BB=9F=20commodity1.txt?=
=?UTF-8?q?=E4=B8=BA=E6=96=87=E4=BB=B6=E5=AF=BC=E5=85=A5=E8=BF=9B=E8=B4=A7?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=AE=B0=E5=BD=95=EF=BC=8Csuppliers1.txt?=
=?UTF-8?q?=E4=B8=BA=E4=BE=9B=E5=BA=94=E5=95=86=E6=96=87=E4=BB=B6=E5=AF=BC?=
=?UTF-8?q?=E5=85=A5=E4=BF=A1=E6=81=AF=EF=BC=8Csuppliers2.txt=E4=B8=BA?=
=?UTF-8?q?=E8=BF=90=E8=A1=8C=E4=B8=80=E4=BA=9B=E5=88=97=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=E5=90=8E=E4=BF=9D=E5=AD=98=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E7=9A=84=E6=96=87=E4=BB=B6=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 +
code/list.cpp | 598 ++++++++++++++++++
code/list.h | 150 +++++
code/main.cpp | 30 +
code/suppliers1.txt | 6 +
code/suppliers2.txt | 15 +
...3\345\217\212\350\257\264\346\230\216.txt" | 16 +
7 files changed, 822 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/list.cpp
create mode 100644 code/list.h
create mode 100644 code/main.cpp
create mode 100644 code/suppliers1.txt
create mode 100644 code/suppliers2.txt
create mode 100644 "code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..67ca69a
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,7 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
+002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
+003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
+004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
+007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
diff --git a/code/list.cpp b/code/list.cpp
new file mode 100644
index 0000000..11797dc
--- /dev/null
+++ b/code/list.cpp
@@ -0,0 +1,598 @@
+#include
+#include
+#include
+#include "list.h"
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail)
+{
+ head = (purchase)malloc(sizeof(purchase_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
+{
+ purchase p;
+ p = (purchase)malloc(sizeof(purchase_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->number, number);
+ strcpy(p->name, name);
+ strcpy(p->source, source);
+ strcpy(p->channel, channel);
+ p->quantity = quantity;
+ p->price = price;
+ p->time.year = time.year;
+ p->time.month = time.month;
+ p->time.day = time.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ڴϢ
+Status Printf_purchas(purchase& p)
+{
+ printf("%s %s %s %s %d %.2lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ return OK;
+}
+
+// ļϢ
+Status Fprintf_purchas(purchase& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ fclose(fp);
+ return OK;
+}
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
+{
+ purchase p;
+ p = head->next;
+ if (!p)
+ {
+ printf("Ϣ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("Ϣʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ
+Status DisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Printf_purchas);
+ return OK;
+}
+
+// ļ
+Status FdisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Fprintf_purchas);
+ return OK;
+}
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail)
+{
+ head = (suppliers)malloc(sizeof(suppliers_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ InitList_purchase(head->purchase_head, head->purchase_tail);
+ return OK;
+}
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->corporate_name, corporate_name) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
+{
+ suppliers p;
+ p = (suppliers)malloc(sizeof(suppliers_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ InitList_purchase(p->purchase_head, p->purchase_tail);
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ }
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail)
+{
+ FILE* fp;
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ fp = fopen("suppliers1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ printf("ҪɾӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
+ return ERROR;
+ }
+ if (p->next)
+ {
+ p->next->pre = p->pre;
+ }
+ p->pre->next = p->next;
+ free(p);
+ printf("ӦϢɾɹ\n");
+ return OK;
+}
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪĹӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ printf("롰˾ơӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ printf("ӦϢijɹ\n");
+ return OK;
+}
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers& p)
+{
+ printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ DisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ļӦϢ
+Status Fprintf_suppliers(suppliers& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ printf("ӡ\n");
+ fclose(fp);
+ FdisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪѯӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ Printf_suppliers(p);
+ return OK;
+}
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
+{
+ suppliers p;
+ p = head->next;
+ if (!p)
+ {
+ printf("ӦϢ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("ӦϢʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴӦ
+Status DisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Printf_suppliers);
+ return OK;
+}
+
+// ļӦ
+Status FdisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Fprintf_suppliers);
+ return OK;
+}
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail)
+{
+ head = (commodity)malloc(sizeof(goods));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
+{
+ commodity p;
+ p = (commodity)malloc(sizeof(goods));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->id_Number, id_Number);
+ strcpy(p->goods_Name, goods_Name);
+ strcpy(p->place, place);
+ p->buy_Prise = buy_Prise;
+ p->sell_Prise = sell_Prise;
+ p->remain_Number = remain_Number;
+ p->quality_Date = quality_Date;
+ p->purchase_Date.year = purchase_Date.year;
+ p->purchase_Date.month = purchase_Date.month;
+ p->purchase_Date.day = purchase_Date.day;
+ p->produce_Date.year = produce_Date.year;
+ p->produce_Date.month = produce_Date.month;
+ p->produce_Date.day = produce_Date.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->id_Number, id_Number) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (getchar() == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ printf("ƷϢ¼ɹ\n");
+ printf("Ϣ¼ɹ\n");
+ return OK;
+}
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ FILE* fp;
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ fp = fopen("commodity1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (fgetc(fp) == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ƷϢɹ\n");
+ printf("Ϣɹ\n");
+ return OK;
+}
\ No newline at end of file
diff --git a/code/list.h b/code/list.h
new file mode 100644
index 0000000..b67f551
--- /dev/null
+++ b/code/list.h
@@ -0,0 +1,150 @@
+#ifndef __PURCHASE_H__
+#define __PURCHASE_H__
+
+// ͷļṹ
+
+//
+#define MAX_SIZE 30
+
+// ״̬
+#define TRUE 1 //
+#define FALSE 0 //
+#define OK 1 //
+#define ERROR 0 //
+#define INFEASIBLE -1 //
+#define OVERFLOW -2 //
+
+// Status ǺֵͣǺ״̬
+typedef int Status;
+
+// ʱṹ壬洢ꡢ¡Ϣ
+struct date
+{
+ int year; //
+ int month; //
+ int day; //
+};
+
+/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
+
+// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
+typedef struct purchase_information
+{
+ char number[MAX_SIZE]; // Ʒ
+ char name[MAX_SIZE]; // Ʒ
+ char source[MAX_SIZE]; // Դ
+ char channel[MAX_SIZE]; //
+ int quantity; //
+ double price; // ۸
+ date time; // ʱ
+ purchase_information* pre; // һָ
+ purchase_information* next; // һָ
+}*purchase;
+
+// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
+typedef struct suppliers_information
+{
+ char corporate_name[MAX_SIZE]; // ˾
+ char main_business[MAX_SIZE]; // Ӫҵ
+ char main_products[MAX_SIZE]; // ӪƷ
+ char brand[MAX_SIZE]; // Ʒ
+ char contact_person[MAX_SIZE]; //
+ char telephone[MAX_SIZE]; // 绰
+ purchase purchase_head; // Ϣͷڵ
+ purchase purchase_tail; // Ϣβ
+ suppliers_information* pre; // һӦָ
+ suppliers_information* next; // һӦָ
+}*suppliers;
+
+typedef struct goods
+{
+ char id_Number[20]; // Ʒ
+ char goods_Name[20]; // Ʒ
+ char place[20]; // λ
+ double buy_Prise; // Ʒ
+ double sell_Prise; // Ʒۼ
+ int remain_Number; // Ʒ
+ int quality_Date; //
+ date purchase_Date; //
+ date produce_Date; //
+ goods* pre; // һƷָ
+ goods* next; // һƷָ
+}*commodity;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail);
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
+
+// ڴϢ
+Status Printf_purchas(purchase& p);
+
+// ļϢ
+Status Fprintf_purchas(purchase& p);
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
+
+// ڴ
+Status DisplayList_purchas(purchase& head);
+
+// ļ
+Status FdisplayList_purchas(purchase& head);
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail);
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail);
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail);
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head);
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail);
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers& p);
+
+// ļӦϢ
+Status Fprintf_suppliers(suppliers& p);
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail);
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
+
+// ڴӦ
+Status DisplayList_suppliers(suppliers& head);
+
+// ļӦ
+Status FdisplayList_suppliers(suppliers& head);
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail);
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ļ¼ƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+#endif
diff --git a/code/main.cpp b/code/main.cpp
new file mode 100644
index 0000000..8a24f48
--- /dev/null
+++ b/code/main.cpp
@@ -0,0 +1,30 @@
+#include "list.h"
+#include
+int main()
+{
+ suppliers suppliers_head, suppliers_tail;
+ commodity commodity_head, commodity_tail;
+ InitList_suppliers(suppliers_head, suppliers_tail);
+ Fadd_suppliers(suppliers_head, suppliers_tail);//ļ빩ӦϢ
+ InitList_commodity(commodity_head, commodity_tail);
+ Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);//ļ¼
+ printf("1.ӽϢ¼\n2.ӹӦϢ\n3.ɾӦϢ\n4.ĹӦϢ\n5.ĻӡǰӦϢ\n6.ļӡǰӦϢ\n7.˳\n");
+ int order;
+ while (1)
+ {
+ printf("ǰŽв\n");
+ scanf("%d", &order);
+ switch (order)
+ {
+ case 1:Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);; break;
+ case 2:Add_suppliers(suppliers_head, suppliers_tail);; break;
+ case 3:ListDelete_suppliers(suppliers_head);; break;
+ case 4:ListAlter_suppliers(suppliers_head, suppliers_tail);; break;
+ case 5:DisplayList_suppliers(suppliers_head);; break;
+ case 6:FdisplayList_suppliers(suppliers_head);; break;
+ case 7:return 0; break;
+ default:return 0;
+ }
+ printf("\n");
+ }
+}
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
new file mode 100644
index 0000000..e894e1d
--- /dev/null
+++ b/code/suppliers2.txt
@@ -0,0 +1,15 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+002 orange tengxun qiang 100 4.000000 2020 7 14
+005 watermelon tengxun qiang 100 6.000000 2020 7 14
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+001 apple wangyi qiang 100 5.000000 2020 7 14
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+004 pear xiaomi qiang 100 5.000000 2020 7 14
+huawei huawei1 huawei2 huawei3 huawei4 4444
+006 peach huawei qiang 100 3.000000 2020 7 14
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+007 pen zhongxing qiang 100 1.000000 2020 7 14
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
+003 banana sanxing qiang 100 9.000000 2020 7 14
+lianxiang lianxiang1 lianxiang2 lianxiang3 lianxiang4 9999
+009 computer lianxiang qiang 100 1000.000000 2020 7 14
diff --git "a/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt" "b/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
new file mode 100644
index 0000000..e9e624d
--- /dev/null
+++ "b/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
@@ -0,0 +1,16 @@
+测试样例:
+1.添加进货信息记录(记得最后空格)
+009 computer 2020 7 14 lianxiang qiang 100 1000 1200 2020 5 20 365 eastroom
+提示未添加,创建并定义供应商信息
+lianxiang1 lianxiang2 lianxiang3 lianxiang4 9999
+////////////
+2.添加供应商信息(记得最后空格)
+xuegao xuegao1 xuegao 2 xuegao3 xuegao 4 1010
+3.删除供应商信息
+tenngxun
+4.修改供应商信息
+huawei
+提示输入新的信息(所有信息)
+huawei huawei1 huawei2 huawei3 huawei4 1212
+5.屏幕打印当前供应商信息
+6.文件打印当前供应商信息
\ No newline at end of file
--
Gitee
From d3265a3dfbd03f01b6f401a5315566bcc5e72ded Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:29:33 +0800
Subject: [PATCH 11/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/=E6=BA=90.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 363 ----------------------------------------
1 file changed, 363 deletions(-)
delete mode 100644 "code/\346\272\220.cpp"
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
deleted file mode 100644
index f2e4157..0000000
--- "a/code/\346\272\220.cpp"
+++ /dev/null
@@ -1,363 +0,0 @@
-#include
-#include
-#include
-#include
-//时间结构体
-struct date
-{
- int year;//年
- int month;//月
- int day;//日
-};
-//库存商品结构体
-struct goods
-{
- char id_Number[20];//商品编号
- char goods_Name[20];//商品名
- double buy_Price;//商品进价
- double sell_Price;//商品售价
- date produce_Date;//生产日期
- date purchase_Date;//进货日期
- int quality_Date;//保质期
- int remain_Number;//剩余数量
- char place[20];//库存位置
- goods* next;
-};
-//卖的货结构体
-struct soldGoods
-{
- char id_Number[20];//商品编号
- char name[20];
- int count;//数量
- double price;//单价
-};
-//销售员结构体
-struct salespersons
-{
- char id_Number[20];//雇员编号
- char salesperson_Name[20];//雇员名
- double money;//销售额
- salespersons* next;//后继指针
-};
-//销售记录结构体
-struct records
-{
- char id[20];//货物id
- char goodsName[20];//货物名
- char people[20];//销售员
- int count;//销售数量
- double price;//销售金额
- //销售时间
- int year;
- int mon;
- int day;
- int hour;
- int min;
- int sec;
- records* next;
-};
-FILE* femployeeData = fopen("employeedata.txt", "r+");
-FILE* fgoodsData = fopen("goodsdata.txt", "r+");
-//创建商品链表
-goods* createGoodsList()
-{
- goods* goodsHead, * p, * goodsEnd;
- goodsHead = (goods*)malloc(sizeof(goods));
- goodsHead->next = NULL;
- goodsEnd = goodsHead;
- int n = 0;
- while(n<17)
- {
- p = (goods*)malloc(sizeof(goods));
- fscanf(fgoodsData,
- "%s %s %lf %lf %d %d %d %d %d %d %d %d %s",
- p->id_Number,
- p->goods_Name,
- &p->buy_Price,
- &p->sell_Price,
- &p->produce_Date.year,
- &p->produce_Date.month,
- &p->produce_Date.day,
- &p->purchase_Date.year,
- &p->purchase_Date.month,
- &p->purchase_Date.day,
- &p->quality_Date,
- &p->remain_Number,
- p->place);
- p->next = NULL;
- goodsEnd->next = p;
- goodsEnd = p;
- n++;
- }
- return goodsHead;
-}
-//创建雇员链表
-salespersons* createSalespersonList()
-{
- salespersons* head, * p, * end;
- head = (salespersons*)malloc(sizeof(salespersons));
- head->next = NULL;
- end = head;
- for (int i = 0;i < 10;i++)
- {
- p = (salespersons*)malloc(sizeof(salespersons));
- fscanf(femployeeData, "%s %s %lf", p->id_Number, p->salesperson_Name, &p->money);
- p->next = NULL;
- end->next = p;
- end = p;
- }
- return head;
-}
-//创建实时记录链表
-records* createSingleRecordList()
-{
- records* recordHead;
- recordHead = (records*)malloc(sizeof(records));
- recordHead->next = NULL;
- return recordHead;
-}
-//货物是否存在(货查)
-goods* searchGoods(char* id, goods* head)
-{
- goods* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(id, p->id_Number) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//实时销售记录
-void singleRecords(records* singleRecord, soldGoods soldGoods,goods *goods, salespersons* salesperson)
-{
- records* p;
- p = (records*)malloc(sizeof(records));
- strcpy(p->id, goods->id_Number);//货物编号
- strcpy(p->goodsName, goods->goods_Name);//货名
- p->count = soldGoods.count;//数量
- strcpy(p->people, salesperson->salesperson_Name);//销售员
- p->price = soldGoods.count * goods->sell_Price;//售价
- time_t t;
- struct tm* lt;
- time(&t);
- lt = localtime(&t);
- p->year = lt->tm_year + 1900;//年
- p->mon = lt->tm_mon + 1;//月
- p->day = lt->tm_mday;//日
- p->hour = lt->tm_hour;//时
- p->min = lt->tm_min;//分
- p->sec = lt->tm_sec;//秒
- p->next = NULL;
- p->next = singleRecord->next;
- singleRecord->next = p;
-}
-//总销售记录
-records* allRecords(records* head)
-{
- records* allHead, * p1, * p2, * p3, * allEnd;
- allHead = (records*)malloc(sizeof(records));
- allEnd = allHead;
- p1 = head->next;
- while (p1 != NULL)
- {
- p2 = (records*)malloc(sizeof(records));
- p2->count = p1->count;
- p2->day = p1->day;
- strcpy(p2->goodsName, p1->goodsName);
- p2->hour = p1->hour;
- strcpy(p2->id, p1->id);
- p2->min = p1->min;
- p2->mon = p1->mon;
- p2->price = p1->price;
- p2->sec = p1->sec;
- p2->year = p1->year;
- p2->next = NULL;
- allEnd->next = p2;
- allEnd = p2;
- p1 = p1->next;
- }
- p1 = allHead->next;
- while (p1 != NULL)
- {
- p3 = p1;
- p2 = p1->next;
- while (p2!=NULL)
- {
- if (strcmp(p1->goodsName, p2->goodsName) == 0)
- {
- p1->count = p1->count + p2->count;
- p1->price = p1->price + p2->price;
- p3->next = p2->next;
- free(p2);
- }
- else
- p3 = p2;
- p2 = p3->next;
- }
- p1 = p1->next;
- }
- return allHead;
-}
-//查找实时记录
-records* searchSingleRecord(records* head, char* id)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(id, p->id) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//查找总记录
-records* searchAllRecord(records* head, char* name)
-{
- records* p;
- p = head->next;
- while (p != NULL)
- {
- if (strcmp(name, p->goodsName) == 0)
- {
- return p;
- }
- p = p->next;
- }
- return NULL;
-}
-//打印实时记录
-void printSingleRecord(records* head)
-{
- records* p;
- p = head->next;
- printf("商品编号 商品名 卖货人 销售额 销售时间\n");
- while (p != NULL)
- {
- printf("%s %s %s %lf %d年%d月%d日 %d:%d:%d\n", p->id, p->goodsName, p->people, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
- p = p->next;
- }
-}
-//打印总记录
-void printAllRecord(records* head)
-{
- records* p;
- p = head->next;
- printf("商品名 销售额 销售时间\n");
- while (p != NULL)
- {
- printf("%s %lf %d年%d月%d日 %d:%d:%d\n", p->goodsName, p->price, p->year, p->mon, p->day, p->hour, p->min, p->sec);
- p = p->next;
- }
-}
-//卖货返回实时销售记录(货删和改,记录增)
-double sell(salespersons* salespersonHead, goods* goodsHead, records* singleRecord,int a)
-{
- salespersons* p;
- p = salespersonHead->next;
- soldGoods soldGoods;
- double money;
- char id[20];
- printf("请依次输入销售员编号 商品编号 购买数量\n");
- scanf("%s %s %d", id, soldGoods.id_Number, &soldGoods.count);
- while (p != NULL)
- {
- if (!strcmp(p->id_Number, id) && searchGoods(soldGoods.id_Number, goodsHead))
- {
- goods* n = searchGoods(soldGoods.id_Number, goodsHead);
- if (soldGoods.count > n->remain_Number)
- {
- printf("计数错误,请重新请点商品数量\n");
- a = a + 1;//重新计数
- return 0;
- }
- p->money = p->money + soldGoods.count * n->sell_Price;//更新销售额
- n->remain_Number = n->remain_Number - soldGoods.count;//更新库存
- if (n->remain_Number == 0)
- {
- printf("%s %s正好卖没货了\n", n->id_Number, n->goods_Name);//可以删除但还是要进货的
- }
- //更新销售记录
- singleRecords(singleRecord, soldGoods,n, p);
- return soldGoods.count * n->sell_Price;
- }
- p = p->next;
- }
-}
-int main()
-{
- salespersons* salesperson;//销售员头指针
- records* all;//总销售记录头指针
- records* single;//实时销售记录头指针
- goods* goods;//货物头指针
- double money1=0,money2=0,money3=0;
- int n;
- int a;
- single = createSingleRecordList();
- salesperson = createSalespersonList();
- goods = createGoodsList();
- while (1)
- {
- printf("来顾客了请按“1”\n");
- printf("打印实时销售记录请按“2”\n");
- printf("打印总销售记录“3”\n");
- printf("退出程序请按“0”\n");
- scanf("%d", &a);
- if (a == 1)
- {
- printf("输入顾客所买东西的种类数:");
- scanf("%d", &n);
- printf("开始扫码(没有设备手动输入吧亲!)\n");
- while (n > 0)
- {
- money2=money2+sell(salesperson, goods, single, n);
- n--;
- }
- printf("输入顾客所付钱数:");
- scanf("%lf", &money1);
- if(money1>=money2)
- printf("找零:%.2f\n", money1 - money2);
- else
- {
- printf("所付金额不足,请继续付款");
- scanf("%lf", &money3);
- money1 = money1 + money3;
- printf("找零:%.2f\n", money1 - money2);
- }
- }
- if (a == 2)
- {
- printSingleRecord(single);
- }
- if (a == 3)
- {
- all = allRecords(single);
- printAllRecord(all);
- }
- if (a == 0)
- {
- printf("下班了,祝你晚餐愉快!\n");
- break;
- }
- }
- //看看员工和库存更没更新
- /*goods = goods->next;
- while (goods != NULL)
- {
- printf("%s %d\n", goods->goods_Name, goods->remain_Number);
- goods = goods->next;
- }
- salesperson = salesperson->next;
- while (salesperson != NULL)
- {
- printf("%s %.2f\n", salesperson->salesperson_Name, salesperson->money);
- salesperson = salesperson->next;
- }*/
- return 0;
-}
\ No newline at end of file
--
Gitee
From e7a6ca5d85e458a2bfbdd29048e4b4eb532c8c10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:29:49 +0800
Subject: [PATCH 12/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/list.h?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/list.h | 150 ----------------------------------------------------
1 file changed, 150 deletions(-)
delete mode 100644 code/list.h
diff --git a/code/list.h b/code/list.h
deleted file mode 100644
index b67f551..0000000
--- a/code/list.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef __PURCHASE_H__
-#define __PURCHASE_H__
-
-// ͷļṹ
-
-//
-#define MAX_SIZE 30
-
-// ״̬
-#define TRUE 1 //
-#define FALSE 0 //
-#define OK 1 //
-#define ERROR 0 //
-#define INFEASIBLE -1 //
-#define OVERFLOW -2 //
-
-// Status ǺֵͣǺ״̬
-typedef int Status;
-
-// ʱṹ壬洢ꡢ¡Ϣ
-struct date
-{
- int year; //
- int month; //
- int day; //
-};
-
-/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
-
-// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
-typedef struct purchase_information
-{
- char number[MAX_SIZE]; // Ʒ
- char name[MAX_SIZE]; // Ʒ
- char source[MAX_SIZE]; // Դ
- char channel[MAX_SIZE]; //
- int quantity; //
- double price; // ۸
- date time; // ʱ
- purchase_information* pre; // һָ
- purchase_information* next; // һָ
-}*purchase;
-
-// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
-typedef struct suppliers_information
-{
- char corporate_name[MAX_SIZE]; // ˾
- char main_business[MAX_SIZE]; // Ӫҵ
- char main_products[MAX_SIZE]; // ӪƷ
- char brand[MAX_SIZE]; // Ʒ
- char contact_person[MAX_SIZE]; //
- char telephone[MAX_SIZE]; // 绰
- purchase purchase_head; // Ϣͷڵ
- purchase purchase_tail; // Ϣβ
- suppliers_information* pre; // һӦָ
- suppliers_information* next; // һӦָ
-}*suppliers;
-
-typedef struct goods
-{
- char id_Number[20]; // Ʒ
- char goods_Name[20]; // Ʒ
- char place[20]; // λ
- double buy_Prise; // Ʒ
- double sell_Prise; // Ʒۼ
- int remain_Number; // Ʒ
- int quality_Date; //
- date purchase_Date; //
- date produce_Date; //
- goods* pre; // һƷָ
- goods* next; // һƷָ
-}*commodity;
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail);
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
-
-// ڴϢ
-Status Printf_purchas(purchase& p);
-
-// ļϢ
-Status Fprintf_purchas(purchase& p);
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
-
-// ڴ
-Status DisplayList_purchas(purchase& head);
-
-// ļ
-Status FdisplayList_purchas(purchase& head);
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail);
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail);
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail);
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head);
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail);
-
-// ڴӦϢ
-Status Printf_suppliers(suppliers& p);
-
-// ļӦϢ
-Status Fprintf_suppliers(suppliers& p);
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail);
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
-
-// ڴӦ
-Status DisplayList_suppliers(suppliers& head);
-
-// ļӦ
-Status FdisplayList_suppliers(suppliers& head);
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail);
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ļ¼ƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-#endif
--
Gitee
From d3b04ab2503474864b2a5248fbb036b7e7d2ad04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:30:08 +0800
Subject: [PATCH 13/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/list.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/list.cpp | 598 --------------------------------------------------
1 file changed, 598 deletions(-)
delete mode 100644 code/list.cpp
diff --git a/code/list.cpp b/code/list.cpp
deleted file mode 100644
index 11797dc..0000000
--- a/code/list.cpp
+++ /dev/null
@@ -1,598 +0,0 @@
-#include
-#include
-#include
-#include "list.h"
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail)
-{
- head = (purchase)malloc(sizeof(purchase_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
-{
- purchase p;
- p = (purchase)malloc(sizeof(purchase_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->number, number);
- strcpy(p->name, name);
- strcpy(p->source, source);
- strcpy(p->channel, channel);
- p->quantity = quantity;
- p->price = price;
- p->time.year = time.year;
- p->time.month = time.month;
- p->time.day = time.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ڴϢ
-Status Printf_purchas(purchase& p)
-{
- printf("%s %s %s %s %d %.2lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- return OK;
-}
-
-// ļϢ
-Status Fprintf_purchas(purchase& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- fclose(fp);
- return OK;
-}
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
-{
- purchase p;
- p = head->next;
- if (!p)
- {
- printf("Ϣ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("Ϣʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ
-Status DisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Printf_purchas);
- return OK;
-}
-
-// ļ
-Status FdisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Fprintf_purchas);
- return OK;
-}
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail)
-{
- head = (suppliers)malloc(sizeof(suppliers_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- InitList_purchase(head->purchase_head, head->purchase_tail);
- return OK;
-}
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->corporate_name, corporate_name) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
-{
- suppliers p;
- p = (suppliers)malloc(sizeof(suppliers_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- InitList_purchase(p->purchase_head, p->purchase_tail);
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
- if (getchar() == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (getchar() == ' ')
- {
- break;
- }
- }
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail)
-{
- FILE* fp;
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- fp = fopen("suppliers1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- }
- fclose(fp);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- printf("ҪɾӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
- return ERROR;
- }
- if (p->next)
- {
- p->next->pre = p->pre;
- }
- p->pre->next = p->next;
- free(p);
- printf("ӦϢɾɹ\n");
- return OK;
-}
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪĹӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- printf("롰˾ơӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- printf("ӦϢijɹ\n");
- return OK;
-}
-
-// ڴӦϢ
-Status Printf_suppliers(suppliers& p)
-{
- printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- DisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// ļӦϢ
-Status Fprintf_suppliers(suppliers& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- printf("ӡ\n");
- fclose(fp);
- FdisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪѯӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- Printf_suppliers(p);
- return OK;
-}
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
-{
- suppliers p;
- p = head->next;
- if (!p)
- {
- printf("ӦϢ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("ӦϢʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴӦ
-Status DisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Printf_suppliers);
- return OK;
-}
-
-// ļӦ
-Status FdisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Fprintf_suppliers);
- return OK;
-}
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail)
-{
- head = (commodity)malloc(sizeof(goods));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
-{
- commodity p;
- p = (commodity)malloc(sizeof(goods));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->id_Number, id_Number);
- strcpy(p->goods_Name, goods_Name);
- strcpy(p->place, place);
- p->buy_Prise = buy_Prise;
- p->sell_Prise = sell_Prise;
- p->remain_Number = remain_Number;
- p->quality_Date = quality_Date;
- p->purchase_Date.year = purchase_Date.year;
- p->purchase_Date.month = purchase_Date.month;
- p->purchase_Date.day = purchase_Date.day;
- p->produce_Date.year = produce_Date.year;
- p->produce_Date.month = produce_Date.month;
- p->produce_Date.day = produce_Date.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->id_Number, id_Number) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (getchar() == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- printf("ƷϢ¼ɹ\n");
- printf("Ϣ¼ɹ\n");
- return OK;
-}
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- FILE* fp;
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- fp = fopen("commodity1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (fgetc(fp) == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- fclose(fp);
- printf("ƷϢɹ\n");
- printf("Ϣɹ\n");
- return OK;
-}
\ No newline at end of file
--
Gitee
From 999607971fd5d829d3dd8400eaf4bef7282b6f43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:30:30 +0800
Subject: [PATCH 14/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/main.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/main.cpp | 30 ------------------------------
1 file changed, 30 deletions(-)
delete mode 100644 code/main.cpp
diff --git a/code/main.cpp b/code/main.cpp
deleted file mode 100644
index 8a24f48..0000000
--- a/code/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "list.h"
-#include
-int main()
-{
- suppliers suppliers_head, suppliers_tail;
- commodity commodity_head, commodity_tail;
- InitList_suppliers(suppliers_head, suppliers_tail);
- Fadd_suppliers(suppliers_head, suppliers_tail);//ļ빩ӦϢ
- InitList_commodity(commodity_head, commodity_tail);
- Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);//ļ¼
- printf("1.ӽϢ¼\n2.ӹӦϢ\n3.ɾӦϢ\n4.ĹӦϢ\n5.ĻӡǰӦϢ\n6.ļӡǰӦϢ\n7.˳\n");
- int order;
- while (1)
- {
- printf("ǰŽв\n");
- scanf("%d", &order);
- switch (order)
- {
- case 1:Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);; break;
- case 2:Add_suppliers(suppliers_head, suppliers_tail);; break;
- case 3:ListDelete_suppliers(suppliers_head);; break;
- case 4:ListAlter_suppliers(suppliers_head, suppliers_tail);; break;
- case 5:DisplayList_suppliers(suppliers_head);; break;
- case 6:FdisplayList_suppliers(suppliers_head);; break;
- case 7:return 0; break;
- default:return 0;
- }
- printf("\n");
- }
-}
--
Gitee
From a6d55b0ce4046a50840e08a17718eeaef3041759 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:35:28 +0800
Subject: [PATCH 15/48] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=20=E6=9C=80=E7=BB=88?=
=?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E2=80=9C=E4=BE=9B=E5=BA=94=E5=95=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=AE=A1=E7=90=86=E2=80=9D=E3=80=81=E2=80=9C?=
=?UTF-8?q?=E8=BF=9B=E8=B4=A7=E7=AE=A1=E7=90=86=E2=80=9D=E5=92=8C=E2=80=9C?=
=?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=95=8C=E9=9D=A2=E2=80=9D=E7=9A=84=E6=BA=90?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=20=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?=
=?UTF-8?q?=E4=BA=9B=E9=94=99=E8=AF=AF=EF=BC=8C=E5=AE=8C=E5=96=84=E4=BA=86?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E4=BA=86=E7=AA=97=E5=8F=A3=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.cpp | 775 ++++++++++++++++++++++++++++++++++++++++
code/purchase.h | 170 +++++++++
"code/\346\272\220.cpp" | 10 +
3 files changed, 955 insertions(+)
create mode 100644 code/purchase.cpp
create mode 100644 code/purchase.h
create mode 100644 "code/\346\272\220.cpp"
diff --git a/code/purchase.cpp b/code/purchase.cpp
new file mode 100644
index 0000000..2dc18bd
--- /dev/null
+++ b/code/purchase.cpp
@@ -0,0 +1,775 @@
+#include
+#include
+#include
+#include "purchase.h"
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail)
+{
+ head = (purchase)malloc(sizeof(purchase_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
+{
+ purchase p;
+ p = (purchase)malloc(sizeof(purchase_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->number, number);
+ strcpy(p->name, name);
+ strcpy(p->source, source);
+ strcpy(p->channel, channel);
+ p->quantity = quantity;
+ p->price = price;
+ p->time.year = time.year;
+ p->time.month = time.month;
+ p->time.day = time.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p)
+{
+ printf("%s %s %s %s %d %.2lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ return OK;
+}
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ fclose(fp);
+ return OK;
+}
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
+{
+ purchase p;
+ p = head->next;
+ if (!p)
+ {
+ printf("Ϣ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("Ϣʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Printf_purchas);
+ return OK;
+}
+
+// ļе
+Status FdisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Fprintf_purchas);
+ return OK;
+}
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail)
+{
+ head = (suppliers)malloc(sizeof(suppliers_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ InitList_purchase(head->purchase_head, head->purchase_tail);
+ return OK;
+}
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->corporate_name, corporate_name) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
+{
+ suppliers p;
+ p = (suppliers)malloc(sizeof(suppliers_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ InitList_purchase(p->purchase_head, p->purchase_tail);
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ }
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail)
+{
+ FILE* fp;
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ fp = fopen("suppliers1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ printf("ҪɾӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
+ return ERROR;
+ }
+ if (p->next)
+ {
+ p->next->pre = p->pre;
+ }
+ p->pre->next = p->next;
+ free(p);
+ printf("ӦϢɾɹ\n");
+ return OK;
+}
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪĹӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ printf("롰˾ơӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ printf("ӦϢijɹ\n");
+ return OK;
+}
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪѯӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ Printf_suppliers(p);
+ return OK;
+}
+
+// ڴ¼ӦϢ
+Status Printf_suppliers(suppliers& p)
+{
+ printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ DisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ fclose(fp);
+ FdisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
+{
+ suppliers p;
+ p = head->next;
+ if (!p)
+ {
+ printf("ӦϢ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("ӦϢʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Printf_suppliers);
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Fprintf_suppliers);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail)
+{
+ head = (commodity)malloc(sizeof(goods));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
+{
+ commodity p;
+ p = (commodity)malloc(sizeof(goods));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->id_Number, id_Number);
+ strcpy(p->goods_Name, goods_Name);
+ strcpy(p->place, place);
+ p->buy_Prise = buy_Prise;
+ p->sell_Prise = sell_Prise;
+ p->remain_Number = remain_Number;
+ p->quality_Date = quality_Date;
+ p->purchase_Date.year = purchase_Date.year;
+ p->purchase_Date.month = purchase_Date.month;
+ p->purchase_Date.day = purchase_Date.day;
+ p->produce_Date.year = produce_Date.year;
+ p->produce_Date.month = produce_Date.month;
+ p->produce_Date.day = produce_Date.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->id_Number, id_Number) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (getchar() == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ printf("ƷϢ¼ɹ\n");
+ printf("Ϣ¼ɹ\n");
+ return OK;
+}
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ FILE* fp;
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ fp = fopen("commodity1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (fgetc(fp) == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ƷϢɹ\n");
+ printf("Ϣɹ\n");
+ return OK;
+}
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ DisplayList_suppliers(suppliers_head);
+ break;
+ case 2:
+ FdisplayList_suppliers(suppliers_head);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ ListDelete_suppliers(suppliers_head);
+ break;
+ case 3:
+ ListAlter_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 4:
+ ListSearch_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 5:
+ Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 6:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢϢ\n3.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.ӦϢ\n2.\n3.˳\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 3:
+ exit(OK);
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
diff --git a/code/purchase.h b/code/purchase.h
new file mode 100644
index 0000000..0dfce48
--- /dev/null
+++ b/code/purchase.h
@@ -0,0 +1,170 @@
+#ifndef __PURCHASE_H__
+#define __PURCHASE_H__
+
+// ͷļṹ
+
+//
+#define MAX_SIZE 30
+
+// ״̬
+#define TRUE 1 //
+#define FALSE 0 //
+#define OK 1 //
+#define ERROR 0 //
+#define INFEASIBLE -1 //
+#define OVERFLOW -2 //
+
+// Status ǺֵͣǺ״̬
+typedef int Status;
+
+// ʱṹ壬洢ꡢ¡Ϣ
+struct date
+{
+ int year; //
+ int month; //
+ int day; //
+};
+
+/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
+
+// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
+typedef struct purchase_information
+{
+ char number[MAX_SIZE]; // Ʒ
+ char name[MAX_SIZE]; // Ʒ
+ char source[MAX_SIZE]; // Դ
+ char channel[MAX_SIZE]; //
+ int quantity; //
+ double price; // ۸
+ date time; // ʱ
+ purchase_information* pre; // һָ
+ purchase_information* next; // һָ
+}*purchase;
+
+// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
+typedef struct suppliers_information
+{
+ char corporate_name[MAX_SIZE]; // ˾
+ char main_business[MAX_SIZE]; // Ӫҵ
+ char main_products[MAX_SIZE]; // ӪƷ
+ char brand[MAX_SIZE]; // Ʒ
+ char contact_person[MAX_SIZE]; //
+ char telephone[MAX_SIZE]; // 绰
+ purchase purchase_head; // Ϣͷڵ
+ purchase purchase_tail; // Ϣβ
+ suppliers_information* pre; // һӦָ
+ suppliers_information* next; // һӦָ
+}*suppliers;
+
+typedef struct goods
+{
+ char id_Number[20]; // Ʒ
+ char goods_Name[20]; // Ʒ
+ char place[20]; // λ
+ double buy_Prise; // Ʒ
+ double sell_Prise; // Ʒۼ
+ int remain_Number; // Ʒ
+ int quality_Date; //
+ date purchase_Date; //
+ date produce_Date; //
+ goods* pre; // һƷָ
+ goods* next; // һƷָ
+}*commodity;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail);
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p);
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p);
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head);
+
+// ļе
+Status FdisplayList_purchas(purchase& head);
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail);
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail);
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail);
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head);
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail);
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail);
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers& p);
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p);
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head);
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head);
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail);
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+#endif
\ No newline at end of file
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
new file mode 100644
index 0000000..9034f27
--- /dev/null
+++ "b/code/\346\272\220.cpp"
@@ -0,0 +1,10 @@
+#include "purchase.h"
+Status main()
+{
+ suppliers suppliers_head, suppliers_tail;
+ commodity commodity_head, commodity_tail;
+ InitList_suppliers(suppliers_head, suppliers_tail);
+ InitList_commodity(commodity_head, commodity_tail);
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ return OK;
+}
--
Gitee
From d06c1f902df0640b2fb378460e1e51d9fcebd7ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:36:04 +0800
Subject: [PATCH 16/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 code/commodity1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
deleted file mode 100644
index 67ca69a..0000000
--- a/code/commodity1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
-002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
-003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
-004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
-005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
-006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
-007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
--
Gitee
From 00a041a9c4902125537895913b1cfe967dc33e65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:36:25 +0800
Subject: [PATCH 17/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers2.txt | 15 ---------------
1 file changed, 15 deletions(-)
delete mode 100644 code/suppliers2.txt
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
deleted file mode 100644
index e894e1d..0000000
--- a/code/suppliers2.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-002 orange tengxun qiang 100 4.000000 2020 7 14
-005 watermelon tengxun qiang 100 6.000000 2020 7 14
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-001 apple wangyi qiang 100 5.000000 2020 7 14
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-004 pear xiaomi qiang 100 5.000000 2020 7 14
-huawei huawei1 huawei2 huawei3 huawei4 4444
-006 peach huawei qiang 100 3.000000 2020 7 14
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-007 pen zhongxing qiang 100 1.000000 2020 7 14
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
-003 banana sanxing qiang 100 9.000000 2020 7 14
-lianxiang lianxiang1 lianxiang2 lianxiang3 lianxiang4 9999
-009 computer lianxiang qiang 100 1000.000000 2020 7 14
--
Gitee
From 4ff1005fe59f9a68c43fabeac5f807a86f6d44ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:36:34 +0800
Subject: [PATCH 18/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers1.txt | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 code/suppliers1.txt
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
deleted file mode 100644
index 7e80b65..0000000
--- a/code/suppliers1.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-huawei huawei1 huawei2 huawei3 huawei4 4444
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From bfcd0870bcb423df79265eeefcaa04a4d3a5b3e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:39:26 +0800
Subject: [PATCH 19/48] =?UTF-8?q?=E2=80=9C=E4=BE=9B=E8=B4=A7=E5=95=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E2=80=9D=E5=92=8C=E2=80=9C?=
=?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E5=92=8C=E8=BF=9B=E8=B4=A7?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E5=AF=BC=E5=85=A5=E2=80=9D=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=20=E6=9C=AA=E4=BD=9C=E4=BB=BB=E4=BD=95=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 +++++++
code/suppliers1.txt | 6 ++++++
2 files changed, 13 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/suppliers1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..67ca69a
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,7 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
+002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
+003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
+004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
+007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From f00226fb2197a85676963d786eaf29d0da969e4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:41:23 +0800
Subject: [PATCH 20/48] =?UTF-8?q?=E2=80=9C=E4=BE=9B=E5=BA=94=E5=95=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA=E2=80=9D=E5=92=8C=E2=80=9C?=
=?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E5=92=8C=E8=BF=9B=E8=B4=A7?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA=E2=80=9D=E7=9A=84=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=20=E6=9C=AA=E4=BD=9C=E4=BB=BB=E4=BD=95=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity2.txt | 2 ++
code/suppliers2.txt | 13 +++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 code/commodity2.txt
create mode 100644 code/suppliers2.txt
diff --git a/code/commodity2.txt b/code/commodity2.txt
new file mode 100644
index 0000000..e0fd2be
--- /dev/null
+++ b/code/commodity2.txt
@@ -0,0 +1,2 @@
+000 pingguo zhongguo guoyuan 400 1 2020 12 21
+002 juzi zhongguo guoyuan 400 1 2020 12 21
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
new file mode 100644
index 0000000..7ca7004
--- /dev/null
+++ b/code/suppliers2.txt
@@ -0,0 +1,13 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+002 orange tengxun qiang 100 4.000000 2020 7 14
+005 watermelon tengxun qiang 100 6.000000 2020 7 14
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+001 apple wangyi qiang 100 5.000000 2020 7 14
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+004 pear xiaomi qiang 100 5.000000 2020 7 14
+huawei huawei1 huawei2 huawei3 huawei4 4444
+006 peach huawei qiang 100 3.000000 2020 7 14
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+007 pen zhongxing qiang 100 1.000000 2020 7 14
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
+003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From 01fccdd8c0debf79943fb725e387462a5b86d9d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:41:42 +0800
Subject: [PATCH 21/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 code/commodity1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
deleted file mode 100644
index 67ca69a..0000000
--- a/code/commodity1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
-002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
-003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
-004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
-005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
-006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
-007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
--
Gitee
From 619244daf5f442df0e32e268c03c5ca6f5b0b4dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:41:49 +0800
Subject: [PATCH 22/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers1.txt | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 code/suppliers1.txt
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
deleted file mode 100644
index 7e80b65..0000000
--- a/code/suppliers1.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-huawei huawei1 huawei2 huawei3 huawei4 4444
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From 6a5dc13d702d9416a4c11c6f8c15dce91e415975 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:42:22 +0800
Subject: [PATCH 23/48] =?UTF-8?q?=E2=80=9C=E4=BE=9B=E5=BA=94=E5=95=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E2=80=9D=E5=92=8C=E2=80=9C?=
=?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E5=92=8C=E8=BF=9B=E8=B4=A7?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E2=80=9D=E7=9A=84=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=20=E6=9C=AA=E4=BD=9C=E4=BB=BB=E4=BD=95=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 +++++++
code/suppliers1.txt | 6 ++++++
2 files changed, 13 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/suppliers1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..67ca69a
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,7 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
+002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
+003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
+004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
+007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From 4b658bf2e34e783b8af506486358fa222f7a3bc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 02:43:38 +0800
Subject: [PATCH 24/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/=E6=B5=8B=E8=AF=95=E6=A0=B7=E4=BE=8B=E5=8F=8A=E8=AF=B4?=
=?UTF-8?q?=E6=98=8E.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...\213\345\217\212\350\257\264\346\230\216.txt" | 16 ----------------
1 file changed, 16 deletions(-)
delete mode 100644 "code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
diff --git "a/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt" "b/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
deleted file mode 100644
index e9e624d..0000000
--- "a/code/\346\265\213\350\257\225\346\240\267\344\276\213\345\217\212\350\257\264\346\230\216.txt"
+++ /dev/null
@@ -1,16 +0,0 @@
-测试样例:
-1.添加进货信息记录(记得最后空格)
-009 computer 2020 7 14 lianxiang qiang 100 1000 1200 2020 5 20 365 eastroom
-提示未添加,创建并定义供应商信息
-lianxiang1 lianxiang2 lianxiang3 lianxiang4 9999
-////////////
-2.添加供应商信息(记得最后空格)
-xuegao xuegao1 xuegao 2 xuegao3 xuegao 4 1010
-3.删除供应商信息
-tenngxun
-4.修改供应商信息
-huawei
-提示输入新的信息(所有信息)
-huawei huawei1 huawei2 huawei3 huawei4 1212
-5.屏幕打印当前供应商信息
-6.文件打印当前供应商信息
\ No newline at end of file
--
Gitee
From 6c70755d614a724fa6ff446f73fe11045a021146 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:24:24 +0800
Subject: [PATCH 25/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 code/commodity1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
deleted file mode 100644
index 67ca69a..0000000
--- a/code/commodity1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
-002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
-003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
-004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
-005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
-006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
-007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
--
Gitee
From 26879cec75de17f86ded77df4d430fe00f9c9f47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:24:32 +0800
Subject: [PATCH 26/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity2.txt | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 code/commodity2.txt
diff --git a/code/commodity2.txt b/code/commodity2.txt
deleted file mode 100644
index e0fd2be..0000000
--- a/code/commodity2.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-000 pingguo zhongguo guoyuan 400 1 2020 12 21
-002 juzi zhongguo guoyuan 400 1 2020 12 21
--
Gitee
From acd078351a8fe27d25ef60a1b089cd9c80852905 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:24:37 +0800
Subject: [PATCH 27/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.cpp | 775 ----------------------------------------------
1 file changed, 775 deletions(-)
delete mode 100644 code/purchase.cpp
diff --git a/code/purchase.cpp b/code/purchase.cpp
deleted file mode 100644
index 2dc18bd..0000000
--- a/code/purchase.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-#include
-#include
-#include
-#include "purchase.h"
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail)
-{
- head = (purchase)malloc(sizeof(purchase_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
-{
- purchase p;
- p = (purchase)malloc(sizeof(purchase_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->number, number);
- strcpy(p->name, name);
- strcpy(p->source, source);
- strcpy(p->channel, channel);
- p->quantity = quantity;
- p->price = price;
- p->time.year = time.year;
- p->time.month = time.month;
- p->time.day = time.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p)
-{
- printf("%s %s %s %s %d %.2lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- return OK;
-}
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- fclose(fp);
- return OK;
-}
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
-{
- purchase p;
- p = head->next;
- if (!p)
- {
- printf("Ϣ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("Ϣʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Printf_purchas);
- return OK;
-}
-
-// ļе
-Status FdisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Fprintf_purchas);
- return OK;
-}
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail)
-{
- head = (suppliers)malloc(sizeof(suppliers_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- InitList_purchase(head->purchase_head, head->purchase_tail);
- return OK;
-}
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->corporate_name, corporate_name) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
-{
- suppliers p;
- p = (suppliers)malloc(sizeof(suppliers_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- InitList_purchase(p->purchase_head, p->purchase_tail);
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
- if (getchar() == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (getchar() == ' ')
- {
- break;
- }
- }
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail)
-{
- FILE* fp;
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- fp = fopen("suppliers1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- }
- fclose(fp);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- printf("ҪɾӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
- return ERROR;
- }
- if (p->next)
- {
- p->next->pre = p->pre;
- }
- p->pre->next = p->next;
- free(p);
- printf("ӦϢɾɹ\n");
- return OK;
-}
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪĹӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- printf("롰˾ơӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- printf("ӦϢijɹ\n");
- return OK;
-}
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪѯӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- Printf_suppliers(p);
- return OK;
-}
-
-// ڴ¼ӦϢ
-Status Printf_suppliers(suppliers& p)
-{
- printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- DisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- fclose(fp);
- FdisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
-{
- suppliers p;
- p = head->next;
- if (!p)
- {
- printf("ӦϢ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("ӦϢʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Printf_suppliers);
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Fprintf_suppliers);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail)
-{
- head = (commodity)malloc(sizeof(goods));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
-{
- commodity p;
- p = (commodity)malloc(sizeof(goods));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->id_Number, id_Number);
- strcpy(p->goods_Name, goods_Name);
- strcpy(p->place, place);
- p->buy_Prise = buy_Prise;
- p->sell_Prise = sell_Prise;
- p->remain_Number = remain_Number;
- p->quality_Date = quality_Date;
- p->purchase_Date.year = purchase_Date.year;
- p->purchase_Date.month = purchase_Date.month;
- p->purchase_Date.day = purchase_Date.day;
- p->produce_Date.year = produce_Date.year;
- p->produce_Date.month = produce_Date.month;
- p->produce_Date.day = produce_Date.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->id_Number, id_Number) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (getchar() == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- printf("ƷϢ¼ɹ\n");
- printf("Ϣ¼ɹ\n");
- return OK;
-}
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- FILE* fp;
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- fp = fopen("commodity1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (fgetc(fp) == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- fclose(fp);
- printf("ƷϢɹ\n");
- printf("Ϣɹ\n");
- return OK;
-}
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_suppliers(suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_suppliers(suppliers_head, suppliers_tail);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- DisplayList_suppliers(suppliers_head);
- break;
- case 2:
- FdisplayList_suppliers(suppliers_head);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- ListDelete_suppliers(suppliers_head);
- break;
- case 3:
- ListAlter_suppliers(suppliers_head, suppliers_tail);
- break;
- case 4:
- ListSearch_suppliers(suppliers_head, suppliers_tail);
- break;
- case 5:
- Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 6:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢϢ\n3.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 3:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.ӦϢ\n2.\n3.˳\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 3:
- exit(OK);
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
--
Gitee
From 6276cb70838b509b64220f9b508d1522270ca832 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:24:47 +0800
Subject: [PATCH 28/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.h?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.h | 170 ------------------------------------------------
1 file changed, 170 deletions(-)
delete mode 100644 code/purchase.h
diff --git a/code/purchase.h b/code/purchase.h
deleted file mode 100644
index 0dfce48..0000000
--- a/code/purchase.h
+++ /dev/null
@@ -1,170 +0,0 @@
-#ifndef __PURCHASE_H__
-#define __PURCHASE_H__
-
-// ͷļṹ
-
-//
-#define MAX_SIZE 30
-
-// ״̬
-#define TRUE 1 //
-#define FALSE 0 //
-#define OK 1 //
-#define ERROR 0 //
-#define INFEASIBLE -1 //
-#define OVERFLOW -2 //
-
-// Status ǺֵͣǺ״̬
-typedef int Status;
-
-// ʱṹ壬洢ꡢ¡Ϣ
-struct date
-{
- int year; //
- int month; //
- int day; //
-};
-
-/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
-
-// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
-typedef struct purchase_information
-{
- char number[MAX_SIZE]; // Ʒ
- char name[MAX_SIZE]; // Ʒ
- char source[MAX_SIZE]; // Դ
- char channel[MAX_SIZE]; //
- int quantity; //
- double price; // ۸
- date time; // ʱ
- purchase_information* pre; // һָ
- purchase_information* next; // һָ
-}*purchase;
-
-// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
-typedef struct suppliers_information
-{
- char corporate_name[MAX_SIZE]; // ˾
- char main_business[MAX_SIZE]; // Ӫҵ
- char main_products[MAX_SIZE]; // ӪƷ
- char brand[MAX_SIZE]; // Ʒ
- char contact_person[MAX_SIZE]; //
- char telephone[MAX_SIZE]; // 绰
- purchase purchase_head; // Ϣͷڵ
- purchase purchase_tail; // Ϣβ
- suppliers_information* pre; // һӦָ
- suppliers_information* next; // һӦָ
-}*suppliers;
-
-typedef struct goods
-{
- char id_Number[20]; // Ʒ
- char goods_Name[20]; // Ʒ
- char place[20]; // λ
- double buy_Prise; // Ʒ
- double sell_Prise; // Ʒۼ
- int remain_Number; // Ʒ
- int quality_Date; //
- date purchase_Date; //
- date produce_Date; //
- goods* pre; // һƷָ
- goods* next; // һƷָ
-}*commodity;
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail);
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p);
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p);
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head);
-
-// ļе
-Status FdisplayList_purchas(purchase& head);
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail);
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail);
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail);
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head);
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail);
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail);
-
-// ڴӦϢ
-Status Printf_suppliers(suppliers& p);
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p);
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head);
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head);
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail);
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-#endif
\ No newline at end of file
--
Gitee
From d5af0e5c2ece27fb56d9a2699d1826bc3e839de5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:24:57 +0800
Subject: [PATCH 29/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers1.txt | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 code/suppliers1.txt
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
deleted file mode 100644
index 7e80b65..0000000
--- a/code/suppliers1.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-huawei huawei1 huawei2 huawei3 huawei4 4444
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From 3b2b4a2ecf7cb214e06595cb336a153d779f9276 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:25:05 +0800
Subject: [PATCH 30/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers2.txt | 13 -------------
1 file changed, 13 deletions(-)
delete mode 100644 code/suppliers2.txt
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
deleted file mode 100644
index 7ca7004..0000000
--- a/code/suppliers2.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-002 orange tengxun qiang 100 4.000000 2020 7 14
-005 watermelon tengxun qiang 100 6.000000 2020 7 14
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-001 apple wangyi qiang 100 5.000000 2020 7 14
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-004 pear xiaomi qiang 100 5.000000 2020 7 14
-huawei huawei1 huawei2 huawei3 huawei4 4444
-006 peach huawei qiang 100 3.000000 2020 7 14
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-007 pen zhongxing qiang 100 1.000000 2020 7 14
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
-003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From f57d2464c5558724d2483ae6e5bc5b49ba0be9fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:25:14 +0800
Subject: [PATCH 31/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/=E6=BA=90.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"code/\346\272\220.cpp" | 10 ----------
1 file changed, 10 deletions(-)
delete mode 100644 "code/\346\272\220.cpp"
diff --git "a/code/\346\272\220.cpp" "b/code/\346\272\220.cpp"
deleted file mode 100644
index 9034f27..0000000
--- "a/code/\346\272\220.cpp"
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "purchase.h"
-Status main()
-{
- suppliers suppliers_head, suppliers_tail;
- commodity commodity_head, commodity_tail;
- InitList_suppliers(suppliers_head, suppliers_tail);
- InitList_commodity(commodity_head, commodity_tail);
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- return OK;
-}
--
Gitee
From 85e3ae21bed90c8770507fb8dc88bd05d8db227a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:33:42 +0800
Subject: [PATCH 32/48] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E7=AE=A1=E7=90=86=E5=92=8C=E8=BF=9B=E8=B4=A7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E2=80=94=E2=80=94=E6=9C=80=E7=BB=88=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 +
code/commodity2.txt | 2 +
code/main.cpp | 10 +
code/purchase.cpp | 775 ++++++++++++++++++++++++++++++++++++++++++++
code/purchase.h | 170 ++++++++++
code/suppliers1.txt | 6 +
code/suppliers2.txt | 13 +
7 files changed, 983 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/commodity2.txt
create mode 100644 code/main.cpp
create mode 100644 code/purchase.cpp
create mode 100644 code/purchase.h
create mode 100644 code/suppliers1.txt
create mode 100644 code/suppliers2.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..67ca69a
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,7 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
+002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
+003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
+004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
+007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
diff --git a/code/commodity2.txt b/code/commodity2.txt
new file mode 100644
index 0000000..e0fd2be
--- /dev/null
+++ b/code/commodity2.txt
@@ -0,0 +1,2 @@
+000 pingguo zhongguo guoyuan 400 1 2020 12 21
+002 juzi zhongguo guoyuan 400 1 2020 12 21
diff --git a/code/main.cpp b/code/main.cpp
new file mode 100644
index 0000000..9034f27
--- /dev/null
+++ b/code/main.cpp
@@ -0,0 +1,10 @@
+#include "purchase.h"
+Status main()
+{
+ suppliers suppliers_head, suppliers_tail;
+ commodity commodity_head, commodity_tail;
+ InitList_suppliers(suppliers_head, suppliers_tail);
+ InitList_commodity(commodity_head, commodity_tail);
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ return OK;
+}
diff --git a/code/purchase.cpp b/code/purchase.cpp
new file mode 100644
index 0000000..f808f08
--- /dev/null
+++ b/code/purchase.cpp
@@ -0,0 +1,775 @@
+#include
+#include
+#include
+#include "purchase.h"
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail)
+{
+ head = (purchase)malloc(sizeof(purchase_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
+{
+ purchase p;
+ p = (purchase)malloc(sizeof(purchase_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->number, number);
+ strcpy(p->name, name);
+ strcpy(p->source, source);
+ strcpy(p->channel, channel);
+ p->quantity = quantity;
+ p->price = price;
+ p->time.year = time.year;
+ p->time.month = time.month;
+ p->time.day = time.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p)
+{
+ printf("%s %s %s %s %d %.2lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ return OK;
+}
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ fclose(fp);
+ return OK;
+}
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
+{
+ purchase p;
+ p = head->next;
+ if (!p)
+ {
+ printf("Ϣ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("Ϣʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Printf_purchas);
+ return OK;
+}
+
+// ļе
+Status FdisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Fprintf_purchas);
+ return OK;
+}
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail)
+{
+ head = (suppliers)malloc(sizeof(suppliers_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ InitList_purchase(head->purchase_head, head->purchase_tail);
+ return OK;
+}
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->corporate_name, corporate_name) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
+{
+ suppliers p;
+ p = (suppliers)malloc(sizeof(suppliers_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ InitList_purchase(p->purchase_head, p->purchase_tail);
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ }
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail)
+{
+ FILE* fp;
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ fp = fopen("suppliers1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ printf("ҪɾӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
+ return ERROR;
+ }
+ if (p->next)
+ {
+ p->next->pre = p->pre;
+ }
+ p->pre->next = p->next;
+ free(p);
+ printf("ӦϢɾɹ\n");
+ return OK;
+}
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪĹӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ printf("롰˾ơӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ printf("ӦϢijɹ\n");
+ return OK;
+}
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪѯӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ Printf_suppliers(p);
+ return OK;
+}
+
+// ڴ¼ӦϢ
+Status Printf_suppliers(suppliers& p)
+{
+ printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ DisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ fclose(fp);
+ FdisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
+{
+ suppliers p;
+ p = head->next;
+ if (!p)
+ {
+ printf("ӦϢ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("ӦϢʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Printf_suppliers);
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Fprintf_suppliers);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail)
+{
+ head = (commodity)malloc(sizeof(goods));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
+{
+ commodity p;
+ p = (commodity)malloc(sizeof(goods));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->id_Number, id_Number);
+ strcpy(p->goods_Name, goods_Name);
+ strcpy(p->place, place);
+ p->buy_Prise = buy_Prise;
+ p->sell_Prise = sell_Prise;
+ p->remain_Number = remain_Number;
+ p->quality_Date = quality_Date;
+ p->purchase_Date.year = purchase_Date.year;
+ p->purchase_Date.month = purchase_Date.month;
+ p->purchase_Date.day = purchase_Date.day;
+ p->produce_Date.year = produce_Date.year;
+ p->produce_Date.month = produce_Date.month;
+ p->produce_Date.day = produce_Date.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->id_Number, id_Number) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (getchar() == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ printf("ƷϢ¼ɹ\n");
+ printf("Ϣ¼ɹ\n");
+ return OK;
+}
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ FILE* fp;
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ fp = fopen("commodity1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (fgetc(fp) == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ƷϢɹ\n");
+ printf("Ϣɹ\n");
+ return OK;
+}
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ DisplayList_suppliers(suppliers_head);
+ break;
+ case 2:
+ FdisplayList_suppliers(suppliers_head);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ ListDelete_suppliers(suppliers_head);
+ break;
+ case 3:
+ ListAlter_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 4:
+ ListSearch_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 5:
+ Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 6:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢ\n3.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.ӦϢ\n2.\n3.˳\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 3:
+ exit(OK);
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
diff --git a/code/purchase.h b/code/purchase.h
new file mode 100644
index 0000000..f5cdc78
--- /dev/null
+++ b/code/purchase.h
@@ -0,0 +1,170 @@
+#ifndef __PURCHASE_H__
+#define __PURCHASE_H__
+
+// ͷļṹ
+
+//
+#define MAX_SIZE 30
+
+// ״̬
+#define TRUE 1 //
+#define FALSE 0 //
+#define OK 1 //
+#define ERROR 0 //
+#define INFEASIBLE -1 //
+#define OVERFLOW -2 //
+
+// Status ǺֵͣǺ״̬
+typedef int Status;
+
+// ʱṹ壬洢ꡢ¡Ϣ
+struct date
+{
+ int year; //
+ int month; //
+ int day; //
+};
+
+/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
+
+// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
+typedef struct purchase_information
+{
+ char number[MAX_SIZE]; // Ʒ
+ char name[MAX_SIZE]; // Ʒ
+ char source[MAX_SIZE]; // Դ
+ char channel[MAX_SIZE]; //
+ int quantity; //
+ double price; // ۸
+ date time; // ʱ
+ purchase_information* pre; // һָ
+ purchase_information* next; // һָ
+}*purchase;
+
+// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
+typedef struct suppliers_information
+{
+ char corporate_name[MAX_SIZE]; // ˾
+ char main_business[MAX_SIZE]; // Ӫҵ
+ char main_products[MAX_SIZE]; // ӪƷ
+ char brand[MAX_SIZE]; // Ʒ
+ char contact_person[MAX_SIZE]; //
+ char telephone[MAX_SIZE]; // 绰
+ purchase purchase_head; // Ϣͷڵ
+ purchase purchase_tail; // Ϣβ
+ suppliers_information* pre; // һӦָ
+ suppliers_information* next; // һӦָ
+}*suppliers;
+
+typedef struct goods
+{
+ char id_Number[20]; // Ʒ
+ char goods_Name[20]; // Ʒ
+ char place[20]; // λ
+ double buy_Prise; // Ʒ
+ double sell_Prise; // Ʒۼ
+ int remain_Number; // Ʒ
+ int quality_Date; //
+ date purchase_Date; //
+ date produce_Date; //
+ goods* pre; // һƷָ
+ goods* next; // һƷָ
+}*commodity;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail);
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p);
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p);
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head);
+
+// ļе
+Status FdisplayList_purchas(purchase& head);
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail);
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail);
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail);
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head);
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail);
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail);
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers& p);
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p);
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head);
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head);
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail);
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+#endif#pragma once
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
new file mode 100644
index 0000000..7ca7004
--- /dev/null
+++ b/code/suppliers2.txt
@@ -0,0 +1,13 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+002 orange tengxun qiang 100 4.000000 2020 7 14
+005 watermelon tengxun qiang 100 6.000000 2020 7 14
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+001 apple wangyi qiang 100 5.000000 2020 7 14
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+004 pear xiaomi qiang 100 5.000000 2020 7 14
+huawei huawei1 huawei2 huawei3 huawei4 4444
+006 peach huawei qiang 100 3.000000 2020 7 14
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+007 pen zhongxing qiang 100 1.000000 2020 7 14
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
+003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From 7fc8bf3bc463e23c915173e4bd28a2fd7fde4649 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:56:27 +0800
Subject: [PATCH 33/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 code/commodity1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
deleted file mode 100644
index 67ca69a..0000000
--- a/code/commodity1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
-002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
-003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
-004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
-005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
-006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
-007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
--
Gitee
From 788d92c9999a30355cc63053227ab0703b881393 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:56:32 +0800
Subject: [PATCH 34/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity2.txt | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 code/commodity2.txt
diff --git a/code/commodity2.txt b/code/commodity2.txt
deleted file mode 100644
index e0fd2be..0000000
--- a/code/commodity2.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-000 pingguo zhongguo guoyuan 400 1 2020 12 21
-002 juzi zhongguo guoyuan 400 1 2020 12 21
--
Gitee
From 1fce419cc75188846a7a2784c04333a9a4740e2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:56:36 +0800
Subject: [PATCH 35/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/main.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/main.cpp | 10 ----------
1 file changed, 10 deletions(-)
delete mode 100644 code/main.cpp
diff --git a/code/main.cpp b/code/main.cpp
deleted file mode 100644
index 9034f27..0000000
--- a/code/main.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "purchase.h"
-Status main()
-{
- suppliers suppliers_head, suppliers_tail;
- commodity commodity_head, commodity_tail;
- InitList_suppliers(suppliers_head, suppliers_tail);
- InitList_commodity(commodity_head, commodity_tail);
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- return OK;
-}
--
Gitee
From 5f6251b8a7bb473ec7f3308eefd6613033870a12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:56:41 +0800
Subject: [PATCH 36/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.cpp | 775 ----------------------------------------------
1 file changed, 775 deletions(-)
delete mode 100644 code/purchase.cpp
diff --git a/code/purchase.cpp b/code/purchase.cpp
deleted file mode 100644
index f808f08..0000000
--- a/code/purchase.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-#include
-#include
-#include
-#include "purchase.h"
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail)
-{
- head = (purchase)malloc(sizeof(purchase_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
-{
- purchase p;
- p = (purchase)malloc(sizeof(purchase_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->number, number);
- strcpy(p->name, name);
- strcpy(p->source, source);
- strcpy(p->channel, channel);
- p->quantity = quantity;
- p->price = price;
- p->time.year = time.year;
- p->time.month = time.month;
- p->time.day = time.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p)
-{
- printf("%s %s %s %s %d %.2lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- return OK;
-}
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- fclose(fp);
- return OK;
-}
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
-{
- purchase p;
- p = head->next;
- if (!p)
- {
- printf("Ϣ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("Ϣʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Printf_purchas);
- return OK;
-}
-
-// ļе
-Status FdisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Fprintf_purchas);
- return OK;
-}
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail)
-{
- head = (suppliers)malloc(sizeof(suppliers_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- InitList_purchase(head->purchase_head, head->purchase_tail);
- return OK;
-}
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->corporate_name, corporate_name) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
-{
- suppliers p;
- p = (suppliers)malloc(sizeof(suppliers_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- InitList_purchase(p->purchase_head, p->purchase_tail);
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
- if (getchar() == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (getchar() == ' ')
- {
- break;
- }
- }
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail)
-{
- FILE* fp;
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- fp = fopen("suppliers1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- }
- fclose(fp);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- printf("ҪɾӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
- return ERROR;
- }
- if (p->next)
- {
- p->next->pre = p->pre;
- }
- p->pre->next = p->next;
- free(p);
- printf("ӦϢɾɹ\n");
- return OK;
-}
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪĹӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- printf("롰˾ơӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- printf("ӦϢijɹ\n");
- return OK;
-}
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪѯӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- Printf_suppliers(p);
- return OK;
-}
-
-// ڴ¼ӦϢ
-Status Printf_suppliers(suppliers& p)
-{
- printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- DisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- fclose(fp);
- FdisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
-{
- suppliers p;
- p = head->next;
- if (!p)
- {
- printf("ӦϢ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("ӦϢʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Printf_suppliers);
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Fprintf_suppliers);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail)
-{
- head = (commodity)malloc(sizeof(goods));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
-{
- commodity p;
- p = (commodity)malloc(sizeof(goods));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->id_Number, id_Number);
- strcpy(p->goods_Name, goods_Name);
- strcpy(p->place, place);
- p->buy_Prise = buy_Prise;
- p->sell_Prise = sell_Prise;
- p->remain_Number = remain_Number;
- p->quality_Date = quality_Date;
- p->purchase_Date.year = purchase_Date.year;
- p->purchase_Date.month = purchase_Date.month;
- p->purchase_Date.day = purchase_Date.day;
- p->produce_Date.year = produce_Date.year;
- p->produce_Date.month = produce_Date.month;
- p->produce_Date.day = produce_Date.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->id_Number, id_Number) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (getchar() == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- printf("ƷϢ¼ɹ\n");
- printf("Ϣ¼ɹ\n");
- return OK;
-}
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- FILE* fp;
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- fp = fopen("commodity1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (fgetc(fp) == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- fclose(fp);
- printf("ƷϢɹ\n");
- printf("Ϣɹ\n");
- return OK;
-}
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_suppliers(suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_suppliers(suppliers_head, suppliers_tail);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- DisplayList_suppliers(suppliers_head);
- break;
- case 2:
- FdisplayList_suppliers(suppliers_head);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- ListDelete_suppliers(suppliers_head);
- break;
- case 3:
- ListAlter_suppliers(suppliers_head, suppliers_tail);
- break;
- case 4:
- ListSearch_suppliers(suppliers_head, suppliers_tail);
- break;
- case 5:
- Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 6:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢ\n3.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 3:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.ӦϢ\n2.\n3.˳\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 3:
- exit(OK);
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
--
Gitee
From b0a448f371ed7f7b1bff9455810e617ba6684b1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:56:54 +0800
Subject: [PATCH 37/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.h?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.h | 170 ------------------------------------------------
1 file changed, 170 deletions(-)
delete mode 100644 code/purchase.h
diff --git a/code/purchase.h b/code/purchase.h
deleted file mode 100644
index f5cdc78..0000000
--- a/code/purchase.h
+++ /dev/null
@@ -1,170 +0,0 @@
-#ifndef __PURCHASE_H__
-#define __PURCHASE_H__
-
-// ͷļṹ
-
-//
-#define MAX_SIZE 30
-
-// ״̬
-#define TRUE 1 //
-#define FALSE 0 //
-#define OK 1 //
-#define ERROR 0 //
-#define INFEASIBLE -1 //
-#define OVERFLOW -2 //
-
-// Status ǺֵͣǺ״̬
-typedef int Status;
-
-// ʱṹ壬洢ꡢ¡Ϣ
-struct date
-{
- int year; //
- int month; //
- int day; //
-};
-
-/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
-
-// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
-typedef struct purchase_information
-{
- char number[MAX_SIZE]; // Ʒ
- char name[MAX_SIZE]; // Ʒ
- char source[MAX_SIZE]; // Դ
- char channel[MAX_SIZE]; //
- int quantity; //
- double price; // ۸
- date time; // ʱ
- purchase_information* pre; // һָ
- purchase_information* next; // һָ
-}*purchase;
-
-// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
-typedef struct suppliers_information
-{
- char corporate_name[MAX_SIZE]; // ˾
- char main_business[MAX_SIZE]; // Ӫҵ
- char main_products[MAX_SIZE]; // ӪƷ
- char brand[MAX_SIZE]; // Ʒ
- char contact_person[MAX_SIZE]; //
- char telephone[MAX_SIZE]; // 绰
- purchase purchase_head; // Ϣͷڵ
- purchase purchase_tail; // Ϣβ
- suppliers_information* pre; // һӦָ
- suppliers_information* next; // һӦָ
-}*suppliers;
-
-typedef struct goods
-{
- char id_Number[20]; // Ʒ
- char goods_Name[20]; // Ʒ
- char place[20]; // λ
- double buy_Prise; // Ʒ
- double sell_Prise; // Ʒۼ
- int remain_Number; // Ʒ
- int quality_Date; //
- date purchase_Date; //
- date produce_Date; //
- goods* pre; // һƷָ
- goods* next; // һƷָ
-}*commodity;
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail);
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p);
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p);
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head);
-
-// ļе
-Status FdisplayList_purchas(purchase& head);
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail);
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail);
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail);
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head);
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail);
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail);
-
-// ڴӦϢ
-Status Printf_suppliers(suppliers& p);
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p);
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head);
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head);
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail);
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-#endif#pragma once
--
Gitee
From 9d11696412787195027b314fdcb360e1da0f4edf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:57:03 +0800
Subject: [PATCH 38/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers1.txt | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 code/suppliers1.txt
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
deleted file mode 100644
index 7e80b65..0000000
--- a/code/suppliers1.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-huawei huawei1 huawei2 huawei3 huawei4 4444
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From b2539b4fc1ff6a855296a5d6c4bf179c864735ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:57:11 +0800
Subject: [PATCH 39/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers2.txt | 13 -------------
1 file changed, 13 deletions(-)
delete mode 100644 code/suppliers2.txt
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
deleted file mode 100644
index 7ca7004..0000000
--- a/code/suppliers2.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-002 orange tengxun qiang 100 4.000000 2020 7 14
-005 watermelon tengxun qiang 100 6.000000 2020 7 14
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-001 apple wangyi qiang 100 5.000000 2020 7 14
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-004 pear xiaomi qiang 100 5.000000 2020 7 14
-huawei huawei1 huawei2 huawei3 huawei4 4444
-006 peach huawei qiang 100 3.000000 2020 7 14
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-007 pen zhongxing qiang 100 1.000000 2020 7 14
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
-003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From 3ff408c9185c1b74f4bd843ca10dd25c2fdb8722 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E4=BA=8E=E6=98=8A?= <2074819354@qq.com>
Date: Fri, 17 Jul 2020 12:58:25 +0800
Subject: [PATCH 40/48] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E7=AE=A1=E7=90=86=E5=92=8C=E8=BF=9B=E8=B4=A7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E2=80=94=E2=80=94=E6=9C=80=E7=BB=88=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 +
code/commodity2.txt | 2 +
code/main.cpp | 10 +
code/purchase.cpp | 775 ++++++++++++++++++++++++++++++++++++++++++++
code/purchase.h | 170 ++++++++++
code/suppliers1.txt | 6 +
code/suppliers2.txt | 13 +
7 files changed, 983 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/commodity2.txt
create mode 100644 code/main.cpp
create mode 100644 code/purchase.cpp
create mode 100644 code/purchase.h
create mode 100644 code/suppliers1.txt
create mode 100644 code/suppliers2.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..67ca69a
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,7 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
+002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
+003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
+004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
+007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
diff --git a/code/commodity2.txt b/code/commodity2.txt
new file mode 100644
index 0000000..e0fd2be
--- /dev/null
+++ b/code/commodity2.txt
@@ -0,0 +1,2 @@
+000 pingguo zhongguo guoyuan 400 1 2020 12 21
+002 juzi zhongguo guoyuan 400 1 2020 12 21
diff --git a/code/main.cpp b/code/main.cpp
new file mode 100644
index 0000000..9034f27
--- /dev/null
+++ b/code/main.cpp
@@ -0,0 +1,10 @@
+#include "purchase.h"
+Status main()
+{
+ suppliers suppliers_head, suppliers_tail;
+ commodity commodity_head, commodity_tail;
+ InitList_suppliers(suppliers_head, suppliers_tail);
+ InitList_commodity(commodity_head, commodity_tail);
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ return OK;
+}
diff --git a/code/purchase.cpp b/code/purchase.cpp
new file mode 100644
index 0000000..19f0068
--- /dev/null
+++ b/code/purchase.cpp
@@ -0,0 +1,775 @@
+#include
+#include
+#include
+#include "purchase.h"
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail)
+{
+ head = (purchase)malloc(sizeof(purchase_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
+{
+ purchase p;
+ p = (purchase)malloc(sizeof(purchase_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->number, number);
+ strcpy(p->name, name);
+ strcpy(p->source, source);
+ strcpy(p->channel, channel);
+ p->quantity = quantity;
+ p->price = price;
+ p->time.year = time.year;
+ p->time.month = time.month;
+ p->time.day = time.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p)
+{
+ printf("%s %s %s %s %d %.2lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ return OK;
+}
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ fclose(fp);
+ return OK;
+}
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
+{
+ purchase p;
+ p = head->next;
+ if (!p)
+ {
+ printf("Ϣ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("Ϣʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Printf_purchas);
+ return OK;
+}
+
+// ļе
+Status FdisplayList_purchas(purchase& head)
+{
+ TraverseList_purchas(head, Fprintf_purchas);
+ return OK;
+}
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail)
+{
+ head = (suppliers)malloc(sizeof(suppliers_information));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ InitList_purchase(head->purchase_head, head->purchase_tail);
+ return OK;
+}
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->corporate_name, corporate_name) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
+{
+ suppliers p;
+ p = (suppliers)malloc(sizeof(suppliers_information));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ InitList_purchase(p->purchase_head, p->purchase_tail);
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (getchar() == ' ')
+ {
+ break;
+ }
+ }
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail)
+{
+ FILE* fp;
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ fp = fopen("suppliers1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if (fgetc(fp) == ' ')
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ printf("ҪɾӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
+ return ERROR;
+ }
+ if (p->next)
+ {
+ p->next->pre = p->pre;
+ }
+ p->pre->next = p->next;
+ free(p);
+ printf("ӦϢɾɹ\n");
+ return OK;
+}
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪĹӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ printf("롰˾ơӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ printf("ӦϢijɹ\n");
+ return OK;
+}
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪѯӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if (!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while (!flag)
+ {
+ scanf("%c", &option);
+ switch (option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ Printf_suppliers(p);
+ return OK;
+}
+
+// ڴ¼ӦϢ
+Status Printf_suppliers(suppliers& p)
+{
+ printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ DisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p)
+{
+ FILE* fp;
+ fp = fopen("suppliers2.txt", "a");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ fclose(fp);
+ FdisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
+{
+ suppliers p;
+ p = head->next;
+ if (!p)
+ {
+ printf("ӦϢ\n");
+ return OK;
+ }
+ while (p)
+ {
+ if (!visit(p))
+ {
+ printf("ӦϢʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Printf_suppliers);
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head)
+{
+ TraverseList_suppliers(head, Fprintf_suppliers);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail)
+{
+ head = (commodity)malloc(sizeof(goods));
+ if (!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
+{
+ commodity p;
+ p = (commodity)malloc(sizeof(goods));
+ if (!p)
+ exit(OVERFLOW);
+ strcpy(p->id_Number, id_Number);
+ strcpy(p->goods_Name, goods_Name);
+ strcpy(p->place, place);
+ p->buy_Prise = buy_Prise;
+ p->sell_Prise = sell_Prise;
+ p->remain_Number = remain_Number;
+ p->quality_Date = quality_Date;
+ p->purchase_Date.year = purchase_Date.year;
+ p->purchase_Date.month = purchase_Date.month;
+ p->purchase_Date.day = purchase_Date.day;
+ p->produce_Date.year = produce_Date.year;
+ p->produce_Date.month = produce_Date.month;
+ p->produce_Date.day = produce_Date.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
+{
+ p = head->next;
+ while (p)
+ {
+ if (strcmp(p->id_Number, id_Number) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
+ while (1)
+ {
+ scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (getchar() == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ printf("ƷϢ¼ɹ\n");
+ printf("Ϣ¼ɹ\n");
+ return OK;
+}
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ FILE* fp;
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Prise;
+ double sell_Prise;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ fp = fopen("commodity1.txt", "r");
+ if (fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while (1)
+ {
+ fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if (fgetc(fp) == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if (p)
+ {
+ if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if (!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
+ if (flag == true)
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ƷϢɹ\n");
+ printf("Ϣɹ\n");
+ return OK;
+}
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ DisplayList_suppliers(suppliers_head);
+ break;
+ case 2:
+ FdisplayList_suppliers(suppliers_head);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ ListDelete_suppliers(suppliers_head);
+ break;
+ case 3:
+ ListAlter_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 4:
+ ListSearch_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 5:
+ Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 6:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢ\n3.\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.ӦϢ\n2.\n3.˳\n");
+ while (!flag)
+ {
+ scanf("%d", &option);
+ switch (option)
+ {
+ case 1:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 3:
+ exit(OK);
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
\ No newline at end of file
diff --git a/code/purchase.h b/code/purchase.h
new file mode 100644
index 0000000..0dfce48
--- /dev/null
+++ b/code/purchase.h
@@ -0,0 +1,170 @@
+#ifndef __PURCHASE_H__
+#define __PURCHASE_H__
+
+// ͷļṹ
+
+//
+#define MAX_SIZE 30
+
+// ״̬
+#define TRUE 1 //
+#define FALSE 0 //
+#define OK 1 //
+#define ERROR 0 //
+#define INFEASIBLE -1 //
+#define OVERFLOW -2 //
+
+// Status ǺֵͣǺ״̬
+typedef int Status;
+
+// ʱṹ壬洢ꡢ¡Ϣ
+struct date
+{
+ int year; //
+ int month; //
+ int day; //
+};
+
+/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
+
+// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
+typedef struct purchase_information
+{
+ char number[MAX_SIZE]; // Ʒ
+ char name[MAX_SIZE]; // Ʒ
+ char source[MAX_SIZE]; // Դ
+ char channel[MAX_SIZE]; //
+ int quantity; //
+ double price; // ۸
+ date time; // ʱ
+ purchase_information* pre; // һָ
+ purchase_information* next; // һָ
+}*purchase;
+
+// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
+typedef struct suppliers_information
+{
+ char corporate_name[MAX_SIZE]; // ˾
+ char main_business[MAX_SIZE]; // Ӫҵ
+ char main_products[MAX_SIZE]; // ӪƷ
+ char brand[MAX_SIZE]; // Ʒ
+ char contact_person[MAX_SIZE]; //
+ char telephone[MAX_SIZE]; // 绰
+ purchase purchase_head; // Ϣͷڵ
+ purchase purchase_tail; // Ϣβ
+ suppliers_information* pre; // һӦָ
+ suppliers_information* next; // һӦָ
+}*suppliers;
+
+typedef struct goods
+{
+ char id_Number[20]; // Ʒ
+ char goods_Name[20]; // Ʒ
+ char place[20]; // λ
+ double buy_Prise; // Ʒ
+ double sell_Prise; // Ʒۼ
+ int remain_Number; // Ʒ
+ int quality_Date; //
+ date purchase_Date; //
+ date produce_Date; //
+ goods* pre; // һƷָ
+ goods* next; // һƷָ
+}*commodity;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase& head, purchase& tail);
+
+// ڽβһ
+Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase& p);
+
+// ļеϢ
+Status Fprintf_purchas(purchase& p);
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
+
+// ڴ¼
+Status DisplayList_purchas(purchase& head);
+
+// ļе
+Status FdisplayList_purchas(purchase& head);
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers& head, suppliers& tail);
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers& head, suppliers& tail);
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers& head, suppliers& tail);
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers& head);
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers& head, suppliers& tail);
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers& head, suppliers& tail);
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers& p);
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers& p);
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers& head);
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers& head);
+
+// һյĴͷƷ
+Status InitList_commodity(commodity& head, commodity& tail);
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ļеƷϢ
+Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+// ӦϢ
+Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+//
+Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
+ suppliers& suppliers_head, suppliers& suppliers_tail);
+
+#endif
\ No newline at end of file
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
new file mode 100644
index 0000000..7ca7004
--- /dev/null
+++ b/code/suppliers2.txt
@@ -0,0 +1,13 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+002 orange tengxun qiang 100 4.000000 2020 7 14
+005 watermelon tengxun qiang 100 6.000000 2020 7 14
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+001 apple wangyi qiang 100 5.000000 2020 7 14
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+004 pear xiaomi qiang 100 5.000000 2020 7 14
+huawei huawei1 huawei2 huawei3 huawei4 4444
+006 peach huawei qiang 100 3.000000 2020 7 14
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+007 pen zhongxing qiang 100 1.000000 2020 7 14
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
+003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From 04023ae936c756ebe2105829e23fbea5e8d02507 Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:01:53 +0800
Subject: [PATCH 41/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 code/commodity1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
deleted file mode 100644
index 67ca69a..0000000
--- a/code/commodity1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-001 apple 2020 7 14 wangyi qiang 100 5 6 2020 5 20 365 westroom
-002 orange 2020 7 14 tengxun qiang 100 4 5 2020 6 10 90 westroom
-003 banana 2020 7 14 sanxing qiang 100 9 10 2020 6 10 90 westroom
-004 pear 2020 7 14 xiaomi qiang 100 5 6 2020 6 20 90 westroom
-005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
-006 peach 2020 7 14 huawei qiang 100 3 4 2020 6 20 90 eastroom
-007 pen 2020 7 14 zhongxing qiang 100 1 2 2020 5 11 365 eastroom
\ No newline at end of file
--
Gitee
From bab7755e8e0e43a6d401fc6f20d2ed2d80b552d2 Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:01 +0800
Subject: [PATCH 42/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/commodity2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity2.txt | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 code/commodity2.txt
diff --git a/code/commodity2.txt b/code/commodity2.txt
deleted file mode 100644
index e0fd2be..0000000
--- a/code/commodity2.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-000 pingguo zhongguo guoyuan 400 1 2020 12 21
-002 juzi zhongguo guoyuan 400 1 2020 12 21
--
Gitee
From 1be375f292f39a796e00295881ea52a7fd651815 Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:07 +0800
Subject: [PATCH 43/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/main.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/main.cpp | 10 ----------
1 file changed, 10 deletions(-)
delete mode 100644 code/main.cpp
diff --git a/code/main.cpp b/code/main.cpp
deleted file mode 100644
index 9034f27..0000000
--- a/code/main.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "purchase.h"
-Status main()
-{
- suppliers suppliers_head, suppliers_tail;
- commodity commodity_head, commodity_tail;
- InitList_suppliers(suppliers_head, suppliers_tail);
- InitList_commodity(commodity_head, commodity_tail);
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- return OK;
-}
--
Gitee
From 12194312e453809f68f0c0d839ba37331ccb0d0d Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:12 +0800
Subject: [PATCH 44/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.cpp | 775 ----------------------------------------------
1 file changed, 775 deletions(-)
delete mode 100644 code/purchase.cpp
diff --git a/code/purchase.cpp b/code/purchase.cpp
deleted file mode 100644
index 19f0068..0000000
--- a/code/purchase.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-#include
-#include
-#include
-#include "purchase.h"
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail)
-{
- head = (purchase)malloc(sizeof(purchase_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
-{
- purchase p;
- p = (purchase)malloc(sizeof(purchase_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->number, number);
- strcpy(p->name, name);
- strcpy(p->source, source);
- strcpy(p->channel, channel);
- p->quantity = quantity;
- p->price = price;
- p->time.year = time.year;
- p->time.month = time.month;
- p->time.day = time.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p)
-{
- printf("%s %s %s %s %d %.2lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- return OK;
-}
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
- p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
- fclose(fp);
- return OK;
-}
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p))
-{
- purchase p;
- p = head->next;
- if (!p)
- {
- printf("Ϣ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("Ϣʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Printf_purchas);
- return OK;
-}
-
-// ļе
-Status FdisplayList_purchas(purchase& head)
-{
- TraverseList_purchas(head, Fprintf_purchas);
- return OK;
-}
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail)
-{
- head = (suppliers)malloc(sizeof(suppliers_information));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- InitList_purchase(head->purchase_head, head->purchase_tail);
- return OK;
-}
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->corporate_name, corporate_name) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
-{
- suppliers p;
- p = (suppliers)malloc(sizeof(suppliers_information));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- InitList_purchase(p->purchase_head, p->purchase_tail);
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
- if (getchar() == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (getchar() == ' ')
- {
- break;
- }
- }
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail)
-{
- FILE* fp;
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- fp = fopen("suppliers1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- ListHandle_suppliers(head, p, corporate_name);
- if (p)
- {
- printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- else
- continue;
- }
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- if (fgetc(fp) == ' ')
- {
- break;
- }
- }
- fclose(fp);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- printf("ҪɾӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
- return ERROR;
- }
- if (p->next)
- {
- p->next->pre = p->pre;
- }
- p->pre->next = p->next;
- free(p);
- printf("ӦϢɾɹ\n");
- return OK;
-}
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪĹӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- printf("롰˾ơӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
- strcpy(p->corporate_name, corporate_name);
- strcpy(p->main_business, main_business);
- strcpy(p->main_products, main_products);
- strcpy(p->brand, brand);
- strcpy(p->contact_person, contact_person);
- strcpy(p->telephone, telephone);
- printf("ӦϢijɹ\n");
- return OK;
-}
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail)
-{
- suppliers p;
- char corporate_name[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- char option;
- bool flag = false;
- printf("ҪѯӦ̵Ĺ˾ƣ\n");
- scanf("%s", corporate_name);
- getchar();
- ListHandle_suppliers(head, p, corporate_name);
- if (!p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
- while (!flag)
- {
- scanf("%c", &option);
- switch (option)
- {
- case 'y':
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- return OK;
- case 'n':
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return ERROR;
- }
- Printf_suppliers(p);
- return OK;
-}
-
-// ڴ¼ӦϢ
-Status Printf_suppliers(suppliers& p)
-{
- printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- DisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p)
-{
- FILE* fp;
- fp = fopen("suppliers2.txt", "a");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
- fclose(fp);
- FdisplayList_purchas(p->purchase_head);
- return OK;
-}
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p))
-{
- suppliers p;
- p = head->next;
- if (!p)
- {
- printf("ӦϢ\n");
- return OK;
- }
- while (p)
- {
- if (!visit(p))
- {
- printf("ӦϢʧܣ\n");
- return ERROR;
- }
- p = p->next;
- }
- return OK;
-}
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Printf_suppliers);
- printf("ӦϢ¼ɹ\n");
- return OK;
-}
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head)
-{
- TraverseList_suppliers(head, Fprintf_suppliers);
- printf("ӦϢɹ\n");
- return OK;
-}
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail)
-{
- head = (commodity)malloc(sizeof(goods));
- if (!head)
- exit(OVERFLOW);
- head->next = NULL;
- tail = head;
- return OK;
-}
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
-{
- commodity p;
- p = (commodity)malloc(sizeof(goods));
- if (!p)
- exit(OVERFLOW);
- strcpy(p->id_Number, id_Number);
- strcpy(p->goods_Name, goods_Name);
- strcpy(p->place, place);
- p->buy_Prise = buy_Prise;
- p->sell_Prise = sell_Prise;
- p->remain_Number = remain_Number;
- p->quality_Date = quality_Date;
- p->purchase_Date.year = purchase_Date.year;
- p->purchase_Date.month = purchase_Date.month;
- p->purchase_Date.day = purchase_Date.day;
- p->produce_Date.year = produce_Date.year;
- p->produce_Date.month = produce_Date.month;
- p->produce_Date.day = produce_Date.day;
- p->pre = tail;
- p->next = NULL;
- tail->next = p;
- tail = p;
- return OK;
-}
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[])
-{
- p = head->next;
- while (p)
- {
- if (strcmp(p->id_Number, id_Number) == 0)
- {
- break;
- }
- p = p->next;
- }
- return OK;
-}
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
- while (1)
- {
- scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (getchar() == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- printf("ƷϢ¼ɹ\n");
- printf("Ϣ¼ɹ\n");
- return OK;
-}
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- FILE* fp;
- commodity p;
- suppliers suppliers_p;
- char id_Number[20];
- char goods_Name[20];
- char place[20];
- char source[MAX_SIZE];
- char channel[MAX_SIZE];
- char main_business[MAX_SIZE];
- char main_products[MAX_SIZE];
- char brand[MAX_SIZE];
- char contact_person[MAX_SIZE];
- char telephone[MAX_SIZE];
- double buy_Prise;
- double sell_Prise;
- int quantity;
- int quality_Date;
- date purchase_Date;
- date produce_Date;
- bool flag = false;
- fp = fopen("commodity1.txt", "r");
- if (fp == NULL)
- {
- printf("Can not open the file!");
- exit(INFEASIBLE);
- }
- while (1)
- {
- fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
- id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
- &buy_Prise, &sell_Prise, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
- if (fgetc(fp) == ' ')
- {
- flag = true;
- }
- ListHandle_commodity(head, p, id_Number);
- if (p)
- {
- if (strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
- || p->buy_Prise != buy_Prise || p->sell_Prise != sell_Prise || p->quality_Date != quality_Date
- || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
- || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
- {
- printf(" %s ѴƷϢ\n", id_Number);
- return ERROR;
- }
- p->remain_Number += quantity;
- }
- else
- ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Prise, sell_Prise, quantity, quality_Date, purchase_Date, produce_Date);
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- if (!suppliers_p)
- {
- printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
- printf("롰ӪҵӪƷƷơˡ绰\n");
- scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
- ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
- printf("ӦϢӳɹ\n");
- ListHandle_suppliers(suppliers_head, suppliers_p, source);
- }
- ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Prise, purchase_Date);
- if (flag == true)
- {
- break;
- }
- }
- fclose(fp);
- printf("ƷϢɹ\n");
- printf("Ϣɹ\n");
- return OK;
-}
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_suppliers(suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_suppliers(suppliers_head, suppliers_tail);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- DisplayList_suppliers(suppliers_head);
- break;
- case 2:
- FdisplayList_suppliers(suppliers_head);
- break;
- case 3:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 4:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- ListDelete_suppliers(suppliers_head);
- break;
- case 3:
- ListAlter_suppliers(suppliers_head, suppliers_tail);
- break;
- case 4:
- ListSearch_suppliers(suppliers_head, suppliers_tail);
- break;
- case 5:
- Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 6:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢ\n3.\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 2:
- Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- break;
- case 3:
- Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail)
-{
- int option;
- bool flag = false;
- system("cls");
- printf("\n1.ӦϢ\n2.\n3.˳\n");
- while (!flag)
- {
- scanf("%d", &option);
- switch (option)
- {
- case 1:
- Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 2:
- Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
- flag = true;
- break;
- case 3:
- exit(OK);
- default:
- printf("룡\n");
- break;
- }
- }
- return OK;
-}
\ No newline at end of file
--
Gitee
From 4a51805490659c201102fa51158c266f2dbf482c Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:16 +0800
Subject: [PATCH 45/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/purchase.h?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/purchase.h | 170 ------------------------------------------------
1 file changed, 170 deletions(-)
delete mode 100644 code/purchase.h
diff --git a/code/purchase.h b/code/purchase.h
deleted file mode 100644
index 0dfce48..0000000
--- a/code/purchase.h
+++ /dev/null
@@ -1,170 +0,0 @@
-#ifndef __PURCHASE_H__
-#define __PURCHASE_H__
-
-// ͷļṹ
-
-//
-#define MAX_SIZE 30
-
-// ״̬
-#define TRUE 1 //
-#define FALSE 0 //
-#define OK 1 //
-#define ERROR 0 //
-#define INFEASIBLE -1 //
-#define OVERFLOW -2 //
-
-// Status ǺֵͣǺ״̬
-typedef int Status;
-
-// ʱṹ壬洢ꡢ¡Ϣ
-struct date
-{
- int year; //
- int month; //
- int day; //
-};
-
-/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
-
-// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
-typedef struct purchase_information
-{
- char number[MAX_SIZE]; // Ʒ
- char name[MAX_SIZE]; // Ʒ
- char source[MAX_SIZE]; // Դ
- char channel[MAX_SIZE]; //
- int quantity; //
- double price; // ۸
- date time; // ʱ
- purchase_information* pre; // һָ
- purchase_information* next; // һָ
-}*purchase;
-
-// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
-typedef struct suppliers_information
-{
- char corporate_name[MAX_SIZE]; // ˾
- char main_business[MAX_SIZE]; // Ӫҵ
- char main_products[MAX_SIZE]; // ӪƷ
- char brand[MAX_SIZE]; // Ʒ
- char contact_person[MAX_SIZE]; //
- char telephone[MAX_SIZE]; // 绰
- purchase purchase_head; // Ϣͷڵ
- purchase purchase_tail; // Ϣβ
- suppliers_information* pre; // һӦָ
- suppliers_information* next; // һӦָ
-}*suppliers;
-
-typedef struct goods
-{
- char id_Number[20]; // Ʒ
- char goods_Name[20]; // Ʒ
- char place[20]; // λ
- double buy_Prise; // Ʒ
- double sell_Prise; // Ʒۼ
- int remain_Number; // Ʒ
- int quality_Date; //
- date purchase_Date; //
- date produce_Date; //
- goods* pre; // һƷָ
- goods* next; // һƷָ
-}*commodity;
-
-// һյĴͷĽ˫
-Status InitList_purchase(purchase& head, purchase& tail);
-
-// ڽβһ
-Status ListAdd_purchase(purchase& tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
-
-// ڴ¼Ϣ
-Status Printf_purchas(purchase& p);
-
-// ļеϢ
-Status Fprintf_purchas(purchase& p);
-
-// ζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_purchas(purchase& head, Status(*visit)(purchase& p));
-
-// ڴ¼
-Status DisplayList_purchas(purchase& head);
-
-// ļе
-Status FdisplayList_purchas(purchase& head);
-
-// һյĴͷĹӦ˫
-Status InitList_suppliers(suppliers& head, suppliers& tail);
-
-// ҹӦ̹˾ؼƥĹӦ̽
-Status ListHandle_suppliers(suppliers& head, suppliers& p, char corporate_name[]);
-
-// ڹӦβһӦ̽
-Status ListAdd_suppliers(suppliers& tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
-
-// Ӵ¼빩ӦϢ
-Status Add_suppliers(suppliers& head, suppliers& tail);
-
-// ļе빩ӦϢ
-Status Fadd_suppliers(suppliers& head, suppliers& tail);
-
-// ɾӦ̹˾ؼƥĹӦ̽
-Status ListDelete_suppliers(suppliers& head);
-
-// ĹӦ̹˾ؼƥĹӦ̽
-Status ListAlter_suppliers(suppliers& head, suppliers& tail);
-
-// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
-Status ListSearch_suppliers(suppliers& head, suppliers& tail);
-
-// ڴӦϢ
-Status Printf_suppliers(suppliers& p);
-
-// ļеӦϢ
-Status Fprintf_suppliers(suppliers& p);
-
-// Ӧζÿڵúvisit()һvisit()ʧܣʧ
-Status TraverseList_suppliers(suppliers& head, Status(*visit)(suppliers& p));
-
-// ڴ¼Ӧ
-Status DisplayList_suppliers(suppliers& head);
-
-// ļеӦ
-Status FdisplayList_suppliers(suppliers& head);
-
-// һյĴͷƷ
-Status InitList_commodity(commodity& head, commodity& tail);
-
-// ƷβһƷ
-Status ListAdd_commodity(commodity& tail, char id_Number[], char goods_Name[], char place[],
- double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
-
-// ƷؼƥĹӦ̽
-Status ListHandle_commodity(commodity& head, commodity& p, char id_Number[]);
-
-// Ӵ¼ƷϢ
-Status Add_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ļеƷϢ
-Status Fadd_commodity(commodity& head, commodity& tail, suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӹӦϢ
-Status Interface_add_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӡӦϢ
-Status Interface_print_suppliers(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-// ӦϢ
-Status Interface_suppliers_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Interface_purchase_management(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-//
-Status Main_interface(commodity& commodity_head, commodity& commodity_tail,
- suppliers& suppliers_head, suppliers& suppliers_tail);
-
-#endif
\ No newline at end of file
--
Gitee
From cf1ca7ec360d552d54573c29858a9143854b220c Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:21 +0800
Subject: [PATCH 46/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers1.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers1.txt | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 code/suppliers1.txt
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
deleted file mode 100644
index 7e80b65..0000000
--- a/code/suppliers1.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-huawei huawei1 huawei2 huawei3 huawei4 4444
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee
From de49c441be87f70df90c22e8a4de703cfb44e20a Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:02:26 +0800
Subject: [PATCH 47/48] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20co?=
=?UTF-8?q?de/suppliers2.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/suppliers2.txt | 13 -------------
1 file changed, 13 deletions(-)
delete mode 100644 code/suppliers2.txt
diff --git a/code/suppliers2.txt b/code/suppliers2.txt
deleted file mode 100644
index 7ca7004..0000000
--- a/code/suppliers2.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
-002 orange tengxun qiang 100 4.000000 2020 7 14
-005 watermelon tengxun qiang 100 6.000000 2020 7 14
-wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
-001 apple wangyi qiang 100 5.000000 2020 7 14
-xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
-004 pear xiaomi qiang 100 5.000000 2020 7 14
-huawei huawei1 huawei2 huawei3 huawei4 4444
-006 peach huawei qiang 100 3.000000 2020 7 14
-zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
-007 pen zhongxing qiang 100 1.000000 2020 7 14
-sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
-003 banana sanxing qiang 100 9.000000 2020 7 14
--
Gitee
From af88b976f9926a40093f4561158d72f5e7752a43 Mon Sep 17 00:00:00 2001
From: hyp19991114
Date: Fri, 17 Jul 2020 20:06:57 +0800
Subject: [PATCH 48/48] =?UTF-8?q?=E9=9B=86=E6=88=90=E5=90=8E=E7=9A=84?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
code/commodity1.txt | 12 +
code/purchase.cpp | 780 ++++++++++++++++++++++++++++++++++++++++++++
code/purchase.h | 159 +++++++++
code/suppliers1.txt | 6 +
4 files changed, 957 insertions(+)
create mode 100644 code/commodity1.txt
create mode 100644 code/purchase.cpp
create mode 100644 code/purchase.h
create mode 100644 code/suppliers1.txt
diff --git a/code/commodity1.txt b/code/commodity1.txt
new file mode 100644
index 0000000..8c3e0c2
--- /dev/null
+++ b/code/commodity1.txt
@@ -0,0 +1,12 @@
+001 apple 2020 7 14 wangyi qiang 100 5 6 2020 6 20 365 westroom
+002 orange 2020 6 14 tengxun qiang 80 4 5 2020 6 10 35 westroom
+003 banana 2020 7 5 sanxing qiang 100 9 10 2020 7 2 15 westroom
+004 pear 2020 6 30 xiaomi qiang 90 5 6 2020 6 20 90 westroom
+005 watermelon 2020 7 14 tengxun qiang 100 6 7 2020 6 15 90 eastroom
+006 peach 2020 7 12 huawei qiang 100 3 5 2020 7 10 5 eastroom
+007 pen 2020 7 14 zhongxing qiang 45 1 2 2020 5 11 365 eastroom
+008 camera 2020 7 14 sanxing gift 10 500 650 2020 7 10 365 west-1A
+009 computer 2020 6 10 huawei gift 30 3000 4000 2020 6 1 1000 west-1B
+010 audio 2020 7 14 xiaomi buy 80 100 150 2020 7 5 180 east-1A
+011 phone 2020 6 2 huawei buy 5 5000 6000 2020 6 1 700 east-1B
+012 MP3 2020 7 14 zhongxing buy 100 50 70 2020 6 20 365 east-1C
\ No newline at end of file
diff --git a/code/purchase.cpp b/code/purchase.cpp
new file mode 100644
index 0000000..efa919d
--- /dev/null
+++ b/code/purchase.cpp
@@ -0,0 +1,780 @@
+#include
+#include
+#include
+#include "purchase.h"
+
+suppliers suppliers_head;
+suppliers suppliers_tail;
+commodity commodity_head;
+commodity commodity_tail;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase &head, purchase &tail)
+{
+ head = (purchase)malloc(sizeof(purchase_information));
+ if(!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ڽβһ
+Status ListAdd_purchase(purchase &tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time)
+{
+ purchase p;
+ p = (purchase)malloc(sizeof(purchase_information));
+ if(!p)
+ exit(OVERFLOW);
+ strcpy(p->number, number);
+ strcpy(p->name, name);
+ strcpy(p->source, source);
+ strcpy(p->channel, channel);
+ p->quantity = quantity;
+ p->price = price;
+ p->time.year = time.year;
+ p->time.month = time.month;
+ p->time.day = time.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase &p)
+{
+ printf("%s %s %s %s %d %.2lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ return OK;
+}
+
+// ļеϢ
+Status Fprintf_purchas(purchase &p)
+{
+ FILE *fp;
+ fp = fopen("suppliers2.txt", "a");
+ if(fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %d %lf %d %d %d\n",
+ p->number, p->name, p->source, p->channel, p->quantity, p->price, p->time.year, p->time.month, p->time.day);
+ fclose(fp);
+ return OK;
+}
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase &head, Status(*visit)(purchase &p))
+{
+ purchase p;
+ p = head->next;
+ if(!p)
+ {
+ printf("Ϣ\n");
+ return OK;
+ }
+ while(p)
+ {
+ if(!visit(p))
+ {
+ printf("Ϣʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼
+Status DisplayList_purchas(purchase &head)
+{
+ TraverseList_purchas(head, Printf_purchas);
+ return OK;
+}
+
+// ļе
+Status FdisplayList_purchas(purchase &head)
+{
+ TraverseList_purchas(head, Fprintf_purchas);
+ return OK;
+}
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers &head, suppliers &tail)
+{
+ head = (suppliers)malloc(sizeof(suppliers_information));
+ if(!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ InitList_purchase(head->purchase_head, head->purchase_tail);
+ return OK;
+}
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers &head, suppliers &p, char corporate_name[])
+{
+ p = head->next;
+ while(p)
+ {
+ if(strcmp(p->corporate_name, corporate_name) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers &tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[])
+{
+ suppliers p;
+ p = (suppliers)malloc(sizeof(suppliers_information));
+ if(!p)
+ exit(OVERFLOW);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ InitList_purchase(p->purchase_head, p->purchase_tail);
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers &head, suppliers &tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ printf("롰˾ơӪҵӪƷƷơˡ绰ԿոΪβ\n");
+ while(1)
+ {
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if(p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣӡ\n", p->corporate_name);
+ if(getchar() == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if(getchar() == ' ')
+ {
+ break;
+ }
+ }
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers &head, suppliers &tail)
+{
+ FILE *fp;
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ fp = fopen("suppliers1.txt", "r");
+ if(fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while(1)
+ {
+ fscanf(fp, "%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ ListHandle_suppliers(head, p, corporate_name);
+ if(p)
+ {
+ printf("˾Ϊ %s ĹӦѴڣ!\n", p->corporate_name);
+ if(fgetc(fp) == ' ')
+ {
+ break;
+ }
+ else
+ continue;
+ }
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ if(fgetc(fp) == ' ')
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers &head)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ printf("ҪɾӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ ListHandle_suppliers(head, p, corporate_name);
+ if(!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ,ɾ\n");
+ return ERROR;
+ }
+ if(p->next)
+ {
+ p->next->pre = p->pre;
+ }
+ p->pre->next = p->next;
+ free(p);
+ printf("ӦϢɾɹ\n");
+ return OK;
+}
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers &head, suppliers &tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪĹӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if(!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while(!flag)
+ {
+ scanf("%c", &option);
+ switch(option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ printf("롰˾ơӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s %s", corporate_name, main_business, main_products, brand, contact_person, telephone);
+ strcpy(p->corporate_name, corporate_name);
+ strcpy(p->main_business, main_business);
+ strcpy(p->main_products, main_products);
+ strcpy(p->brand, brand);
+ strcpy(p->contact_person, contact_person);
+ strcpy(p->telephone, telephone);
+ printf("ӦϢijɹ\n");
+ return OK;
+}
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers &head, suppliers &tail)
+{
+ suppliers p;
+ char corporate_name[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ char option;
+ bool flag = false;
+ printf("ҪѯӦ̵Ĺ˾ƣ\n");
+ scanf("%s", corporate_name);
+ getchar();
+ ListHandle_suppliers(head, p, corporate_name);
+ if(!p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣Ƿӣy/n\n", corporate_name);
+ while(!flag)
+ {
+ scanf("%c", &option);
+ switch(option)
+ {
+ case 'y':
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(tail, corporate_name, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ return OK;
+ case 'n':
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return ERROR;
+ }
+ Printf_suppliers(p);
+ return OK;
+}
+
+// ڴ¼ӦϢ
+Status Printf_suppliers(suppliers &p)
+{
+ printf("%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ DisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers &p)
+{
+ FILE *fp;
+ fp = fopen("suppliers2.txt", "a");
+ if(fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ fprintf(fp, "%s %s %s %s %s %s\n", p->corporate_name, p->main_business, p->main_products, p->brand, p->contact_person, p->telephone);
+ fclose(fp);
+ FdisplayList_purchas(p->purchase_head);
+ return OK;
+}
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers &head, Status(*visit)(suppliers &p))
+{
+ suppliers p;
+ p = head->next;
+ if(!p)
+ {
+ printf("ӦϢ\n");
+ return OK;
+ }
+ while(p)
+ {
+ if(!visit(p))
+ {
+ printf("ӦϢʧܣ\n");
+ return ERROR;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers &head)
+{
+ TraverseList_suppliers(head, Printf_suppliers);
+ printf("ӦϢ¼ɹ\n");
+ return OK;
+}
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers &head)
+{
+ TraverseList_suppliers(head, Fprintf_suppliers);
+ printf("ӦϢɹ\n");
+ return OK;
+}
+
+// һյĴͷƷ
+Status InitList_commodity(commodity &head, commodity &tail)
+{
+ head = (commodity)malloc(sizeof(goods));
+ if(!head)
+ exit(OVERFLOW);
+ head->next = NULL;
+ tail = head;
+ return OK;
+}
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity &tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Price, double sell_Price, int remain_Number, int quality_Date, date purchase_Date, date produce_Date)
+{
+ commodity p;
+ p = (commodity)malloc(sizeof(goods));
+ if(!p)
+ exit(OVERFLOW);
+ strcpy(p->id_Number, id_Number);
+ strcpy(p->goods_Name, goods_Name);
+ strcpy(p->place, place);
+ p->buy_Price = buy_Price;
+ p->sell_Price = sell_Price;
+ p->remain_Number = remain_Number;
+ p->quality_Date = quality_Date;
+ p->purchase_Date.year = purchase_Date.year;
+ p->purchase_Date.month = purchase_Date.month;
+ p->purchase_Date.day = purchase_Date.day;
+ p->produce_Date.year = produce_Date.year;
+ p->produce_Date.month = produce_Date.month;
+ p->produce_Date.day = produce_Date.day;
+ p->pre = tail;
+ p->next = NULL;
+ tail->next = p;
+ tail = p;
+ return OK;
+}
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity &head, commodity &p, char id_Number[])
+{
+ p = head->next;
+ while(p)
+ {
+ if(strcmp(p->id_Number, id_Number) == 0)
+ {
+ break;
+ }
+ p = p->next;
+ }
+ return OK;
+}
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity &head, commodity &tail, suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Price;
+ double sell_Price;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ printf("롰ƷšƷơڡԴӦ̣ƷۡƷۼۡڡڡλáԿոΪβ\n");
+ while(1)
+ {
+ scanf("%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Price, &sell_Price, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if(getchar() == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if(p)
+ {
+ if(strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Price != buy_Price || p->sell_Price != sell_Price || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Price, sell_Price, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if(!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Price, purchase_Date);
+ if(flag == true)
+ {
+ break;
+ }
+ }
+ printf("ƷϢ¼ɹ\n");
+ printf("Ϣ¼ɹ\n");
+ return OK;
+}
+
+// ļеƷϢ
+Status Fadd_commodity(commodity &head, commodity &tail, suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ FILE *fp;
+ commodity p;
+ suppliers suppliers_p;
+ char id_Number[20];
+ char goods_Name[20];
+ char place[20];
+ char source[MAX_SIZE];
+ char channel[MAX_SIZE];
+ char main_business[MAX_SIZE];
+ char main_products[MAX_SIZE];
+ char brand[MAX_SIZE];
+ char contact_person[MAX_SIZE];
+ char telephone[MAX_SIZE];
+ double buy_Price;
+ double sell_Price;
+ int quantity;
+ int quality_Date;
+ date purchase_Date;
+ date produce_Date;
+ bool flag = false;
+ fp = fopen("commodity1.txt", "r");
+ if(fp == NULL)
+ {
+ printf("Can not open the file!");
+ exit(INFEASIBLE);
+ }
+ while(1)
+ {
+ fscanf(fp, "%s %s %d %d %d %s %s %d %lf %lf %d %d %d %d %s",
+ id_Number, goods_Name, &purchase_Date.year, &purchase_Date.month, &purchase_Date.day, source, channel, &quantity,
+ &buy_Price, &sell_Price, &produce_Date.year, &produce_Date.month, &produce_Date.day, &quality_Date, place);
+ if(fgetc(fp) == ' ')
+ {
+ flag = true;
+ }
+ ListHandle_commodity(head, p, id_Number);
+ if(p)
+ {
+ if(strcmp(p->goods_Name, goods_Name) != 0 || strcmp(p->place, place) != 0
+ || p->buy_Price != buy_Price || p->sell_Price != sell_Price || p->quality_Date != quality_Date
+ || p->purchase_Date.year != purchase_Date.year || p->purchase_Date.month != purchase_Date.month || p->purchase_Date.day != purchase_Date.day
+ || p->produce_Date.year != produce_Date.year || p->produce_Date.month != produce_Date.month || p->produce_Date.day != produce_Date.day)
+ {
+ printf(" %s ѴƷϢ\n", id_Number);
+ return ERROR;
+ }
+ p->remain_Number += quantity;
+ }
+ else
+ ListAdd_commodity(tail, id_Number, goods_Name, place, buy_Price, sell_Price, quantity, quality_Date, purchase_Date, produce_Date);
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ if(!suppliers_p)
+ {
+ printf("δҵ˾Ϊ %s ĹӦ̣!\n", source);
+ printf("롰ӪҵӪƷƷơˡ绰\n");
+ scanf("%s %s %s %s %s", main_business, main_products, brand, contact_person, telephone);
+ ListAdd_suppliers(suppliers_tail, source, main_business, main_products, brand, contact_person, telephone);
+ printf("ӦϢӳɹ\n");
+ ListHandle_suppliers(suppliers_head, suppliers_p, source);
+ }
+ ListAdd_purchase(suppliers_p->purchase_tail, id_Number, goods_Name, source, channel, quantity, buy_Price, purchase_Date);
+ if(flag == true)
+ {
+ break;
+ }
+ }
+ fclose(fp);
+ printf("ƷϢɹ\n");
+ printf("Ϣɹ\n");
+ return OK;
+}
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӹӦϢ\n1.Ӵ¼빩ӦϢ\n2.ļе빩ӦϢ\n3.һ\n4.\n");
+ while(!flag)
+ {
+ scanf("%d", &option);
+ switch(option)
+ {
+ case 1:
+ Add_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӡӦϢ\n1.Ӵ¼ӦϢ\n2.ļеӦϢ\n3.һ\n4.\n");
+ while(!flag)
+ {
+ scanf("%d", &option);
+ switch(option)
+ {
+ case 1:
+ DisplayList_suppliers(suppliers_head);
+ break;
+ case 2:
+ FdisplayList_suppliers(suppliers_head);
+ break;
+ case 3:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 4:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+// ӦϢ
+Status Interface_suppliers_management(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("ӦϢ\n1.ӹӦϢ\n2.ɾӦϢ\n3.ĹӦϢ\n4.ѯӦϢ\n5.ӡӦϢ\n6.\n");
+ while(!flag)
+ {
+ scanf("%d", &option);
+ switch(option)
+ {
+ case 1:
+ Interface_add_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ ListDelete_suppliers(suppliers_head);
+ break;
+ case 3:
+ ListAlter_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 4:
+ ListSearch_suppliers(suppliers_head, suppliers_tail);
+ break;
+ case 5:
+ Interface_print_suppliers(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 6:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Interface_purchase_management(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.Ӵ¼ƷϢͽϢ\n2.ļеƷϢͽϢ\n3.\n");
+ while(!flag)
+ {
+ scanf("%d", &option);
+ switch(option)
+ {
+ case 1:
+ Add_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 2:
+ Fadd_commodity(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ break;
+ case 3:
+ Main_interface(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
+
+//
+Status Main_interface(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail)
+{
+ int option;
+ bool flag = false;
+ system("cls");
+ printf("\n1.ӦϢ\n2.\n3.˳\n");
+ while(!flag)
+ {
+ scanf("%d", &option);
+ switch(option)
+ {
+ case 1:
+ Interface_suppliers_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 2:
+ Interface_purchase_management(commodity_head, commodity_tail, suppliers_head, suppliers_tail);
+ flag = true;
+ break;
+ case 3:
+ return OK;
+ default:
+ printf("룡\n");
+ break;
+ }
+ }
+ return OK;
+}
diff --git a/code/purchase.h b/code/purchase.h
new file mode 100644
index 0000000..9dd0e32
--- /dev/null
+++ b/code/purchase.h
@@ -0,0 +1,159 @@
+#ifndef __PURCHASE_H__
+#define __PURCHASE_H__
+
+// ͷļṹ
+
+//
+#define MAX_SIZE 30
+
+// ״̬
+#define TRUE 1 //
+#define FALSE 0 //
+#define OK 1 //
+#define ERROR 0 //
+#define INFEASIBLE -1 //
+#define OVERFLOW -2 //
+
+// Status ǺֵͣǺ״̬
+typedef int Status;
+
+// ʱṹ壬洢ꡢ¡Ϣ
+#include "date.h"
+
+// Ʒ棩ṹ
+#include "sell.h"
+
+/* ˫ĵڵ㣬ӦĽṹԱͬʱĹ캯purchase.cppУ */
+
+// ϢԳеIJɹй洢Щʱ䡢Դ/۸Ϣ
+typedef struct purchase_information
+{
+ char number[MAX_SIZE]; // Ʒ
+ char name[MAX_SIZE]; // Ʒ
+ char source[MAX_SIZE]; // Դ
+ char channel[MAX_SIZE]; //
+ int quantity; //
+ double price; // ۸
+ date time; // ʱ
+ purchase_information *pre; // һָ
+ purchase_information *next; // һָ
+}*purchase;
+
+// ӦϢ洢˾ơӪҵ/ƷƷơˡ绰Ϣ
+struct suppliers_information
+{
+ char corporate_name[MAX_SIZE]; // ˾
+ char main_business[MAX_SIZE]; // Ӫҵ
+ char main_products[MAX_SIZE]; // ӪƷ
+ char brand[MAX_SIZE]; // Ʒ
+ char contact_person[MAX_SIZE]; //
+ char telephone[MAX_SIZE]; // 绰
+ purchase purchase_head; // Ϣͷڵ
+ purchase purchase_tail; // Ϣβ
+ suppliers_information *pre; // һӦָ
+ suppliers_information *next; // һӦָ
+};
+typedef struct suppliers_information *suppliers;
+
+extern suppliers suppliers_head;
+extern suppliers suppliers_tail;
+extern commodity commodity_head;
+extern commodity commodity_tail;
+
+// һյĴͷĽ˫
+Status InitList_purchase(purchase &head, purchase &tail);
+
+// ڽβһ
+Status ListAdd_purchase(purchase &tail, char number[], char name[], char source[], char channel[], int quantity, double price, date time);
+
+// ڴ¼Ϣ
+Status Printf_purchas(purchase &p);
+
+// ļеϢ
+Status Fprintf_purchas(purchase &p);
+
+// ζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_purchas(purchase &head, Status(*visit)(purchase &p));
+
+// ڴ¼
+Status DisplayList_purchas(purchase &head);
+
+// ļе
+Status FdisplayList_purchas(purchase &head);
+
+// һյĴͷĹӦ˫
+Status InitList_suppliers(suppliers &head, suppliers &tail);
+
+// ҹӦ̹˾ؼƥĹӦ̽
+Status ListHandle_suppliers(suppliers &head, suppliers &p, char corporate_name[]);
+
+// ڹӦβһӦ̽
+Status ListAdd_suppliers(suppliers &tail, char corporate_name[], char main_business[], char main_products[], char brand[], char contact_person[], char telephone[]);
+
+// Ӵ¼빩ӦϢ
+Status Add_suppliers(suppliers &head, suppliers &tail);
+
+// ļе빩ӦϢ
+Status Fadd_suppliers(suppliers &head, suppliers &tail);
+
+// ɾӦ̹˾ؼƥĹӦ̽
+Status ListDelete_suppliers(suppliers &head);
+
+// ĹӦ̹˾ؼƥĹӦ̽
+Status ListAlter_suppliers(suppliers &head, suppliers &tail);
+
+// ѯӦ̹˾ؼƥĹӦ̽㹩ӦϢ
+Status ListSearch_suppliers(suppliers &head, suppliers &tail);
+
+// ڴӦϢ
+Status Printf_suppliers(suppliers &p);
+
+// ļеӦϢ
+Status Fprintf_suppliers(suppliers &p);
+
+// Ӧζÿڵúvisit()һvisit()ʧܣʧ
+Status TraverseList_suppliers(suppliers &head, Status(*visit)(suppliers &p));
+
+// ڴ¼Ӧ
+Status DisplayList_suppliers(suppliers &head);
+
+// ļеӦ
+Status FdisplayList_suppliers(suppliers &head);
+
+// һյĴͷƷ
+Status InitList_commodity(commodity &head, commodity &tail);
+
+// ƷβһƷ
+Status ListAdd_commodity(commodity &tail, char id_Number[], char goods_Name[], char place[],
+ double buy_Prise, double sell_Prise, int remain_Number, int quality_Date, date purchase_Date, date produce_Date);
+
+// ƷؼƥĹӦ̽
+Status ListHandle_commodity(commodity &head, commodity &p, char id_Number[]);
+
+// Ӵ¼ƷϢ
+Status Add_commodity(commodity &head, commodity &tail, suppliers &suppliers_head, suppliers &suppliers_tail);
+
+// ļеƷϢ
+Status Fadd_commodity(commodity &head, commodity &tail, suppliers &suppliers_head, suppliers &suppliers_tail);
+
+// ӹӦϢ
+Status Interface_add_suppliers(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail);
+
+// ӡӦϢ
+Status Interface_print_suppliers(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail);
+
+// ӦϢ
+Status Interface_suppliers_management(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail);
+
+//
+Status Interface_purchase_management(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail);
+
+//
+Status Main_interface(commodity &commodity_head, commodity &commodity_tail,
+ suppliers &suppliers_head, suppliers &suppliers_tail);
+
+#endif
\ No newline at end of file
diff --git a/code/suppliers1.txt b/code/suppliers1.txt
new file mode 100644
index 0000000..7e80b65
--- /dev/null
+++ b/code/suppliers1.txt
@@ -0,0 +1,6 @@
+tengxun tengxun1 tengxun2 tengxun3 tengxun4 1111
+wangyi wangyi1 wangyi2 wangyi3 wangyi4 2222
+xiaomi xiaomi1 xiaomi2 xiaomi3 xiaomi4 3333
+huawei huawei1 huawei2 huawei3 huawei4 4444
+zhongxing zhongxing1 zhongxing2 zhongxing3 zhongxing4 5555
+sanxing sanxing1 sanxing2 sanxing3 sanxing4 6666
\ No newline at end of file
--
Gitee