Commit 2d8be98e by krmaet

Add new file

parent 4cb8780c
Showing with 319 additions and 0 deletions
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <mysql/mysql.h>
#include <ncurses.h>
#include "changedata.h"
#include "main.h"
int optionMenu(char *options[], int count, char buffer[STR_MAX], int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
noecho();
int i;
int choice;
int highlight = 0;
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
mvwprintw(menu_win, 2, 1, "%s", buffer);
mvwprintw(menu_win, 2, 1, "Choose what to change:");
while (1)
{
//Print out the list with the current selection highlighted
for (i = 0; i < count; i++)
{
if (i == highlight)
{
wattron(menu_win, A_REVERSE);
mvwprintw(menu_win, i + 3, 1, "%s", options[i]);
wattroff(menu_win, A_REVERSE);
}
else
{
mvwprintw(menu_win, i + 3, 1, "%s", options[i]);
}
}
//Read if arrow up or down was pressed
choice = wgetch(menu_win);
switch(choice){
case UP_KEY:
highlight--;
if (highlight == -1)
{
highlight = 0;
}
break;
case DOWN_KEY:
highlight++;
if (highlight == count)
{
highlight = count - 1;
}
break;
default:
break;
}
//If a choice was selected, break loop
if (choice == ENTER_KEY)
{
break;
}
}
delwin(menu_win);
wrefresh(menu_win);
return highlight;
}
void CheckIn(int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
noecho();
int i, choice;
int highlight = 0;
char bookingNum[BOOKING_NUM];
char *options[2] = {"Yes", "No"};
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
mvwprintw(menu_win, 1, 1, "Enter booking number");
mvwprintw(menu_win, 2, 1, "--------------------");
echo();
mvwscanw(menu_win, 3, 1, "%s", bookingNum);
noecho();
//Check if booking exists!!!
// SIIA LÄHEB SQL KÜSIMINE NUMNBRI JA CHECK IN KOHTA
mvwprintw(menu_win, 5, 1, "Person checked in?");
while (1)
{
for (i = 0; i < 2; i++)
{
if (i == highlight)
{
wattron(menu_win, A_REVERSE);
mvwprintw(menu_win, i + 6, 1, "%s", options[i]);
wattroff(menu_win, A_REVERSE);
}
else
{
mvwprintw(menu_win, i + 6, 1, "%s", options[i]);
}
}
choice = wgetch(menu_win);
switch(choice){
case UP_KEY:
highlight--;
if (highlight == -1)
{
highlight = 0;
}
break;
case DOWN_KEY:
highlight++;
if (highlight == 2)
{
highlight = 2 - 1;
}
break;
default:
break;
}
if (choice == ENTER_KEY)
{
break;
}
}
//~ mvwprintw(menu_win, 2 + 4, 1, "Your choice was: %s", options[highlight]);
// SIIA LÄHEB SQL MUUTMINE
wrefresh(menu_win);
}
void CheckBooking(char *bookingNumber, int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
char temp[STR_MAX];
int bookingCheck = 1;
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
mvwprintw(menu_win, 1, 1, "Enter booking number");
mvwprintw(menu_win, 2, 1, "--------------------");
echo();
mvwscanw(menu_win, 3, 1, "%s", temp);
noecho();
// SIIA LÄHEB SQL BOOKING KÜSIMINE
if (bookingCheck == 1)
{
strcpy(bookingNumber, temp);
}
else
{
mvwprintw(menu_win, 5, 1, "Booking number does not exist!");
mvwprintw(menu_win, 6, 1, "Press any key to continue!");
wgetch(menu_win);
}
wrefresh(menu_win);
delwin(menu_win);
}
void ChangeName(char *booking, int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
char newName[STR_MAX];
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
//Display booking number
mvwprintw(menu_win, 1, 1, "Booking number");
mvwprintw(menu_win, 2, 1, "--------------");
mvwprintw(menu_win, 3, 1, "%s", booking);
// SIIA LÄHEB SQL NIME KÜSIMINE
//Display current name associated with the booking number
mvwprintw(menu_win, 5, 1, "Name");
mvwprintw(menu_win, 6, 1, "----");
mvwprintw(menu_win, 7, 1, "%s", "Mari Mets");
//Change the name associated with the booking number
mvwprintw(menu_win, 9, 1, "Change name");
mvwprintw(menu_win, 10, 1, "----");
echo();
mvwscanw(menu_win, 11, 1, "%s", newName);
noecho();
// SIIA LÄHEB SQL NIME MUUTMINE
wrefresh(menu_win);
delwin(menu_win);
}
void ChangeDocument(char *booking, int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
char newNumber[STR_MAX];
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
//Display booking number
mvwprintw(menu_win, 1, 1, "Booking number");
mvwprintw(menu_win, 2, 1, "--------------");
mvwprintw(menu_win, 3, 1, "%s", booking);
// SIIA LÄHEB SQL DOKUMENDI KÜSIMINE
//Display current name associated with the booking number
mvwprintw(menu_win, 5, 1, "Document number");
mvwprintw(menu_win, 6, 1, "---------------");
mvwprintw(menu_win, 7, 1, "%s", "A51567");
//Change the name associated with the booking number
mvwprintw(menu_win, 9, 1, "Change nunber");
mvwprintw(menu_win, 10, 1, "----");
echo();
mvwscanw(menu_win, 11, 1, "%s", newNumber);
noecho();
// SIIA LÄHEB SQL DOKUMENDI MUUTMINE
wrefresh(menu_win);
delwin(menu_win);
}
void ChangeBaggage(char *booking, int *row, int *col)
{
WINDOW *menu_win;
clear();
refresh();
int i, choice;
char *options[3] = {"Non priority Carry-On", "Prioriy Carry-On", "Check-In"};
int highlight = 0;
menu_win = create_newwin(28, 100, 1, *col / 2 - 100/2);
//Display booking number
mvwprintw(menu_win, 1, 1, "Booking number");
mvwprintw(menu_win, 2, 1, "--------------");
mvwprintw(menu_win, 3, 1, "%s", booking);
// SIIA LÄHEB SQL PAGASI KÜSIMINE
//Display current name associated with the booking number
mvwprintw(menu_win, 5, 1, "Current baggage");
mvwprintw(menu_win, 6, 1, "---------------");
mvwprintw(menu_win, 7, 1, "%s", "Carry-On");
//Change the name associated with the booking number
mvwprintw(menu_win, 9, 1, "Change baggage");
mvwprintw(menu_win, 10, 1, "----");
while (1)
{
for (i = 0; i < 3; i++)
{
if (i == highlight)
{
wattron(menu_win, A_REVERSE);
mvwprintw(menu_win, i + 11, 1, "%s", options[i]);
wattroff(menu_win, A_REVERSE);
}
else
{
mvwprintw(menu_win, i + 11, 1, "%s", options[i]);
}
}
choice = wgetch(menu_win);
switch(choice){
case UP_KEY:
highlight--;
if (highlight == -1)
{
highlight = 0;
}
break;
case DOWN_KEY:
highlight++;
if (highlight == 3)
{
highlight = 3 - 1;
}
break;
default:
break;
}
if (choice == ENTER_KEY)
{
break;
}
}
// SIIA LÄHEB SQL PAGASI MUUTMINE
wrefresh(menu_win);
delwin(menu_win);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment