unit unitApplicants;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, Buttons, ComCtrls;

type
  TfrmApplicants = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    lvApplicants: TListView;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    txtSearch: TEdit;
    btnSearch: TBitBtn;
    btnAdd: TBitBtn;
    cmbSearch: TComboBox;
    lvGirlsApp: TListView;
    TabSheet2: TTabSheet;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    txtSearch2: TEdit;
    btnSearch2: TBitBtn;
    btnAdd2: TBitBtn;
    cmbSem: TComboBox;
    lvBoysApp: TListView;
    PopupMenu1: TPopupMenu;
    AdmitApplicant1: TMenuItem;
    PopupMenu2: TPopupMenu;
    AdmitApplicant2: TMenuItem;
    AddPicture1: TMenuItem;
    AddPicture2: TMenuItem;
    procedure btnSearch2Click(Sender: TObject);
    procedure btnSearchClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
    procedure AdmitApplicant1Click(Sender: TObject);
    procedure AdmitApplicant2Click(Sender: TObject);
    procedure btnAdd2Click(Sender: TObject);
    procedure btnPrintClick(Sender: TObject);
    procedure btnPrintBClick(Sender: TObject);
    procedure AddPicture1Click(Sender: TObject);
    procedure AddPicture2Click(Sender: TObject);
  private
    { Private declarations }
  public
      primary : Integer;
      primaryKey:string;
      appid : Integer;
      primaryAppID : Integer;
      procedure gApplicants;
      procedure bApplicants;
      procedure Girlsapplicants;
      procedure Boysapplicants;
      procedure updatestat;
      procedure viewFirstsem;
      procedure viewSecsem;
      procedure viewBoysSem;
      procedure viewBoysFirstSem;
  end;

var
  frmApplicants: TfrmApplicants;

implementation

uses unitRegistration, DM, AssignRoom, unitUpdateApp;

{$R *.dfm}

procedure TfrmApplicants.btnSearch2Click(Sender: TObject);
begin
      if (cmbSem.Text = 'First Semester') then
          begin
                  viewBoysFirstSem;
          end
            else if (cmbSem.Text = 'Second Semester') then
            begin
                  viewBoysSem;
            end
              else if Length(txtSearch2.Text) > 0 then
              begin
                    bApplicants;
              end
                else  begin
                    MessageDlg('Please input first the textbox when searching.',mtInformation,[mbOK],0);
                end;
end;

procedure TfrmApplicants.btnSearchClick(Sender: TObject);
begin
       if (cmbSearch.Text = 'First Semester') then
          begin
                  viewFirstsem;
          end
            else if (cmbSearch.Text = 'Second Semester') then
            begin
                  viewSecsem;
            end
              else if Length(txtSearch.Text) > 0 then
              begin
                  gApplicants;
              end
                else  begin
                    MessageDlg('Please input first the textbox when searching.',mtInformation,[mbOK],0);
                end;
end;

procedure TfrmApplicants.FormShow(Sender: TObject);
begin
    Girlsapplicants;
    Boysapplicants;
end;

procedure TfrmApplicants.btnAddClick(Sender: TObject);
begin
      Registration.ShowModal;
end;

procedure TfrmApplicants.Girlsapplicants;
var newState : TListItem;
begin
       if DataModule1.tr.InTransaction then
           DataModule1.tr.Commit;

           DataModule1.query.SQL.Clear;
            DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF WHERE GENDER = :A');
           DataModule1.query.Params.AsString[0] := 'Female';
           DataModule1.query.Prepare;
           DataModule1.query.Open();
           lvGirlsApp.Items.BeginUpdate;
           lvGirlsApp.Items.Clear;

                if DataModule1.query.Fields.IsNull[0] then Exit;
                    while not DataModule1.query.Eof do begin

                    newState := lvGirlsApp.Items.Add;
                    newState.Caption := DataModule1.query.Fields.AsString[0];
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
       
                    DataModule1.query.Next;
                  end;
                      if DataModule1.tr.InTransaction then
                          DataModule1.tr.Commit;
                          lvGirlsApp.Items.EndUpdate;
 end;

