/pruefungskonfig.cpp
http://abicalc.googlecode.com/ · C++ · 598 lines · 472 code · 57 blank · 69 comment · 191 complexity · 5562a9dbc7c9947e5993228e1c69ab26 MD5 · raw file
- //---------------------------------------------------------------------------
-
- #include <vcl.h>
- #include <shellapi.h>
- #pragma hdrstop
-
-
- #include "pruefungskonfig.h"
- #include "kursconfiguration.h"
- #include "noteneing.h"
- #include "pruefungen.h"
- #include "start.h"
- #include "info.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- Tpruefungskonfiguration *pruefungskonfiguration;
- //---------------------------------------------------------------------------
- __fastcall Tpruefungskonfiguration::Tpruefungskonfiguration(TComponent* Owner)
- : TForm(Owner)
- {
-
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::CBBellClick(TObject *Sender)
- {
- String P5 = this->CoBoP5->Items->Strings[this->CoBoP5->ItemIndex];
- if(this->LP1->Caption == "En"&& (this->CoBoP5->Items->Strings[this->CoBoP5->ItemIndex] == "Ma")){
- ShowMessage("Leider keine BELL möglich");
- this->CBBell->Enabled = false;
- this->CBBell->Checked = false;
- return;
- }
- if(this->CBBell->Checked){
- this->CoBoP5->Enabled = false;
- }else{
- this->CoBoP5->Enabled = true;
- }
- this->aenderungSpeichern();
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Button1_Click(TObject *Sender)
- {
- //Core-Objekt wieder erneuern
- kurskonfiguration->core = this->core ;
- kurskonfiguration->Show();
- this->Close();
- }
- //---------------------------------------------------------------------------
-
-
- void __fastcall Tpruefungskonfiguration::FormShow(TObject *Sender)
- {
- if(this->core != NULL){
- Kurs *lk1 = this->core->getLKByPosition(1); //LK 1
- this->LP1->Caption = lk1->getName();
- Kurs *lk2 = this->core->getLKByPosition(2); //LK2
- this->LP2->Caption = lk2->getName();
-
- String currP3 = NULL;
- String currP4 = NULL;
- String currP5 = NULL;
-
- Pruefungen *p =this->core->getPruefungen() ;
-
- if(p != NULL){
- currP3 = p->get(3)->getName();
- currP4 = p->get(4)->getName();
- currP5 = p->get(5)->getName();
-
- }
-
- this->CoBoP4->Enabled = false;
- this->CoBoP5->Enabled = false;
-
- this->initP3(lk1, currP3); //Prüfungsfach 3 init
- this->initP4(lk1, currP4); //Prüfungsfach 4 init
- this->initP5(lk1, currP5); //Prüfungsfach 5 init
- if(p != NULL && p->get(5)->isBell()){
- this->CBBell->Checked = true;
- }
- this->aenderungSpeichern();
-
- }else{
- throw new Exception("Keine Daten");
- }
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::CoBoP3Change(TObject *Sender)
- {
- this->CoBoP4->Enabled = true; // P3 gewählt, nun darf man auch P4 wählen
- int cCoBoP4 = this->CoBoP4->Items->Count;
- //Änderungen an P3
- if(this->LP1->Caption == "Ma"){
- /**
- * Deutsch als P3
- **/
-
- if(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex] == "De"){
- this->initP4(this->core->getLKByPosition(1), NULL); //LK zur Identifikation
- cCoBoP4 = this->CoBoP4->Items->Count;
- for(int i =0; i<cCoBoP4; i++){
- if(this->CoBoP4->Items->Strings[i] == "De"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- if(this->CoBoP4->Items->Strings[i] == "En"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- if(this->CoBoP4->Items->Strings[i] == this->core->getFS()->getName()){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
-
- }
- }
- /**
- * Ge als P3
- **/
- if(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex] == "Ge"){
- this->initP4(this->core->getLKByPosition(1), NULL); //LK zur Identifikation
- cCoBoP4 = this->CoBoP4->Items->Count;
- for(int i =0; i<cCoBoP4; i++){
- if(this->CoBoP4->Items->Strings[i] == "Ge"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- if(this->CoBoP4->Items->Strings[i] == "Wi"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- }
-
-
-
- }
- }else if (this->LP1->Caption == "En"){
- /**
- * Ma als P3
- **/
- if(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex] == "Ma"){
- this->initP4(this->core->getLKByPosition(1), NULL); //LK zur Identifikation
- cCoBoP4 = this->CoBoP4->Items->Count;
- for(int i =0; i<cCoBoP4; i++){
- if(this->CoBoP4->Items->Strings[i] == "De"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- if(this->CoBoP4->Items->Strings[i] == "Ma"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- }
- }
- /**
- * De als P3
- **/
- if(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex] == "De"){
- this->initP4(this->core->getLKByPosition(1), NULL); //LK zur Identifikation
- cCoBoP4 = this->CoBoP4->Items->Count;
- for(int i =0; i<cCoBoP4; i++){
- if(this->CoBoP4->Items->Strings[i] == "De"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- if(this->CoBoP4->Items->Strings[i] == "Ma"){
- this->CoBoP4->Items->Delete(i);
- i--; //i um 1 verringern, da Liste bei löschung 1 kürzer
- }
- }
- }
- /**
- * Ge als P3
- **/
- if(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex] == "Ge"){
- this->initP4(this->core->getLKByPosition(1), NULL); //LK zur Identifikation
- cCoBoP4 = this->CoBoP4->Items->Count;
- for(int i =0; i<cCoBoP4; i++){
- if(this->CoBoP4->Items->Strings[i] == "Wi"){
- this->CoBoP4->Items->Delete(i);
- i--;
- }
- if(this->CoBoP4->Items->Strings[i] == "Ge"){
- this->CoBoP4->Items->Delete(i);
- i--;
- }
- }
- }
-
- }
- this->CoBoP4->ItemIndex = 0;
- this->CoBoP5->ItemIndex = 0;
-
- this->CoBoP4Change(Sender);
-
- this->aenderungSpeichern();
- }
- //---------------------------------------------------------------------------
- void __fastcall Tpruefungskonfiguration::CoBoP4Change(TObject *Sender)
- {
- this->CoBoP5->Enabled = true; // P3 gewählt, nun darf man auch P4 wählen
- String currP3 = this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex];
- //
- if(this->LP1->Caption == "De"){
- this->initP5(this->core->getLKByPosition(1), NULL);
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "De"){
- this->CoBoP5->Items->Delete(i);
- }
- }
- }
-
- if(this->LP1->Caption == "Ma"){
- /**
- * P5
- **/
- this->initP5(this->core->getLKByPosition(1), NULL);
-
- //aktuell ausgewähltes P4
- String currP4 = this->CoBoP4->Items->Strings[this->CoBoP4->ItemIndex];
- if(currP4 == "De"){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "De"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- if(this->CoBoP5->Items->Strings[i] == "Ma"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- /**
- * drittes Prüfungsfach entfernen
- **/
- if(this->CoBoP5->Items->Strings[i] == currP3){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- }
- }
- if(currP4 == "En" || currP4 == this->core->getFS()->getName()){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "Ma"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- if(this->CoBoP5->Items->Strings[i] == "En"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- if(this->CoBoP5->Items->Strings[i] == this->core->getFS()->getName()){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- /**
- * drittes Prüfungsfach entfernen
- **/
- if(this->CoBoP5->Items->Strings[i] == currP3){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- }
- }
- if(currP4 == "Ge" || currP4 == "Wi"){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "De"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- }
-
- }
- }else if(this->LP1->Caption == "En"){
- /**
- * P5
- **/
- this->initP5(this->core->getLKByPosition(1), NULL);
- //aktuell ausgewähltes P4
- String currP4 = this->CoBoP4->Items->Strings[this->CoBoP4->ItemIndex];
- if(currP4 == "De"){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "En"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- if(this->CoBoP5->Items->Strings[i] == "De"){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- if(this->CoBoP5->Items->Strings[i] == "Wi"){
- this->CoBoP5->Items->Delete(i);
- i-- ;
- }
- if(this->CoBoP5->Items->Strings[i] == "Ge"){
- this->CoBoP5->Items->Delete(i);
- i-- ;
- }
- /**
- * drittes Prüfungsfach entfernen
- **/
- if(this->CoBoP5->Items->Strings[i] == currP3){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- }
- }
- if(currP4 == "Ma"){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- if(this->CoBoP5->Items->Strings[i] == "Ma"){
- this->CoBoP5->Items->Delete(i);
- i-- ;
- }
- if(this->CoBoP5->Items->Strings[i] == "Wi"){
- this->CoBoP5->Items->Delete(i);
- i-- ;
- }
- if(this->CoBoP5->Items->Strings[i] == "Ge"){
- this->CoBoP5->Items->Delete(i);
- i-- ;
- }
- /**
- * drittes Prüfungsfach entfernen
- **/
- if(this->CoBoP5->Items->Strings[i] == currP3){
- this->CoBoP5->Items->Delete(i);
- i--;
- }
- }
- }
- if(currP4 == "Ge" || currP4 == "Wi"){
- int cCoBoP5 = this->CoBoP5->Items->Count;
- for(int i =0; i<cCoBoP5; i++){
- /**
- * drittes Prüfungsfach entfernen
- **/
- if(this->CoBoP5->Items->Strings[i] == currP3){
- this->CoBoP5->Items->Delete(i);
- i--;
- this->CoBoP5->ItemIndex = 0;
- this->CoBoP5->Enabled = false; //Gibt nur 1 Möglichkeit
- }
- }
- }
- }
- this->CoBoP5->ItemIndex = 0;
- this->aenderungSpeichern();
- }
- //---------------------------------------------------------------------------
-
- void Tpruefungskonfiguration::initP3(Kurs *lk1, String checked){
- this->CoBoP3->Items->Clear();
- if(lk1->getName() == "De"){
- this->CoBoP3->Items->Add("Ma");
- this->CoBoP3->ItemIndex = 0;
- this->CoBoP3->Enabled = false;
- this->CoBoP4->Enabled = true; //Sonst ist gar keine Auswahl möglich
- }
- if(lk1->getName() == "Ma"){
- this->CoBoP3->Items->Add("De");
- this->CoBoP3->Items->Add("Ge");
- //this->CoBoP3->ItemIndex = 0;
- }
- if(lk1->getName() == "En"){
- this->CoBoP3->Items->Add("Ma");
- this->CoBoP3->Items->Add("De");
- this->CoBoP3->Items->Add("Ge");
- //this->CoBoP3->ItemIndex = 0;
- }
- if(checked != NULL){
- for (int i =0; i < this->CoBoP3->Items->Count; i++) {
- if(this->CoBoP3->Items->Strings[i] == checked){
- this->CoBoP3->ItemIndex = i;
- this->CoBoP3->Enabled = true;
- }
- }
- }
- }
- void Tpruefungskonfiguration::initP4(Kurs *lk1, String checked){
- this->CoBoP4->Items->Clear();
- if(lk1->getName() == "De"){
- this->CoBoP4->Items->Add("Ge");
- //this->CoBoP4->ItemIndex = 0;
- Kurs *wi = this->core->getKursByName("Wi");
- if(wi != NULL){
- if(!wi->isAbg()){
- this->CoBoP4->Items->Add("Wi");
- this->CoBoP4->ItemIndex = -1;
- }else{
- this->CoBoP4->Enabled = false;
- this->CoBoP5->Enabled = true;
- this->CoBoP4->ItemIndex = 0;
- }
- }
-
- }
- if(lk1->getName() == "Ma"){
- Kurs *fs = this->core->getFS();
- this->CoBoP4->Items->Add("Ge");
- this->CoBoP4->Items->Add("En");
- this->CoBoP4->Items->Add(fs->getName());
- // this->CoBoP4->ItemIndex = 0;
- Kurs *wi = this->core->getKursByName("Wi");
- if(wi != NULL){
- if(!wi->isAbg()){
- this->CoBoP4->Items->Add("Wi");
- }
- }
- this->CoBoP4->Items->Add("De");
- }
- if(lk1->getName() == "En"){
- this->CoBoP4->Items->Add("Ge");
- this->CoBoP4->Items->Add("De");
- this->CoBoP4->Items->Add("Ma");
- Kurs *wi = this->core->getKursByName("Wi");
- if(wi != NULL){
- if(!wi->isAbg()){
- this->CoBoP4->Items->Add("Wi");
- }
- }
- //this->CoBoP4->ItemIndex = 0;
-
- }
-
- if(checked != NULL){
- for (int i =0; i < this->CoBoP4->Items->Count; i++) {
- if(this->CoBoP4->Items->Strings[i] == checked){
- this->CoBoP4->ItemIndex = i;
- this->CoBoP4->Enabled = true;
- }
- }
- }
-
-
- }
- void Tpruefungskonfiguration::initP5(Kurs *lk1, String checked){
- this->CoBoP5->Items->Clear();
- if(lk1->getName() == "De"){
- this->CoBoP5->Items->Add("En");
- this->CoBoP5->Items->Add(this->core->getFS()->getName());
- //this->CoBoP5->ItemIndex = 0;
- }
- if(lk1->getName() == "Ma"){
- Kurs *fs = this->core->getFS();
- this->CoBoP5->Items->Add(fs->getName());
- this->CoBoP5->Items->Add("En");
- this->CoBoP5->Items->Add("De");
- //this->CoBoP5->ItemIndex = 0;
- }
- if(lk1->getName() == "En"){
- this->CoBoP5->Items->Add("Ma");
- this->CoBoP5->Items->Add("De");
- //this->CoBoP5->ItemIndex =0;
- }
-
- for (int i =0; i < this->CoBoP5->Items->Count; i++) {
- String tmp = this->CoBoP5->Items->Strings[i];
- if(tmp==checked){
- this->CoBoP5->ItemIndex = i;
- this->CoBoP5->Enabled = true;
- }
- }
-
- }
-
- void __fastcall Tpruefungskonfiguration::CoBoP5Change(TObject *Sender)
- {
- if(this->CoBoP5->Items->Strings[this->CoBoP5->ItemIndex] != "Ma"){
- this->CBBell->Enabled = true;
- }else {
- this->CBBell->Enabled = false;
- }
- this->aenderungSpeichern();
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Button2_Click(TObject *Sender)
- {
- this->aenderungSpeichern();
-
- if(this->core->getPruefungen()->get(1) != NULL && this->core->getPruefungen()->get(2) != NULL && this->core->getPruefungen()->get(3) != NULL && this->core->getPruefungen()->get(4) != NULL && this->core->getPruefungen()->get(5) != NULL){
-
- //if(this->CoBoP3->ItemIndex != -1 && this->CoBoP4->ItemIndex != -1 && this->CoBoP5->ItemIndex != -1){
-
- noteneingabe->core = this->core;
- noteneingabe->Show();
- this->Close();
- }else{
- ShowMessage("Bitte Prüfungen wählen");
- }
-
- }
- //---------------------------------------------------------------------------
-
- void Tpruefungskonfiguration::aenderungSpeichern(){
- this->core->isChanged = true;
- Pruefungen *p = new Pruefungen();
- Kurse_Pruefung *p1 = new Kurse_Pruefung(this->LP1->Caption);
- if(this->CBNP1->Checked)
- p1->setNachpruefung(true);
- p->add(p1, 1);
- Kurse_Pruefung *p2 = new Kurse_Pruefung(this->LP2->Caption);
- if(this->CBNP2->Checked)
- p2->setNachpruefung(true);
- p->add(p2, 2);
- Kurse_Pruefung *p3 = new Kurse_Pruefung(this->CoBoP3->Items->Strings[this->CoBoP3->ItemIndex]);
- if(this->CBNP3->Checked)
- p3->setNachpruefung(true);
- p->add(p3, 3);
- Kurse_Pruefung *p4 = new Kurse_Pruefung(this->CoBoP4->Items->Strings[this->CoBoP4->ItemIndex]);
- p->add(p4, 4);
- Kurse_Pruefung *p5 = new Kurse_Pruefung(this->CoBoP5->Items->Strings[this->CoBoP5->ItemIndex]);
- if(this->CBBell->Checked){
- p5->setBell(true);
- }
- p->add(p5, 5);
-
- this->core->clearPruefungen();
- this->core->setPruefungen(p);
-
-
- }
-
- void __fastcall Tpruefungskonfiguration::CBNP1Click(TObject *Sender)
- {
- TCheckBox *sender = dynamic_cast<TCheckBox*>(Sender);
- if(sender->Name == "CBNP1" && sender->Checked){
- this->core->getPruefungen()->get(1)->setNachpruefung(true);
- }
- if(sender->Name == "CBNP2" && sender->Checked){
- this->core->getPruefungen()->get(2)->setNachpruefung(true);
- }
- if(sender->Name == "CBNP3" && sender->Checked){
- this->core->getPruefungen()->get(3)->setNachpruefung(true);
- }
-
- }
- //---------------------------------------------------------------------------
-
-
-
- void __fastcall Tpruefungskonfiguration::Beenden1Click(TObject *Sender)
- {
- Application->Terminate();
- }
- //---------------------------------------------------------------------------
-
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Speichern1Click(TObject *Sender)
- {
- if(this->core->savePath == ""){
- if(this->SaveDialog1->Execute()){
- this->core->savePath = this->SaveDialog1->FileName;
- }
- }
- this->core->saveToFile(this->core->savePath);
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Speichernunter1Click(TObject *Sender)
- {
- if(this->SaveDialog1->Execute()){
- this->core->savePath = this->SaveDialog1->FileName;
- this->core->saveToFile(this->core->savePath);
- }
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Drucken1Click(TObject *Sender)
- {
- String name = InputBox("Name des Schülers", "Bitte den Namen des Schülers eingeben!", "");
- if(name != "")
- this->core->print(name);
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Info1Click(TObject *Sender)
- {
- infoform->Show();
- }
- //---------------------------------------------------------------------------
-
- void __fastcall Tpruefungskonfiguration::Hilfebenutzen1Click(TObject *Sender)
- {
- ShellExecute(Handle, "open", "http://redmine.vadaru.com/projects/abicalc/wiki/Benutzerhandbuch",
- NULL,NULL,SW_SHOWDEFAULT);
- }
- //---------------------------------------------------------------------------