Product Management System

Source: Internet
Author: User

# Include
   # Include
   # Include
   # Include
   # Include
   Typedef struct com {// char num [10]; long num; char name [10]; Long Count; // char amount [10]; // char from [20]; // char stockdate [10]; struct com * Next;} com; # define Len sizeof (COM) # define print "%-15ld %-15 S %-15ld/N", ptr1-> num, ptr1-> name, ptr1-> countcom * head = NULL; com * ptr1 = NULL, * ptr2 = NULL; file * FP; void start (); // start function overcom * openfile (); // load module overcom * input (); // enter overcom * insert_perf (); // insert overcom * d El_perf (); // Delete overcom * revise_perf (); // modify overcom * pass (); // sort overvoid save (COM * head ); // save overvoid printf_perf (); // output overvoid search (); // search for overchar filename1 [20]; char filename2 [] = ". dat "; int main (void) {start (); System (" CLS "); fflush (stdin); // printf (" press any key to go to the main menu/N "); // getch (); int select; char menu [] = {"1. enter goods information/N "2. output all goods information/N "" 3. insert product information/N "4. delete product information/N "5. modify product information/N "" 6. overall Sorting/N "7. comprehensive search/N" "8. disk/N "" 0. exit/N "}; do {system (" CLS "); printf ("/n ********************************* **************************************** * *****/N "); printf ("chlaws production "); printf ("/n *********************************** **************************************** * ***/N "); puts (menu ); printf ("************************************* **************************************** **/N "); printf ("chlaws production"); printf ("/n **************** **************************************** ***********************"); Printf ("select from 0-8:"); scanf ("% d", & select); Switch (select) {Case 1: Head = input (); // input module break; Case 2: printf_perf (); // output module break; Case 3: Head = insert_perf (); // insert module break; Case 4: head = del_perf (); // Delete module break; Case 5: Head = revise_perf (); // modify module break; Case 6: Head = pass (); // sorting module break; Case 7: Search (); // query module break; case 8: Save (head); // save Module B Reak; Case 0: break;} while (select); getch (); Return 0;} void start () {system ("CLS"); fflush (stdin ); char message [] = {"Instructions for use of supermarket goods inventory management system/N" "this system is a supermarket goods inventory information management system/N" "system that inputs multiple types of goods information, the system will save the product category name/N "you entered as the file name/N" ". The system will insert and delete the saved product information after it is called up, modify/N "" and then save/N "again. At the same time, the system also has the product number, goods name/N "" sorting and searching function/N "" welcome to use Goods Information Inventory Management System/N "}; puts (Message ); printf ("press any key to return/N"); getch ();} com * input () {system ("CLS"); fflush (stdin); com * ptr3; int n = 0; char cell [5]; char y [] = "yes"; ptr1 = (COM *) malloc (LEN); printf ("input num:/N "); fflush (stdin); scanf ("% lD", & ptr1-> num); fflush (stdin); printf ("input name:/N"); fflush (stdin ); gets (ptr1-> name); printf ("input count:/N"); fflush (stdin); scanf ("% lD", & ptr1-> count ); head = ptr1; ptr2 = ptr1; do {printf ("are you continue input? (Yes/No)/n "); fflush (stdin); gets (cell); If (strcmpi (cell," no ") = 0) {break ;} ptr1 = (COM *) malloc (LEN); printf ("input num:/N"); fflush (stdin); scanf ("% lD ", & ptr1-> num); printf ("input name:/N"); fflush (stdin); gets (ptr1-> name); printf ("input count: /n "); fflush (stdin); scanf (" % d ", & ptr1-> count); ptr2-> next = ptr1; ptr2 = ptr1; printf ("input OK! /N ");} while (strcmpi (cell, y) = 0 ); printf ("/n *************************** ********************"); ptr2-> next = NULL; ptr3 = head; while (ptr3! = NULL) {printf ("/nnum: % LD/tname: % S/tcount: % LD/N", ptr3-> num, ptr3-> name, ptr3-> count); ptr3 = ptr3-> next;} printf ("/n pay attention to save/N"); printf ("/n press any key to return/N "); getch (); return head;} com * insert_perf () {system ("CLS"); fflush (stdin); com * ptr3 = (COM *) malloc (LEN ); char key [4]; head = openfile (); ptr1 = head; while (ptr1-> next! = NULL) {ptr1 = ptr1-> next;} printf ("input insert goods's num:/N"); fflush (stdin); scanf ("% lD ", & ptr3-> num); printf ("input insert goods's name:/N"); fflush (stdin); gets (ptr3-> name ); printf ("input insert goods's count:/N"); fflush (stdin); scanf ("% lD", & ptr3-> count); // ptr1 = ptr3; ptr3-> next = ptr1-> next; ptr1-> next = ptr3; ptr1 = ptr3; printf ("insert OK! /N "); do {printf (" are you continue insert data? (Yes/No)/n "); fflush (stdin); gets (key); If (! Strcmpi (key, "no") {printf ("OK! You already insert! /N "); break;} If (! Strcmpi (key, "yes") {ptr3 = (COM *) malloc (LEN); printf ("input insert goods's num:/N "); fflush (stdin); scanf ("% lD", & ptr3-> num); printf ("input insert goods's name:/N"); fflush (stdin ); gets (ptr3-> name); printf ("input insert goods's count:/N"); fflush (stdin); scanf ("% lD ", & ptr3-> count); ptr3-> next = ptr1-> next; ptr1-> next = ptr3; ptr1 = ptr3 ;}} while (! Strcmpi (key, "yes ")); //// // save it to a file ////////////////////// //////////////////////////////////////// printf ("/n pay attention to save/N "); printf ("/n press any key to return/N"); getch (); return head;} com * del_perf () {system ("CLS"); fflush (stdin ); int choise; int N; long num; char name [20]; char key [4]; com * ptr3; head = openfile (); If (Head = NULL) {return NULL;} do {system ("CLS"); printf ("input you can delete goods's num or name! /N "); printf (" 1. Input num to delete/n2.input name to delete/n3.press any key to return "); printf ("/ninput you choise! /N "); printf (" choise: "); fflush (stdin); scanf (" % d ", & choise); ptr1 = head; n = 1; if (choise! = 1 & choise! = 2) {break;} If (choise = 1) {printf ("input num! /N "); fflush (stdin); scanf (" % lD ", & num); // printf (" ptr1-> num = % lD ", ptr1-> num); While (ptr1! = NULL & ptr1-> num! = Num) {ptr2 = ptr1; ptr1 = ptr1-> next; n = n + 1; // printf ("ptr1-> num = % lD, ptr2-> num = % lD, n = % d ", ptr1-> num, ptr2-> num, n);} If (ptr1! = NULL) {If (n = 1) {head = ptr1-> next;} If (n! = 1) {ptr2-> next = ptr1-> next;} Free (ptr1); printf ("delete OK! /N "); printf (" last data:/N "); ptr3 = head; while (ptr3! = NULL) {printf ("/n %-15ld %-15 S %-15ld/N", ptr3-> num, ptr3-> name, ptr3-> count ); ptr3 = ptr3-> next ;}} else {printf ("in database can not find you input data/N ");}} // If choise = 1if (choise = 2) {printf ("input name/N"); fflush (stdin); gets (name ); while (strcmpi (ptr1-> name, name )! = 0 & ptr1-> next! = NULL) {ptr2 = ptr1; ptr1 = ptr1-> next; n = n + 1;} If (ptr1! = NULL) {If (n = 1) {head = ptr1-> next;} else {ptr2-> next = ptr1-> next;} Free (ptr1 ); printf ("delete OK! /N "); printf (" last data:/N "); ptr3 = head; while (ptr3! = NULL) {printf ("/n %-15ld %-15 S %-15ld/N", ptr3-> num, ptr3-> name, ptr3-> count ); ptr3 = ptr3-> next ;}} else {printf ("in database can not find you input name! /N ") ;}}// if choise = 2; printf ("/Nare you continue to delete? (Yes/No)/n "); fflush (stdin); gets (key);} while (strcmpi (key," yes ") = 0 ); printf ("/n pay attention to save/N"); printf ("/n press any key to return/N"); getch (); return head;} com * revise_perf () {long num; int choise; char name [20]; char key [4]; head = openfile (); fflush (stdin); If (Head = NULL) {return NULL;} do {ptr1 = head; System ("CLS"); printf ("1: Modify information by product number/N2: Modify information by product name/N3: do not press any key/N "); fflush (stdin); scanf (" % d ", & choise); printf (" choise = % d ", choise); If (choise! = 1 & choise! = 2) {break;} If (choise = 1) {printf ("/N input goods number/N"); fflush (stdin); scanf ("% lD ", & num); While (ptr1! = NULL & ptr1-> num! = Num) {ptr1 = ptr1-> next;} If (ptr1! = NULL) {printf ("the information you want to modify has been found/N"); printf ("goods No.: % LD/n goods name: % s/n goods quantity: % lD ", ptr1-> num, ptr1-> name, ptr1-> count); sleep (2000); System (" CLS "); printf ("/n enter the information you want to modify here/N"); printf ("/n enter the modified product number:/N"); fflush (stdin ); scanf ("% lD", & ptr1-> num); printf ("/n enter the modified product name:/N"); fflush (stdin ); gets (ptr1-> name); printf ("/N input:/N"); fflush (stdin); scanf ("% lD ", & ptr1-> count);} else {printf ("the product number you entered does not exist/N");} // C Hoise = 1if (choise = 2) {printf ("/N input goods name/N"); fflush (stdin); gets (name); // while (ptr1! = NULL & strcmpi (ptr1-> name, name )! = 0) {ptr1 = ptr1-> next;} If (ptr1! = NULL) {printf ("the information you want to modify has been found/N"); printf ("goods No.: % LD/n goods name: % s/n goods quantity: % lD ", ptr1-> num, ptr1-> name, ptr1-> count); sleep (2000); System (" CLS "); printf ("/n enter the information you want to modify here/N"); printf ("/n enter the modified product number:/N"); fflush (stdin ); scanf ("% lD", & ptr1-> num); printf ("/n enter the modified product name:/N"); fflush (stdin ); gets (ptr1-> name); printf ("/N input:/N"); fflush (stdin); scanf ("% lD ", & ptr1-> count);} else {printf ("the name of the product you entered does not exist/N");} // ch Oise = 2 printf ("whether to continue modifying (yes/no)/n"); fflush (stdin); gets (key) ;}while (strcmpi (key, "Yes") = 0); printf ("/n pay attention to save/N"); printf ("/n press any key to return/N"); getch (); return head;} com * pass () {char key [4]; int choise; int select; long temp; head = openfile (); fflush (stdin ); if (Head = NULL) {return NULL;} do {system ("CLS"); ptr1 = head; ptr2 = head-> next; printf ("1: sort by product number/N2: sort by product quantity/N3: do not perform any operation by any key/N "); fflush (stdin); scanf (" % d ", & choise ); If (choise! = 1 & choise! = 2) {break;} If (choise = 1) {system ("CLS"); printf ("1. sort by size/N2. sort by size/N "); fflush (stdin); scanf (" % d ", & select ); if (select = 1) {While (ptr1! = NULL) {While (ptr2! = NULL) {If (ptr1-> num> ptr2-> num) {temp = ptr1-> num; ptr1-> num = ptr2-> num; ptr2-> num = temp;} ptr2 = ptr2-> next;} // while ptr2ptr1 = ptr1-> next; If (ptr1-> next = NULL) {break ;} elseptr2 = ptr1-> next;} // while ptr1} // sort by size if (select = 2) {While (ptr1! = NULL) {While (ptr2! = NULL) {If (ptr1-> num <ptr2-> num) {temp = ptr1-> num; ptr1-> num = ptr2-> num; ptr2-> num = temp;} ptr2 = ptr2-> next;} // while ptr2ptr1 = ptr1-> next; If (ptr1-> next = NULL) {break ;} elseptr2 = ptr1-> next;} // while prt1} // sort printf in ascending order ("sorting completed! /N ");} // choise = 1if (choise = 2) {system (" CLS "); printf (" 1. sort by size/N2. sort by size/N "); fflush (stdin); scanf (" % d ", & select ); if (select = 1) {While (ptr1! = NULL) {While (ptr2! = NULL) {If (ptr1-> count> ptr2-> count) {temp = ptr1-> count; ptr1-> COUNT = ptr2-> count; ptr2-> COUNT = temp;} ptr2 = ptr2-> next;} // while ptr2ptr1 = ptr1-> next; If (ptr1-> next = NULL) {break ;} elseptr2 = ptr1-> next;} // while ptr1} // sort by size if (select = 2) {While (ptr1! = NULL) {While (ptr2! = NULL) {If (ptr1-> count <ptr2-> count) {temp = ptr1-> count; ptr1-> COUNT = ptr2-> count; ptr2-> COUNT = temp;} ptr2 = ptr2-> next;} // while ptr2ptr1 = ptr1-> next; If (ptr1-> next = NULL) {break ;} elseptr2 = ptr1-> next;} // while prt1} // printf ("the sorting operation is completed! /N ");} // choise = 2 printf ("/n whether to continue sorting! (Yes/No)/n "); fflush (stdin); gets (key);} while (! Strcmpi (key, "yes"); printf ("/n pay attention to save/N"); printf ("/n press any key to return/N"); getch (); return head;} void save (COM * head) {system ("CLS"); fflush (stdin); printf ("/ninput filename1/N"); fflush (stdin ); gets (filename1); If (FP = fopen (strcat (filename1, filename2), "WB") = NULL) {printf ("cannot file! /N "); return;} ptr1 = head; fflush (stdin); rewind (FP); While (ptr1! = NULL) {If (! Fwrite (ptr1, Len, 1, FP) {printf ("input to file false! /N "); return;} ptr1 = ptr1-> next;} fclose (FP); printf (" Save OK! /N "); printf (" press any key to return/N "); getch ();} void printf_perf () {system (" CLS "); fflush (stdin ); head = openfile (); int I = 1; if (Head = NULL) {return;} fflush (stdin); ptr2 = head; while (ptr2! = NULL) {printf ("/nnum: % LD/tname: % S/tcount: % LD/N", ptr2-> num, ptr2-> name, ptr2-> count); ptr2 = ptr2-> next; I ++; If (I/15 = 1) {printf ("input any key to look next page/N"); getch (); System ("CLS"); I = 1 ;}} printf ("return by any key/N"); getch ();} void search () {system ("CLS"); fflush (stdin); int choise; long num; char name [20]; head = openfile (); ptr1 = head; printf ("input you can search goods's num or name! /N "); printf (" 1. Input num/n2.input name/n3.press any key to return "); printf ("/ninput you choise! /N "); fflush (stdin); scanf (" % d ", & choise); If (choise = 1) {printf (" input num! /N "); fflush (stdin); scanf (" % lD ", & num); While (ptr1-> num! = Num & ptr1-> next! = NULL) {// ptr2 = ptr1; ptr1 = ptr1-> next; // n = n + 1;} If (ptr1! = NULL) {printf ("find data! /N "); sleep (1000); System (" CLS "); printf (print );} else {printf ("in database can not find you input data/N") ;}} if (choise = 2) {printf ("input name/N "); fflush (stdin); gets (name); While (strcmpi (ptr1-> name, name )! = 0 & ptr1-> next! = NULL) {// ptr2 = ptr1; ptr1 = ptr1-> next; // n = n + 1;} If (ptr1! = NULL) {printf ("find data! /N "); sleep (1000); System (" CLS "); printf (print);} else {printf (" in database can not find you input name! /N ") ;}}// printf (" press any key to return/N "); getch () ;}com * openfile () {system (" CLS "); int n = 1; printf ("input filename1:/N"); fflush (stdin); gets (filename1); If (FP = fopen (strcat (filename1, filename2 ), "rb") = NULL) {printf ("can not open file! /N "); getch (); Return (null);} If (! (Ptr2 = ptr1 = (COM *) malloc (LEN) {printf ("memory assign false! /N "); getch (); Return (null);} If (! Fread (ptr1, Len, 1, FP) {printf ("can not read in file/N"); getch (); Return (null );} if (ptr1-> next = NULL) {head = ptr1;} else {do {If (n = 1) {head = ptr1 ;} else {ptr2-> next = ptr1;} n = n + 1; ptr2 = ptr1; If (! (Ptr1 = (COM *) malloc (LEN) {printf ("memory assign false! /N "); getch (); Return (null);} If (! Fread (ptr1, Len, 1, FP) {printf ("can not read in file/N"); getch (); Return (null );}} while (ptr1-> next! = NULL); ptr2-> next = ptr1;} fclose (FP); // printf ("return by any key/N"); // getch (); return head ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.