procedure TfrmApplicants.Boysapplicants;
var newState : TListItem;
begin
       if DataModule1.tr.InTransaction then
           DataModule1.tr.Commit;

           DataModule1.query.SQL.Clear;
          DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF WHERE GENDER = :A');
           DataModule1.query.Params.AsString[0] := 'Male';
           DataModule1.query.Prepare;
           DataModule1.query.Open();
           lvBoysApp.Items.BeginUpdate;
           lvBoysApp.Items.Clear;

                if DataModule1.query.Fields.IsNull[0] then Exit;
                    while not DataModule1.query.Eof do begin

                    newState := lvBoysApp.Items.Add;
                    newState.Caption := DataModule1.query.Fields.AsString[0];
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                    newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
                    DataModule1.query.Next;
                  end;
                      if DataModule1.tr.InTransaction then
                        DataModule1.tr.Commit;
                          lvBoysApp.Items.EndUpdate;
end;


procedure TfrmApplicants.updatestat;
var pk:String;
begin
pk := lvApplicants.ItemFocused.Caption;
if DataModule1.tr.InTransaction then
        DataModule1.tr.Commit;

            DataModule1.query.SQL.Clear;
            DataModule1.query.SQL.Add('UPDATE APPLICANTS');
            DataModule1.query.SQL.Add('SET APP_STATUS = :A WHERE APPID = :B');
            DataModule1.query.Params.AsString[0] := 'Rejected';
            DataModule1.query.Params.AsString[1] := pk;
            DataModule1.query.Prepare;
            DataModule1.query.Open();

                if DataModule1.tr.InTransaction then
                    DataModule1.tr.Commit;
end;


procedure TfrmApplicants.gApplicants;
var newState : TListItem;
begin
          DataModule1.query.SQL.Clear;
         DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE STUDENT_ID LIKE :A OR APP_LNAME = :B OR APP_FNAME = :C AND GENDER = :D');
          DataModule1.query.Params.AsString[0] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[1] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[2] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[3] := 'Female';
          DataModule1.query.Prepare;
          DataModule1.query.Open();
          lvGirlsApp.Items.BeginUpdate;
          lvGirlsApp.Items.Clear;

            if DataModule1.query.Fields.IsNull[0] then Exit;
              while not DataModule1.query.Eof do begin

                newState := lvGirlsApp.Items.Add;
                newState.Caption := DataModule1.query.Fields.AsString[0];
                newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
                DataModule1.query.Next;
          end;
              if DataModule1.tr.InTransaction then
                  DataModule1.tr.Commit;
                    lvGirlsApp.Items.EndUpdate;
end;


procedure TfrmApplicants.bApplicants;
var newState : TListItem;
begin
          DataModule1.query.SQL.Clear;
         DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE STUDENT_ID LIKE :A OR APP_LNAME = :B OR APP_FNAME = :C AND GENDER = :D');
          DataModule1.query.Params.AsString[0] := trim(txtSearch2.Text);
          DataModule1.query.Params.AsString[1] := trim(txtSearch2.Text);
          DataModule1.query.Params.AsString[2] := trim(txtSearch2.Text);
          DataModule1.query.Params.AsString[3] := 'Male';
          DataModule1.query.Prepare;
          DataModule1.query.Open();
          lvBoysApp.Items.BeginUpdate;
          lvBoysApp.Items.Clear;

            if DataModule1.query.Fields.IsNull[0] then Exit;
              while not DataModule1.query.Eof do begin

                newState := lvBoysApp.Items.Add;
                newState.Caption := DataModule1.query.Fields.AsString[0];
                newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
                DataModule1.query.Next;
          end;
              if DataModule1.tr.InTransaction then
                  DataModule1.tr.Commit;
                    lvBoysApp.Items.EndUpdate;
end;


procedure TfrmApplicants.viewBoysSem;
var newState : TListItem;
begin
        if DataModule1.tr.InTransaction then
           DataModule1.tr.Commit;

           DataModule1.query.SQL.Clear;
           DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE ACADYR = :A AND SEM = :B AND GENDER = :C');
          DataModule1.query.Params.AsString[0] := trim(txtSearch2.Text);
          DataModule1.query.Params.AsString[1] := 'Second Semester';
          DataModule1.query.Params.AsString[2] := 'Male';
           DataModule1.query.Prepare;
           DataModule1.query.Open();
           lvBoysApp.Items.BeginUpdate;
           lvBoysApp.Items.Clear;

                if DataModule1.query.Fields.IsNull[0] then Exit;
                    while not DataModule1.query.Eof do begin

                      newState := lvBoysApp.Items.Add;
                      newState.Caption := DataModule1.query.Fields.AsString[0];
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
                      newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
                      DataModule1.query.Next;
                  end;
                      if DataModule1.tr.InTransaction then
                        DataModule1.tr.Commit;
                         lvBoysApp.Items.EndUpdate;
end;


procedure TfrmApplicants.viewBoysFirstSem;
var newState : TListItem;
begin
      if DataModule1.tr.InTransaction then
        DataModule1.tr.Commit;

        DataModule1.query.SQL.Clear;
         DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE ACADYR = :A AND SEM = :B AND GENDER = :C');
          DataModule1.query.Params.AsString[0] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[1] := 'First Semester';
          DataModule1.query.Params.AsString[2] := 'Male';
        DataModule1.query.Prepare;
        DataModule1.query.Open();
        lvBoysApp.Items.BeginUpdate;
        lvBoysApp.Items.Clear;

          if DataModule1.query.Fields.IsNull[0] then Exit;
            while not DataModule1.query.Eof do begin

            newState := lvBoysApp.Items.Add;
            newState.Caption := DataModule1.query.Fields.AsString[0];
            newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
            DataModule1.query.Next;
end;
            if DataModule1.tr.InTransaction then
            DataModule1.tr.Commit;
            lvBoysApp.Items.EndUpdate;
end;

procedure TfrmApplicants.viewFirstsem;
var newState : TListItem;
begin
      if DataModule1.tr.InTransaction then
          DataModule1.tr.Commit;

          DataModule1.query.SQL.Clear;
          DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE ACADYR = :A AND SEM = :B AND GENDER = :C');
          DataModule1.query.Params.AsString[0] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[1] := 'First Semester';
          DataModule1.query.Params.AsString[2] := 'Female';
          DataModule1.query.Prepare;
          DataModule1.query.Open();
          lvGirlsApp.Items.BeginUpdate;
          lvGirlsApp.Items.Clear;

          if DataModule1.query.Fields.IsNull[0] then Exit;
            while not DataModule1.query.Eof do begin

            newState := lvGirlsApp.Items.Add;
            newState.Caption := DataModule1.query.Fields.AsString[0];
            newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
            DataModule1.query.Next;
end;
            if DataModule1.tr.InTransaction then
               DataModule1.tr.Commit;
               lvGirlsApp.Items.EndUpdate;
end;


procedure TfrmApplicants.viewSecsem;
var newState : TListItem;
begin
        if DataModule1.tr.InTransaction then
            DataModule1.tr.Commit;

            DataModule1.query.SQL.Clear;
           DataModule1.query.SQL.Add('SELECT APPID,STUDENT_ID,APP_LNAME,APP_FNAME,MIDDLE_NAME,GENDER,APP_BDAY,ADDRESS,YEAR_COURSE,APP_SCHOLARSHIP,APP_STATUS,ACADYR,SEM,DATEAPPLIED,CONPERSON,MOBNO,REL FROM STUDENTPROF');
          DataModule1.query.SQL.Add('WHERE ACADYR = :A AND SEM = :B AND GENDER = :C');
          DataModule1.query.Params.AsString[0] := trim(txtSearch.Text);
          DataModule1.query.Params.AsString[1] := 'Second Semester';
          DataModule1.query.Params.AsString[2] := 'Female';
            DataModule1.query.Open();
            lvGirlsApp.Items.BeginUpdate;
            lvGirlsApp.Items.Clear;

            if DataModule1.query.Fields.IsNull[0] then Exit;
            while not DataModule1.query.Eof do begin

            newState := lvGirlsApp.Items.Add;
            newState.Caption := DataModule1.query.Fields.AsString[0];
            newState.SubItems.Add(DataModule1.query.Fields.AsString[1]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[2]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[3]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[4]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[5]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[6]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[7]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[8]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[9]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[10]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[11]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[12]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[13]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[14]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[15]);
            newState.SubItems.Add(DataModule1.query.Fields.AsString[16]);
            DataModule1.query.Next;
end;
            if DataModule1.tr.InTransaction then
                DataModule1.tr.Commit;
                lvGirlsApp.Items.EndUpdate;
end;
procedure TfrmApplicants.AdmitApplicant1Click(Sender: TObject);
begin
      if (lvBoysApp.ItemFocused.SubItems[10] = 'Admit') then
       begin
           MessageDlg('The applicant has been admitted.',mtError,[mbOK],0);
           exit
       end;

     if (lvBoysApp.ItemFocused.SubItems[10] = 'Rejected') then
       begin
           MessageDlg('The applicant has been rejected.',mtError,[mbOK],0);
           exit
       end;
     if MessageDlg('Are you sure do want to admit the applicants.', mtConfirmation,[mbYes,mbNo],0) = mrYes then
        begin

            frmRMAss.txtAppid.Text := lvBoysApp.ItemFocused.Caption;
            frmRMAss.txtID.Text := lvBoysApp.ItemFocused.SubItems[0];
            frmRMAss.txtLname.Text := lvBoysApp.ItemFocused.SubItems[1];
            frmRMAss.txtFname.Text := lvBoysApp.ItemFocused.SubItems[2];
            frmRMAss.txtacad.Text := lvBoysApp.ItemFocused.SubItems[10];
            frmRMAss.txtsem.Text := lvBoysApp.ItemFocused.SubItems[11];
            frmRMAss.ShowModal
        end
          else
          exit;
