Student
parent
4191855611
commit
328bbf1538
|
@ -1,49 +0,0 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
public class Controller {
|
||||
|
||||
private Student student;
|
||||
private Student_login view;
|
||||
|
||||
public Controller() {
|
||||
this.view = new Student_login();
|
||||
view.getInsertStudent().addActionListener(e -> login());
|
||||
|
||||
}
|
||||
|
||||
public void login() {
|
||||
|
||||
String idText = view.getEingabeId().getText();
|
||||
int id = Integer.parseInt(idText);
|
||||
String name = view.getEingabeName().getText();
|
||||
String vorname = view.getEingabeVorname().getText();
|
||||
String geburtstag = view.getEingabeGeburtstag().getText();
|
||||
String geschlecht = view.getEingabeGeschlecht().getSelectedItem().toString();
|
||||
String teleN = view.getEingabeTeleN().getText();
|
||||
String email = view.getEingabeEmail().getText();
|
||||
String Adresse = view.getEingabeAdresse().getText();
|
||||
|
||||
student = LoginStudent.login(name,vorname,geschlecht,email,teleN,Adresse,geburtstag,id);
|
||||
|
||||
String[] werte = {student.getId()+"",student.getName(), student.getVorname(), student.getGeburtstag(),student.getGeschlecht(), student.getTele(), student.getEmail(), student.getAdresse()};
|
||||
view.getModel().addRow(werte);
|
||||
System.out.println("Erfolgreich");
|
||||
restAlleInputs();
|
||||
|
||||
}
|
||||
|
||||
public void restAlleInputs() {
|
||||
view.setEingabeName("");;
|
||||
view.setEingabeTeleN("");
|
||||
view.setEingabeAdresse("");
|
||||
view.setEingabeEmail("");;
|
||||
view.setEingabeGeburtstag("");;
|
||||
view.setEingabeVorname("");
|
||||
view.setEingabeId("");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Controller();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LoginStudent {
|
||||
|
||||
private static ArrayList<Student> alleStudent = new ArrayList<>();
|
||||
|
||||
public static Student login(String name, String vorname, String geschlecht, String email, String teleN, String Adresse,String geburtstag, int id) {
|
||||
Student studen = new Student(name, vorname, geschlecht, email, teleN, Adresse, geburtstag, id);
|
||||
alleStudent.add(studen);
|
||||
|
||||
return studen;
|
||||
}
|
||||
|
||||
public ArrayList<Student> getalleStudent(){
|
||||
return alleStudent;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,8 +11,7 @@ public class Student {
|
|||
private String geburtstag;
|
||||
private int id;
|
||||
|
||||
public Student(String name, String vorname, String geschlecht, String email, String tele, String adresse,
|
||||
String geburtstag, int id) {
|
||||
public Student(String name, String vorname, String geschlecht, String email, String tele, String adresse,String geburtstag, int id) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.vorname = vorname;
|
||||
|
@ -87,5 +86,13 @@ public class Student {
|
|||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Student [name=" + name + ", vorname=" + vorname + ", geschlecht=" + geschlecht + ", email=" + email
|
||||
+ ", tele=" + tele + ", adresse=" + adresse + ", geburtstag=" + geburtstag + ", id=" + id + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.awt.Font;
|
|||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import java.awt.ScrollPane;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
|
@ -215,6 +217,16 @@ public class Student_login extends JFrame {
|
|||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void showInfo(String message) {
|
||||
JOptionPane.showMessageDialog(null, message, "Studen angemeldet", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
public void showErrore(String error) {
|
||||
JOptionPane.showMessageDialog(null, error, "Studen nicht gefunden", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
public JTextField getEingabeId() {
|
||||
return eingabeId;
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
|
||||
public class VerwalteStudent {
|
||||
|
||||
private Student student;
|
||||
private Student_login view;
|
||||
private ArrayList<Student> allStudents;
|
||||
public VerwalteStudent() {
|
||||
this.view = new Student_login();
|
||||
view.getInsertStudent().addActionListener(e -> login());
|
||||
view.getLoescheStudent().addActionListener(e -> loeschen());
|
||||
view.getSucheStudent().addActionListener(e -> showUser());
|
||||
allStudents = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public void login() {
|
||||
|
||||
String idText = view.getEingabeId().getText();
|
||||
int id = Integer.parseInt(idText);
|
||||
String name = view.getEingabeName().getText();
|
||||
String vorname = view.getEingabeVorname().getText();
|
||||
String geburtstag = view.getEingabeGeburtstag().getText();
|
||||
String geschlecht = view.getEingabeGeschlecht().getSelectedItem().toString();
|
||||
String teleN = view.getEingabeTeleN().getText();
|
||||
String email = view.getEingabeEmail().getText();
|
||||
String Adresse = view.getEingabeAdresse().getText();
|
||||
|
||||
student = new Student(name, vorname, geschlecht, email, teleN, Adresse, geburtstag, id);
|
||||
allStudents.add(student);
|
||||
view.showInfo(student.toString());
|
||||
|
||||
// String[] array = {student.getId()+"",student.getAdresse(),student.getEmail(),student.getGeburtstag(),student.getGeschlecht(),student.getName(),student.getTele()};
|
||||
// view.getModel().addRow(array);
|
||||
|
||||
|
||||
restAlleInputs();
|
||||
|
||||
}
|
||||
|
||||
public void loeschen() {
|
||||
|
||||
String idText = view.getEingabeIdZuLoeschen().getText();
|
||||
int id = Integer.parseInt(idText);
|
||||
student = findStudent(id);
|
||||
if (student != null) {
|
||||
allStudents.remove(student);
|
||||
view.showInfo("Student wurde erfolgreich gelöscht");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Student findStudent(int id) {
|
||||
for (Student s : allStudents)
|
||||
if (s.getId() == id)
|
||||
return s;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showUser() {
|
||||
String studentName = view.getEingabeNameZuSuchen().getText();
|
||||
student = findStudent(studentName);
|
||||
if (student != null) {
|
||||
String[] array = {student.getId()+"",student.getAdresse(),student.getEmail(),student.getGeburtstag(),student.getGeschlecht(),student.getName(),student.getTele()};
|
||||
view.getModel().addRow(array);
|
||||
view.setEingabeNameZuSuchen("");
|
||||
}else
|
||||
view.showErrore("Der Student wurde nicht gefunden");
|
||||
}
|
||||
|
||||
private Student findStudent(String studentName) {
|
||||
for (Student s : allStudents)
|
||||
if (s.getName().equals(studentName))
|
||||
return s;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void restAlleInputs() {
|
||||
view.setEingabeName("");;
|
||||
view.setEingabeTeleN("");
|
||||
view.setEingabeAdresse("");
|
||||
view.setEingabeEmail("");;
|
||||
view.setEingabeGeburtstag("");;
|
||||
view.setEingabeVorname("");
|
||||
view.setEingabeId("");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new VerwalteStudent();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue