sub exportieren { my $auswahl_chkb1 = 0; my $auswahl_chkb2 = 0; my $auswahl_chkb3 = 0; my $auswahl_chkb4 = 0; my $export_tw = $mw->Toplevel(); my $windowHeight = "300"; my $windowWidth = "540"; my $screenHeight = $export_tw->screenheight; my $screenWidth = $export_tw->screenwidth; $export_tw->geometry($windowWidth."x".$windowHeight); $export_tw->geometry("+".int($screenWidth/2 - $windowWidth/2)."+".int($screenHeight/2 - $windowHeight/2)); my $f1_tw = $export_tw->LabFrame(-label => "Ziel wählen",-labelside => 'acrosstop')->place(-x => 20, -y => 30, -height => 65, -width => 500 ); my $Label1_tw = $export_tw->Label(-text => "Export von Schülerdaten:",-anchor => 'w')->place( -x => 21, -y => 10, -height => 21, -width => 493); my $Label2_tw = $f1_tw->Label(-text => "Ziel-Datei:")->place( -x => 5, -y => 5, -height => 23, -width => 74); my $Entry1_tw = $f1_tw->Entry(-width => 50, -relief => "sunken")->place( -x => 79, -y => 5, -height => 24, -width => 224); $Entry1_tw->delete(0, 'end'); $Entry1_tw->insert('end', 'C:\'); #$pfad = $Entry1_tw->get(); &Speicher_aktualisieren; my $Button1_tw = $f1_tw->Button(-text => 'Durchsuchen', -relief => "raised", -command => sub { if (my $TargetFolder = BrowseForFolder("Bitte wählen Sie den Ziel-Ordner", CSIDL_DESKTOP)) { $Entry1_tw->delete(0, 'end'); $Entry1_tw->insert('end', $TargetFolder); &Speicher_aktualisieren; } }, )->place( -x => 308, -y => 5, -height => 24, -width => 152); my $f2_tw = $export_tw->LabFrame(-label => "Auswahl",-labelside => 'acrosstop') ->place(-x => 20, -y => 100, -height => 125, -width => 245); $f2_tw->Checkbutton( -text => "Schüler Datenbank", -anchor => "w", -command => \&Speicher_aktualisieren, -variable => \$auswahl_chkb1 )->place( -x => 0, -y => 0, -height => 22, -width => 100); $f2_tw->Checkbutton( -text => "Buchungsdaten", -anchor => "w", -command => \&Speicher_aktualisieren, -variable => \$auswahl_chkb2 )->place( -x => 0, -y => 24, -height => 22, -width => 100); $f2_tw->Checkbutton( -text => "Bilddateien", -anchor => "w", -command => \&Speicher_aktualisieren, -variable => \$auswahl_chkb3 )->place( -x => 0, -y => 48, -height => 22, -width => 100); $f2_tw->Checkbutton( -text => "Alles", -anchor => "w", -command => \&Speicher_aktualisieren, -variable => \$auswahl_chkb4 )->place( -x => 0, -y => 72, -height => 22, -width => 100); my $f3_tw = $export_tw->LabFrame(-label => "Speicher",-labelside => 'acrosstop') ->place(-x => 270, -y => 100, -height => 125, -width => 245); $f3_tw->Label( -text => "Speicherbedarf:", -anchor => 'w' )->place( -x => 0, -y => 0, -height => 20, -width => 100); $f3_tw->Label( -textvariable => \$speicherbedarf, -anchor => 'e', -foreground => 'blue' )->place( -x => 110, -y => 0, -height => 20, -width => 100); $f3_tw->Label( -text => "Freier Speicher:", -anchor => 'w' )->place( -x => 0, -y => 25, -height => 20, -width => 100); $f3_tw->Label( -textvariable => \$freierspeicher, -anchor => 'e', -foreground => 'blue' )->place( -x => 110, -y => 25, -height => 20, -width => 100); $Label3_tw = $export_tw->Label( -textvariable => \$var_status_tw, -anchor => 'w', -foreground => 'red' )->place( -x => 74, -y => 230, -height => 20, -width => 300); $var_status_tw = ""; my $Button2_tw = $export_tw->Button( -text => "Sichern", -relief => "raised", -command => sub { my $pfad = $Entry1_tw->get(); if ( $pfad eq "" ) { $var_status_tw = "Fehler: Bitte geben Sie einen gültigen Pfad an!"; $Label3_tw->configure(-foreground => 'red'); return; } my @target = (); my @folder = (); print "1:$auswahl_chkb1 "; print "2:$auswahl_chkb2 "; print "3:$auswahl_chkb3 "; print "4:$auswahl_chkb4\n"; if ( $auswahl_chkb4 == 1 ) { @folder2 = Foldercont("."); shift @folder2; foreach(@folder2) { my $pfad2 = $_; $pfad2 = reverse($pfad2); chop $pfad2; chop $pfad2; $pfad2 = reverse($pfad2); push @folder, "\.\\$pfad2"; push @target, "$pfad$pfad2\n"; } } else { if ( $auswahl_chkb1 == 1 ) { push @folder, ".\\schueler.csv"; push @target, $pfad."schueler.csv"; } if ( $auswahl_chkb2 == 1 ) { my @folder2 = Foldercont(".\\daten"); shift @folder2; foreach(@folder2) { my $pfad2 = $_; $pfad2 = reverse($pfad2); chop $pfad2; chop $pfad2; $pfad2 = reverse($pfad2); push @folder, "\.\\$pfad2"; push @target, "$pfad$pfad2\n"; } } if ( $auswahl_chkb3 == 1 ) { my @folder2 = Foldercont(".\\bilder"); shift @folder2; foreach(@folder2) { my $pfad2 = $_; $pfad2 = reverse($pfad2); chop $pfad2; chop $pfad2; $pfad2 = reverse($pfad2); push @folder, "\.\\$pfad2"; push @target, "$pfad$pfad2\n"; } } } #if (CopyEx (\@folder => \@target, FOF_NOCONFIRMMKDIR)) # { # $mw->messageBox(-icon => 'info', -message => "Das Backup wurde erfolgreich erstellt! ", -title => 'Herzlichen Glückwunsch', -type => 'Ok', -default => 'Ok'); # } # else # { # $mw->messageBox(-icon => 'info', -message => "Fehler beim kopieren aufgetreten! ", -title => 'Fehler!', -type => 'Ok', -default => 'Ok'); # } my $cnt = 0; foreach (@target) { print "$cnt:$folder[$cnt] - $target[$cnt]\n"; $cnt++; } print "\nAnzahl: $cnt\n-------------------------------\n"; } )->place( -x => 43, -y => 265, -height => 23, -width => 136); my $Button3_tw = $export_tw->Button( -text => "Abbrechen", -relief => "raised", -command => sub { $export_tw->destroy() } )->place( -x => 361, -y => 265, -height => 23, -width => 136); my $Label4_tw = $export_tw->Label(-text => "Status:",-anchor => 'w')->place( -x => 24, -y => 230, -height => 20, -width => 50); $export_tw->bind ('', sub{ $export_tw->destroy() }); $Button1_tw->focus(); } sub Speicher_aktualisieren { my $summe = 0; my @zwischensumme; if ( $auswahl_chkb1 == 1 ) { $summe = $summe + -s 'schueler.csv'; } if ( $auswahl_chkb2 == 1 ) { @zwischensumme = Foldercont(".\\daten"); $summe = $summe + $zwischensumme[0]; } if ( $auswahl_chkb3 == 1 ) { @zwischensumme = Foldercont(".\\bilder"); $summe = $summe + $zwischensumme[0]; } if ( $auswahl_chkb4 == 1 ) { @zwischensumme = Foldercont("."); $summe = $zwischensumme[0]; $auswahl_chkb1 = 1; $auswahl_chkb2 = 1; $auswahl_chkb3 = 1; } $speicherbedarf = sprintf("%.2f", $summe/1048576)." MB"; my $pfad = $Entry1_tw->get(); if (GetDiskFreeSpace $pfad) { $freierspeicher = GetDiskFreeSpace $pfad; $freierspeicher = sprintf("%.2f", $freierspeicher/1048576)." MB"; } }