Advertisement
Guest User

project

a guest
Jul 20th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.83 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4. #include<stdlib.h>   //for using styme("CLS")
  5. #define ENTER 13
  6. #define BKSP 8
  7. //subfunction diclaration
  8. void login();
  9. void menu();
  10. struct data
  11. {
  12.     int phone,batch;
  13.     char name [100];
  14.     char email[100];
  15.     char blood_group[10];
  16.  
  17. } entry;
  18.  
  19. //char query[20],name[20];
  20. // FILE *fp,*ft;
  21. // int i,n,l,found;
  22. int main()
  23. {
  24.  
  25.     login();       // call login function
  26.     return 0;
  27. }
  28. void login()
  29. {
  30.     int i;
  31.     char password[100],ch;
  32.     char username[100];
  33.     printf("\n\n\t\t*************************************************\n\t\t*\t\t\t\t\t\t*\n\t\t*\tENTER YOUR USERNAME AND PASSWORD\t*\n\t\t*\t\t\t\t\t\t*\n\t\t*************************************************\n");
  34.     printf("\n\t\t\tUSERNAME:");
  35.     scanf("%s",&username);
  36.     printf("\n\t\t\tPASSWORD:");
  37.  
  38.     for(i=0; i<100; i++)      //loop for password input
  39.  
  40.     {
  41.         ch = getch();       //getch don't showing input from user
  42.         if(ch==ENTER)
  43.         {
  44.             break;
  45.         }
  46.  
  47.         else
  48.         {
  49.             password[i] = ch;
  50.             ch = '*' ;
  51.             printf("%c",ch);
  52.         }
  53.  
  54.     }
  55.  
  56.     password[i] = '\0';       //in string last character is a null character
  57.     if(strcmp(username,"abc")==0)   // strcmp for compearision
  58.     {
  59.  
  60.  
  61.         if(strcmp(password,"123")==0)
  62.         {
  63.             getch();                   // getch is used to hold the window
  64.             system("CLS");
  65.             printf("\n\n\t\tSUCCESSFULLY LOG IN......");
  66.             printf("\n\n\t\tPress Any Key To Countinue..... ");
  67.             getch();
  68.             system("CLS");
  69.             menu();   // call menu function
  70.         }
  71.         else
  72.         {
  73.             printf("\n\n\t\tPlease Enter Correct Password.....");
  74.             printf("\n\n\t\tPress Any Key To Countinue..... ");
  75.             getch();
  76.             system("CLS"); //system("CLS") using for clear screen
  77.             login();    // call login function
  78.         }
  79.  
  80.  
  81.     }
  82.     else
  83.     {
  84.         printf("\n\n\t\tPlease Enter Correct Username.....");
  85.         printf("\n\n\t\tPress Any Key To Countinue..... ");
  86.         getch();
  87.         system("CLS");
  88.         login();  // call login function
  89.     }
  90.  
  91.  
  92.  
  93.  
  94. }
  95.  
  96. void menu()
  97. {
  98.     int choise,quite;
  99.     FILE *fp,*ft;
  100.     int i,n,l,found;
  101.     printf("\n\n\t\t   ======WELCOME TO BLOOD GROUP MANAGEMENT======\n");
  102.     printf("\n\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*\n\t\t\t*\t     Main Menu      \t*\n\t\t\t*\t\t\t\t*\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*");
  103.     printf("\n\t\t\t*\t  [1]Data Entry\t\t*\n");
  104.     printf("\t\t\t*\t  [2]All List\t\t*\n");
  105.     printf("\t\t\t*\t  [3]Search\t\t*\n");
  106.     printf("\t\t\t*\t  [4]Delete\t\t*\n");
  107.     printf("\t\t\t*\t  [5]About Us\t\t*\n");
  108.     printf("\t\t\t*\t  [6]Exit\t\t*\n\t\t\t*\t\t\t\t*\n");
  109.     printf("\t\t\t*********************************\n\n");
  110.     printf("\t\t\t\tChoise Any Number: ");
  111.  
  112.     scanf("%d",&choise);
  113.  
  114.     switch(choise)
  115.     {
  116.  
  117.     case 6:
  118.         system("CLS");
  119.         printf("\n\n\n\t\t\t*********************************\n\t\t\t*\t   Are you sure?\t*\n\t\t\t*********************************\n\t\t\t*\t[1]YES   *\t[2]NO   *\n\t\t\t*********************************");
  120.         printf("\n\n\t\t\tChoise Any Number: ");
  121.         scanf("%d",&quite);
  122.         if(quite==1)
  123.         {
  124.             system("CLS");
  125.             printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
  126.             break;
  127.         }
  128.         else if(quite==2)
  129.         {
  130.  
  131.             system("CLS");
  132.             menu();       // call menu function
  133.         }
  134.         else
  135.         {
  136.             printf("\n\n\t\t\tInvalid....\n\n ");
  137.             getch();
  138.             system("CLS");
  139.             menu();                     //if invalid go to menu
  140.  
  141.  
  142.         }
  143.         break;
  144.     case 1:
  145.         system("CLS");
  146.         fp=fopen("bloodgroup.txt","a");                //open a text file name bloodgroup.txt
  147.         printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
  148.  
  149.         while(1)
  150.         {
  151.             fflush(stdin);                               //fflush(stdin) using for clear buffer memory
  152.             printf("\n\t\t(to exit enter a blank space in name option)");
  153.             printf("\n\n\t\t\tName:");
  154.             gets(entry.name);
  155.             if( strcmp(entry.name," ")==0)
  156.             {
  157.                 break;
  158.             }
  159.             fflush(stdin);
  160.             printf("\t\t\tBlood Group:");
  161.             gets(entry.blood_group);
  162.             fflush(stdin);
  163.             printf("\t\t\tBatch:");
  164.             scanf("%d",&entry.batch);
  165.             fflush(stdin);
  166.             printf("\t\t\tPhone:");
  167.             scanf("[%d",&entry.phone);
  168.             fflush(stdin);
  169.             printf("\t\t\tEmail:");
  170.             gets(entry.email);
  171.             fflush(stdin);
  172.             fwrite(&entry,sizeof(entry),1,fp);             //fwrite for written all entry in file
  173.             system("CLS");
  174.             printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
  175.         }
  176.         printf("\n\n\n\t\t\t(Press [1]exit or [2]menu)");
  177.          printf("\n\n\t\t\tChoise Any Number: ");
  178.         scanf("%d",&quite);
  179.         if(quite==1)
  180.         {
  181.             system("CLS");
  182.             printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
  183.             break;
  184.         }
  185.         else if(quite==2)
  186.         {
  187.  
  188.             system("CLS");
  189.             menu();       // call menu function
  190.         }
  191.         else
  192.         {
  193.             printf("\n\n\t\t\tPlease Enter Valid Option....\n\n ");
  194.             getch();
  195.             system("CLS");
  196.             menu();
  197.  
  198.         fclose(fp);                                         //closing file
  199.         break;
  200.     case 5:
  201.         system("CLS");
  202.          printf("\n\n\t\tINFORMATION ABOUT GROUP 404 NOT FOUND\n\t===========================================================");
  203.          printf("\n\t\tName:Md.Mahedi Hasan\n\t\tID:181-15-10900\n\t\tSECTION:D\n");
  204.          printf("\n\t\tName:Sajib Ahmed\n\t\tID:181-15-10874\n\t\tSECTION:D\n");
  205.          printf("\n\t\tName:Mohd.Mehedi Hasan Joy\n\t\tID:181-15-10628\n\t\tSECTION:D\n");
  206.          printf("\n\t\tName:Akkhar Ulok\n\t\tID:181-15-11207\n\t\tSECTION:D");
  207.          printf("\n\n\t\t\tThis is an c project\n\t===========================================================");
  208.          printf("\n\t\t\tPress any key to continue....");
  209.          getch();
  210.           system("CLS");
  211.          menu();
  212.          break;
  213.  
  214.  
  215.  
  216.     default:
  217.  
  218.         printf("\n\t\t\tPlease Enter Valid Option....");
  219.         printf("\n\t\t\tPress any key to continue....");
  220.         getch();
  221.         system("CLS");
  222.         menu();
  223.         break;
  224.     }
  225.  
  226.  
  227.  
  228. }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement