Example #1
0
void Student2::set_student2()
{
	set_student();
	cout << "Degree: ";
	string degree;
	cin >> degree;
	set_degree(degree);
	cout << "\n";

	if (get_semester() != 0)
	{
		cout << "Type averages for semesters:\n";
		double *average = new double[get_semester()];
		for (int i = 0; i < get_semester(); i++)
		{
			cout << i + 1 << ". ";
			cin >> average[i];
		}
		set_average(average);
	}
Example #2
0
void Student::info_student()
{
	cout << "register number: " << get_register_no() << ", semester: " << get_semester() << ", major: " << get_major() << ", department: " << get_dept() << "\n\n";
}
Example #3
0
//student menu screen
void studentMenu(char* username) {
    //query
    char q[150] = "\0";
    
    MYSQL_RES *res_set;
    MYSQL_ROW row;
    
    strcat(q, "SELECT name FROM student where id = ");
    strcat(q, username);
    
    mysql_query(connection,q);
    res_set = mysql_store_result(connection);
    
    row = mysql_fetch_row(res_set);
    
    int z;
    int m = 0, y = 0;
    char* semester;
    get_year(&y);
    semester = get_semester(m);
    
    printf("\t\t\t---------------------------------------\n");
    printf("\t\t\t           Student Menu           \n");
    printf("\t\t\t---------------------------------------\n\n");
    printf("\t\t\tHi, %s\n", row[0]);
    
    printf("\n\t\t\t%s, %d\n", semester, y);
    memset(q, 0, sizeof(q));
    
    MYSQL_RES *res_set2;
    MYSQL_ROW row2;
    
    sprintf(q, "select u.UoSName from unitofstudy u, transcript t where u.UoSCode = t.UoSCode and t.Studid = %s and t.Semester = '%s' and t.Year = %d;", username, semester, y);
    //puts(q);
    
    mysql_query(connection,q);
    res_set2 = mysql_store_result(connection);
    int numrows = (int)mysql_num_rows(res_set2);
    
    for (int i = 0; i < numrows; i++)
    {
        row2 = mysql_fetch_row(res_set2);
        if( row2 != NULL )
        {
            printf("\t\t\t%s\n", row2[0]);

        }
    }
    
    printf("\n\t\t\t---------------------------------------\n");
    
    //free?
    if(semester != NULL) {
        //free(semester);
        semester = NULL;
    }
    
    // free resources
    mysql_free_result(res_set);
    mysql_free_result(res_set2);
    
    do
    {
        printf("\t\t\t---------------------------------------\n");
        printf("\t\t\t           Commands List           \n");
        printf("\t\t\t---------------------------------------\n");
        printf("\t\t\t    [1]Transcript               \n");
        printf("\t\t\t    [2]Enroll Class             \n");
        printf("\t\t\t    [3]Withdraw Class           \n");
        printf("\t\t\t    [4]Personal Details         \n");
        printf("\t\t\t    [5]Logout                   \n");
        printf("\t\t\t    [0]Exit                     \n");
        printf("\t\t\t---------------------------------------\n\n");
        printf("Please enter the command: ");
        scanf("%d", &z);
        //system("color 2f");
        switch(z)
        {
            case 0 :return;
            case 1 :transcript(username);break;
            case 2 :enroll(username);break;
            case 3 :withdraw(username);break;
            case 4 :personaldetail(username);break;
            case 5 :logoutStudent(username);break;
            default:printf("\n INVALID COMMAND");
        }
    }
    while( 1 );
}
Example #4
0
//withdraw screen
void withdraw(char * username) {
    printf("\n\t\t\t---------------------------------------\n");
    printf("\t\t\t              Withdraw Class               \n");
    printf("\t\t\t---------------------------------------\n");
    
    int m = 0, y = 0;
    char * semester;
    get_year(&y);
    semester = get_semester(m);

    //print current quarter course list
    printf("\tCurrent Registered classes: \n\n\t%s, %d\n\n", semester, y);
    
    //queryjj
    char q[500] = "\0";
    MYSQL_RES *res_set;
    MYSQL_ROW row;
    
    sprintf(q, "select t.uoscode, u.uosname, t.grade from transcript t, unitofstudy u where t.uoscode = u.uoscode and t.studid = %s and t.semester = '%s' and t.year = %d;",username , semester, y);
    //puts(q);
    mysql_query(connection,q);
    res_set = mysql_store_result(connection);
    int numrows = (int)mysql_num_rows(res_set);
    // Display results

    for (int i = 0; i < numrows; i++)
    {
        row = mysql_fetch_row(res_set);
        
        if( row != NULL )
        {
            printf("\t%s ", row[0]);
            printf("\t%-40s ", row[1]);
            printf("\t%s\n", row[2]);
            
        }
    }
    //free resources
    mysql_free_result(res_set);
    
    char z[20];
    do {
        printf("\n\t\t\t---------------------------------------\n");
        printf("\t\t\t           Commands List           \n");
        printf("\t\t\t---------------------------------------\n");
        printf("\t\t\t  [course number]Withdraw a class\n");
        printf("\t\t\t  [0]Back to main menu                 \n");
        printf("\t\t\t---------------------------------------\n\n");
        printf("Please enter the command: ");
        scanf("%s", z);
        //system("color 2f");
        if(strcmp(z, "0") == 0) {
            //studentMenu(username);
            
            break;
        }
        else {
            
        //call procedure withdraw here
            memset(q, 0, sizeof(q));
            MYSQL_RES *res_set2;
            MYSQL_ROW row2;
            sprintf(q, "call withdraw(%s, '%s', '%s', %d);", username, z, semester, y);
            //puts(q);
            mysql_query(connection,q);
            res_set2 = mysql_store_result(connection);
            int numrows2 = (int)mysql_num_rows(res_set);
            // Display results
            
            for (int i = 0; i < numrows2; i++)
            {
                row2 = mysql_fetch_row(res_set2);
                
                if( row2 != NULL )
                {
                    printf("\t%s\n", row2[0]);
 
                }
            }

            //free resources
            mysql_free_result(res_set2);
        }
    }
    while(1);
}
Example #5
0
//enroll screen
void enroll(char * username) {
    printf("\n\t\t\t---------------------------------------\n");
    printf("\t\t\t              Enroll Class               \n");
    printf("\t\t\t---------------------------------------\n");
    
    int m = 0, y = 0;
    char * semester;
    char * next_semester;
    
    get_year(&y);
    semester = get_semester(m);
    next_semester = get_next_semester(m);
    int y_next_semester = get_yearofnextsemester(y, semester);
    //print current quarter course list
    printf("\tCurrent Quarter: %s, %d\n\n", semester, y);
    
    //query
    char q[500] = "\0";
    MYSQL_RES *res_set;
    MYSQL_ROW row;
    
    sprintf(q, "select u.UoSCode, u.UoSName, o.Enrollment, o.MaxEnrollment,u.Credits from uosoffering o, unitofstudy u where o.uoscode = u.uoscode and o.semester ='%s' and o.year = %d;", semester, y);
    //puts(q);
    mysql_query(connection,q);
    res_set = mysql_store_result(connection);
    int numrows = (int)mysql_num_rows(res_set);
    // Display results
    printf("\tUoSCode");
    printf("\tCourse\t\t\t\t\t\t");
    printf("\tEnrollment");
    printf("\tCapacity");
    printf("\tCredit\n");
    for (int i = 0; i < numrows; i++)
    {
        row = mysql_fetch_row(res_set);

        if( row != NULL )
        {
            printf("\t%s ", row[0]);
            printf("\t%-40s ", row[1]);
            printf("\t%s", row[2]);
            printf("\t\t%s", row[3]);
            printf("\t\t%s\n", row[4]);
            
        }
    }
    //free resources
    mysql_free_result(res_set);
    
    //print next quarter course list
    printf("\n\tNext Quarter: %s, %d\n\n", next_semester, y_next_semester);
    //query
    memset(q, 0, sizeof(q));
    MYSQL_RES *res_set2;
    MYSQL_ROW row2;
    
    sprintf(q, "select u.UoSCode, u.UoSName, o.Enrollment, o.MaxEnrollment,u.Credits from uosoffering o, unitofstudy u where o.uoscode = u.uoscode and o.semester ='%s' and o.year = %d;", next_semester, y_next_semester);
    //puts(q);
    mysql_query(connection,q);
    res_set2 = mysql_store_result(connection);
    int numrows2 = (int)mysql_num_rows(res_set2);
    // Display results
    printf("\tUoSCode");
    printf("\tCourse\t\t\t\t\t\t");
    printf("\tEnrollment");
    printf("\tCapacity");
    printf("\tCredit\n");
    for (int i = 0; i < numrows2; i++)
    {
        row2 = mysql_fetch_row(res_set2);
        
        if( row2 != NULL )
        {
            printf("\t%s ", row2[0]);
            printf("\t%-40s ", row2[1]);
            printf("\t%s", row2[2]);
            printf("\t\t%s", row2[3]);
            printf("\t\t%s\n", row2[4]);
            
        }
    }
    //free resources
    mysql_free_result(res_set2);
    
    char z[20];
    do {
        printf("\n\t\t\t---------------------------------------\n");
        printf("\t\t\t           Commands List           \n");
        printf("\t\t\t---------------------------------------\n");
        printf("\t\t\t  [1]Enroll a class\n");
        printf("\t\t\t  [0]Back to main menu                 \n");
        printf("\t\t\t---------------------------------------\n\n");
        printf("Please enter the command: ");
        scanf("%s", z);
        //system("color 2f");
        if(strcmp(z, "0") == 0) {
            //studentMenu(username);
            break;
        }
        else if(strcmp(z, "1") == 0) {
            char coursenumber[9];
            int whichsemester;
            memset(q, 0, sizeof(q));
            MYSQL_RES *res_set3;
            MYSQL_ROW row3;
            printf("\nPlease enter course number: ");
            scanf("%s", coursenumber);
            
            printf("\nPlease choose current quarter or next quarter(input 1 for now, or 2 for next) : ");
            scanf("%d", &whichsemester);
            
            sprintf(q, "CALL enrollclass(%s, '%s', %d, '%s', %d);",
                    username, semester, y, coursenumber, whichsemester);
            // Display results
            mysql_query(connection,q);
            res_set3 = mysql_store_result(connection);
            int numrows3 = (int)mysql_num_rows(res_set3);
            
            for (int i = 0; i < numrows3; i++) {
                row3 = mysql_fetch_row(res_set3);
                if(row3 != NULL) {
                    if (i == 0) {
                        fprintf(stdout, "%s\n", row3[0]);
                    }
                    else {
                        fprintf(stdout, "Prerequisites: %s   %s\n", row3[0], row3[1]);
                    }
                }
            }
            //free resources
            mysql_free_result(res_set3);
            
        }
        else
            printf("INVALID COMMAND.");
    }
    while(1);
    
}