学生管理系统(界面+源代码).(优选)
学生管理系统源代码

cin>>targetNum;modify_Num(targetNum);cout<<endl;display();}if(key == 2){char targetName[20];cout<cin>>targetName;modify_Name(targetName);cout<<endl;display();}if(key == 3){exit(0);}*/show_Start();menu_CMD();return 0;}void show_Start(){void show_Table(){cout<<" <<"\t"<<" "<<"\t"<<"cout<<"\t"<<subject[0]<<"\t"<<subject[1]<<"\t"<<subject[2]; cout<<endl;}void menu_CMD(){int key;while(1){cout<<"1. <<endl; cout<<"2. <<endl; cout<<"3. <<endl; cout<<"4. <<endl; cout<<"5. <<endl; cout<<"6. <<endl; cout<<"cin>>key;while(1){if((key < 1)||(key > 6)) {int key;cout<< "<<endl; cout<< (1 - 5) : " cin>>key;}else{break;}}switch(key){case 1:addRecord();break;case 2:deleteRecord();break;case 3:modifyRecord();break;case 4:queryRecord();break;case 5:display();break;case 6:quit();break;}}}um;cout<<" : "; cin>>record[stuNum].name; cout<<"(M , F) : "; cin>>record[stuNum].sex;int i;for(i = 0;i < SUBJECT_NUM;i++) {cout<<" "<<subject[i]<< cin>>record[stuNum].score[i];}}if((choi == 'N')||(choi == 'n')) {cout<<" <<endl;cout<<endl;}cout<< <<stuNum<<" cout<<endl;!"<<endl;}"<<endl;cout<<"2. <<endl;cout<<"3. "<<endl;}um == tarNum) {if(i = stuNum){cout<<" : "<<endl; show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t" <<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2]; cout<<endl;cout<<endl<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum - 1;i++){ cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){ cout<<"\t"<<record[i].score[j];} cout<<endl;}/*stuNum--;cout<<" <<stuNum<<";cout<<endl;*/}if(i != stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score [2];for(int j = i+1;j <= stuNum;j++){record[j-1] = record[j];}um<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<"cout<<endl;*/}stuNum--;cout<<" "<<stuNum<< cout<<endl;}}}/*ame,tarName) == 0){um<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];cout<<endl;cout<<endl<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum - 1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}}/if(i != stuNum){cout<<" : "<<endl; show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t" <<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score [2];um<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){ cout<<"\t"<<record[i].score[j];}cout<<endl;}cout<<endl;} void delete_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){ ame,tarName) == 0){if(i == stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score [2];cout<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<" ";cout<<endl;*/}/if(i != stuNum){cout<<" "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t";cout<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].s core[2];cout<<endl;for(int j = i+1;j <= stuNum;j++){record[j-1] = record[j];}cout<<" : "<<endl;cout<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<cout<<endl;*/}stuNum--;cout<<" <<stuNum<< ";cout<<endl;}}}/***********************************************************************************************************************************************************/void Info_modify(){cout<<"\ : "<<endl;cout<<"1. "<<endl;cout<<"2. "<<endl;cout<<"3. "<<endl;}void modifyRecord(){ int key; cout<<endl;Info_modify(); cout<<" : "; cin>>key;um == tarNum){ cout<<endl<<" "<<endl; cout<<" : ";cin>>record[i].num; cout<<" : ";cin>>record[i].name; cout<<";cin>>record[i].sex; cout<<" "<<subject[0]<<" "; cin>>record[i].score[0];cout<<" "<<subject[1]<<" : "; cin>>record[i].score[1]; cout<<" "<<subject[2]<< "; cin>>record[i].score[2]; } } }void modify_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,tarName) == 0) {cout<<endl<<" : "<<endl;cout<<" : "; cin>>record[i].num;cout<<" : "; cin>>record[i].name;cout<<" : "; cin>>record[i].sex;cout<<" "<<subject[0]<<" : "; cin>>record[i].score[0]; cout<<" "<<subject[1]<<" : " cin>>record[i].score[1]; cout<<" "<<subject[2]<<" : ";cin>>record[i].score[2];}}}void Info_query(){cout<<" : "<<endl; cout<<"1. "<<endl;cout<<"2. "<<endl;cout<<"3. "<<endl;}if(key == 3){while(1){menu_CMD();}void query_Num(int tarNum){int i;for(i = 1;i <= stuNum;i++){if(record[i].num == tarNum){um<<"\t"<<record[i].name<<"\t"<<record[i].sex;cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<recor d[i].score[2];cout<<endl;}}}ame,tarName) == 0){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<recor d[i].score[2];cout<<endl;}}}um<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}cout<<endl;}//void quit(){char choi;cout<<" "<<endl;cout<<" (Y/N) : ";cin>>choi;if((choi == 'Y')||(choi == 'y')) {cout<< "<<endl;exit(0);}/ else{cout<<endl; menu_CMD();。
学生信息管理系统源代码(java)

目录1.Client.java (2)2.LoginGUI.java (2)3.AdminGUI.java (6)4.StudentGUI.java (14)5.Select.java (17)6.UpdateAndInsert.java (24)7.Delete.java (27)8.Student.java (29)9.Administrator.java (31)1.Client.java/*程序入口*/package ms;public class Client{public static void main(String[] args){LoginGUI lg=new LoginGUI();lg.login();}}2.LoginGUI.java/*登陆主窗口*/package ms;import java.awt.BorderLayout;import java.awt.Choice;import java.awt.GridLayout;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;public class LoginGUI{JFrame log=null; //登陆主窗口JPanel jPanel1=null; //用于存放用户名、密码、登录方式标签JPanel jPanel2=null; //用于存放用户名、密码输入框和登录方式选择框JPanel jPanel3=null; //用于存放登陆、退出按钮JLabel jLabel1=null; //用于存放用户名标签JLabel jLabel2=null; //用于存放密码标签JLabel jLabel3=null; //用于存放登录方式标签JLabel jLabel4=null; //学生管理系统登陆标签TextField t1=null; //用于存放用户名输入TextField t2=null; //用于存放密码输入Choice c=null; //用于存放登录方式选择JButton jB1=null; //登陆按钮JButton jB2=null; //退出按钮String UserName=null; //存放用户输入的用户名String UserPassword=null; //存放用户输入的密码int UserLimit=-1; //存放用户选择登陆权限public LoginGUI(){super();this.log = new JFrame("学生学籍管理系统");this.jPanel1=new JPanel();this.jPanel2=new JPanel();this.jPanel3=new JPanel();jLabel1=new JLabel("用户名");jLabel2=new JLabel("密码");jLabel3=new JLabel("登录方式");jLabel4=new JLabel(new ImageIcon("image/login.jpg"));t1=new TextField();t2=new TextField();c=new Choice(); //创建一个登录方式下拉选择框c.add("学生登陆");c.add("管理员登陆");jB1=new JButton("登陆"); //创建登陆按钮jB2=new JButton("退出"); //创建退出按钮}public void login(){BorderLayout border=new BorderLayout();border.setVgap(15);border.setHgap(10);log.setLayout(border); //设置登陆主窗口布局管理器为BorderLayoutlog.add(jPanel1, BorderLayout.WEST);log.add(jPanel2, BorderLayout.CENTER);log.add(jPanel3, BorderLayout.SOUTH);log.add(jLabel4,BorderLayout.NORTH);jPanel1.setLayout(new GridLayout(3,1,30,20)); //3行1列jPanel2.setLayout(new GridLayout(3,1,30,20));jPanel3.setLayout(new GridLayout(1,2,10,30));jPanel1.add(jLabel1); //添加三个标签用户名、密码、登陆方式jPanel1.add(jLabel2);jPanel1.add(jLabel3);jPanel2.add(t1); //添加用户名、密码输入文本框登陆方式选择框jPanel2.add(t2);jPanel2.add(c);jPanel3.add(jB1); //添加两个按钮jPanel3.add(jB2);jB1.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){erName=LoginGUI.this.t1.getText();erPassword=LoginGUI.this.t2.getText();erLimit=LoginGUI.this.c.getSelectedIndex();if(erLimit==0){StudentGUI ll=new StudentGUI(LoginGUI.this.log,erName);Select sel=new Select();sel.setStudentList();for(int i=0;i<sel.getStudentAllId().size();i++){if(sel.getStudentAllId().get(i).toString().equals(erNa me)&&sel.getStudentAllPassword().get(i).equals(erPass word)){log.setVisible(false);ll.studentGo();}else if(i==sel.getStudentAllId().size()-1){JOptionPane.showMessageDialog(LoginGUI.this.log,"用户名密码错误");}}}else if(erLimit==1){AdminGUI admin=new AdminGUI(LoginGUI.this.log);Select sel=new Select();sel.setAdminList();for(int i=0;i<sel.getAdminAllId().size();i++){if(sel.getAdminAllId().get(i).toString().equals(erNam e)&&sel.getAdminAllPassword().get(i).equals(erPasswor d)){log.setVisible(false);admin.adminGo();}else if(i==sel.getAdminAllId().size()-1){JOptionPane.showMessageDialog(LoginGUI.this.log,"用户名密码错误");}}}}});jB2.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){System.exit(0);}});log.setSize(240,260);log.setLocationRelativeTo(null);log.setResizable(false);log.addWindowListener(new WindowAdapter(){@Overridepublic void windowClosing(WindowEvent e){System.exit(0);}});log.setVisible(true);}}3.AdminGUI.java/*管理员登陆图形界面*/package ms;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.TextArea;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;public class AdminGUI{JDialog log=null;//管理员登陆主窗口JPanel jp1=null;//用于存放管理员登陆标签和jp5JPanel jp2=null;//用于存放查询修改增加删除按钮JPanel jp3=null;//用于存放信息块和jp5JPanel jp4=null;//用于存放修改插入删除按钮JPanel jp5=null;//用于存放请输入学号文本框JLabel jadminLog=null; //管理员登陆标签JLabel jLabel=null; //请输入学号标签TextField tf=null; //请输入学号文本框JButton jb1=null;//查询按钮JButton jb2=null;//修改按钮JButton jb3=null;//增加按钮JButton jb4=null;//删除按钮JButton jb5=null; //列出全部学生信息TextArea ta=null;//信息文本框JLabel jl=null; //用于站位String id=null; //用于保存用户输入查询学号TextField[] jtf = new T extField[9] ;JDialog jdialog=null;public AdminGUI(JFrame log){super();this.log = new JDialog(log,"管理员登陆",true);jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();jp5=new JPanel();jadminLog=new JLabel(new ImageIcon("image/admin.jpg"));jLabel=new JLabel("请输入学号");tf=new TextField();jb1=new JButton("查询");jb2=new JButton("修改");jb3=new JButton("增加");jb4=new JButton("删除");jb5=new JButton("列出全部学生信息");ta=new TextArea("点击查询按钮将在此显示查询信息");jl=new JLabel();}public void adminGo(){BorderLayout bl=new BorderLayout();bl.setVgap(30);bl.setHgap(30);log.setLayout(bl);log.add(jp1,BorderLayout.NORTH);BorderLayout bl1=new BorderLayout();bl1.setVgap(20);jp1.setLayout(bl1);jp1.add(jadminLog,BorderLayout.CENTER);jp5.setLayout(new GridLayout(1,2,200,200));jp5.add(jLabel);jp5.add(tf);log.add(jp2,BorderLayout.WEST);jp2.setLayout(new GridLayout(2,1,200,300));jp2.add(jb1);jp2.add(jb5);log.add(jp3,BorderLayout.CENTER);jp3.setLayout(new BorderLayout(10, 10));jp3.add(jp5,BorderLayout.NORTH);jp3.add(ta);jp5.setLayout(new GridLayout(1,5,10,10));jp5.add(jLabel);jp5.add(tf);log.add(jp4,BorderLayout.SOUTH);jp4.setLayout(new GridLayout(1,3,200,30));jp4.add(jb2);jp4.add(jb3);jp4.add(jb4);log.addWindowListener(new WindowAdapter(){@Overridepublic void windowClosing(WindowEvent e){System.exit(0);}});jb1.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){AdminGUI.this.id=AdminGUI.this.tf.getText();Select sel=new Select();sel.selectStudent(AdminGUI.this.id);if(sel.getStudent()!=null){Student student=sel.getStudent();AdminGUI.this.ta.setText("学号\t\t"+"姓名\t\t"+"性别\t\t"+"出生日期\t\t"+"民族\t\t"+"籍贯\t\t"+"专业\t\t"+"班级\t\t"+"联系电话\t\t"+"密码\t\t");AdminGUI.this.ta.append("\n"+student.getId()+"\t\t"+student.getNa me()+"\t\t"+student.getSex()+"\t\t"+student.getBornDate()+"\t\t"+student.getNationality()+"\t\t"+student.getNationality()+"\t\t"+stu dent.getMaj()+"\t"+student.getCla()+"\t\t"+student.getTelNum()+"\t\t"+student.getPassword()+"\n");}else{AdminGUI.this.ta.setText("查无此人");}}});jb5.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){Select sel=new Select();sel.selectAllStudent();AdminGUI.this.ta.setText("学号\t\t"+"姓名\t\t"+"性别\t\t"+"出生日期\t\t"+"民族\t\t"+"籍贯\t\t"+"专业\t\t"+"班级\t\t"+"联系电话\t\t"+"密码\t\t\n");for(int i=0;i<sel.getAllStudent().size();i++){Student student=sel.getAllStudent().get(i);AdminGUI.this.ta.append(student.getId()+"\t\t"+student.getName() +"\t\t"+student.getSex()+"\t\t"+student.getBornDate()+"\t\t"+student.getNationality()+"\t\t"+student.getHometown()+"\t\t"+st udent.getMaj()+"\t"+student.getCla()+"\t\t"+student.getTelNum()+"\t\t"+student.getPa ssword()+"\n");}}});log.setSize(850,580);log.setLocationRelativeTo(null);log.setResizable(false);jb3.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){jdialog=new JDialog(AdminGUI.this.log);String[] str=new String[]{"姓名","性别","出生日期","民族","籍贯","专业","班级","联系电话","密码"};JLabel[] jlabel=new JLabel[9];for(int i=0;i<9;i++){jlabel[i]=new JLabel(str[i]);jtf[i]=new TextField();}JPanel jpanel1=new JPanel();JPanel jpanel2=new JPanel();JButton jbutton1=new JButton("确定");JButton jbutton2=new JButton("取消");jdialog.setLayout(new BorderLayout());jdialog.add(jpanel1,BorderLayout.CENTER);jdialog.add(jpanel2,BorderLayout.SOUTH);jpanel1.setLayout(new GridLayout(9,2,10,10));for(int i=0;i<9;i++){jpanel1.add(jlabel[i]);jpanel1.add(jtf[i]);}jpanel2.add(jbutton1);jpanel2.add(jbutton2);jbutton1.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){Student student=new Student();student.setName(AdminGUI.this.jtf[0].getText());student.setSex(AdminGUI.this.jtf[1].getText()); student.setBornDate(AdminGUI.this.jtf[2].getText());student.setNationality(AdminGUI.this.jtf[3].getText());student.setHometown(AdminGUI.this.jtf[4].getText());student.setMaj(AdminGUI.this.jtf[5].getText());student.setCla(AdminGUI.this.jtf[6].getText());student.setTelNum(AdminGUI.this.jtf[7].getText()); student.setPassword(AdminGUI.this.jtf[8].getText());UpdateAndInsert up=new UpdateAndInsert();if(up.insertStudent(student)==true){JOptionPane.showMessageDialog(AdminGUI.this.log,"添加成功");}jdialog.dispose();}});jbutton2.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){jdialog.dispose();}});jdialog.setSize(500,400);jdialog.setLocationRelativeTo(null);jdialog.setResizable(false);jdialog.setVisible(true);}});jb4.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){if(new Delete().delete(AdminGUI.this.tf.getText())==true){JOptionPane.showMessageDialog(AdminGUI.this.log,"刪除成功");}elseJOptionPane.showMessageDialog(AdminGUI.this.log,"刪除失敗");}});jb2.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){Select sel=new Select();AdminGUI.this.id=AdminGUI.this.tf.getText();sel.selectStudent(AdminGUI.this.tf.getText());Student student=sel.getStudent();if(student==null){JOptionPane.showMessageDialog(AdminGUI.this.log,"请检查输入的学号");}else{jdialog=new JDialog(AdminGUI.this.log);String[] str=new String[]{"姓名","性别","出生日期","民族","籍贯","专业","班级","联系电话","密码"};JLabel[] jlabel=new JLabel[9];for(int i=0;i<9;i++){jlabel[i]=new JLabel(str[i]);}jtf[0]=new TextField(student.getName());jtf[1]=new TextField(student.getSex());jtf[2]=new TextField(student.getBornDate());jtf[3]=new TextField(student.getNationality());jtf[4]=new TextField(student.getHometown());jtf[5]=new TextField(student.getMaj());jtf[6]=new TextField(student.getCla());jtf[7]=new TextField(student.getTelNum());jtf[8]=new TextField(student.getPassword());JPanel jpanel1=new JPanel();JPanel jpanel2=new JPanel();JButton jbutton1=new JButton("确定");JButton jbutton2=new JButton("取消");jdialog.setLayout(new BorderLayout());jdialog.add(jpanel1,BorderLayout.CENTER);jdialog.add(jpanel2,BorderLayout.SOUTH);jpanel1.setLayout(new GridLayout(9,2,10,10));for(int i=0;i<9;i++){jpanel1.add(jlabel[i]);jpanel1.add(jtf[i]);}jpanel2.add(jbutton1);jpanel2.add(jbutton2);jbutton1.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){Student student=new Student(Integer.parseInt(AdminGUI.this.id), jtf[0].getText(), jtf[1].getText(), jtf[2].getText(), jtf[3].getText(), jtf[4].getText(), jtf[5].getText(), jtf[6].getText(), jtf[7].getText(), jtf[8].getText());UpdateAndInsert up=new UpdateAndInsert();if(up.updateStudent(student)==true){JOptionPane.showMessageDialog(AdminGUI.this.log,"更改成功");;}jdialog.dispose();}});jbutton2.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){jdialog.dispose();}});jdialog.setSize(500,400);jdialog.setLocationRelativeTo(null);jdialog.setResizable(false);jdialog.setVisible(true);}}});log.setVisible(true);}}4.StudentGUI.java/*学生操作图形界面*/package ms;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.TextField;import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;public class StudentGUI{JDialog log=null;//学生登入类主窗口JPanel jp1=null;//用于存放登入块JPanel jp2=null;//用于存放信息块JPanel jp3=null;//用于密码存放修改块JPanel jp4=null;//用于存放我的信息按钮JLabel jl1=null;//学生登入标签JLabel jl2=null;//学号标签JLabel jl3=null;//学生姓名标签JLabel jl4=null;//性别标签JLabel jl5=null;//出生日期标签JLabel jl6=null;//民族标签JLabel jl7=null;//籍贯标签JLabel jl8=null;//专业标签JLabel jl9=null;//班级标签JLabel jl10=null;//联系电话标签JLabel jl11=null;//请输入密码标签JButton jb1=null;//我的信息按钮JButton jb2=null;//密码修改按钮TextField t1=null;//学号文本框TextField t2=null;//学生姓名文本框TextField t3=null;//性别文本框TextField t4=null;//出生日期文本框TextField t5=null;//民族文本框TextField t6=null;//籍贯文本框TextField t7=null;//专业文本框TextField t8=null;//班级文本框TextField t9=null;//联系电话文本框TextField t10=null;//密码文本框JPanel jp5=new JPanel();//存放密码输入框String id=null;public StudentGUI(JFrame log,String str){super();this.log = new JDialog(log,"学生登入",true);jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();jl1=new JLabel(new ImageIcon("image/student.jpg"));jl2=new JLabel("学号:");jl3=new JLabel("学生姓名:");jl4=new JLabel("性别:");jl5=new JLabel("出生日期:");jl6=new JLabel("民族:");jl7=new JLabel("籍贯:");jl8=new JLabel("专业:");jl9=new JLabel("班级:");jl10=new JLabel("联系电话:");jl11=new JLabel("请输入新密码:");jb1=new JButton("我的信息");jb2=new JButton("密码修改");t1=new TextField();t2=new TextField();t3=new TextField();t4=new TextField();t5=new TextField();t6=new TextField();t7=new TextField();t8=new TextField();t9=new TextField();t10=new TextField();this.id=str;}public void studentGo(){BorderLayout bl=new BorderLayout();bl.setHgap(30);bl.setVgap(30);log.setLayout(bl);log.add(jp1,BorderLayout.NORTH);//将登入块信息块密码修改块放入主窗口log.add(jp2,BorderLayout.CENTER);log.add(jp3,BorderLayout.SOUTH);log.add(jp4,BorderLayout.WEST);jp1.add(jl1,BorderLayout.CENTER);jp2.setLayout(new GridLayout(5,2,20,10));jp2.add(jl2);jp2.add(t1);jp2.add(jl3);jp2.add(t2);jp2.add(jl4);jp2.add(t3);jp2.add(jl5);jp2.add(t4);jp2.add(jl6);jp2.add(t5);jp2.add(jl7);jp2.add(t6);jp2.add(jl8);jp2.add(t7);jp2.add(jl9);jp2.add(t8);jp2.add(jl10);jp2.add(t9);jp4.add(jb1);BorderLayout bl1=new BorderLayout();bl1.setHgap(38);jp3.setLayout(bl1);jp3.add(jb2,BorderLayout.WEST);jp3.add(jp5,BorderLayout.CENTER);jp5.setLayout(new GridLayout());jp5.add(jl11);jp5.add(t10);jb1.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){Select sel=new Select();sel.selectStudent(id);Student student=sel.getStudent();t1.setText(new Integer(student.getId()).toString());t2.setText(student.getName());t3.setText(student.getSex());t4.setText(student.getBornDate());t5.setText(student.getNationality());t6.setText(student.getHometown());t7.setText(student.getMaj());t8.setText(student.getCla());t9.setText(student.getTelNum());}});jb2.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e){String password=StudentGUI.this.t10.getText();UpdateAndInsert up=new UpdateAndInsert();if(up.updatePassword(id, password)==true){JOptionPane.showMessageDialog(StudentGUI.this.log,"修改成功");}}});log.addWindowListener(new WindowAdapter(){@Overridepublic void windowClosing(WindowEvent e){System.exit(0);}});log.setSize(550,420);log.setLocationRelativeTo(null);log.setResizable(false);log.setVisible(true);}}5.Select.java/* 查询类包括查询的各种方法*/package ms;import java.sql.*;import java.util.LinkedList;public class Select{private LinkedList<Integer> studentAllId=null;private LinkedList<String> studentAllPassword=null;private LinkedList<Integer> adminAllId=null;private LinkedList<String> adminAllPassword=null;private Student student=null;private LinkedList<Student> allStudent=null;// 定义MySQL的数据库驱动程序public static final String DBDRIVER = "org.gjt.mm.mysql.Driver" ;// 定义MySQL数据库的连接地址public static final String DBURL = "jdbc:mysql://localhost:3306/studentMS" ;// MySQL数据库的连接用户名public static final String DBUSER = "root" ;// MySQL数据库的连接密码public static final String DBPASS = "systemout" ;public Select(){super();this.studentAllId = new LinkedList<Integer>();this.studentAllPassword = new LinkedList<String>();this.adminAllId = new LinkedList<Integer>();this.adminAllPassword = new LinkedList<String>();this.allStudent = new LinkedList<Student>();}public LinkedList<Integer> getStudentAllId(){return studentAllId;}public LinkedList<String> getStudentAllPassword(){return studentAllPassword;}public LinkedList<Integer> getAdminAllId(){return adminAllId;}public LinkedList<String> getAdminAllPassword(){return adminAllPassword;}public Student getStudent(){return student;}public LinkedList<Student> getAllStudent(){return allStudent;}public void setStudentList() //设置studentAllId 和studentAllPassword{Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = "select id,password from student";try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){e.printStackTrace() ;}try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;}catch(SQLException e){e.printStackTrace() ;}try{stmt = conn.createStatement() ; //得到stmt对象用于执行sql语句} catch (SQLException e1){e1.printStackTrace();}try{rs = stmt.executeQuery(sql) ;//保存sql查询结果} catch (SQLException e1){e1.printStackTrace();}try{while(rs.next()){studentAllId.add(rs.getInt(1));studentAllPassword.add(rs.getString(2));}} catch (SQLException e1){e1.printStackTrace();}try{rs.close() ;stmt.close() ;conn.close() ; // 数据库关闭}catch(SQLException e){e.printStackTrace() ;}}public void setAdminList(){Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = "select id,password from admin";try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){e.printStackTrace() ;}try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;}catch(SQLException e){e.printStackTrace() ;}try{stmt = conn.createStatement() ; //得到stmt对象用于执行sql语句} catch (SQLException e1){e1.printStackTrace();}try{rs = stmt.executeQuery(sql) ;//保存sql查询结果} catch (SQLException e1){e1.printStackTrace();}try{while(rs.next()){adminAllId.add(rs.getInt(1));adminAllPassword.add(rs.getString(2));}} catch (SQLException e1){e1.printStackTrace();}try{rs.close() ;stmt.close() ;conn.close() ; // 数据库关闭}catch(SQLException e){e.printStackTrace() ;}}public boolean selectStudent(String str){Connection conn = null ; // 数据库连接PreparedStatement pstmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = "select name,sex,bornDate,nationality,hometown,maj,cla,telNum,password "+ "from student where id=?";try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){e.printStackTrace() ;}try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;}catch(SQLException e){e.printStackTrace() ;}try{pstmt = conn.prepareStatement(sql) ; //得到stmt对象用于执行sql语句} catch (SQLException e1){e1.printStackTrace();}try{pstmt.setString(1, str);} catch (SQLException e2){e2.printStackTrace();}try{rs = pstmt.executeQuery() ;//保存sql查询结果} catch (SQLException e1){e1.printStackTrace();}try{while(rs.next()){student=new Student(Integer.parseInt(str),rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9));}} catch (SQLException e1){e1.printStackTrace();}try{rs.close() ;pstmt.close() ;conn.close() ; // 数据库关闭}catch(SQLException e){e.printStackTrace() ;}if(student !=null){return true;}else{return false;}}public void selectAllStudent(){Connection conn = null ; // 数据库连接PreparedStatement pstmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = "select * "+"from student";try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){e.printStackTrace() ;}try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;}catch(SQLException e){e.printStackTrace() ;}try{pstmt = conn.prepareStatement(sql) ; //得到stmt对象用于执行sql语句} catch (SQLException e1){e1.printStackTrace();}try{rs = pstmt.executeQuery() ;//保存sql查询结果} catch (SQLException e1){e1.printStackTrace();}try{while(rs.next()){student=new Student(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10));allStudent.add(student);}} catch (SQLException e1){e1.printStackTrace();}try{rs.close() ;pstmt.close() ;conn.close() ; // 数据库关闭}catch(SQLException e){e.printStackTrace() ;}}}6.UpdateAndInsert.java/*修改&&插入类定义了修改和插入的所有方法*/package ms;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;public class UpdateAndInsert{// 定义MySQL的数据库驱动程序public static final String DBDRIVER = "org.gjt.mm.mysql.Driver" ;// 定义MySQL数据库的连接地址public static final String DBURL = "jdbc:mysql://localhost:3306/studentMS" ;// MySQL数据库的连接用户名public static final String DBUSER = "root" ;// MySQL数据库的连接密码public static final String DBPASS = "systemout" ;public boolean insertStudent (Student student){String name=student.getName();String sex=student.getSex();String bornDate=student.getBornDate();String nationality=student.getNationality();String hometown=student.getHometown();String maj=student.getMaj();String cla=student.getCla();String telNum=student.getTelNum();String password=student.getPassword();Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库操作try{Class.forName(DBDRIVER) ;} catch (ClassNotFoundException e){// TODO Auto-generated catch blocke.printStackTrace();} // 加载驱动程序String sql = "INSERT INTO student(name,sex,bornDate,nationality,hometown,maj,cla,telNum,passw ord) "+" VALUES('"+name+"','"+sex+"','"+bornDate+"','"+nationality+"','"+hometown+"' ,'"+maj+"','"+cla+"','"+telNum+"','"+password+"')";try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();}try{stmt = conn.createStatement() ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();} // 实例化Statement对象try{stmt.executeUpdate(sql) ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();} // 执行数据库更新操作try{stmt.close() ; // 关闭操作conn.close() ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();} // 数据库关闭return true;}public boolean updateStudent(Student student){Select sel=new Select();if(sel.selectStudent(newInteger(student.getId()).toString())==false){return false;}Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库操作String name=student.getName();String sex=student.getSex();String bornDate=student.getBornDate();String nationality=student.getNationality();String hometown =student.getHometown();String maj=student.getMaj();String cla=student.getCla();String telNum=student.getTelNum();String password=student.getPassword();String sql="UPDATE student SET name='"+name+"',sex='"+sex+"',bornDate='"+bornDate+"',nationality ='"+nationality+"',hometown='"+hometown+"',maj='"+maj+"',cla='"+c la+"',telNum='"+telNum+"',password='"+password+"' WHERE id="+student.getId() ;try{conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;} catch (SQLException e1){// TODO Auto-generated catch blocke1.printStackTrace();}try{stmt = conn.createStatement() ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();} // 实例化Statement对象try{stmt.executeUpdate(sql) ;} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();} // 执行数据库更新操作try{stmt.close() ; // 关闭操作conn.close() ; // 数据库关闭} catch (SQLException e){// TODO Auto-generated catch blocke.printStackTrace();}return true;}。
学生信息管理系统C语言源代码

#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define len sizeof(struct student)FILE *fp;struct student{long num;char name[15];int age;char sex[3];char chushen[10];char dizhi[20];char phone[11];char email[20];struct student *next;};void menu(){printf("===========学生信息管理系统==========\n\n");printf(" 1、录入学生信息\n");printf(" 2、浏览学生信息\n");printf(" 3、查询学生信息\n");printf(" 4、删除学生信息\n");printf(" 5、插入学生信息\n");printf(" 6、修改学生信息\n");printf(" 7、排序学生信息\n");printf(" 8、退出管理系统\n");printf("=====================================\n");}struct student *creat() //录入学生信息{int n;struct student *head;struct student *p1,*p2;n=0;p1=p2=(struct student *) malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chushen ,p1->dizhi,p1->phone,p1->email);head=NULL;while(p1->num!=0){n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(struct student *)malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chu shen,p1->dizhi,p1->phone,p1->email);}p2->next=NULL;return(head);}void insert(struct student *head) //插入学生信息{int search_num;struct student *p,*q,*s;p=head;printf("在哪个学生前插入请输入学号:\n");scanf("%d",&search_num);while((p!=NULL)&&(p->num!=search_num)){q=p;p=p->next;}s=(struct student *)malloc(len);q->next=s;system("cls");printf("请输入学生信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&s->num,&s->age,s->name,s->sex,s->chushen,s->diz hi,s->phone,s->email);s->next=p;}void printList(struct student *head) //浏览全部学生信息{struct student *p;p=head;if(head==NULL)printf("没有学生信息!!\n");else{do{fread(p,len,1,fp);printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);p=p->next;}while(p!=NULL);}}void findList_num(struct student *head,long search_num) //按学号查找{struct student *p;p=head;while((p!=NULL)&&(p->num!=search_num))p=p->next;if(p!=NULL)printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);elseprintf("没有该学生信息!!\n");}void findList_name(struct student *head,char *search_name) //按姓名查找{struct student *p;int cmp1=0,cmp=0;p=head;while(p!=NULL)if(strcmp(p->name,search_name)!=0){p=p->next;cmp++;}else{printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->dizhi,p->phone,p->email);p=p->next;cmp1=1;}if(cmp!=0&&cmp1==0)printf("没有该学生信息!!\n");}void xiugai(struct student *p1,long xiu_num) //修改学生信息{struct student *p2;p2=p1;while((p2!=NULL)&&(p2->num!=xiu_num))p2=p2->next;if(p2!=NULL){scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p2->num,&p2->age,p2->name,p2->sex,p2->chu shen,p2->dizhi,p2->phone,p2->email);}elseprintf("没有该学生信息!!\n");}struct student *delList(struct student *head,long del_num) // 删除学生信息{struct student *p,*q;p=head;q=head;while(p &&(p->num != del_num)){q=p;p=p->next;}if(p==NULL)printf("无此学号!\n");else{if(p == head){head = p->next;free(p);}else{q->next = p->next;free(p);}}return head;}void paixu(struct student *head) //按学号排序{struct student *p,*f,*t;char ch[100];int i;t=f=p=head;for(p=head;p->next!=NULL;p=p->next){for(t=head,f=t->next;t->next!=NULL;t=t->next,f=f->next){if(t->num>f->num>0){i=t->num;t->num=f->num;f->num=i;i=t->age;t->age=f->age;f->age=i;strcpy(ch,t->name);strcpy(t->name,f->name);strcpy(f->name,ch);strcpy(ch,t->sex);strcpy(t->sex,f->sex);strcpy(f->sex,ch);strcpy(ch,t->chushen);strcpy(t->chushen,f->chushen);strcpy(f->chushen,ch);strcpy(ch,t->dizhi);strcpy(t->dizhi,f->dizhi);strcpy(f->dizhi,ch);strcpy(ch,t->phone);strcpy(t->phone,f->phone);strcpy(f->phone,ch);strcpy(ch,t->email);strcpy(t->email,f->email);strcpy(f->email,ch);}}}// return head;}void save(struct student *head) //保存为磁盘文件{struct student *p;if((fp=fopen("keshe","w"))==NULL){printf("cannot open this file\n");exit(0);}p=head;while(p!=NULL){fprintf(fp,"%d\n",p->num);fprintf(fp,"%d\n",p->age);fprintf(fp,"%s\n",p->name);fprintf(fp,"%s\n",p->sex);fprintf(fp,"%s\n",p->chushen);fprintf(fp,"%s\n",p->dizhi);fprintf(fp,"%s\n",p->phone);fprintf(fp,"%s\n",p->email);p=p->next;}fclose(fp);}struct student *read() //从磁盘读取文件{struct student *head=NULL;struct student *p=NULL;struct student *t=NULL;int a;// fp=fopen("keshe","r");if((fp=fopen("keshe","r"))==NULL){printf("cannot open this file\n");exit(0);}while(1){t=(struct student *)malloc(len);a=fscanf(fp,"%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&t->num,&t->age,t->name,t->sex,t->chush en,t->dizhi,t->phone,t->email);if(a==0||a==-1)return head;t->next=NULL;if(p==NULL){p=t;head=t;}else{p->next=t;p=p->next;p->next=NULL;}}fclose(fp);}void main(){int code=0;struct student *pt = NULL;while(code!=8){menu();printf("请输入上述序号进行操作:\n");scanf("%d",&code);system("cls");switch(code){case 1:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=creat();save(pt);system("cls");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("************录入学生信息成功***********!!\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 2:{system("cls");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();printList(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 3:{int search=0;system("cls");printf("===========================查询学生信息==============================\n");printf("---------------------------------------------------------------------\n");while(search!=3){printf("1、按学号查询\n2、按姓名查询\n3、退出查询\n");scanf("%d",&search);switch(search){case 1:{long search_num;system("cls");printf("请输入学生学号\n");scanf("%d",&search_num);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 2:{char search_name[15];system("cls");printf("请输入学生姓名\n");scanf("%s",search_name);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_name(read(),search_name);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};}}system("cls");};break;case 4:{long del_num;system("cls");printf("===========================删除学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("请输入要删除学生信息的学号:\n");scanf("%d",&del_num);system("cls");pt=delList(read(),del_num);save(pt);printf("===========================删除结果================================\n");printf("-------------------------------------------------------------------\n");printf("学号为%d的学生信息成功删除\n",del_num);printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 5:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");insert(pt);save(pt);system("cls");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("****插入学生信息成功***!!\n\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");}break;case 6:{long search_num;system("cls");printf("请输入要修改的学生学号:\n");scanf("%d",&search_num);system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================修改学生信息==================================\n");printf("-------------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("\n");printf("请输入修改信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();xiugai(pt,search_num);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("****修改学生信息成功***!!\n\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 7:{system("cls");printf(" 按学号从小到大排序\n\n");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();paixu(pt);printList(pt);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 8:read();break;}}}。
学生管理系统源代码2

学生管理系统源代码2学生管理系统源代码#include <stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>#define LEN sizeof(struct scorenode)#define DEBUGstruct scorenode{int number;/*学号*/char name[10];/*姓名*/float yuwen;/*语文成绩*/float yingyu;/*英语成绩*/float shuxue;/*数学成绩 */struct scorenode *next;};typedef struct scorenode score;int n,k;/*n,k为全局变量,本程序中的函数均可以使用它*/score *creat(void)/*函数creat,功能:创建链表,此函数带回一个指向链表头的指针*/{score*head;score *p1,*p2,*p3,*max;int i,j;float fen;char t[10];n=0;p1=p2=p3=(score *)malloc(LEN);head=p3; /*开辟一个新单元*/printf("请输入学生资料,输0退出!\n");repeat1: printf("请输入学生学号(学号应大于0):");/*输入学号,学号应大于0*/scanf("%d",&p1->number);while(p1->number<0){getchar();printf("输入错误,请重新输入学生学号:");scanf("%d",&p1->number);}/*输入学号为字符或小于0时,程序报错,提示重新输入学号*/ if(p1->number==0)goto end;/*当输入的学号为0时,转到末尾,结束创建链表*/ else{p3=head;if(n>0){for(i=0;i<n;i++){if(p1->number!=p3->number)p3=p3->next;else{printf("学号重复,请重输!\n");goto repeat1;/*当输入的学号已经存在,程序报错,返回前面重新输入*/ }}}printf("请输入学生姓名:");scanf("%s",&p1->name);/*输入学生姓名*/printf("请输入语文成绩(0~100):");/*输入语文成绩,成绩应在0-100*/scanf("%f",&p1->yuwen);while(p1->yuwen<0||p1->yuwen>100){getchar();printf("输入错误,请重新输入语文成绩");/*输入错误,重新输入语文成绩直到正确为止*/scanf("%f",&p1->yuwen);}printf("请输入英语成绩(0~100):");/*输入英语成绩,成绩应在0-100*/scanf("%f",&p1->yingyu);while(p1->yingyu<0||p1->yingyu>100){getchar();printf("输入错误,请重新输入英语成绩");/*输入错误,重新输入英语成绩直到正确为止*/scanf("%f",&p1->yingyu);printf("请输入数学成绩(0~100):");/*输入数学成绩,成绩应在0-100*/scanf("%f",&p1->shuxue);while(p1->shuxue<0||p1->shuxue>100){getchar();printf("输入错误,请重新输入数学成绩");scanf("%f",&p1->shuxue);}/*输入错误,重新输入数学成绩直到正确为止*/head=NULL;while(p1->number!=0){n=n+1;if(n==1)head=p1;elsep2->next=p1;p2=p1;p1=(score *)malloc(LEN);printf("请输入学生资料,输0退出!\n");repeat2:printf("请输入学生学号(学号应大于0):");scanf("%d",&p1->number);/*输入学号,学号应大于0*/while(p1->number<0){getchar();printf("输入错误,请重新输入学生学号:");scanf("%d",&p1->number);}/*输入学号为字符或小于0时,程序报错,提示重新输入学号*/ if(p1->number==0)goto end;/*当输入的学号为0时,转到末尾,结束创建链表*/ else{p3=head;if(n>0){for(i=0;i<n;i++){if(p1->number!=p3->number)p3=p3->next;else{printf("学号重复,请重输!\n");goto repeat2;/*当输入的学号已经存在,程序报错,返回前面重新输入*/ }}}}printf("请输入学生姓名:");scanf("%s",&p1->name);/*输入学生姓名*/printf("请输入语文成绩(0~100):");scanf("%f",&p1->yuwen);/*输入语文成绩,成绩应在0-100*/while(p1->yuwen<0||p1->yuwen>100){getchar();printf("输入错误,请重新输入语文成绩");scanf("%f",&p1->yuwen);}/*输入错误,重新输入语文成绩直到正确为止*/printf("请输入英语成绩(0~100):");scanf("%f",&p1->yingyu);/*输入英语成绩,成绩应在0-100*/while(p1->yingyu<0||p1->yingyu>100){getchar();printf("输入错误,请重新输入英语成绩");scanf("%f",&p1->yingyu);}/*输入错误,重新输入英语成绩直到正确为止*/printf("请输入数学成绩(0~100):");scanf("%f",&p1->shuxue);/*输入数学成绩,成绩应在0-100*/while(p1->shuxue<0||p1->shuxue>100){getchar();printf("输入错误,请重新输入数学成绩");scanf("%f",&p1->shuxue);}/*输入错误,重新输入数学成绩直到正确为止*/}end: p1=head;p3=p1;for(i=1;i<n;i++){for(j=i+1;j<=n;j++){max=p1;p1=p1->next;if(max->number>p1->number){k=max->number;max->number=p1->number;p1->number=k;/*交换前后结点中的学号值,使得学号大者移到后面的结点中*/strcpy(t,max->name);strcpy(max->name,p1->name);strcpy(p1->name,t);/*交换前后结点中的姓名,使之与学号相匹配*/fen=max->yuwen;max->yuwen=p1->yuwen;p1->yuwen=fen;/*交换前后结点中的语文成绩,使之与学号相匹配*/fen=max->yingyu;max->yingyu=p1->yingyu;p1->yingyu=fen;/*交换前后结点中的英语成绩,使之与学号相匹配*/fen=max->shuxue;max->shuxue=p1->shuxue;p1->shuxue=fen;/*交换前后结点中的数学成绩,使之与学号相匹配*/}}max=head;p1=head;/*重新使max,p指向链表头*/}p2->next=NULL;/*链表结尾*/printf("输入的学生数为:%d个!\n",n);return(head);}score *load(score *head)/*函数load,功能:从文件读入学生记录*/{ score *p1,*p2;int m=0;char filepn[10];FILE *fp;printf("请输入文件路径及文件名:");scanf("%s",filepn);/*输入文件路径及名称*/if((fp=fopen(filepn,"r+"))==NULL){printf("不能打开文件!\n");return 0;}fscanf(fp," 考试成绩管理系统\n");fscanf(fp,"作者:袁杰班级:计科七班学号:2009301500206 \n");fscanf(fp,"-----------------------------------------\n"); fscanf(fp,"|学号\t|姓名\t|语文\t|英语\t|数学\t|\n");fscanf(fp,"-----------------------------------------\n");/ *读入表格域*/printf(" 考试成绩管理系统 \n"); printf(" 作者:袁杰班级:计科七班学号:2009301500206 \n");printf("-----------------------------------------\n");printf("|学号\t|姓名\t|语文\t|英语\t|数学\t|\n");printf("-----------------------------------------\n");/*打印表格域*/m=m+1;if(m==1){p1=(score *)malloc(LEN); /*开辟一个新单元*/fscanf(fp,"%d%s%f%f%f",&p1->number,p1->name,&p1->yuwen,&p1 ->yingyu,&p1->shuxue);printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p1->number,p1->name,p1->yuwen,p1->yingyu,p1->shuxue);/*文件读入与显示*/head=NULL;do{n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(score *)malloc(LEN); /*开辟一个新单元*/fscanf(fp,"%d%s%f%f%f\n",&p1->number,p1->name,&p1->yuwen,& p1->yingyu,&p1->shuxue);printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p1->number,p1->name,p1->yuwen,p1->yingyu,p1->shuxue);/*文件读入与显示*/}while(!feof(fp));p2->next=p1;p1->next=NULL;n=n+1;}printf("-----------------------------------------\n");/*表格下线*/fclose(fp);/*结束读入,关闭文件*/return (head);}score *add(score *head,score *stu)/*函数add,功能:追加学生资料,并且将所有学生资料按学号排序*/ {score *p0,*p1,*p2,*p3,*max;int i,j;float fen;char t[10];p3=stu=(score *)malloc(LEN);/*开辟一个新单元*/printf("\n输入要增加的学生的资料!");repeat4: printf("请输入学生学号(学号应大于0):");scanf("%d",&stu->number);/*输入学号,学号应大于0*/while(stu->number<0){getchar();printf("输入错误,请重新输入学生学号:");scanf("%d",&stu->number);}/*输入错误,重新输入学号*/if(stu->number==0)goto end2;/*当输入的学号为0时,转到末尾,结束追加*/ else{p3=head;if(n>0){for(i=0;i<n;i++){if(stu->number!=p3->number)p3=p3->next;else{printf("学号重复,请重输!\n");goto repeat4;/*当输入的学号已经存在,程序报错,返回前面重新输入*/ }}}}/******************************************************/ printf("输入学生姓名:");scanf("%s",stu->name); /*输入学生姓名*/printf("请输入语文成绩(0~100):");scanf("%f",&stu->yuwen); /*输入语文成绩,成绩应在0-100*/while(stu->yuwen<0||stu->yuwen>100){getchar();printf("输入错误,请重新输入语文成绩");scanf("%f",&stu->yuwen);} /*输入错误,重新输入语文成绩直到正确为止*/printf("请输入英语成绩(0~100):");scanf("%f",&stu->yingyu);/*输入英语成绩,成绩应在0-100*/while(stu->yingyu<0||stu->yingyu>100){getchar();printf("输入错误,请重新输入英语成绩");scanf("%f",&stu->yingyu);}/*输入错误,重新输入英语成绩直到正确为止*/printf("请输入数学成绩(0~100):");scanf("%f",&stu->shuxue);/*输入数学成绩,成绩应在0-100*/while(stu->shuxue<0||stu->shuxue>100){getchar();printf("输入错误,请重新输入数学成绩");scanf("%f",&stu->shuxue);}/*输入错误,重新输入数学成绩直到正确为止*/p1=head;p0=stu;if(head==NULL){head=p0;p0->next=NULL;}/*当原来链表为空时,从首结点开始存放资料*/else/*原来链表不为空*/{if(p1->next==NULL)/*找到原来链表的末尾*/{p1->next=p0;p0->next=NULL;/*将它与新开单元相连接*/}else{while(p1->next!=NULL)/*还没找到末尾,继续找*/{p2=p1;p1=p1->next;}p1->next=p0;p0->next=NULL;}}n=n+1;p1=head;p0=stu;for(i=1;i<n;i++){for(j=i+1;j<=n;j++) {max=p1;p1=p1->next;if(max->number>p1->number) {k=max->number;max->number=p1->number;p1->number=k;/*交换前后结点中的学号值,使得学号大者移到后面的结点中*/strcpy(t,max->name);strcpy(max->name,p1->name);strcpy(p1->name,t);/*交换前后结点中的姓名,使之与学号相匹配*/fen=max->yuwen;max->yuwen=p1->yuwen;p1->yuwen=fen;/*交换前后结点中的语文成绩,使之与学号相匹配*/fen=max->yingyu;max->yingyu=p1->yingyu;p1->yingyu=fen;/*交换前后结点中的英语成绩,使之与学号相匹配*/fen=max->shuxue;max->shuxue=p1->shuxue;p1->shuxue=fen;/*交换前后结点中的数学成绩,使之与学号相匹配*/}}max=head;p1=head;/*重新使max,p指向链表头*/} end2:printf("现在的学生数为:%d个!\n",n);return(head);}score *search(score *head)/*函数search,功能:查询学生成绩*/{int number;score *p1,*p2;printf("输入要查询的学生的学号,");scanf("%d",&number);while(number!=0){if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}printf("-----------------------------------------\n"); printf("|学号\t|姓名\t|语文\t|英语\t|数学\t|\n");printf("-----------------------------------------\n");/*打印表格域*/p1=head;while(number!=p1->number&&p1->next!=NULL){p2=p1;p1=p1->next;}if(number==p1->number){printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p1->number,p1 ->name,p1->yuwen,p1->yingyu,p1->shuxue);printf("-----------------------------------------\n");}/*打印表格域*/elseprintf("%d不存在此学生!\n",number);printf("输入要查询的学生的学号,");scanf("%d",&number);}printf("已经退出了!\n");return(head);}score *del(score *head)/*函数del,功能:删除学生资料*/ {score *p1,*p2;int number;printf("输入要删除的学生的学号(输入0时退出):");scanf("%d",&number);getchar();while(number!=0)/*输入学号为0时退出*/{if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}p1=head;while(number!=p1->number&&p1->next!=NULL)/*p1指向的不是所要找的首结点,并且后面还有结点*/ {p2=p1;p1=p1->next;} /*p1后移一个结点*/if(number==p1->number)/*找到了*/{if(p1==head)head=p1->next;/*若p1指向的是首结点,把地二个结点地址赋予head*/ elsep2->next=p1->next;/*否则将下一个结点地址赋给前一结点地址*/printf("删除:%d\n",number);n=n-1;}elseprintf("%d不存在此学生!\n",number); /*找不到该结点*/printf("输入要删除的学生的学号:");scanf("%d",&number);getchar();}#ifdef DEBUGprintf("已经退出了!\n");#endifprintf("现在的学生数为:%d个!\n",n); return(head);}void print(score *head)/*函数print,功能:显示学生成绩*/score *p;if(head==NULL){printf("\n没有任何学生资料!\n");}else{printf("%d\n",n);printf("-----------------------------------------\n"); printf("|学号\t|姓名\t|语文\t|英语\t|数学\t|\n");printf("-----------------------------------------\n");/*打印表格域*/p=head;do{printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p-> name,p->yuwen,p->yingyu,p->shuxue);printf("-----------------------------------------\n");/*打印表格域*/p=p->next;}while (p!=NULL);/*打印完成了*/}}score *statistics(score *head)/*函数statistics,功能:统计学生成绩*/{floatsum1=0,sum2=0,sum3=0,ave1=0,ave2=0,ave3=0,max=0,min;score *p;int x,y=0,i=0;p=head;printf("1个人总分和平均分\t2单科平均分\t3总分最高分\t4总分最低分\n");scanf("%d",&x);getchar();switch(x){case 1: if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}/*链表为空*/else{printf("---------------------------------------------------------\n");printf("|学号\t|姓名\t|语文\t|英语\t|数学\t|总分\t|平均分\t|\n");printf("---------------------------------------------------------\n");/*打印表格域*/while(p!=NULL){sum1=p->yuwen+p->yingyu+p->shuxue; /*计算个人总分*/ave1=sum1/3;/*计算个人平均分*/printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|\n", p->number,p->name,p->yuwen,p->yingyu,p->shuxue,sum1,ave1); /*打印结果*/printf("---------------------------------------------------------\n");/*打印表格域*/p=p->next;}}return(head); break;case 2: if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}/*链表为空*/while(p!=NULL){sum1=sum1+p->yuwen;sum2=sum2+p->yingyu;sum3=sum3+p->shuxue;/*计算总分*/y=y+1;ave1=sum1/y;ave2=sum2/y;ave3=sum3/y;/*计算平均分*/p=p->next;/*使p指向下一个结点*/}printf("语文平均分是%.1f\n",ave1);printf("英语平均分是%.1f\n",ave2);printf("数学平均分是%.1f\n",ave3);/*打印结果*/return(head); break;case 3:if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}/*链表为空*/max=p->yuwen+p->yingyu+p->shuxue;while(i<n){i=i+1;sum1=p->yuwen+p->yingyu+p->shuxue; /*计算个人总分*/ if(max<sum1)max=sum1;p=p->next;}printf("总分最高分:%.1f",max);printf("\n");return(head); break;case 4: if(head==NULL){printf("\n没有任何学生资料!\n");return(head);}/*链表为空*/while(p!=NULL){min=p->yuwen+p->yingyu+p->shuxue; while(p!=NULL){sum2=p->yuwen+p->yingyu+p->shuxue;if(min>sum2)min=sum2;p=p->next;}}printf("总分最低分:%.1f",min);printf("\n");return(head); break;default :printf("输入错误,请重试!\n"); }return(head);}save(score *p1)/*函数save,功能:保存学生的资料*/{FILE *fp;char filepn[20];/*用来存放文件保存路径以及文件名*/printf("请输入文件路径及文件名:");scanf("%s",filepn);if((fp=fopen(filepn,"w+"))==NULL){printf("不能打开文件!\n");return 0;}fprintf(fp," 考试成绩管理系统\n");fprintf(fp," 作者:袁杰班级:计科七班学号:2009301500206 \n");fprintf(fp,"-----------------------------------------\n"); fprintf(fp,"|学号\t|姓名\t|语文\t|英语\t|数学\t|\n");fprintf(fp,"-----------------------------------------\n"); /*打印表格域*/while(p1!=NULL){fprintf(fp,"%d\t%s\t%.1f\t%.1f\t%.1f\t\n",p1->number,p1->n ame,p1->yuwen,p1->yingyu,p1->shuxue);p1=p1->next;/*下移一个结点*/}fclose(fp);printf("文件已经保存!\n");return 0;}score *taxis(score *head)/*定义排序函数。
学生信息管理系统系统源代码

学生信息管理系统系统源代码(总34页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--系统源代码一、登录界面代码using System;using ;using ;using ;using ;using partial class login : protected void txtid_Click(object sender, EventArgs e){= "";= "";}protected void Button1_Click(object sender, EventArgs e){string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);();DataSet ds=new DataSet () ;SqlDataAdapter da = new SqlDataAdapter("select * from users where userid='" + + "' and userpwd='" + + "'", conn);(ds);if [0].==0){Label3 .Text ="账号或密码错误,请重新输入!";}else{Session ["userid"]=txtid .Text ;Session["userpwd"] = ;Session["username"] = [0].Rows[0]["username"].ToString(); Session["userpower"] = [0].Rows[0]["userpower"].ToString(); if (Session["userpower"].ToString () == "0"){("admin/");}else if (Session["userpower"].ToString() == "1"){("student/");}else{= "对不起,权限验证失败";}}();();}}二、添加课程页面代码using System;using ;using ;using ;using ;using partial class addcourse : SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){"onblur", "checkcourseid()");string strconn = ["connStr"];conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if == ""){= "课程号不能为空";}else{string sqlstr = "";sqlstr = "insert intocourse(courseid,coursename,coursetime,fen,type,teacher)values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();try{();("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){("<script>javascript:alert('添加失败!!!');</script>");}finally{();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e) {= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}三、添加成绩程序代码using System;using ;using ;using ;using ;using partial class addscore : SqlCommand mycmd; SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);}{if .ToString ()== ""){= "学号不能为空";}else{string sqlstr = "";sqlstr = "insert intoscore(userid,username,courseid,coursename,score,[year])values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();try{();("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){("<script>javascript:alert('添加失败!!!');</script>");}finally{();sqlstr = "";}}}{= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e){("");}protected void userid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select username from students where userid='" + + "'";();mycmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select coursename from course where courseid='" + + "'";();mycmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["coursename"].ToString();}}}四、添加学生程序代码using System;using ;using ;using ;using ;using ;using ;using partial class addstudent : SqlComman d mycmd; protected void Page_Load(object sender, EventArgs e){"onblur", "checkuserid()");string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e) {if == "")return;string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sqlstr = "";string sql = "";sqlstr = "insert intostudents(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhua ny,tel,idc,zhengzmm,zhiw,huoj,weij)values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();string name = 获取上传文件的名称string type = ("\\") + 1);alue = wpath;();oString();string sql = "select courseid from course where courseid='" + nam + "'"; SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);();SqlDataReader dr = ();if ()){("<b class='Error'>该课程号已经存在,请换一个</b>");}else{("<b class='Right'>该课程号可以使用</b>");}();}}六、检查学号唯一性程序代码using System;using ;using ;using ;using ;using partial class checkuser : protected void Page_Load(object sen der, EventArgs e){= 0;string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = ["name"].ToString();string sql = "select userid from students where userid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);();SqlDataReader dr = ();if ()){("<b class='Error'>该学号已经存在,请换一个</b>");}else{("<b class='Right'>该学号可以使用</b>");}();}}七、课程信息程序代码using System;using ;using ;using ;using ;using partial class course : SqlConnection conn;SqlDataReader getdata;protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);SqlDataReader getdata;SqlCommand mycmd;DataSet ds = new DataSet();string sql = "";sql = "select * from course order by courseid";mycmd = new SqlCommand(sql, conn);();getdata = ();= getdata;();();();}protected void Button1_Click(object sender, EventArgs e) {DataSet ds;SqlDataReader da;string strsql = "";SqlCommand cmd;();strsql = "select * from course where courseid='" + + "'or coursename like '" + + "'";cmd = new SqlCommand(strsql, conn);da = ();= da;();();();}}八、编辑、删除学生信息程序代码using System;using ;using ;using ;using ;using partial class images_editstudent : SqlCommand cmd;SqlCommand cmd2;protected void Page_Load(object sender, EventArgs e){if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "select * from students where userid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["userId"].ToString();= reader["username"].ToString();= reader["sex"].ToString();= reader["minzu"].ToString();= reader["birthday"].ToString();= reader["class"].ToString();= reader["comefrom"].ToString();= reader["xuey"].ToString();= reader["zhuany"].ToString();= reader["tel"].ToString();= reader["idc"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, EventArgs e) {string uid="";uid=Page .Request ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql="";sql = "update students set userid='" + + "',username='" + + "',minzu='" + + "',sex='" + + "',birthday='" + + "',class='" + + "',comefrom='" + + "',beizhu='" + + "',xuey='" + + "',zhuany='" + + "',tel='" + + "',idc='" + + "',zhengzmm='" + + "'where userid='" + uid + "'";cmd=new SqlCommand (sql,conn );();try{();["color"] = "blue";= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch(SqlException ){= "编辑失败";["color"] = "red";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";string sqlall = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "delete from students where userid='" + uid + "'";sqlall = "delete from images where userid='" + uid + "'";cmd = new SqlCommand(sql, conn);cmd2 = new SqlCommand(sqlall,conn);();try{();string sql1 = "";sql1 = "delete from users where userid='" + uid + "'"; SqlCommand cmd1 = new SqlCommand(sql1, conn); ();try{();["color"] = "blue";= "删除成功";("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){= "删除失败";("<script>javascript:alert('删除失败!!!');</script>"); }finally{sql1 = "";}}catch(SqlException ){= "删除失败";["color"] = "red";}();();= "";= "";= "";= "";= "";= "";= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}九、编辑、删除课程信息程序代码using System;using ;using ;using ;using ;using partial class editcourse : SqlCommand cmd;protected void Page_Load(object sender, EventArgs e){if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "select * from course where courseid='" + uid + "'"; SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["courseid"].ToString();= reader["coursename"].ToString();= reader["coursetime"].ToString();= reader["fen"].ToString();= reader["type"].ToString();= reader["teacher"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, Even tArgs e){string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql = "";sql = "update course set courseid='" + + "',coursename='" + +"',coursetime='" + + "',fen='" + + "',type='" + + "',teacher='" + + "' where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){= "编辑失败";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "delete from course where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "删除成功";("<script>javascript:alert('删除成功!!!');</script>"); }catch (SqlException){= "删除失败";}();();= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}十、编辑、删除成绩信息程序代码using System;using ;using ;using ;using ;using partial class editscore : SqlCommand cmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e) {if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "select * from score where id='" + uid + "'"; SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["id"].ToString();= reader["userid"].ToString();= reader["username"].ToString();= reader["courseid"].ToString();= reader["coursename"].ToString();= reader["score"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = ["id"];string sql = "";string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "update score set userid='" + + "',username='" + + "',courseid='" + + "',coursename='" + + "',score='" + + "',[year]='" + + "'where id='" + uid + "'";cmd = new SqlCommand(sql,conn );();try{();= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){= "编辑失败";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = ["id"];string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "delete from score where id='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "删除成功";("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){= "删除失败";}();();= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e){("");}protected void userid_SelectedIndexChanged(object sender, EventArgs e) {string strconn = ["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select username from students where userid='" + + "'";cmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select coursename from course where courseid='" + + "'";();cmd = new SqlCommand(sqlstr, c onn);();SqlDataReader da;da = ();while ()){= da["coursename"].ToString();}}}十一、修改密码程序代码using System;using ;using ;using ;using partial class modify_pwd : Sql Connection conn; protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e) {string sql="";SqlCommand cmd;string uid;string pwd;uid = Session["userid"].ToString ();pwd = Session["userpwd"].ToString();if == ""){= "原密码不能为空";}else if == ""){= "新密码不能为空";}else if !={= "新密码和确认密码不一致";}else if != pwd)= "原密码不正确";}else{sql = "";sql = "update users set userpwd='" + + "'where userid='" + uid + "'"; cmd = new SqlCommand(sql, conn);();try{();= "密码修改成功";}catch (SqlException){= "密码修改失败";}finally{();}}}protected void Button2_Click(object sender, EventArgs e){("");}}十二、学生身份操作主界面程序代码using System;using ;using ;using ;using ;using partial class student : protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string strsql = "";string a = Session["userid"].ToString();();strsql = "select * from students where userid='"+a+"'";DataSet ds=new DataSet () ;SqlDataAdapter da= new SqlDataAdapter(strsql, conn);(ds);if [0]. == 0){Response .Write ("没有记录");}else{= [0].Rows[0]["userid"].ToString();= [0].Rows[0]["username"].ToString();= [0].Rows[0]["sex"].ToString();= [0].Rows[0]["minzu"].ToString();= DateTime .Parse [0].Rows[0]["birthday"].ToString()).ToShortDateString ();= [0].Rows[0]["class"].ToString();= [0].Rows[0]["comefrom"].ToString();= [0].Rows[0]["beizhu"].ToString();}();}}十三、学生身份成绩信息程序代码using System;using ;using ;using ;using ;using partial class score : SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);SqlDataReader getdata;SqlDataAdapter da = new SqlDataAdapter();SqlCommand mycmd;DataSet ds = new DataSet();string Sql;Sql = "select * from score where userid='" + Session["user id"] + "'"; mycmd = new SqlCommand(Sql, conn);= mycmd;(ds, "login");();// getdata = ();// = getdata;= ["login"]; ;();();}protected void Button1_Click(object sender, EventArgs e){= 0;SqlDataReader getdata;SqlDataAdapter da = new SqlDataAdapter();SqlCommand mycmd;DataSet ds = new DataSet();string Sql;Sql = "select * from score where userid='" + + "'or year='" + + "'"; mycmd = new SqlCommand(Sql, conn);= mycmd;(ds, "login");();//getdata = ();// = getdata;= ["login"]; ;();();}protected void datagrid1_PageIndexC hanged(object source, DataGridPageChangedEventArgs e){= ;();}}。
学生管理系统(界面+源代码)

内蒙古信息工程系学实训报告系部:信息技术系课程名称:网站网页制作专业班级:14计算机网络技术一班姓名:xxx任课老师:xxx实验实训项目名称网站制作实验类型验证型实验室思科网络实验室实验时间[实验方案设计(步骤)]实验目的:1.熟练掌握SQL语句的编写。
2.掌握使用VS2010对网页的设计。
实验步骤:1.登录页面主要代码:protected void Button1_Click(object sender, EventArgs e){string username = TextBox1.Text;string password = TextBox2.Text;string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("select * from UserInfo where username='" + username + "' and password='" + password + "'", conn);conn.Open();SqlDataReader reader = cmd.ExecuteReader();//记?录?集ˉif (reader.Read()){Response.Redirect("main.aspx");}else{Label1.Text = "用?户§名?或ò者?密ü码?错洙?误ó!?!?";}conn.Close();}2.主页面+用户信息管理页面左侧主要运用了TreeView控件,然后用户信息运用了GridView控件,链接数据源,在页面中展示用户信息,主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"AutoGenerateColumns="False"DataKeyNames="Userid"DataSourceID="SqlDataSource1"style="font-family: 楷?体?; font-size: medium"Width="550px"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None" BorderWidth="1px"CellPadding="3"CellSpacing="2"><Columns><asp:BoundField DataField="Userid"HeaderText="序ò号?"ReadOnly="True"SortExpression="Userid"/><asp:BoundField DataField="UserName"HeaderText="用?户§名?"SortExpression="UserName"/><asp:BoundField DataField="Password"HeaderText="密ü码?"SortExpression="Password"/><asp:BoundField DataField="Email"HeaderText="电?子哩?邮?件t" SortExpression="Email"/><asp:CommandField ShowDeleteButton="True"ShowEditButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView><br/><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString %>"DeleteCommand="DELETE FROM [UserInfo] WHERE [Userid] = @Userid"InsertCommand="INSERT INTO [UserInfo] ([Userid], [UserName], [Password], [Email]) VALUES (@Userid, @UserName, @Password, @Email)"SelectCommand="SELECT * FROM [UserInfo]"UpdateCommand="UPDATE [UserInfo] SET [UserName] = @UserName, [Password] = @Password, [Email] = @Email WHERE [Userid] = @Userid">3.学籍信息添加页面主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoStudentXj(Sno,Sname,Ssex,Sbrithday,DepartNo,ClassNo,Tel,Srxtime,xuezhi,xueli,address,youbian ,zzmm,pingjia)values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + RadioButtonList1.Text + "','" + this.TextBox3.Text + "','" + this.TextBox12.Text + "','" + this.TextBox4.Text + "','" + this.TextBox5.Text + "','" + this.TextBox6.Text + "','" +this.TextBox7.Text + "','" + this.TextBox8.Text + "','" + this.TextBox9.Text + "','" +this.TextBox10.Text + "','" + DropDownList1.Text + "','" + this.TextBox11.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();}4.学籍信息修改本页面也是用GridView控件,与数据库连接,展示出学籍信息,然后生成“修改”,单击“修改”方可进行修改,主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Sno"DataSourceID="SqlDataSource1"style="text-align: center; font-family: 楷?体?; font-size: large; margin-top: 0px;"Width="1471px"><Columns><asp:BoundField DataField="Sno"HeaderText="Sno"ReadOnly="True"SortExpression="Sno"/><asp:BoundField DataField="Sname"HeaderText="Sname"SortExpression="Sname"/><asp:BoundField DataField="Ssex"HeaderText="Ssex"SortExpression="Ssex"/><asp:BoundField DataField="Sbrithday"HeaderText="Sbrithday"本页面运用GridView控件展示出学生信息,设置三种条件查询,按学号、姓名、系别方可查询出学生信息,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentXj", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentXj where Sno='" +this.TextBox1.Text + "' or Sname='"+ this.TextBox2.Text + "' or DepartNo='"+ this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}6.课程信息添加主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoCourse(Courseid,CourseName,Credit,Datetime)values('" + this.TextBox1.Text + "','" +this.TextBox2.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();Label1.Text = "添?加ó成é功|!?!?!?";}7.课程信息修改添加了GridView控件,使它与数据源连接,查询课程信息分三个条件,按课程编号、课程名称、日期方可查询,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from Course", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from Course where Courseid='" + this.TextBox1.Text + "' or CourseName='" + this.TextBox2.Text + "' or Datetime='" +this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}9.课程信息删除主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Courseid"DataSourceID="SqlDataSource1"style="text-align: center; font-family: 楷?体?; font-size: large;"><Columns><asp:BoundField DataField="Courseid"HeaderText="Courseid"ReadOnly="True"SortExpression="Courseid"/><asp:BoundField DataField="CourseName"HeaderText="CourseName"SortExpression="CourseName"/><asp:BoundField DataField="Credit"HeaderText="Credit"SortExpression="Credit"/><asp:BoundField DataField="Datetime"HeaderText="Datetime"SortExpression="Datetime"/><asp:CommandField ShowDeleteButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView></center><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString3 %>"DeleteCommand="DELETE FROM [Course] WHERE [Courseid] = @Courseid"InsertCommand="INSERT INTO [Course] ([Courseid], [CourseName], [Credit],[Datetime]) VALUES (@Courseid, @CourseName, @Credit, @Datetime)"SelectCommand="SELECT * FROM [Course]"UpdateCommand="UPDATE [Course] SET [CourseName] = @CourseName, [Credit] = @Credit, [Datetime] = @Datetime WHERE [Courseid] = @Courseid"><DeleteParameters><asp:Parameter Name="Courseid"Type="Int32"/></DeleteParameters>10.学生成绩添加主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoStudentCJ(Sno,Sname,CourseName,Score)values('" + this.TextBox1.Text + "','" +this.TextBox2.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();Label1.Text = "添?加ó成é功|!?!?!?";}11.学生成绩修改主要代码:<asp:GridView ID="GridView1"runat="server"添加了GridView控件,使它与数据源连接,查询课程信息分三个条件,按课程名称、学号、姓名方可查询,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentCJ", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button2_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentCJ where CourseName='" + this.TextBox1.Text + "' or Sno='" + this.TextBox2.Text + "' or Sname='" + this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}13.学生成绩删除主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Sno"DataSourceID="SqlDataSource1"style="font-family: 楷?体?; font-size: large; text-align: center"Width="561px"><Columns><asp:BoundField DataField="Sno"HeaderText="Sno"ReadOnly="True"SortExpression="Sno"/><asp:BoundField DataField="Sname"HeaderText="Sname"SortExpression="Sname"/><asp:BoundField DataField="CourseName"HeaderText="CourseName"SortExpression="CourseName"/><asp:BoundField DataField="Score"HeaderText="Score"SortExpression="Score"/><asp:CommandField ShowDeleteButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString6 %>"DeleteCommand="DELETE FROM [StudentCJ] WHERE [Sno] = @Sno"InsertCommand="INSERT INTO [StudentCJ] ([Sno], [Sname], [CourseName], [Score]) VALUES (@Sno, @Sname, @CourseName, @Score)"SelectCommand="SELECT * FROM [StudentCJ]"UpdateCommand="UPDATE [StudentCJ] SET [Sname] = @Sname, [CourseName] = @CourseName, [Score] = @Score WHERE [Sno] = @Sno"><DeleteParameters><asp:Parameter Name="Sno"Type="String"/></DeleteParameters>。
学生管理查询系统源代码

学生管理查询系统Java编程首先我们需要理清思路关于课程的类程序代码:public class course {String name;String courseID;String term;String classHour;String creditHour;Object teacher;String students;public student[] student;}关于学生的类程序代码:public class student {String name;String sex;String stuID;String classname;String major;String collge;String loginName;String password;String college;}关于教师的类程序代码:public class teacher {String name;String sex;String teacherID;String college;String school;String loginName;String password;}关于成绩的类程序代码:public class score {String courseID;String studentID;String scores;}关于测试的类程序代码:public class text {public static void main(String[]args){student s=new student();="XXX";s.sex="X";s.stuID="XXXXXXXXXXX";s.classname="13XX";teacher t =new teacher();="XX";t.sex="X";t.college="XXXXXXXXX";course c =new course();="XXXXXXXX";c.teacher=t;System.out.println("姓名:"++" 性别:"+s.sex+" 学号:"+s.stuID+" 专业:"+s.classname);System.out.println("教室姓名:"++" 性别:"+t.sex+" 课程名称:"+t.college);}}。
(完整版)JAVA学生管理系统源代码

JA V A学生管理系统源代码一、程序import java.util.*;public class Test {//主程序public static void main(String[] args){Scanner in = new Scanner(System.in);System.out.println("------请定义学生的人数:------");Student[] stuArr = new Student[in.nextInt()];Admin adminStu = new Admin();while(true){System.out.println("-----请选择你要执行的功能-----");System.out.println("10:添加一个学生");System.out.println("11:查找一个学生");System.out.println("12:根据学生编号更新学生基本信息");System.out.println("13:根据学生编号删除学生");System.out.println("14:根据编号输入学生各门成绩");System.out.println("15:根据某门成绩进行排序");System.out.println("16:根据总分进行排序");System.out.println("99:退出系统");String number = in.next();if(number.equals("10")){System.out.println("请输入学生的编号:");int num = in.nextInt();System.out.println("请输入学生的姓名:");String name = in.next();System.out.println("请输入学生的年龄:");int age = in.nextInt();adminStu.Create(num,name,age,stuArr);//添加学生}else if(number.equals("11")){System.out.println("执行查找学生基本信息的操作");System.out.println("请输入学生的编号进行查找:");int num = in.nextInt();adminStu.find(num,stuArr);//查找学生}else if(number.equals("12")){System.out.println("执行更新学员的基本信息操作");System.out.println("请输入学生的编号:");int num = in.nextInt();System.out.println("请输入学生的姓名:");String name = in.next();System.out.println("请输入学生的年龄:");int age = in.nextInt();adminStu.update(num,name,age,stuArr);//更新学生基本信息}else if(number.equals("13")){System.out.println("执行删除学生操作");System.out.println("请输入学生编号:");int num = in.nextInt();adminStu.delete(num,stuArr);//删除学生}else if(number.equals("14")){System.out.println("执行输入成绩操作");System.out.println("请输入学生编号:");int num = in.nextInt();adminStu.input(num, stuArr);//输入成绩}else if(number.equals("15")){System.out.println("执行根据某科目成绩排序操作");System.out.println("请选择需要排序的科目名(1.java 2.C# 3.html 4.sql):");int num = in.nextInt();adminStu.courseSort(num,stuArr);//按科目排序}else if(number.equals("16")){System.out.println("执行根据总分排序操作");adminStu.sumSort(stuArr);//按总分排序}else if(number.equals("99")){System.out.println("--------程序已退出--------");//break;System.exit(0);}}}}二、学生类public class Student {//学生类private int num;private String name;private int age;private int java;private int C;private int html;private int sql;private int sum;private int avg;public int getNum() {return num;}public void setNum(int num) { this.num = num;}public String getName() {return name;}public void setName(String name) { = name;}public int getAge() {return age;}public void setAge(int age) { this.age = age;}public int getJava() {return java;}public void setJava(int java) { this.java = java;}public int getC() {return C;}public void setC(int c) {C = c;}public int getHtml() {return html;}public void setHtml(int html) { this.html = html;}public int getSql() {return sql;}public void setSql(int sql) { this.sql = sql;}public int getSum() {return sum;}public void setSum() {this.sum = this.java+this.C+this.html+this.sql;}public int getAvg() {return avg;}public void setAvg() {this.avg = this.sum/4;}public String toString(){String str= "\t"+this.num+"\t"++"\t"+this.age+"\t"+this.java+"\t"+this.C+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"+this.avg;return str;}}三、管理学生类import java.util.*;public class Admin {//用来管理学生的一个类String msg = "\t编号\t姓名\t年龄\tjava\tC#\thtml\tsql\t总分\t 平均分";public void print(Student[] arr){//刷新数据的方法System.out.println(msg);for(int i=0;i<arr.length;i++){if(arr[i]!=null){arr[i].setSum();arr[i].setAvg();System.out.println(arr[i]);}}}public boolean exist(int num,Student stu){//判断学生是否存在的方法if(stu!=null){if(stu.getNum()==num){return true;}else{return false;}}return false;}public void Create(int num,String name,int age,Student[] arr){//添加学生的方法Student stu = new Student();stu.setNum(num);stu.setName(name);stu.setAge(age);int i = this.setIndex(arr);if(i==99999){System.out.println("学生人数已添满,不能再添加了");}else{arr[i]=stu;}this.print(arr);}public int setIndex(Student[] arr){//返回数组为空的下标for(int i=0;i<arr.length;i++){if(arr[i]==null){return i;}}return 99999;}public void find(int num,Student[] arr){//查询学生的方法for(int i=0;i<arr.length;i++){//判断学生是否存在if(this.exist(num,arr[i])==true){System.out.println(msg);System.out.println(arr[i]);return;}}System.out.println("-----没有这个学生的存在-----");}public void update(int num,String name,int age,Student[] arr){//更新学生基本信息的方法for(int i=0;i<arr.length;i++){if(this.exist(num, arr[i])==true){arr[i].setName(name);arr[i].setAge(age);System.out.println("--------更新学生信息成功!-------");this.print(arr);return;}}System.out.println("------没找到这个学生更新信息失败------");}public void delete(int num,Student[] arr){//删除学生的方法for(int i=0;i<arr.length;i++){if(this.exist(num,arr[i])){arr[i] = null;this.print(arr);return;}}System.out.println("您所指定编号的学生不存在");}public void input(int num,Student[] arr){//输入学生成绩的方法for(int i=0;i<arr.length;i++){if(this.exist(num, arr[i])){Scanner in = new Scanner(System.in);System.out.println("请输入"+arr[i].getName()+"java 的成绩:");if(in.hasNextInt()){//输入非整形数则不执行arr[i].setJava(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"C#的成绩:");if(in.hasNextInt()){arr[i].setC(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"html 的成绩:");if(in.hasNextInt()){arr[i].setHtml(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"sql 的成绩:");if(in.hasNextInt()){arr[i].setSql(in.nextInt());}else{return;}this.print(arr);return;}}}public void courseSort(int num,Student[] arr){//根据指定科目排序的方法if(num==1){//这里不能用冒泡排序(因为冒泡排序是相邻的比较,而相邻的可能不存在,那么相隔的两个就不能交换)for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getJava()<arr[j].getJava()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==2){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getC()<arr[j].getC()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==3){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getHtml()<arr[j].getHtml()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==4){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getSql()<arr[j].getSql()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}this.print(arr);}public void sumSort(Student[] arr){//根据总分排序的方法for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getSum()<arr[j].getSum()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}this.print(arr);}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
内蒙古信息工程系学实训报告系部:信息技术系课程名称:网站网页制作专业班级:14计算机网络技术一班姓名:xxx任课老师:xxx实验实训项目名称网站制作实验类型验证型实验室思科网络实验室实验时间[实验方案设计(步骤)]实验目的:1.熟练掌握SQL语句的编写。
2.掌握使用VS2010对网页的设计。
实验步骤:1.登录页面主要代码:protected void Button1_Click(object sender, EventArgs e){string username = TextBox1.Text;string password = TextBox2.Text;string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("select * from UserInfo where username='" + username + "' and password='" + password + "'", conn);conn.Open();SqlDataReader reader = cmd.ExecuteReader();//记?录?集ˉif (reader.Read()){Response.Redirect("main.aspx");}else{Label1.Text = "用?户§名?或ò者?密ü码?错洙?误ó!?!?";}conn.Close();}2.主页面+用户信息管理页面左侧主要运用了TreeView控件,然后用户信息运用了GridView控件,链接数据源,在页面中展示用户信息,主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"AutoGenerateColumns="False"DataKeyNames="Userid"DataSourceID="SqlDataSource1"style="font-family: 楷?体?; font-size: medium"Width="550px"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None" BorderWidth="1px"CellPadding="3"CellSpacing="2"><Columns><asp:BoundField DataField="Userid"HeaderText="序ò号?"ReadOnly="True"SortExpression="Userid"/><asp:BoundField DataField="UserName"HeaderText="用?户§名?"SortExpression="UserName"/><asp:BoundField DataField="Password"HeaderText="密ü码?"SortExpression="Password"/><asp:BoundField DataField="Email"HeaderText="电?子哩?邮?件t" SortExpression="Email"/><asp:CommandField ShowDeleteButton="True"ShowEditButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView><br/><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString %>"DeleteCommand="DELETE FROM [UserInfo] WHERE [Userid] = @Userid"InsertCommand="INSERT INTO [UserInfo] ([Userid], [UserName], [Password], [Email]) VALUES (@Userid, @UserName, @Password, @Email)"SelectCommand="SELECT * FROM [UserInfo]"UpdateCommand="UPDATE [UserInfo] SET [UserName] = @UserName, [Password] = @Password, [Email] = @Email WHERE [Userid] = @Userid">3.学籍信息添加页面主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoStudentXj(Sno,Sname,Ssex,Sbrithday,DepartNo,ClassNo,Tel,Srxtime,xuezhi,xueli,address,youbian ,zzmm,pingjia)values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + RadioButtonList1.Text + "','" + this.TextBox3.Text + "','" + this.TextBox12.Text + "','" + this.TextBox4.Text + "','" + this.TextBox5.Text + "','" + this.TextBox6.Text + "','" +this.TextBox7.Text + "','" + this.TextBox8.Text + "','" + this.TextBox9.Text + "','" +this.TextBox10.Text + "','" + DropDownList1.Text + "','" + this.TextBox11.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();}4.学籍信息修改本页面也是用GridView控件,与数据库连接,展示出学籍信息,然后生成“修改”,单击“修改”方可进行修改,主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Sno"DataSourceID="SqlDataSource1"style="text-align: center; font-family: 楷?体?; font-size: large; margin-top: 0px;"Width="1471px"><Columns><asp:BoundField DataField="Sno"HeaderText="Sno"ReadOnly="True"SortExpression="Sno"/><asp:BoundField DataField="Sname"HeaderText="Sname"SortExpression="Sname"/><asp:BoundField DataField="Ssex"HeaderText="Ssex"SortExpression="Ssex"/><asp:BoundField DataField="Sbrithday"HeaderText="Sbrithday"本页面运用GridView控件展示出学生信息,设置三种条件查询,按学号、姓名、系别方可查询出学生信息,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentXj", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentXj where Sno='" +this.TextBox1.Text + "' or Sname='"+ this.TextBox2.Text + "' or DepartNo='"+ this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}6.课程信息添加主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoCourse(Courseid,CourseName,Credit,Datetime)values('" + this.TextBox1.Text + "','" +this.TextBox2.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();Label1.Text = "添?加ó成é功|!?!?!?";}7.课程信息修改添加了GridView控件,使它与数据源连接,查询课程信息分三个条件,按课程编号、课程名称、日期方可查询,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from Course", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from Course where Courseid='" + this.TextBox1.Text + "' or CourseName='" + this.TextBox2.Text + "' or Datetime='" +this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}9.课程信息删除主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Courseid"DataSourceID="SqlDataSource1"style="text-align: center; font-family: 楷?体?; font-size: large;"><Columns><asp:BoundField DataField="Courseid"HeaderText="Courseid"ReadOnly="True"SortExpression="Courseid"/><asp:BoundField DataField="CourseName"HeaderText="CourseName"SortExpression="CourseName"/><asp:BoundField DataField="Credit"HeaderText="Credit"SortExpression="Credit"/><asp:BoundField DataField="Datetime"HeaderText="Datetime"SortExpression="Datetime"/><asp:CommandField ShowDeleteButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView></center><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString3 %>"DeleteCommand="DELETE FROM [Course] WHERE [Courseid] = @Courseid"InsertCommand="INSERT INTO [Course] ([Courseid], [CourseName], [Credit],[Datetime]) VALUES (@Courseid, @CourseName, @Credit, @Datetime)"SelectCommand="SELECT * FROM [Course]"UpdateCommand="UPDATE [Course] SET [CourseName] = @CourseName, [Credit] = @Credit, [Datetime] = @Datetime WHERE [Courseid] = @Courseid"><DeleteParameters><asp:Parameter Name="Courseid"Type="Int32"/></DeleteParameters>10.学生成绩添加主要代码:protected void Button1_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlCommand cmd = new SqlCommand("insert intoStudentCJ(Sno,Sname,CourseName,Score)values('" + this.TextBox1.Text + "','" +this.TextBox2.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "')", conn); conn.Open();cmd.ExecuteNonQuery();conn.Close();Label1.Text = "添?加ó成é功|!?!?!?";}11.学生成绩修改主要代码:<asp:GridView ID="GridView1"runat="server"添加了GridView控件,使它与数据源连接,查询课程信息分三个条件,按课程名称、学号、姓名方可查询,主要代码:protected void Page_Load(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentCJ", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}protected void Button2_Click(object sender, EventArgs e){string connStr = "server=(local);uid=sa;pwd=123456;database=StudentManager";SqlConnection conn = new SqlConnection(connStr);SqlDataAdapter da = new SqlDataAdapter("select * from StudentCJ where CourseName='" + this.TextBox1.Text + "' or Sno='" + this.TextBox2.Text + "' or Sname='" + this.TextBox3.Text + "'", conn);DataSet ds = new DataSet();da.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();}13.学生成绩删除主要代码:<asp:GridView ID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False"BackColor="#DEBA84"BorderColor="#DEBA84"BorderStyle="None"BorderWidth="1px"CellPadding="3"CellSpacing="2"DataKeyNames="Sno"DataSourceID="SqlDataSource1"style="font-family: 楷?体?; font-size: large; text-align: center"Width="561px"><Columns><asp:BoundField DataField="Sno"HeaderText="Sno"ReadOnly="True"SortExpression="Sno"/><asp:BoundField DataField="Sname"HeaderText="Sname"SortExpression="Sname"/><asp:BoundField DataField="CourseName"HeaderText="CourseName"SortExpression="CourseName"/><asp:BoundField DataField="Score"HeaderText="Score"SortExpression="Score"/><asp:CommandField ShowDeleteButton="True"/></Columns><FooterStyle BackColor="#F7DFB5"ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129"Font-Bold="True"ForeColor="White"/><PagerStyle ForeColor="#8C4510"HorizontalAlign="Center"/><RowStyle BackColor="#FFF7E7"ForeColor="#8C4510"/><SelectedRowStyle BackColor="#738A9C"Font-Bold="True"ForeColor="White"/><SortedAscendingCellStyle BackColor="#FFF1D4"/><SortedAscendingHeaderStyle BackColor="#B95C30"/><SortedDescendingCellStyle BackColor="#F1E5CE"/><SortedDescendingHeaderStyle BackColor="#93451F"/></asp:GridView><asp:SqlDataSource ID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StudentManagerConnectionString6 %>"DeleteCommand="DELETE FROM [StudentCJ] WHERE [Sno] = @Sno"InsertCommand="INSERT INTO [StudentCJ] ([Sno], [Sname], [CourseName], [Score]) VALUES (@Sno, @Sname, @CourseName, @Score)"SelectCommand="SELECT * FROM [StudentCJ]"UpdateCommand="UPDATE [StudentCJ] SET [Sname] = @Sname, [CourseName] = @CourseName, [Score] = @Score WHERE [Sno] = @Sno"><DeleteParameters><asp:Parameter Name="Sno"Type="String"/></DeleteParameters>最新文件---------------- 仅供参考--------------------已改成-----------word文本--------------------- 方便更改赠人玫瑰,手留余香。