示例#1
0
void addbook(int flag)
{
textcolor(WHITE);
input(6+18,8+2,book.name,30);
input(6+18,8+4,book.author,30);
input(6+18,8+6,book.pub,30);
input(6+18,8+8,book.edition,5);
input(6+18,8+10,book.isbn,30);

input(6+18,8+16,book.lc,5);
input(6+18,8+18,book.accno,15);
input(6+18,8+20,book.bookno,15);

input(6+18,8+26,book.issue_to,20);
input(6+18,8+28,book.issue_date,11);
input(6+18,8+30,book.due_date,11);

for(;;)
{
status("IS THE ENTRY CORRECT (Y/N/C):");
	ch=tolower(getch());
	if (ch=='y'|| ch==13)
	{
		if(flag==1)
		  {
		  if((truefalse=writebook(1))==1) //data written to file by call to ADD records
		  {
		  maxrec++;
		  status("Thanks, Book Added.");
		  break;
		  }
		  }
		 else if(flag==2)
		  {
		 if((truefalse=writebook(2))==2) //data written to file by call to EDIT records
		  {
		  status("Thanks, Book Edited.");
		  break;
		  }
		 }
	}
	else if(ch=='n')
		{status("Please re-enter the info.");
		if(flag==1) addbook(1); else if(flag==2) addbook(2);
		}
	else if (ch==27||ch=='c'){recno=recold;status("Entry cancelled!");break;}
	else
		{count++;
		if (count>=3)
		status("It's Not In the choice.");
		}
}//For Loop
}
示例#2
0
文件: 189.c 项目: bearjb/studyc
void main()
{
   int ch,ch1,ch2,ch3;
   fm=fopen("member.dat","a+");
   ft=fopen("trans.dat","a+");
   fb=fopen("book.dat","a+");

   mainscr();

   while(1)
   {
    bk:
    showmenu(mainmenu,5,10,35);
    ch=getchoice(mainmenu,"MBRHE",10,35,5);
   switch(ch)
   {
    case 1:bk1:
	   showmenu(memmenu,4,10,35);
	   ch1=getchoice(memmenu,"ARIB",10,35,4);
	   switch(ch1)
	   {
	     case 1: addmember(); goto bk1;
	     case 2: renewmem();  goto bk1;
	     case 3: memdupid();  goto bk1;
	     case 4: goto bk;
	   }
	   break;
    case 2:bk2:
	   showmenu(bookmenu,4,10,35);
	   ch2=getchoice(bookmenu,"AIRB",10,35,4);
	   switch(ch2)
	   {
	     case 1: addbook(); goto bk2;
	     case 2: issbook(); goto bk2;
	     case 3: retbook(); goto bk2;
	     case 4: goto bk;
	   }
	   break;
    case 3:bk3:
	   showmenu(rptmenu,4,10,35);
	   ch3=getchoice(rptmenu,"MBTB",10,35,4);
	   switch(ch3)
	   {
	     case 1: allmem(); goto bk3;
	     case 2: allbook();goto bk3;
	     case 3: alltransac();goto bk3;
	     case 4: goto bk;
	   }
	   break;
    case 4:
	   showhelp(); break;
    case 5:fclose(ft); fclose(fm); fclose(fb);
	   exit();
   }
  }
}
示例#3
0
int main()
{
	int ch1,ch2,ch3=1;
	long int ids;
	printf("\nWelcome to Lybrari!!\nThis simple library management software is a part of our project to demonstrate the working of the make utility.\n\nMenu:\n****\nPlease select one of the following options\n");
	do
	{
		printf("1: Add/Delete a member\n2: Add/Remove a book from the library\n3: Book Transactions\n");
		scanf("%d",&ch1);
		switch(ch1)
		{
			case 1:
				printf("\nSubmenu:\n*******\n1: Add a member\n2: Delete a member\n");
				scanf("%d",&ch2);
				switch(ch2)
				{
					case 1:
						insert_member();
						break;
					case 2:
						printf("\nEnter the ID of the member to be deleted: ");
						scanf("%ld",&ids);
						delete_member(ids);
						break;
					default: printf("\nWrong input!! Please enter options 1 or 2");
				}
				break;
			case 2:
				printf("\nSubmenu:\n*******\n1: Add a book\n2: Remove a book\n");
				scanf("%d",&ch2);
				switch(ch2)
				{
					case 1:
						addbook();
						break;
					case 2:
						printf("\nEnter the ID of the book to be deleted: ");
	                                        scanf("%ld",&ids);
						delbook(ids);
						break;
					default: printf("\nWrong input!! Please enter options 1 or 2");
				}
				break;
			case 3:
				book_trans();
				break;
			default: printf("\nWrong choice!! Enter a n option between 1 and 3");
		}
		printf("\nDo you want to continue? [1/0]: ");
		scanf("%d",&ch3);
	}while(ch3==1);
}
示例#4
0
int main() {
	int cho;
	char check,c,esc;
	
	system("clear");
	strcpy(filename,"pranav");
	while(1)
	{    	
		system("clear");
		printf(BOLDYELLOW"\n\n\n\n\n\t\t\t\t\t----------------------*******---------------------"RESET);
		printf(BOLDCYAN"\n\n\n\t\t\t\tHello !! Welcome to PRANAV's Library --- choose from the following menu"RESET);
		printf(YELLOW"\n\n\n\t\t\t\t\t1.Add Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t2.Display Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t3.Delete Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t4.Search a Book "RESET);
		printf(YELLOW"\n\n\t\t\t\t\t5.Edit available book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t6.Exit from this menu"RESET);
		printf(BOLDYELLOW"\n\n\n\n\n\t\t\t\t\t----------------------*******---------------------"RESET);
		printf(BOLDCYAN"\n\n\t\t\t\t\t\t Your Choice:"RESET);
		scanf("%d",&cho);
		switch(cho)
		{
			case 1:
					Password();
					addbook();
					break;
			case 2:
					display_book(lib);
					sleep(2);
					break;
			case 3:
					Password();			
					delete_book(lib);
					sleep(2);
					break;
			case 4:
					search(lib);
					sleep(2);
					break;
			case 5:
					Password();
					edit_info(lib);
					break;
			case 6:
					exitp();
			default:
					printf(BOLDRED"\n\t\t\t\tChoose from following choices only \n"RESET);
					printf(RED"\t\t\tEnter 1 2 3 4 5 6 7"RESET);
		}
	}
}
示例#5
0
int editbook(void)
{
char *temp;
strcpy(temp,book.bookno); // Copies current Bookno to temp

rewind(fp); // moves file pointer to beginning
//truefalse=0; //Sets flag to check if record found or not
while(fread(&tmp,rec_size,1,fp)==1)
	{
		if(strcmp(tmp.bookno,temp)==0)
		{
		status("");
		clsview();
		addbook(2);
		return 1;
		}
	}
//if(truefalse==0) //if strcmp didn't found records then comes here
//status("Sorry, book number didn't match with stored one.");
return 0;
}
void addbook()
{
    system("cls");

    fp = fopen ( "quizdata.txt" , "a+" );

    if(getdata()==1)
	{
	fseek(fp,0,SEEK_END);
	fwrite(&add,sizeof(add),1,fp);
	fclose(fp);
	gotoxy(21,14);
	printf("The record is sucessfully saved");
	gotoxy(21,15);
	printf("Save any more?(Y / N):");
	if(getch()=='n')
	    menu();
	else
	    system("cls");
	    addbook();
	}
    exit(0);
}
示例#7
0
/*--This Function is main USER INTERACTING FUNCTION--*/
void mainloop(void)
{
	for(;;)
	{       fflush(stdin);
		ch=tolower(getch());
		if (ch==32) //SPACE DETECTED
		    {
		    if(recno>=0 && recno<maxrec)
		       {
			 if(tabview==0)
				{
				recno++;
				read_data();
				clsview();
				oneatime_show();
				if(recno == maxrec)
				status("Database - Right Boundary.");
				else
				status("<space> Next Record ->");
				}
			 else status("<space> Switch to One a time view.");
		      }
		    }

		else if (ch==13) //Refresh
		    {
		    setscreen();
		    which_view();
		    status("<CR> Data Refreshed.");
		    }

		else if (ch=='t')
		    {
		    if(tabview==0)
		    {
		    recold=recno;
		    tabview=1;
		    }

		    else
		    {
		    tabview=0;
		    }
		    setscreen();
		    which_view();
		    status("<t> Switch between tab/oneatime view.");
		    }
		else if (ch=='a')
		    {  if (view==1 && tabview==0)
		       {
			recold=recno;
			recno=maxrec+1;
			clsview();
			status("<a>  Please Enter the Book Info.");
			addbook(1);
			//setscreen();
			clsview();
			oneatime_show();
			//which_view();
			//status("Press <H> For Immediate Help.");
		       }
		       else if (tabview==1) status("<a> Switch to one-a-time view.");
		    else  status("<a> You ar not ADMIN!!!.");
		    }
		else if (ch=='e') //edit info
		    {
		    if (view==1)
		       {
			status("Please Enter Records To Modify.");
			truefalse=editbook();
			if(truefalse==0) //if strcmp didn't found records then comes here
			status("Sorry, book number didn't match with stored one.");
			}
		       else if (tabview==1) status("<a> Switch to one-a-time view.");
		       else  status("<a> You ar not ADMIN!!!.");

		    }
	       else if (ch=='f') //edit info
		    {
			if (view==1)
			{
			truefalse=searchbook();
			if(truefalse==0) //if strcmp didn't found records then comes here
			status("Sorry, record not match.");
			else  status("<a> You ar not ADMIN!!!.");
			}
		    }
		else if (ch=='d') //delete
		    {
		    /*strcpy(tempo,book.bookno);
		    ft=fopen("temp.sjb","wb");
		    rewind(fp);
		    while(fread(&tmp,rec_size,1,fp)==1)
		    {
		     if(strcmp(tmp.bookno,tempo)!=0)
		      {fwrite(&tmp,rec_size,1,ft);
		      }
		    else  truefalse=0;
		    }
		    fclose(fp);
		    fclose(ft);
		    remove("library.sjb");
		    rename("temp.sjb","library.sjb");
		    fp=fopen("library.sjb","rb+");
		    recno=0;
		    maxrec=0;
		    read_data(); // Reads data at the initialization time to find
		    maxrec--;

		    if(truefalse==0)*/
		    status("<d> Record can't be deleted.");
		    }
		else if(ch=='x') {html(1);}
		else if (ch==27) break;
		else if(ch==0)
				{//i.e ch==0 if extended code,
				ch2 = getch(); // read second code
				if(ch2==59)
				    status("Function key 1");
				else if(ch2==60)
				    status("Function key 2");
				else if(ch2==75)//LEFT ARROW
				    {
					if(recno>0 && recno<=maxrec)
						{
						if(tabview==0)
						{
						recno--;
						read_data();
						clsview();
						oneatime_show();
						if(recno==0)
						status("Database - Left Boundary.");
						else
						status("<l-arrow> <- Previous Record");
						}
						else status("<space> Switch to One a time view.");
						}
				     }
				else if(ch2==77) //Right Arrow
				    {

				    if(recno>=0 && recno<maxrec)
					{
					if(tabview==0)
					{
					recno++;
					read_data();
					clsview();
					oneatime_show();
					if(recno == maxrec)
					status("Database - Right Boundary.");
					else
					status("<r-arrow> Next Record ->");
					}
					else status("<r-arrow> Switch to One a time view.");
					}
				    }
				else if(ch2==80)  //Down arrow <p>
				    {
				    if (tabview==1)
					{
					if(row <13+25 || recno <maxrec)
					{row++;recno++;
					//if (row>=26) row=13;
					bulet(6,row);
					status("<d-arrow> Select Down"); }
					}
				    else if(tabview==0)  status("<d-arrow> Switch to tabular view.");
				    else printer(1);
				    }
				else if(ch2==72)  //up arrow  <h>
				    {
				    if (tabview==1)
					  {if(row>13 && recno >1) {row--;recno--;} else row=13+25;
					  bulet(6,row);
					  status("<u-arrow> Select Up");
					  }
				    else  status("Please do some Hit n Trial First.");
				    }
				else status("Under construction.");
				}//EXTENDED CODE SCANNED
	}//MAIN LOOP OF THE PROGRAMME
}
void  menu()
{
    system("cls");
    gotoxy(20,1);
    printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
//    Sleep(2000);

    int choice;
    gotoxy(20,3);
    printf("\xDB\xDB\xDB\xDB\xB2 1. Search Book\n");
    gotoxy(20,5);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 2. Add Book\n");
    gotoxy(20,7);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 3. Delete Book\n");
    gotoxy(20,9);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 4. View Booklist\n");
    gotoxy(20,11);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 5. Edit Book Records\n");
    gotoxy(20,13);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 6. Change Password\n");
    gotoxy(20,15);//Sleep(1000);
    printf("\xDB\xDB\xDB\xDB\xB2 7. Close Application\n");
    gotoxy(20,17);
    printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");

    gotoxy(20,18);
	tym();

    gotoxy(20,21);
    fflush(stdin);
    printf("Select an option: ");
    scanf("%d", &choice);

    switch(choice)
	{
		case 1:
		searchbook();
		break;
	case 2:
		addbook();
		break;
    case 3:
		deletebook();
	    break;
	case 4:
		viewlistbook();
	    break;
    case 5:
		editbookrecords();
		break;
    case 6:
		passwordChange();
		break;

	case 7:
	    {
		closeapplication();
	    }
	    default:
		{
		gotoxy(10,23);
		printf("\aWrong Entry!!Please re-entered correct option");
		if(getch())
		menu();
		}

    }
    exit(0);
}