⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 190.c

📁 C++游戏开发书籍的实例非常适合初学但又又想往游戏开发方面发展的人学习哦
💻 C
📖 第 1 页 / 共 2 页
字号:
		design();
		gotoxy(20,10);
		printf("Record has been deleted");
		gotoxy(20,12);
		printf("Check it by going to the displayed record");
		gotoxy(17,23);
		printf("Press Enter to go to MAIN MENU ......");
		getch();


}
  void print()
  {


   clrscr();
  putc('\n',stdprn);
  fputs("\n\t\t\tREPRT OF SALES",stdprn);
  putc('\n',stdprn);
  fputs("===========================",stdprn);
  putc('\n',stdprn);
  putc('\n',stdprn);
  fputs("PRODUCT ID.    NAME.     SALE PRICE.     QUANTITY.    TOTAL  PRICE",stdprn);
  fputs("===================================================================",stdprn);
  putc('\n',stdprn);
  putc('\n',stdprn);

  ptr=fopen("shop.dat","rb");
  while( (fread(&temp,sizeof(temp),1,stdprn))==1)

  {
     fprintf(stdprn," %s",temp.id);
     fprintf(stdprn,"\t%s",temp.desc);
     fprintf(stdprn,"\t%.2f",temp.sale);
     fprintf(stdprn,"\t%ld\n",temp.quantity);
     fprintf(stdprn,"\t%.2f",temp.total);
  }
  fclose(ptr);
 }


void help()
{
  clrscr();
     design();
     textcolor(WHITE);
     gotoxy(20,4);
     cprintf("\xDB\xDB\xDB\xDB\xB2  HELP ABOUT THE PROGRAM  \xB2\xDB\xDB\xDB\xDB");
     gotoxy(4,6);
     cprintf(" [ 2 ] - ENTER  RECORDS : THIS OPTION ALLOWS THE USER TO ENTER NEW ");
     gotoxy(30,7);
     cprintf("RECORDS. USER ENTERS PRODUCT ID, DESCRIPTION,");
     gotoxy(30,8);
     cprintf("QUANTITY AND UNIT PRICE. THE PROGRAMM CALCULATES");
     gotoxy(30,9);
     cprintf("TOTAL PRICE AND DISPLAYS ON THE SCREEN.");
     gotoxy(4,11);
     cprintf(" [ 3 ] - ENTER SALES    :  THIS OPTION ALLOWS THE USER TO SEE PREVIOUS ");
     gotoxy(30,12);
     cprintf("SALE RECORDS.");
     gotoxy(4,14);
     cprintf(" [ 4 ] - SEARCH PURCHASE : THIS OPTION ALLOWS THE USER TO SEARCH SPECIFIC");
     gotoxy(30,15);
     cprintf("RECORD BY ENTERING ID OR 'DESCRIPTION'");
     gotoxy(4,17);
     cprintf(" [ 5 ] - DELETE PURCHASE : THIS OPTION ALLOWS THE USER TO DELETE A SPECIFIC");
     gotoxy(30,18);
     cprintf("RECORD BY ENTERING ITS 'DESCRIPTION' OR ID");
     gotoxy(6,23);
     cprintf("Press any key to continue .............");

     getche();
     clrscr();
      design();
      textcolor(WHITE);
      gotoxy(4,5);
     cprintf(" [ 6 ] - VIEW REPORT  :   THIS OPTION ALLOWS THE USER TO PRINT PREVIOUS");
     gotoxy(30,6);
     cprintf("SALE RECORDS ON PRINTER");
     gotoxy(4,8);
     cprintf(" [ 7 ] - PRINT RECORDS :  THIS OPTION ALLOWS THE USER TO PRINT RECORDS");
     gotoxy(30,9);
     cprintf("OM PRINTER.");
     gotoxy(4,11);
     cprintf(" [ 8 ] - VIEW GRAPH     :  THIS OPTION ALLOWS THE USER TO VIEW GRAPH ");
     gotoxy(30,12);
     cprintf("OF QUANTITY.");
     gotoxy(10,23);
     printf("Press any key to go to the MAIN MENU ........");

 getche();
}


 menu()
{
 int x;
  do{
       {
	clrscr();
	design();
	t();
	textcolor(WHITE);
	gotoxy(24,3);
	cprintf("\xDB\xDB\xDB\xDB\xB2  SAM'S DEPARTMANTAL STORE  \xB2\xDB\xDB\xDB\xDB");
	gotoxy(3,4);
	cprintf("--------------------------------------------------------------------------");
	gotoxy(35,5);
	cprintf("MAIN MENU");
	gotoxy(26,8);
	cprintf(" 1  -   INFORMATION ABOUT PRODUCTS            ");
	gotoxy(26,9);
	cprintf(" 2  -   ENTER  PURCHASE  RECORDS            ");
	gotoxy(26,10);
	cprintf(" 3  -   ENTER PRODUCTS TO BE SALE           ");
	gotoxy(26,11);
	cprintf(" 4  -   SEARCH FOR RECORD                     ");
	gotoxy(26,12);
	cprintf(" 5  -   DELETE RECORD FROM STORE DATABASE     ");
	gotoxy(26,13);
	cprintf(" 6  -   VIEW SALES , PURCHASE & PROFIT REPORT ");
	gotoxy(26,14);
	cprintf(" 7  -   PRINT RECORDS                         ");
	gotoxy(26,15);
	cprintf(" 8  -   BAR  GRAPH OF QUANTITY / PROFIT       ");
	gotoxy(26,16);
	cprintf(" 9  -   RETRIEVE INFORMATION         ");
	gotoxy(26,17);
	cprintf(" H  -   HELP                                  ");
	gotoxy(26,18);
	cprintf(" E  -   EXIT                                  ");
	gotoxy(26,23);
	cprintf("ENTER YOUR CHOICE :: ");
	gotoxy(47,23);
	x=toupper(getch());
	switch(x)
	{
	case '1':
	infor();
	break;

	case '2':
	entry();
	break;

	case '3':
	edit();
	break;

	case '4':
	search();
	break;

	case '5':
	del();
	break;

	case '6':
	report2();
	break;

	case '7':
	print();
	break;

	case 'h': case'H':
	help();
	break;

	case'8':
	graph1();
	break;

	case '9':
	display();
	break;

	case 'e': case 'E':
	exit(0);
	break;

	default:
	clrscr();
	design();
	gotoxy(17,12);
	printf("\a\xDB\xB2  WRONG ENTRY : PRESS ANY KEY AND TRY AGAIN");
	getche();
	}
      }
    }while((x!='e')||(x!='E'));
return x;
}


