/** * @author Li Pei * * @version v1 * * @time 2016/12/7 9:37 * * @program create the corresponding data table entity teacher class, convenient DAO and database connection * */package com.csms. Windows;import Java.awt.font;import Java.awt.event.actionevent;import Java.awt.event.actionlistener;import Java.util.list;import Javax.swing.jbutton;import Javax.swing.jframe;import Javax.swing.jtextfield;import Javax.swing.table.defaulttablemodel;import Com.csms.dao.adminitartordao;import Com.csms.dao.CourseArrangeDAO; Import Com.csms.dao.studentdao;import Com.csms.dao.teacherdao;import Com.csms.entity.adminitartor;import Com.csms.entity.course;import Com.csms.entity.coursearrange;import Com.csms.entity.student;import Com.csms.entity.teacher;public class Admintratorwindow {private static final int windowwide = 200;private static final int Windowhigh = 670;private static Adminitartor admin = null; String userName = Loginwindow.getloginusername (); String userpsd = Loginwindow.getloginpassword (); String url = "src//images//icons//admin.jpg";p rivate JFrame frame = new JfraMe ();p ublic Admintratorwindow () {admin = this.getadminitratorinformation (); This.informationarea (frame); Publicwindowset.windowattribute (frame, windowwide, Windowhigh, url, "admin window"); public void Informationarea (JFrame jfr) {//Headline Publicwindowset.addlabel (JFR, 26, 30, 10, 150, 30, "Administrator Information");//Administrator Photo string url = "src//images//adiminitrator//" + admin.getadminid () + ". jpg"; Publicwindowset.addphotolabel (JFR, 16, 20, 240, 100, 15,)//administrator tag Information Publicwindowset.addlabel (JFR, ID: "); Publicwindowset.addlabel (JFR, 16, 20, 270, 100, 15, "Name:"); Publicwindowset.addlabel (JFR, 16, 20, 300, 100, 15, "Age:"); Publicwindowset.addlabel (JFR, 16, 20, 330, 100, 15, "Gender:"); Publicwindowset.addlabel (JFR, 16, 20, 360, 100, 15, "Mobile:"); Publicwindowset.addlabel (JFR, 16, 20, 390, 100, 15, "Address:");//admin Interface Function button AddButton (1, "Release student Information",, JFR); AddButton (2, "release old Division Information ", 480, JFR); AddButton (3," Publish lesson Information ", 520, JFR); AddButton (4," Delete Information ", 560, JFR); AddButton (5," Exit ", (+), JFR);//Add admin details Publicwindowset.addlabEl (JFR, +,--------------), Admin.getadminid ()); Publicwindowset.addlabel (JFR, +,-------------), Admin.getadminname ()); Publicwindowset.addlabel (JFR, +,----), Integer.tostring (Admin.getadminage ())); Publicwindowset.addlabel (JFR, +,----------), Admin.getadmingender (); Publicwindowset.addlabel (JFR, +,-------------), Admin.getadminphone (); Publicwindowset.addlabel (JFR, 390, Max, admin.getadminaddress ());} Add buttonprivate static void AddButton (int flag, String str, int high, JFrame frm) {JButton button = new JButton (str); BU Tton.setfont (New Font ("Italic", Font.plain, +)); Button.setbounds (+, High, (); button.setcontentareafilled (false); Button.addactionlistener (new ActionListener () {public void actionperformed (ActionEvent e) {switch (flag) {case 1:// Release input student Information new Releasestudentinformationwindow (); break;case 2://Release input teacher Information new Releaseteacherinformationwindow (); break; Case 3://Release Schedule information new Releasecourseinformationwindow (); break;case 4://Delete Information new deleteinforMationwindow (); Break;case 5://exit Frm.dispose (); break;}}); Frm.add (button);} Get all information for admin public adminitartor getadminitratorinformation () {return new Adminitartordao (). GetInformation (UserName, USERPSD);}} Publish student Information class Releasestudentinformationwindow {private JFrame frame = new JFrame (); String url = "src//images//icons//admin.jpg";p ublic Releasestudentinformationwindow () {this.displayinformation ( This.frame);} private void Displayinformation (JFrame jfr) {Publicwindowset.addlabel (JFR, 26, 35, 10, 170, 30, "Student Information entry"); Publicwindowset.addlabel (JFR, 16, 20, 70, 90, 30, "Login name:"); Publicwindowset.addlabel (JFR, 16, 20, 100, 90, 30, "Login password:"); Publicwindowset.addlabel (JFR, 16, 20, 130, 90, 30, "Student Name:"); Publicwindowset.addlabel (JFR, 16, 20, 160, 90, 30, "Student ID:"); Publicwindowset.addlabel (JFR, 16, 20, 190, 90, 30, "Student Age:"); Publicwindowset.addlabel (JFR, 16, 20, 220, 90, 30, "Student Sex:"); Publicwindowset.addlabel (JFR, 16, 20, 250, 90, 30, "Student Faculties:"); Publicwindowset.addlabel (JFR, 16, 20, 280, 90, 30, "Student class:"); JTextField userName = new JTextField (); Publicwindowset.addtextfield (UserName, +, +, +, JFR); JTextField userpsd = new JTextField (); Publicwindowset.addtextfield (USERPSD, +, +, +, JFR); JTextField name = new JTextField (); Publicwindowset.addtextfield (name, +, +, +, JFR); JTextField id = new JTextField (); Publicwindowset.addtextfield (ID, +, +, +, JFR); JTextField age = new JTextField (); Publicwindowset.addtextfield (age, +, JFR); JTextField gender = new JTextField (); Publicwindowset.addtextfield (gender, +, JFR); JTextField sdept = new JTextField (); Publicwindowset.addtextfield (sdept, +, +, JFR); JTextField CLA = new JTextField (); Publicwindowset.addtextfield (CLA, 280, JFR); JButton button = new JButton ("OK Entry"), Button.setbounds (n, +, +), Button.setfont (New Font ("italics", Font.plain, 16)); Button.setcontentareafilled (false); Button.addactionlistener (new ActionListener () {public void actionperformed ( ActioneveNT e) {Student Student = new Student ();//Login name Student.setloginname (Username.gettext ());//Login Password STUDENT.SETLOGINPSD ( Userpsd.gettext ());//Student name Student.setstuname (Name.gettext ());//Student Idstudent.setstuid (Id.gettext ());// Student Age Student.setstuage (integer.valueof (Age.gettext));//Student Sex Student.setstugender (Gender.gettext ());// Student Department Student.setstusdept (Sdept.gettext ());//Student Class Student.setstuclass (Cla.gettext ()); new Studentdao (). Insertstudentinformation (student); Username.settext (""); Userpsd.settext (""); Name.settext (""); Id.settext (""); Age.settext (""); Gender.settext (""); Sdept.settext (""); Cla.settext ("");}}); Jfr.add (button); Publicwindowset.windowattribute (This.frame, +, +, URL, "release student Information");}} Input teacher Information class Releaseteacherinformationwindow {String URL = "src//images//icons//admin.jpg";p rivate JFrame frame = new J FRAME ();p ublic Releaseteacherinformationwindow () {this.displayinformation (frame);} private void Displayinformation (JFrame jfr) {//Add the Teacher information interface to the label group Publicwindowset.addlabel (JFR, 26, 35, 10, 170, 30, "Teacher Information entry "); Publicwindowset.addlabel (JFR, 16, 20, 70, 90, 30, "Login name:"); Publicwindowset.addlabel (JFR, 16, 20, 100, 90, 30, "Login password:"); Publicwindowset.addlabel (JFR, 16, 20, 130, 90, 30, "Teacher's name:"); Publicwindowset.addlabel (JFR, 16, 20, 160, 90, 30, "Teacher ID:"); Publicwindowset.addlabel (JFR, 16, 20, 190, 90, 30, "Teacher Age:"); Publicwindowset.addlabel (JFR, 16, 20, 220, 90, 30, "Teacher Sex:");//Add a text box group for the Teacher Information interface JTextField UserName = new JTextField (); Publicwindowset.addtextfield (UserName, +, +, +, JFR); JTextField userpsd = new JTextField (); Publicwindowset.addtextfield (USERPSD, +, +, +, JFR); JTextField name = new JTextField (); Publicwindowset.addtextfield (name, +, +, +, JFR); JTextField id = new JTextField (); Publicwindowset.addtextfield (ID, +, +, +, JFR); JTextField age = new JTextField (); Publicwindowset.addtextfield (age, +, JFR); JTextField gender = new JTextField (); Publicwindowset.addtextfield (gender, +, JFR); JButton button = new JButton ("OK entry"); bUtton.setbounds (n, +, +), Button.setfont (New Font ("Italic", Font.plain, +)); button.setcontentareafilled (false); Button.addactionlistener (new ActionListener () {public void actionperformed (ActionEvent e) {Teacher Teacher = new Teacher ();//Get the content entered in the text box Teacher.setloginname (Username.gettext ()); TEACHER.SETLOGINPSD (Userpsd.gettext ()); Teacher.setteacname (Name.gettext ()); Teacher.setteacid (Id.gettext ()); Teacher.setteacage (Integer.valueOf ( Age.gettext ())); Teacher.setteacgender (Gender.gettext ());//Insert the newly added information into the database new Teacherdao (). Insertinformation ( Teacher);//After inserting the contents of the text box empty Username.settext (""); Userpsd.settext (""); Name.settext (""); Id.settext (""); Age.settext ("" ); Gender.settext ("");}); Jfr.add (button);//Window property settings Publicwindowset.windowattribute (this.frame, 340, URL, "release teacher Info");}} Input class information class Releasecourseinformationwindow {private JFrame frame = new JFrame (); String url = "src//images//icons//admin.jpg";p rivate void Displayinformation (JFrame jfr) {Publicwindowset.addlabel ( JFR, 26, 35, 10, 170, 30, "PlatoonClass information Entry "); Publicwindowset.addlabel (JFR, 16, 20, 70, 90, 30, "Course ID:"); Publicwindowset.addlabel (JFR, 16, 20, 100, 90, 30, "Instructor:"); Publicwindowset.addlabel (JFR, 16, 20, 130, 90, 30, "Course Name:"); Publicwindowset.addlabel (JFR, 16, 20, 160, 90, 30, "Course credits:"); Publicwindowset.addlabel (JFR, 16, 20, 190, 90, 30, "course Hours:"); Publicwindowset.addlabel (JFR, 16, 20, 220, 90, 30, "course type:"); Publicwindowset.addlabel (JFR, 16, 20, 250, 90, 30, "Number of courses:"); Publicwindowset.addlabel (JFR, 16, 20, 280, 90, 30, "Selected persons:"); Publicwindowset.addlabel (JFR, 16, 20, 310, 90, 30, "course Arrangement:"); JTextField Courid = new JTextField (); Publicwindowset.addtextfield (Courid, +, +, +, JFR); JTextField Teac = new JTextField (); Publicwindowset.addtextfield (Teac, +, +, +, JFR); JTextField name = new JTextField (); Publicwindowset.addtextfield (name, +, +, +, JFR); JTextField cridits = new JTextField (); Publicwindowset.addtextfield (cridits, +, JFR); JTextField times = new JTextField (); Publicwindowset.addtextfield (TimES, +, JFR); JTextField type = new JTextField (); Publicwindowset.addtextfield (type, n, I, +, JFR); JTextField number = new JTextField (); Publicwindowset.addtextfield (number, +, +, +, JFR); JTextField selectnumber = new JTextField (); Publicwindowset.addtextfield (Selectnumber, 280, JFR); JTextField arrange = new JTextField (); Publicwindowset.addtextfield (Arrange, 310, JFR); JButton button = new JButton ("OK Entry"), Button.setbounds (n. 16, +), Button.setfont (New Font ("italics", Font.plain,)); Button.setcontentareafilled (false); Button.addactionlistener (new ActionListener () {public void actionperformed ( ActionEvent e) {Coursearrange CA = new Coursearrange (); Ca.setcourseid (Courid.gettext ()); Ca.setcourseteacher ( Teac.gettext ()); Ca.setcoursename (Name.gettext ()); Ca.setcoursegridits (Integer.valueof (Cridits.gettext ())); Ca.setcoursetimes (Integer.valueof (Times.gettext ())); Ca.setcoursetype (Type.gettext ()); Ca.setcoursenumber ( Integer.valueof (NUMBER.GEttext ()); Ca.setcourseselectnumber (Integer.valueof (Selectnumber.gettext ())); Ca.setcoursearrange ( Arrange.gettext ()); new Coursearrangedao (). Insertcoursearrange (CA); Courid.settext (""); Teac.settext (""); Name.settext (""); Cridits.settext (""); Times.settext (""); Type.settext (""); Number.settext (""); Selectnumber.settext (""); Arrange.settext ("");}}); Jfr.add (button); Publicwindowset.windowattribute (This.frame, $, 420, URL, "Publish lesson Information");} Public Releasecourseinformationwindow () {this.displayinformation (frame);}} Delete Information class Deleteinformationwindow {private JFrame frame = new JFrame (); String url = "src//images//icons//admin.jpg";p ublic Deleteinformationwindow () {this.displayinformation (frame);} private void Displayinformation (JFrame jfr) {//Add category large label Publicwindowset.addlabel (JFR, 26, 40, 10, 170, 30, "delete student Information"); Publicwindowset.addlabel (JFR, 26, 40, 220, 170, 30, "Delete teacher Information"); Publicwindowset.addlabel (JFR, 26, 40, 430, 170, 30, "Delete Course information");//Add Student Information Publicwindowset.addlabel (JFR, 16, 20, 70, 90, 30, " Student ID: "); JtextfieLD Stuidfield = new JTextField (); Publicwindowset.addtextfield (Stuidfield, JFR), This.addbutton (1, "View student Information", This.frame, Stuidfield) ; This.addbutton (2, "Delete student Information", This.frame, Stuidfield);//Add Student Information Publicwindowset.addlabel (JFR, 16, 20, 280, 90, 30, "teacher ID: "); JTextField Teaidfield = new JTextField (); Publicwindowset.addtextfield (Teaidfield, 280, JFR) This.addbutton (3, "View Teacher Info", 325, This.frame, Teaidfield ); This.addbutton (4, "Delete teacher Information", This.frame, Teaidfield);//Add Student Information Publicwindowset.addlabel (JFR, 16, 20, 490, 90, 30, "lesson Process ID: "); JTextField Couidfield = new JTextField (); Publicwindowset.addtextfield (Couidfield, 490, JFR) This.addbutton (5, "View course Information", 535, This.frame, Couidfield ); This.addbutton (6, "Delete Course information", 570, This.frame, Couidfield);//Set window Properties Publicwindowset.windowattribute (JFR, $, 640, URL , "Information Removal window"); public void AddButton (int flag, String str, int. High, JFrame JFR, JTextField tf) {JButton button = new JButton (str); button . SetFont (New Font ("Kai(Font.plain), button.setcontentareafilled (false), Button.setbounds (150, 30); Button.addactionlistener (new ActionListener () {public void actionperformed (ActionEvent e) {switch (flag) {case 1:// View student information DefaultTableModel Stutablemodel; String[] Stustr = {"Student id", "Student Name", "Student Age", "Student gender", "Student faculty", "Student Class"}; JFrame stuframe = new JFrame (); Publicwindowset.windowattribute (Stuframe, 480, +, NULL, "Student Information"); Stutablemodel = Publicwindowset.addtablelist ( Stuframe, STUSTR); list<student> stulist = new Studentdao (). Searchallstudent (); Student Student = null;for (int i = 0; i < stulist.size (); i++) {Student = Stulist.get (i); System.out.println (student.getstusdept () + Student.getstuclass ()) Stutablemodel.addrow (new object[] { Student.getstuid (), Student.getstuname (), Student.getstuage (), Student.getstugender (), student.getstusdept (), Student.getstuclass ()});} Break;case 2://Delete Student information string stuid = Tf.gettext (); if (stuid.length () = = 0) {publicwindowset.promptpopup ("Please enter student id!!! "," Error Prompt ", JFR);} else {new Studentdao (). Deletestudentinformation (Stuid); Tf.settext ("");} Break;case 3://View teacher Information DefaultTableModel Teatablemodel; String[] Teastr = {"Teacher id", "Teacher name", "Teacher Age", "Teacher Sex"}; JFrame teaframe = new JFrame (); Publicwindowset.windowattribute (Teaframe, n, +, NULL, "Teacher Info"); Teatablemodel = Publicwindowset.addtablelist ( Teaframe, TEASTR); Teacher Teacher = null;//performs a query operation list<teacher> teaclist = new Teacherdao (). Searchallteacherinformation (); for (int i = 0; I < teaclist.size (); i++) {teacher = Teaclist.get (i);//Add information to the table component Teatablemodel.addrow (new object[] {teacher.getteacid (), Teacher.getteacname (), Teacher.getteacage (), Teacher.getteacgender ()});} Break;case 4://Delete Teacher information string teaid = Tf.gettext (); if (teaid.length () = = 0) {publicwindowset.promptpopup ("Please enter teacher id!!! "," Error Prompt ", JFR);} else {new Teacherdao (). Deleteteacherinformation (Teaid); Tf.settext ("");} Break;case 5://View schedule information DefaultTableModel Courtablemodel; String[] Courstr = {"Course id", "classroom Teacher", "Course name", "Course credits", "Course hours", "Course type", "courseNumber "," Selected persons "," Course arrangement "}; JFrame courframe = new JFrame (); Publicwindowset.windowattribute (courframe,%, n, NULL, "lesson Information"); Courtablemodel = Publicwindowset.addtablelist ( Courframe, COURSTR); list<coursearrange> courselist = new Coursearrangedao (). Searchallcoursearrange (); Coursearrange coursearrange = null;for (int i = 0; i < courselist.size (); i++) {Coursearrange = Courselist.get (i); CourT Ablemodel.addrow (new object[] {Coursearrange.getcourseid (), Coursearrange.getcourseteacher (), Coursearrange.getcoursename (), Coursearrange.getcoursegridits (), Coursearrange.getcoursetimes (), Coursearrange.getcoursetype (), Coursearrange.getcoursenumber (), Coursearrange.getcourseselectnumber (), Coursearrange.getcoursearrange ()});} Break;case 6://Delete class information string Arrangeid = Tf.gettext (); if (arrangeid.length () = = 0) {publicwindowset.promptpopup (" Please enter the course id!!! "," Error Prompt ", JFR);} else {new Coursearrangedao (). Deletearragecourseinformation (Arrangeid); Tf.settext ("");} Break;}}); Jfr.add (button);}}
----Adminitarorwindow of Students ' course selection system