end;

procedure TfrmApplicants.AdmitApplicant2Click(Sender: TObject);
begin
       if (lvGirlsApp.ItemFocused.SubItems[10] = 'Admit') then
       begin
           MessageDlg('The applicant has been admitted.',mtError,[mbOK],0);
           exit
       end;

     if (lvGirlsApp.ItemFocused.SubItems[10] = 'Rejected') then
       begin
           MessageDlg('The applicant has been rejected.',mtError,[mbOK],0);
           exit
       end;
     if MessageDlg('Are you sure do want to admit the applicants.', mtConfirmation,[mbYes,mbNo],0) = mrYes then
        begin

          frmRMAss.txtAppid.Text := lvGirlsApp.ItemFocused.Caption;
          frmRMAss.txtID.Text := lvGirlsApp.ItemFocused.SubItems[0];
          frmRMAss.txtLname.Text := lvGirlsApp.ItemFocused.SubItems[1];
          frmRMAss.txtFname.Text := lvGirlsApp.ItemFocused.SubItems[2];
          frmRMAss.txtacad.Text := lvGirlsApp.ItemFocused.SubItems[10];
          frmRMAss.txtsem.Text := lvGirlsApp.ItemFocused.SubItems[11];
          frmRMAss.ShowModal
        end
          else
          exit;
end;

procedure TfrmApplicants.btnAdd2Click(Sender: TObject);
begin
       Registration.ShowModal;
end;

procedure TfrmApplicants.btnPrintClick(Sender: TObject);
begin
    DataModule1.rep.Filename := 'C:\Users\janine\Documents\DOMS\Reports\Applicant_Report.rep';
    DataModule1.rep.Report.Params.Items[0].Value := txtSearch.Text;
    DataModule1.rep.Report.Params.Items[1].Value := cmbSearch.Text;
    DataModule1.rep.Report.Params.Items[2].Value := 'Female';
    DataModule1.rep.Preview := True;
    DataModule1.rep.Execute();
end;

procedure TfrmApplicants.btnPrintBClick(Sender: TObject);
begin
     DataModule1.rep.Filename := 'C:\Users\janine\Documents\DOMS\Reports\BoysApplicantRep.rep';
    DataModule1.rep.Report.Params.Items[0].Value := txtSearch2.Text;
    DataModule1.rep.Report.Params.Items[1].Value := cmbSem.Text;
    DataModule1.rep.Report.Params.Items[2].Value := 'Male';
    DataModule1.rep.Preview := True;
    DataModule1.rep.Execute();
end;

procedure TfrmApplicants.AddPicture1Click(Sender: TObject);
begin
 frmUpdateApplicants.txtoccid.Text := lvGirlsApp.ItemFocused.Caption;
      frmUpdateApplicants.txtID.Text := lvGirlsApp.ItemFocused.SubItems[1];
      frmUpdateApplicants.txtLname.Text := lvGirlsApp.ItemFocused.SubItems[2];
      frmUpdateApplicants.txtFname.Text := lvGirlsApp.ItemFocused.SubItems[3];
      frmUpdateApplicants.txtgen.Text := lvGirlsApp.ItemFocused.SubItems[4];
      frmUpdateApplicants.ShowModal;
      end;

procedure TfrmApplicants.AddPicture2Click(Sender: TObject);
begin
    frmUpdateApplicants.txtoccid.Text := lvGirlsApp.ItemFocused.Caption;
      frmUpdateApplicants.txtID.Text := lvGirlsApp.ItemFocused.SubItems[1];
      frmUpdateApplicants.txtLname.Text := lvGirlsApp.ItemFocused.SubItems[2];
      frmUpdateApplicants.txtFname.Text := lvGirlsApp.ItemFocused.SubItems[3];
      frmUpdateApplicants.txtgen.Text := lvGirlsApp.ItemFocused.SubItems[4];
      frmUpdateApplicants.ShowModal;
end;

end.