void main()
{
textbackground(14);
show_mouse();
menu();
}

void graph()
{
  int inscor=1;
  char ch;
  clrscr();
  design();
  gotoxy(20,23);
  printf("Press enter to go to MAIN MENU .....");
  textcolor(10);
  gotoxy(15,4);
  cprintf("************* GRAPH OF PRODUCT QUANTITY *************");
  textcolor(14);
  gotoxy(3,5);
  cprintf(" PRODUCT NAME");
  ptr=fopen("shop.dat","rb");
  while((fread(&temp,sizeof(temp),1,ptr))==1)
     {

     printf("\n \xBA %s   \t:",temp.desc);
     bar(inscor);

   }

  fclose(ptr);
getche();
}
void bar()
{
int j;
for(j=1;j<=temp.quantity;j++)
printf("\xDB");
printf(" %d",temp.quantity);
printf("\n");
}
void report()
{
  char ch;
  clrscr();
  design();
  gotoxy(20,23);
  printf("Press Enter to go to MAIN MENU ........");
  textcolor(GREEN);
  gotoxy(25,4);
  cprintf("\xDB\xDB\xDB\xDB\xDB\xB2 VIEW OF SALES  \xB2\xDB\xDB\xDB\xDB\xDB");
  textcolor(RED);
  gotoxy(4,7);
  cprintf("PRODUCT ID.    NAME.     SALE PRICE.     QUANTITY.    TOTAL  PRICE");
  gotoxy(4,9);
  printf("========================================================================");

  ptr=fopen("shop.dat","rb");
  while((fread(&temp,sizeof(temp),1,ptr))==1)

     {
      printf("\n \xBA %s\t",temp.id);
      printf("\t%s",temp.desc);
      printf("\t\t$%.2f",temp.sale);
      printf("\t\t%d",temp.quantity);
      printf("\t\t $%.2f",temp.total);

       }

getche();
}
void seteffect(int b, int f)
{
   clrscr();
   textbackground(b);
   textcolor(f);
}


void pur()
{
 char ch;
  clrscr();
  design();
  show_mouse();
  gotoxy(20,23);
  printf("Press Enter to go to MAIN MENU ...........");
  textcolor(GREEN);
  gotoxy(25,4);
  cprintf("\xDB\xDB\xDB\xDB\xDB\xB2 VIEW OF PURCHASES  \xB2\xDB\xDB\xDB\xDB\xDB");
  textcolor(RED);
  gotoxy(4,7);
  cprintf("PRODUCT ID.    NAME.     UNIT PRICE.     QUANTITY.       TOTAL  COST");
  gotoxy(4,9);
  printf("========================================================================");

  ptr=fopen("shop.dat","rb");
  while((fread(&temp,sizeof(temp),1,ptr))==1)
     {
      printf("\n \xBA %s\t\t",temp.id);
      printf(" %s",temp.desc);

      printf("\t\t$%.2f",temp.unit);
      printf("\t\t%d",temp.quantity);
      printf("\t\t $%.2f",temp.cost);
       }
getche();
}


void graph2()
{
  int inscor2=1;
  char ch;
  clrscr();
  design();
  gotoxy(20,23);
  printf("Pres Enter to go to MAIN MENU ...........");
  textcolor(10);
  gotoxy(15,4);
  cprintf("************* GRAPH OF PROFIT *************");
  textcolor(14);
  gotoxy(4,5);
  cprintf("PRODUCT NAME");
  ptr=fopen("shop.dat","rb");
  while((fread(&temp,sizeof(temp),1,ptr))==1)
     {

     printf("\n \xBA %s  \t:",temp.desc);
     bar2(inscor2);

   }

  fclose(ptr);
getche();
}
void bar2()
{
int j;
temp.profit=(temp.total-temp.cost);
for(j=1;j<=temp.profit;j++)
printf("\xDB");
printf(" %.1f$",temp.profit);
printf("\n");
}



void graph1()
{
      int sher;
      clrscr();
      textcolor(WHITE);
      gotoxy(24,3);
      printf("\xDB\xDB\xDB\xDB\xB2  BAR GRAPH   \xB2\xDB\xDB\xDB\xDB");
      gotoxy(10,5);
      printf("THIS SECTION IS TO show the graph of quantity and profit ");
      printf("\n\n\t   *********  ENTER THE OPTION WHICH SUITS YOU. *******\n");
      printf("\n\n\t\xDB\xDB\xB2  1.QUANTITY.\n\n");
      printf("\n\t\xDB\xDB\xB2  2.PROFIT.\n");
      printf("\n\n\n\t\t\xDB\xDB\xB2  OPTION:");
      sher=toupper(getch());

  switch(sher)
  {
      case '1':
      graph();
      break;

      case '2':
      graph2();
      break;

      default:
      gotoxy(9,20);
      textcolor(RED);
      cprintf("\a\xDB\xB2 WRONG ENTRY : PRESS ENTER TO GO TO MAIN MENU... ");
      getche();
      }

 }

void report3()
{
 char ch;
  clrscr();
  design();
  gotoxy(20,23);
  printf("Press Enter to go to MAIN MENU .... ");
  textcolor(GREEN);
  gotoxy(25,4);
  cprintf("\xDB\xDB\xDB\xDB\xDB\xB2 VIEW OF PROFIT  \xB2\xDB\xDB\xDB\xDB\xDB");
  textcolor(RED);
  gotoxy(4,7);
  cprintf("PRODUCT ID.      DESCRIPTION.      QUANTITY.         PROFIT.");
  gotoxy(4,9);
  printf("============================================================");

  ptr=fopen("shop.dat","rb");
  while((fread(&temp,sizeof(temp),1,ptr))==1)
     {

      printf("\n \xBA   %s.",temp.id);
      printf("\t\t%s",temp.desc);
      printf("\t\t%d",temp.quantity);
      temp.profit=(temp.total-temp.cost);
      printf("\t\t $%.2f",temp.profit);

       }
getche();
}


void report2()
{

int sher;
      clrscr();
      bbox();
      textcolor(WHITE);
      gotoxy(21,3);
      printf("\xDB\xDB\xDB\xDB\xB2  REPORT OF SALES / PURCHASE  \xB2\xDB\xDB\xDB\xDB");
      gotoxy(5,5);
      printf("\tTHIS SECTION IS VIEWING SALES, PURCHASE and PROFIT REPORTS ");
      gotoxy(10,7);
      printf("  *********  ENTER THE OPTION WHICH SUITS YOU. **********\n");
      gotoxy(12,10);
      printf("\xDB\xDB\xB2  1.SALES.");
      gotoxy(12,12);
      printf("\xDB\xDB\xB2  2.PURCHASE.");
      gotoxy(12,14);
      printf("\xDB\xDB\xB2  3.PROFIT.");
      gotoxy(14,17);
      printf("\xDB\xDB\xB2  OPTION:");
      sher=toupper(getch());


  switch(sher)
  {
      case '1':
      report();
      break;

      case '2':
      pur();
      break;

      case '3':
      report3();
      break;

      default:
	gotoxy(9,20);
	textcolor(RED);
	cprintf("\a\xDB\xB2  WRONG ENTRY : PRESS ENTER TO GO TO MAIN MENU....");
	getche();

    }

 }



void design()
{
int i;
clrscr();
	textcolor(14);
	gotoxy(2,2);
	cprintf("\xC9");
	gotoxy(3,2);
       for(i=1;i<=74;i++)
       cprintf("\xCD");
	gotoxy(77,2);
	cprintf("\xBB");
	gotoxy(2,3);
	cprintf("\xBA");gotoxy(2,4);cprintf("\xBA");gotoxy(2,5);cprintf("\xBA");
	gotoxy(2,6);cprintf("\xBA");gotoxy(2,7);cprintf("\xBA");gotoxy(2,8);cprintf("\xBA");
	gotoxy(2,9);cprintf("\xBA");gotoxy(2,10);cprintf("\xBA");gotoxy(2,11);cprintf("\xBA");gotoxy(2,12);cprintf("\xBA");
	gotoxy(2,13);cprintf("\xBA");gotoxy(2,14);cprintf("\xBA");gotoxy(2,15);cprintf("\xBA");gotoxy(2,16);cprintf("\xBA");
	gotoxy(2,17);cprintf("\xBA");gotoxy(2,18);cprintf("\xBA");gotoxy(2,22);cprintf("\xCC");

	gotoxy(2,19);cprintf("\xBA");gotoxy(2,20);cprintf("\xBA");gotoxy(2,21);cprintf("\xBA");gotoxy(2,24);cprintf("\xC8");
	gotoxy(2,23);cprintf("\xBA");
	gotoxy(3,24);
	for(i=1;i<=74;i++)
	cprintf("\xCD");
	gotoxy(77,18);cprintf("\xBA");gotoxy(77,19);cprintf("\xBA");gotoxy(77,20);cprintf("\xBA");gotoxy(77,21);cprintf("\xBA");gotoxy(77,24);cprintf("\xBC");
	gotoxy(77,23);
	cprintf("\xBA");
	gotoxy(3,22);
	for(i=1;i<=74;i++)
	cprintf("\xCD");
	gotoxy(77,22);
	cprintf("\xB9");
	gotoxy(77,3);
	cprintf("\xBA");gotoxy(77,4);cprintf("\xBA");gotoxy(77,5);cprintf("\xBA");
	gotoxy(77,6);cprintf("\xBA");gotoxy(77,7);cprintf("\xBA");gotoxy(77,8);cprintf("\xBA");
	gotoxy(77,9);cprintf("\xBA");gotoxy(77,10);cprintf("\xBA");gotoxy(77,11);cprintf("\xBA");gotoxy(77,12);cprintf("\xBA");
	gotoxy(77,13);cprintf("\xBA");gotoxy(77,14);cprintf("\xBA");gotoxy(77,15);cprintf("\xBA");gotoxy(77,16);cprintf("\xBA");
	gotoxy(77,17);cprintf("\xBA");
       textcolor(RED);

}

void bbox()
{
	int c,r;
	for(c=1;c<=79;c++)
	{
		gotoxy(c,1);
		printf("

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -