学生管理系统源代码
学生管理系统c语言源代码
int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);
c语言学生管理系统源代码
c语言学生管理系统源代码#include <stdio.h>。
#include <stdlib.h>。
#include <string.h>。
/*定义学生结构体*/。
typedef struct student。
char num[20]; //学号。
char name[20]; //姓名。
int c; //语文成绩。
int math; //数学成绩。
float ave; //平均分。
struct student *next;。
} stu;。
/*函数声明*/。
void menu_select(); //显示菜单。
void add(); //添加学生信息。
void delete(); //删除学生信息。
void modify(); //修改学生信息。
void search(); //查询学生信息。
void get_ave(); //计算学生平均成绩。
void display(); //显示学生信息。
void esc(); //退出系统。
int main()。
menu_select();。
return 0;。
}。
//显示菜单。
void menu_select()。
int select;。
while (1)。
printf("\n学生管理系统\n");。
printf("------菜单------\n");。
printf("1.添加学生信息 2.删除学生信息\n");。
printf("3.修改学生信息 4.查询学生信息\n");。
printf("5.计算学生平均成绩 6.显示学生信息\n");。
printf("7.退出系统\n");。
printf("请输入您的选择:");。
scanf("%d", &select);。
韩顺平学生管理系统源代码
韩顺平学生管理系统源代码Document number【AA80KGB-AA98YT-AAT8CB-2A6UT-A18GG】(一)主界面的设计创建一个类StuManage,该类主要提供给用户一个界面,可以使用户很好的操作学生信息管理系统。
该主界面主要实现了界面的美化,为用户提供各种按钮,实现各种监听事件,具体步骤如下代码。
package com.test2;import javax.swing.*;import java.util.*;import java.awt.*;public class Test3 extends JFrame implements ActionListener {//定义一些控件JPane1 jp1,jp2;JLabel jl1;JButton jb1,jb2,jb3,jb4;JTable jt;JScrollpane jsp;JTextField jtf;StuModel sm;ublic static void main(String[] args){Text3 text=new Test3();}public Test3 (){jp1=new JPane1();jtf=new JTextField(10);jb1=new JButton("查询");jb1.addactionListener(this);jl1=new JLabel("请输入名字");//把各个空间加入到jpljp1.add(jl1);jp1.add(jtf);jp1.add(jbl);jp2=new JPane1 ();jp2=new JButton("添加");jb2.addActionListener( this);jp3=new JButton("修改");jb3.addActionListener( this); jp4=new JButton("删除");jb2.addActionListener( this);//把各个按钮加入到jp2jp2.add(jb2); jp2.add(jb3); jp2.add(jb4);//创建一个数据模型对象sm=new StuModel(); String[] paras={"1"};sm.queryStu("select * from stu where 1=?",paras);//初始化JTablejt=new JTable(sm)//初始化jsp JScrollPanejsp=new JScrollpane(jt);//把jsp放入到jframethis.add(jsp);this.add(jp1,"North");this.add(jp2,"South");this.setSize(400,300);this.setDefaultCloseOperation(JFrame.EXIT ON CLOSE );this.setVisible(true);}public void actionPerformed(ActionEvent arg0){//判断是哪个按钮被点击if(arg0.getSource()==jb1){//因为把对表的数据封装到stuModel中,我们就可以比较简单的完成查询//写一个sql语句String sql="select * fromstu where stuName=?";String paras[]={name};//构建新的数据模型类,并更新StuModel sm=new StuModel();sm.queryStu(sql,paras);//更新JTablejt.setModel(sm); }//当用户点击添加else if (arg0.getSource()==jb2){StuAddDialog sa =new stuAddDialog(this,"添加学校"true);//重新再获得新的数据模型//构建新的数据模型,并更新sm=new StuModel();String [] paras2={"1"};sm.queryStu("select * from stu where 1=?",paras2);//更新JTablejt.setModel(sm);} else if(arg.getSource()==jb3){//用户希望修改if (rowNum==-1) {//提示JOptionPane.showMessageDialog(this,"请选择一行");return ; }//显示修改对话框new StuUpdDialog(this,"修改学生",true,sm,rowNum);// 构建新的数据模型,并更新sm=new StuModel();String [] paras2={"1"};sm.queryStu("select * from stu where 1=?",paras2);// 更新JTablejt.setModel(sm) }else if(arg.getSource()==jb4){//说明用户希望删除记录1、得到该学生的id//getSelectedRow会返回用户中的行如果该用户一行都没有,就返回-1if (rowNum==-1){//提示JOptionPane.showMessageDialog(this,"请选择一行");return ;}//得到学生编号String stuId=(String)sm.getValueAt(rowNum,0);//创建一个aql语句String sql="delete from stu where stuid=?";String[]paras={stuId};StuModel temp=new StuModel();temp.updStu(aql,paras);//更新数据模型// 构建新的数据模型,并更新sm=new StuModel();String [] paras2={"1"};sm.queryStu("select * from stu where 1=?",paras2);// 更新JTablejt.setModel(sm);}}(二) 数据模型设计创建一个SqlHelper类,数据模型是把所有对表的操作都封装到里面,有很高的代码使用性,比如说具体代码如下。
学生信息管理系统完整源代码+mysql文件
数据库所用的数据自己导入MYSQL5.5,Navicat8就可以用了。
下面是具体的数据资料/*MySQL Data TransferSource Host: localhostSource Database: simsTarget Host: localhostTarget Database: simsDate: 2013-6-25 9:24:26*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for manager-- ----------------------------DROP TABLE IF EXISTS `manager`;CREATE TABLE `manager` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Table structure for studentinfo-- ----------------------------DROP TABLE IF EXISTS `studentinfo`;CREATE TABLE `studentinfo` (`Sname` varchar(30) NOT NULL,`Ssex` varchar(10) NOTNULL,`Snumber` varchar(10) NOT NULL,`Sprofession` varchar(30) NOT NULL,`Sclass`varchar(20) NOT NULL,`Sdate` varchar(30) character set utf8 collate utf8_unicode_ciNOT NULL,PRIMARY KEY (`Snumber`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDBfree: 4096 kB';-- ------------------------------ Table structure for userinfo-- ----------------------------DROP TABLE IF EXISTS `userinfo`;CREATE TABLE `userinfo` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) character set utf8 collate utf8_unicode_ci NOT NULL, PRIMARY KEY(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records-- ----------------------------INSERT INTO `manager` VALUES ('1', '1', '2');INSERT INTO `manager` VALUES ('2', '恩恩', '123456');INSERT INTO `manager` VALUES ('3', '大大', '123456');INSERT INTO `manager` VALUES ('4', '啊啊', '123456');INSERT INTO `manager` VALUES ('5', '5', '5');INSERT INTO `manager` VALUES ('6', '孙霞', '123456');INSERT INTO `studentinfo` V ALUES ('张三', '男', '2010303755', '数学', '2', '2010-02- 12');INSERT INTO `studentinfo` V ALUES ('李四', '男', '2010303760', '物理', '1', '1995.9.6'); INSERT INTO `studentinfo` V ALUES ('王二', '女', '2010303761', '应数', '2','1990.9.11');INSERT INTO `studentinfo` V ALUES ('麻子', '女', '2010303762', '信计', '1','1999.9.10');INSERT INTO `userinfo` V ALUES ('1', '1', '1');INSERT INTO `userinfo` V ALUES ('13', '13', '1');INSERT INTO `userinfo` V ALUES ('2', '2', '2');INSERT INTO `userinfo` V ALUES ('3', '3', '3');INSERT INTO `userinfo` V ALUES ('6', '6', '6');INSERT INTO `userinfo` V ALUES ('7', '7', '6');下面是相应的程序:package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Add implements ActionListener {JFrame f1;Container ct;JPanel jp,jp1,jp2,jp3;JButton btn1,btn2;JLabel label;JTextField tf1,tf2,tf3,tf4,tf5,tf6;Add(){f1=new JFrame();ct=f1.getContentPane();//初始化面板jp=new JPanel();jp1=new JPanel(new GridLayout(6,1));jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>添加学生信息</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);tf6.setText("例:2000-02-02");//文本框加入提示语tf6.addFocusListener(new FocusListener(){public void focusGained(FocusEvent e) {tf6.setText("");}public void focusLost(FocusEvent e) {}});jp.add(label);ct.add(jp,"North");jp1.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp1.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp1.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp1.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp1.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp1.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);ct.add(jp1,"West");ct.add(jp2,"East");ct.add(jp3,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f1.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f1.setLocation(xcenter, ycenter);f1.setVisible(true);//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);}public void insert(){if(tf1.getText().equals("")||tf2.getText().equals("")||tf3.getText().equals("")||tf4.getText().equals("")||tf5.getText().equals("")||tf6.getText().equals("")){JOptionPane.showMessageDialog(f1,"请填写完整信息");return;}try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connectioncon=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="insert into studentinfo values('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4.getText()+"','"+tf5.getText()+"','"+tf6.getText()+"');";String query="select * from studentinfo where Snumber='"+tf3.getText().trim()+"'";ResultSet res=st.executeQuery(query);if(res.next()){JOptionPane.showMessageDialog(f1,"学号信息已经存在!");con.close();tf3.setText("");}else if(tf6.getText().length()!=10){JOptionPane.showMessageDialog(f1,"入学时间格式有误!");con.close();tf6.setText("");}int insert=st.executeUpdate(s);if(insert==1){JOptionPane.showMessageDialog(f1,"录入信息成功!");tf1.setText("");tf2.setText("");tf3.setText("");tf4.setText("");tf5.setText("");tf6.setText("");}}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){insert();}else if(cmd.equals("取消")){f1.hide();}}public Container getCt(){return ct;}public void setCt(Container ct){this.ct = ct;}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Delete implements ActionListener {JFrame f2;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JTextField text;JTable table;//接收数据库中返回的信息JButton btn1,btn2,btn3;Object columnName[]={"姓名","性别","学号","专业","班级","入学时间"};Object ar[][]=new Object[80][6];Delete(){f2=new JFrame();ct=f2.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();label=new JLabel();text=new JTextField();btn1=new JButton("查询");btn2=new JButton("删除");btn3=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入要删除的学生姓名:</font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar,columnName);JScrollPane scroll=new JScrollPane(table);text=new JTextField(20);jp2.add(btn1);jp2.add(btn2);jp2.add(btn3);jp1.add(label);jp1.add(text);ct.add(jp1,"North");jp3.setLayout(new BorderLayout());jp3.add(new JLabel("学生信息如下"));jp3.add(scroll);ct.add(jp2,"South");ct.add(jp3,"Center");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f2.setSize(450, 400);int xcenter=(x-450)/2;int ycenter=(y-400)/2;f2.setLocation(xcenter, ycenter);f2.setVisible(true);//f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);btn3.addActionListener(this);}int i=0;public void show(String s){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String sql="select * from studentinfo where Sname='"+s+"'";ResultSet res=st.executeQuery(sql);/*if(!(res.next())){JOptionPane.showMessageDialog(f,"所要查询的信息不存在");} */while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f2.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}public void delete(int line){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String name=(String)(ar[line][2]);String sql="delete from studentinfo where Snumber ='"+name+"'";int del=st.executeUpdate(sql);if(del==1){ar[line][0]="";ar[line][1]="";ar[line][2]="";ar[line][3]="";ar[line][4]="";ar[line][5]="";JOptionPane.showMessageDialog(null,"删除成功!","信息", JOptionPane.YES_NO_OPTION);}con.close();f2.repaint();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("查询")){String qu=text.getText().trim();show(qu);}if(cmd.equals("删除")){int de=table.getSelectedRow();if(de==-1){JOptionPane.showMessageDialog(null,"请选定要删除的行","错误信息", JOptionPane.YES_NO_OPTION);}else{delete(de);}}if(cmd.equals("取消")){f2.hide();}}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.SwingConstants;public class Liulan implements ActionListener {JFrame f4;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JButton btn1,btn2;JTable table;Object[][] ar=new Object[80][6];Object[] columnName={"姓名","性别","学号","专业","班级","入学时间"};Liulan(){f4=new JFrame();ct=f4.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();btn1=new JButton("点击浏览");btn2=new JButton(" 取消");label=new JLabel("<html><font color=#00FF22 size='4'>学生信息浏览<font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar, columnName);JScrollPane scroll=new JScrollPane(table);jp1.add(label);jp2.add(btn1);jp2.add(btn2);jp3.add(scroll);ct.add(jp1,"North");ct.add(jp3,"Center");ct.add(jp2,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f4.setSize(500,530);int xcen=(x-500)/2;int ycen=(y-530)/2;f4.setLocation(xcen,ycen);f4.setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);}int i=0;public void select(){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="select * from studentinfo";ResultSet res=st.executeQuery(s);while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f4.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){// TODO Auto-generated method stubString cmd=e.getActionCommand();if(cmd.equals("点击浏览")){select();}else if(cmd.equals(" 取消")){f4.hide();}}}package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.Connection;import java.sql.DriverManager;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.SwingConstants;@SuppressWarnings("serial")public class Login extends JFrame implements ActionListener {Container cp=null;JFrame f=null;JButton button1,button2,button3;JTextField t1;JPasswordField t2;JLabel jlable1,jlable2;JRadioButton rabtn1,rabtn2;Color c;JPanel jp1,jp2,jp3;String table=null;Login(){f=new JFrame("学生信息管理系统");button1=new JButton("确定");button2=new JButton("取消");button3=new JButton("注册");//button3.setOpaque(false);button3.setBorder(null);button3.setBackground(Color.getColor("#292421"));rabtn1=new JRadioButton("普通用户");rabtn1.setBackground(Color.getColor("#292421"));rabtn2=new JRadioButton("管理员");rabtn2.setBackground(Color.getColor("#292421"));ButtonGroup group=new ButtonGroup();group.add(rabtn1);group.add(rabtn2);cp=f.getContentPane();jlable1=new JLabel("输入用户号");jlable2=new JLabel("输入密码");jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();t1=new JTextField(20);t2=new JPasswordField(20);//jp3.add(group);jp1.add(jlable1);jp1.add(t1);jp1.add(jlable2);jp1.add(t2);jp1.add(rabtn1);jp1.add(rabtn2);jp1.add(button3);JLabel JL=new JLabel("<html><font color=#292421 size='7'><i>欢迎登陆" + "</i></font>",SwingConstants.CENTER);cp.add(JL,"North");jp2.add(button1);jp2.add(button2);cp.add(jp1,"Center");cp.add("South",jp2);cp.setBackground(new Color(127, 255, 212 ));jp2.setBackground(new Color(127, 255, 212 ));jp1.setBackground(new Color(127, 255, 212 ));Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f.setSize(250,300);int xcenter=(x-300)/2;int ycenter=(y-300)/2;f.setLocation(xcenter,ycenter);/*显示在窗口中央*/f.setVisible(true);//f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//------------------------------------------------------------///*监听事件*/button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);rabtn1.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="userinfo";}});rabtn2.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="manager";}});f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});}@SuppressWarnings("deprecation")public void confirm(String tableName){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String id=t1.getText().trim();String Mima=t2.getText().trim();String queryMima="select * from "+tableName+" where id='"+id+"' and mima='"+Mima+"'";ResultSet res=st.executeQuery(queryMima);if(res.next()){if(tableName.equals("manager"))new Mstudent(id);else if(tableName.equals("userinfo"))new Ustudent(id);f.hide();con.close();}else{JOptionPane.showMessageDialog(null,"密码错误请重输!!!","提示!",JOptionPane.YES_NO_OPTION);}t1.setText("");t2.setText("");}catch(SQLException g){System.out.println("错误代码:"+g.getErrorCode());System.out.println("错误内容:"+g.getMessage());}}ItemListener listen=new ItemListener(){public void itemStateChanged(ItemEvent e) {// TODO Auto-generated method stub}};public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){if(table==null){JOptionPane.showMessageDialog(f,"请选择用户类型");}confirm(table);}else if(cmd.equals("取消")){f.dispose();}else if(cmd.equals("注册")){new Regist();}}public static void main(String []arg){new Login();}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenuBar;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;@SuppressWarnings("serial")public class Mstudent extends JFrame implements ActionListener {JButton Query = new JButton("查询信息");JButton add = new JButton("添加信息");JButton delete = new JButton("删除信息");JButton xiugai = new JButton("浏览全部信息");JButton liulan = new JButton("修改密码");JMenuBar mb = new JMenuBar();// 菜单栏JPanel jp = new JPanel();Container cp = getContentPane();String userName;Mstudent(){}Mstudent(String userName){erName = userName;mb.add(Query);mb.add(add);mb.add(delete);mb.add(xiugai);mb.add(liulan);JPanel j=new JPanel();j.add(mb,"Center");cp.add(j, "North");// 设置边框jp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue, 2), null, TitledBorder.CENTER,TitledBorder.TOP));jp.setLayout(new BorderLayout());JLabel label1 = new JLabel("欢迎使用学生信息管理系统",SwingConstants.CENTER);jp.add(label1);JScrollPane scrollpane = new JScrollPane(jp);cp.add(scrollpane,"Center");setTitle("欢迎登陆" + "--" + "你好:" + userName);Toolkit kit = Toolkit.getDefaultToolkit();Dimension screen = kit.getScreenSize();int x = screen.width; /* 取得显示器窗口的宽度*/int y = screen.height; /* 取得显示器窗口的高度*/setSize(600, 600);int xcenter = (x - 600) / 2;int ycenter = (y - 600) / 2;setLocation(xcenter, ycenter);/* 显示在窗口中央*/setVisible(true);//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 注册临听器Query.addActionListener(this);add.addActionListener(this);delete.addActionListener(this);xiugai.addActionListener(this);liulan.addActionListener(this);}public void actionPerformed(ActionEvent e){String cmd = e.getActionCommand();if (cmd.equals("查询信息")){new QueryWays();}if (cmd.equals("添加信息")){new Add();}if (cmd.equals("删除信息")){new Delete();}if (cmd.equals("浏览全部信息")){new Liulan();}if (cmd.equals("修改密码")){new UpdateCode();}}public static void main(String[] args){new Mstudent("");}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Query implements ActionListener {String sql =null;int a;String info;JFrame f3;// Container cp;JPanel jp1,jp2,jp3,jp4,jp,jpwest;JButton btn1,btn2;//确定,取消JLabel label,label2;//标签,请输入姓名(label)JTextField tf,tf1,tf2,tf3,tf4,tf5,tf6;//文本框Query(int a){this.a=a;f3=new JFrame();Container cp=f3.getContentPane();//初始化面板,按钮,标签,文本框jp=new JPanel();jp1=new JPanel();jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();jp4=new JPanel(new GridLayout(6,1));jpwest=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入姓名:" + "</font>",SwingConstants.CENTER);label2=new JLabel("<html><font color=#CC00FF size='4'>请输入学号:" + "</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf=new JTextField(20);//------------------------------------------------tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);//布局,添加控件if(a==0){jp.add(label);jp.add(tf);}else if(a==1){jp.add(label2);jp.add(tf);}cp.add(jp,"North");jp4.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp4.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp4.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp4.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp4.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp4.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);cp.add(jp4,"West");cp.add(jp2,"East");cp.add(jp3,"South");cp.add(jp1);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width; //显示窗口宽度int y=screen.height;//窗口高度f3.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f3.setLocation(xcenter,ycenter);f3.setVisible(true);//f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);/*f3.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});*/。
学生信息管理系统源代码
学生信息管理系统源代码import java.io.*;class StuInfo {public String name;public int number;public String sex;public String age;public String bir;public String email;public String addr;public String tel;public String getName() {return name;}public void setName(String name) { = name;}public int getNumber() {return number;}public void setNumber(int number) {this.number = number;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String getAge() {return age;}public void setAge(String age) {this.age = age;}public String getBir() {return bir;}public void setBir(String bir) {this.bir = bir;}public String getEmail() {return email;}public void setEmail(String email ) { this.email = email;}public String getAddr() {return addr;}public void setAddr(String addr) {this.addr = addr;}public String getTel() {return tel;}public void setTel(String tel) {this.tel = tel;}}public class Student {private static PrintStream out = System.out;private static String filename = "Stu.txt";private static int total = 0;private static int rt = 0;//recyle lengthprivate StuInfo[] stuInfos;private StuInfo[] recycle;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));//创建缓冲流public Student(){stuInfos = new StuInfo[11];}public void 信息录入(){BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));try{System.out.print("\n请输入学生信息(以0结束)\n");System.out.print("学号:\n");StuInfo stu = new StuInfo();stu.setNumber(Integer.parseInt(buf.readLine()));while(stu.getNumber()!=0) {System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());//添加其他输入信息stuInfos[total]=stu;total++;stu = new StuInfo();System.out.print("\n请输入下一个学生信息(以0结束)\n");System.out.print("姓名:\n");stu.setName(buf.readLine());}}catch(Exception e){out.print(e);}}public void 保存数据(){try{FileWriter fwr=new FileWriter(filename);BufferedWriter fw = new BufferedWriter(fwr);fw.write(total+"\r\n");for(int k=0;k<total;k++){//保存学生信息fw.write(stuInfos[k].getNumber()+"\r\n");fw.write(stuInfos[k].getName()+"\r\n");fw.write(stuInfos[k].getSex()+"\r\n");fw.write(stuInfos[k].getAge()+"\r\n");fw.write(stuInfos[k].getBir()+"\r\n");fw.write(stuInfos[k].getEmail()+"\r\n");fw.write(stuInfos[k].getAddr()+"\r\n");fw.write(stuInfos[k].getTel()+"\r\n");}fw.write(rt+"\r\n");for(int k=0;k<rt;k++){//保存回收站信息fw.write(recycle[k].getNumber()+"\r\n");fw.write(recycle[k].getName()+"\r\n");fw.write(recycle[k].getSex()+"\r\n");fw.write(recycle[k].getAge()+"\r\n");fw.write(recycle[k].getBir()+"\r\n");fw.write(recycle[k].getEmail()+"\r\n");fw.write(recycle[k].getAddr()+"\r\n");fw.write(recycle[k].getTel()+"\r\n");}fw.flush();fw.close();fwr.close();System.out.println("\n已保存数据!");}catch(Exception e){out.print(e);}}public void 读取数据(){try{FileReader fr = new FileReader(filename);BufferedReader bfr = new BufferedReader(fr); String buff = bfr.readLine();if(buff != null) {total = Integer.parseInt(buff);}else{total = 0;}StuInfo stu;for(int i=0; i<total;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine())); stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());stuInfos[i]=stu;}buff = bfr.readLine();if(buff!= null) {rt = Integer.parseInt(buff);}else{rt = 0;}for(int i=0; i<rt;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine()));stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());//补全recycle[i]=stu;}// bfr.flush();bfr.close();fr.close();System.out.println("读取成功");}catch(Exception e){out.print(e);}}public void 显示学生(StuInfo[] stus,int length){ try{out.println("----------");for(int i=0;i<length;i++){out.println("学号:"+stus[i].getNumber());out.println("姓名:"+stus[i].getName());out.println("性别:"+stus[i].getSex());out.println("年龄:"+stus[i].getAge());out.println("生日:"+stus[i].getBir());out.println("邮箱:"+stus[i].getEmail());out.println("地址:"+stus[i].getAddr());out.println("电话:"+stus[i].getTel());//输出其他内容.....out.println("----------");}System.out.println("请按任意键继续");buf.read();//}catch(Exception e){out.print(e);}}public void 姓名查询(String name){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(stuInfos[i].getName().equals(name)){result[r]=stuInfos[i];r++;}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生return;}else{显示学生(result, r);}}public void 学号查询(String number ){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(Integer.toString(stuInfos[i].getNumber()).equals(number)){result[r]=stuInfos[i];r++;//补全}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生}else{显示学生(result, r);}}public void 查找菜单(){//全字匹配int choice;try{do{System.out.println("查找界面");//System.out.println("1:按姓名查询");System.out.println("2:按学号查询");System.out.println("0:返回上级");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入姓名");//获得输入的姓名String name = buf.readLine();姓名查询(name);break;case 2:System.out.println("请输入学号");String number = buf.readLine();学号查询(number);//获得输入的学号break;default:System.out.println("对不起,出现异常!");//异常:7}}while(choice!=0);}catch(Exception e){out.print(e);}}public boolean 修改学生(int number) {boolean flag = false;try{for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number) {BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));StuInfo stu = new StuInfo();System.out.print("\n请输入学生信息\n");System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());stu.setNumber(number);stuInfos[i]=stu;System.out.print("修改完成啦!");//提示修改完成break;}}}catch(Exception e){out.print(e);}return flag;}public boolean 删除学生(int number){boolean flag = false;for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number){if(rt==0){recycle = new StuInfo[101];}recycle[rt]=stuInfos[i];for(;i<total-1;i++){stuInfos[i]=stuInfos[i+1];}total--;flag=true;break;}}return flag;}public void 删除页面(){System.out.print("删除页面");//请输入要删除的学号try{int choice;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));System.out.println("1:学生信息修改");System.out.println("2:学生信息删除");System.out.println("请输入您的选择(1--2)");//...choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入要修改的学号:");choice = Integer.parseInt(buf.readLine());修改学生(choice);break;case 2:System.out.println("请输入要删除的学号:");choice = Integer.parseInt(buf.readLine());删除学生(choice);break;//补充}/*if(删除学生(choice)){System.out.print("删除成功!");//删除成功}else{System.out.print("删除失败!");//删除失败}*/}catch(Exception e){out.print(e);}}public void showMenu() {try{int choice;do{System.out.println("学生管理系统主菜单界面");System.out.println("1:学生信息录入");System.out.println("2:学生信息浏览");System.out.println("3:学生信息查询");System.out.println("4:学生修改与删除");System.out.println("5:学生信息保存");System.out.println("6:学生信息读取");System.out.println("0:退出系统");System.out.println("请输入您的选择(0--6)");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:信息录入();//break;case 2://补全方法调用显示学生(stuInfos, total);break;case 3:查找菜单();break;case 4:删除页面();break;case 5:保存数据();break;case 6:读取数据();break;default:System.out.print("出现异常!"); //异常:7}}while(choice!=0);}catch(Exception e){System.out.println(e);}// TODO 自动生成的方法存根}public static void main(String[] args) {Student student = new Student();student.showMenu();}}. ..。
学生信息管理系统系统源代码
学生信息管理系统系统源代码-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII系统源代码一、登录界面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class login : System.Web.UI.Page{protected void txtid_Click(object sender, EventArgs e){txtid.Text = "";txtpassword.Text = "";}protected void Button1_Click(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);conn.Open();DataSet ds=new DataSet () ;SqlDataAdapter da = new SqlDataAdapter("select * from users where userid='" + txtid.Text + "' and userpwd='" + txtpassword.Text + "'", conn); da.Fill(ds);if (ds.Tables[0].Rows.Count==0){Label3 .Text ="账号或密码错误,请重新输入!";}else{Session ["userid"]=txtid .Text ;Session["userpwd"] = txtpassword.Text;Session["username"] = ds.Tables[0].Rows[0]["username"].ToString(); Session["userpower"] = ds.Tables[0].Rows[0]["userpower"].ToString(); if (Session["userpower"].ToString () == "0"){Response.Redirect("admin/index.aspx");}else if (Session["userpower"].ToString() == "1"){Response.Redirect("student/index.aspx");}else{Label3.Text = "对不起,权限验证失败";}}conn.Close();ds.Clear ();}}二、添加课程页面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addcourse : System.Web.UI.Page{SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){courseid.Attributes.Add("onblur", "checkcourseid()");string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if (courseid.Text.ToString() == ""){Label7.Text = "课程号不能为空";}else{string sqlstr = "";sqlstr = "insert intocourse(courseid,coursename,coursetime,fen,type,teacher)values('" +courseid.Text + "','" + coursename.Text + "','" + coursetime.Text + "','" + fen.Text + "','" + type.Text + "','" + teacher.Text + "')";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();try{mycmd.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{conn.Close();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e){courseid.Text = "";coursename.Text = "";coursetime.Text = "";fen.Text = "";type.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("course.aspx");}}三、添加成绩程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addscore : System.Web.UI.Page{SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);}protected void Button1_Click(object sende r, EventArgs e){if (userid.SelectedValue .ToString ()== ""){Label11.Text = "学号不能为空";}else{string sqlstr = "";sqlstr = "insert intoscore(userid,username,courseid,coursename,score,[year])values('" +userid.SelectedValue + "','" + username.Text + "','" + txtcourseid.SelectedValue + "','" + coursename.Text + "','" + score.Text + "','" + txtyear.SelectedValue + "')"; conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();try{mycmd.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{conn.Close();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e){username.Text = "";coursename.Text = "";score.Text = "";txtyear.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("score.aspx");}protected void userid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select username from students where userid='" +userid.SelectedValue + "'";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()){username.Text = da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e) {string sqlstr = "";sqlstr = "select coursename from course where courseid='" + txtcourseid.SelectedValue + "'";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()){coursename.Text = da["coursename"].ToString(); }}}四、添加学生程序代码using System;using System.IO;using System.Text;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addstudent : System.Web.UI.Page{SqlCommand mycmd;protected void Page_Load(object sender, EventArgs e) {userid.Attributes.Add("onblur", "checkuserid()");string strconn = ConfigurationManage r.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if (userid.Text.ToString() == "")return;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sqlstr = "";string sql = "";sqlstr = "insert intostudents(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhuany, tel,idc,zhengzmm,zhiw,huoj,weij)values('" + userid.Text + "','" + txtusername.Text + "','" + txtsex.SelectedItem.Value + "','" + txtminzu.Text + "','" + txtbirthday.Text + "','" + txtclass.Text + "','" + txtcomefrom.Text + "','" + txtbeizhu.Text + "','" + txtxuey.SelectedValue + "','" + txtzhuany.SelectedValue + "','" + txttel.Text + "','" + txtidc.Text + "','" + txtzzmm.SelectedValue + "','" + txtzhiw.Text + "','" + txthuoj.Text + "','" + txtweij.Text + "')";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();string name = this.FileUpload1.FileName;//获取上传文件的名称string type = name.Substring(stIndexOf("\\") + 1);//获取上传文件的后缀string ipath = Server.MapPath("images/") +DateTime.Now.ToString("yyyyMMddhhmmss") + name;string wpath = "images\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + name;string query1 = "insert into images(userid,path) values('" + userid.Text + "',@path)";FileUpload1.SaveAs(ipath); //服务器保存路径SqlCommand cm = new SqlCommand(query1);cm.Connection = conn;cm.Parameters.Add("@path", SqlDbType.VarChar, 50);cm.Parameters["@path"].Value = wpath;cm.ExecuteNonQuery();// this.lb_info.Text = "上传成功!";try{mycmd.ExecuteNonQuery();string sqlstr1 = "";sqlstr1 = "insert into users(userid,username)values('" + userid.Text + "','" + txtusername.Text + "') ";SqlCommand mycmd1 = new SqlCommand(sqlstr1, conn);mycmd1.Dispose();try{mycmd1.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{sqlstr1 = "";}}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>"); }finally{conn.Close();sqlstr = "";}}protected void Button2_Click(object sender, EventArgs e){userid.Text = "";txtusername.Text = "";txtminzu.Text = "";txtbirthday.Text = "";txtclass.Text = "";txtcomefrom.Text = "";txtbeizhu.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("student.aspx");}}五、检查课程号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkcourseid : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){Response.Expires = 0;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = Request.QueryString["name"].ToString();string sql = "select courseid from course where courseid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();SqlDataReader dr = DBHelper.ExecuteReader();if (dr.Read()){Response.Write("<b class='Error'>该课程号已经存在,请换一个</b>"); }else{Response.Write("<b class='Right'>该课程号可以使用</b>");}dr.Close();}}六、检查学号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkuser : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){Response.Expires = 0;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = Request.QueryString["name"].ToString();string sql = "select userid from students where userid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();SqlDataReader dr = DBHelper.ExecuteReader();if (dr.Read()){Response.Write("<b class='Error'>该学号已经存在,请换一个</b>"); }else{Response.Write("<b class='Right'>该学号可以使用</b>"); }dr.Close();}}七、课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class course : System.Web.UI.Page{SqlConnection conn;SqlDataReader getdata;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["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);conn.Open();getdata = mycmd.ExecuteReader();grdMain.DataSource = getdata;grdMain.DataBind();mycmd.Connection.Close();conn.Close();mycmd.Dispose();}protected void Button1_Click(object sender, EventArgs e){DataSet ds;SqlDataReader da;string strsql = "";SqlCommand cmd;conn.Open();strsql = "select * from course where courseid='" + courseid.Text + "'or coursename like '" + coursename.Text + "'";cmd = new SqlCommand(strsql, conn);da = cmd.ExecuteReader();Datagrid1.DataSource = da;Datagrid1.DataBind();conn.Close();cmd.Dispose();cmd.Connection.Close();}}八、编辑、删除学生信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class images_editstudent : System.Web.UI.Page{SqlCommand cmd;SqlCommand cmd2;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; SqlConnection conn = new SqlConnection(strconn);sql = "select * from students where userid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){userid.Text = reader["userId"].ToString();txtusername.Text = reader["username"].ToString();txtsex.SelectedValue = reader["sex"].ToString();txtminzu.Text = reader["minzu"].ToString();txtbirthday.Text = reader["birthday"].ToString();txtclass.Text = reader["class"].ToString();txtcomefrom.Text = reader["comefrom"].ToString();txtxuey.Text = reader["xuey"].ToString();txtzhuany.Text = reader["zhuany"].ToString();txttel.Text = reader["tel"].ToString();txtidc.Text = reader["idc"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid="";uid=Page .Request ["id"];string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql="";sql = "update students set userid='" + userid.Text + "',username='" + txtusername.Text + "',minzu='" + txtminzu.Text + "',sex='" +txtsex.SelectedItem.Value + "',birthday='" + txtbirthday.Text + "',class='" + txtclass.Text + "',comefrom='" + txtcomefrom.Text + "',beizhu='" + txtbeizhu.Text + "',xuey='" + txtxuey.Text + "',zhuany='" + txtzhuany.Text + "',tel='" + txttel.Text+ "',idc='" + txtidc.Text + "',zhengzmm='" + txtzzmm.SelectedValue + "'where userid='" + uid + "'";cmd=new SqlCommand (sql,conn );conn.Open();try{cmd.ExecuteNonQuery();Label11.Style["color"] = "blue";Label11.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>");}catch(SqlException ){Label11.Text = "编辑失败";Label11.Style["color"] = "red";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";string sqlall = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["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);conn.Open();try{cmd.ExecuteNonQuery();string sql1 = "";sql1 = "delete from users where userid='" + uid + "'";SqlCommand cmd1 = new SqlCommand(sql1, conn);cmd1.Dispose();try{cmd1.ExecuteNonQuery();Label11.Style["color"] = "blue";Label11.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){Label11.Text = "删除失败";Response.Write("<script>javascript:alert('删除失败!!!');</script>"); }finally{sql1 = "";}}catch(SqlException ){Label11.Text = "删除失败";Label11.Style["color"] = "red";}cmd.Dispose();conn.Close();userid.Text = "";txtusername.Text = "";txtminzu.Text = "";txtbirthday.Text = "";txtclass.Text = "";txtcomefrom.Text = "";txtbeizhu.Text = "";txtxuey.Text = "";txtzhuany.Text = "";txttel.Text = "";txtidc.Text = "";}protected void Button3_Click(object sender, EventArgs e) {Response.Redirect("student.aspx");}}九、编辑、删除课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class editcourse : System.Web.UI.Page{SqlCommand cmd;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; SqlConnection conn = new SqlConnection(strconn);sql = "select * from course where courseid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){courseid.Text = reader["courseid"].ToString();coursename.Text = reader["coursename"].ToString();coursetime.Text = reader["coursetime"].ToString();fen.Text = reader["fen"].ToString();type.Text = reader["type"].ToString();type.Text = reader["teacher"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSe ttings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql = "";sql = "update course set courseid='" + courseid.Text + "',coursename='" + coursename.Text + "',coursetime='" + coursetime.Text + "',fen='" + fen.Te xt + "',type='" + type.Text + "',teacher='" + teacher.Text + "' where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label7.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){Label7.Text = "编辑失败";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sen der, EventArgs e)string sql = "";string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "delete from course where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label7.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>"); }catch (SqlException){Label7.Text = "删除失败";}cmd.Dispose();conn.Close();courseid.Text = "";coursename.Text = "";coursetime.Text = "";fen.Text = "";type.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("course.aspx");}十、编辑、删除成绩信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class editscore : System.Web.U I.Page{SqlCommand cmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);sql = "select * from score where id='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){id.Text = reader["id"].ToString();userid.Text = reader["userid"].ToString();username.Text = reader["username"].ToString();txtcourseid.Text = reader["courseid"].ToString();coursename.Text = reader["coursename"].ToString();score.Text = reader["score"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = Page.Request["id"];string sql = "";string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);sql = "update score set userid='" + userid.SelectedValue + "',username='" + username.Text + "',courseid='" + txtcourseid.SelectedValue + "',coursename='" + coursename.Text + "',score='" + score.Text + "',[year]='" + txtyear.SelectedValue + "'where id='" + uid + "'";cmd = new SqlCommand(sql,conn );conn.Open();trycmd.ExecuteNonQuery();Label11.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>"); }catch (SqlException){Label11.Text = "编辑失败";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);sql = "delete from score where id='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label11.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>"); }catch (SqlException){Label11.Text = "删除失败";cmd.Dispose();conn.Close();id.Text = "";username.Text = "";coursename.Text = "";score.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("score.aspx");}protected void userid_SelectedIndexChanged(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select username from students where userid='" +userid.SelectedValue + "'";conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader da;da = cmd.ExecuteReader();while (da.Read()){username.Text = da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e) {string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select coursename from course where courseid='" + txtcourseid.SelectedValue + "'";conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader da;da = cmd.ExecuteReader();while (da.Read()){coursename.Text = da["coursename"].ToString();}}}十一、修改密码程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class modify_pwd : System.Web.UI.Page{SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["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 (txtpassword.Text == ""){Label4.Text = "原密码不能为空";}else if (password.Text == ""){Label4.Text = "新密码不能为空";}else if (password.Text != password1.Text){Label4.Text = "新密码和确认密码不一致";}else if (txtpassword.Text != pwd){Label4.Text = "原密码不正确";}。
学生成绩管理系统源代码
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <dos.h>#include<ctype.h>#include<conio.h>#include<stddef.h>#include<time.h>#define PRINT1 textcolor(12); cprintf("\r 请按任意键返回主菜单\n\r");textcolor(10); getch();clrscr(); break;int shoudsave=0;struct student /* 学生信息结构体定义*/{char num[10],name[20],cla[4];int score1,score2,score3,total,ave;};typedef struct node{struct student data;struct node *next;}Node,*L;void print1(){cprintf("\r======================================================================= =========");}void print2(){cprintf("\n\r 1.输入学生成绩信息在这里你可以按照提示输入学生的班级,学号,姓名及各科成绩.\n");cprintf("\n\r 2.注销学生成绩信息在这里你可以按照学号或姓名将某名学生的信息从本系统中删除.\n");cprintf("\n\r 3.查询学生成绩信息在这里你可以按照学号或姓名查询某一名学生的信息.\n");cprintf("\n\r 4.修改学生成绩信息在这里你可以按照提示修改某一名学生的学号,姓名及各科成绩.");cprintf("\n\r 5.学生成绩信息排序在这里你可以看到所有学生的各科成绩.\n"); cprintf("\n\r 6.学生成绩信息统计在这里本系统将为你显示所有科目的最高分及最低分所得学生.\n");cprintf("\n\r 7.显示学生成绩信息在这里你可以看到系统中所有学生的信息.\n"); cprintf("\n\r 8.保存学生成绩信息在这里你可以将学生你信息保存到内存中.\n"); cprintf("\n\r 9.帮助学生成绩信息在这里你可以获得帮助信息.\n");cprintf("\n\r 0.退出系统在这里选择是否保存后,你可以安全的退出本系统.\n\n\r ");}void menu(){cprintf("\n\r\xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");cprintf("\r\xba 学生信息导入\xba 学生信息处理\xba");cprintf("\r\xba____________________________________\xba___________________________ _______________\xba");cprintf("\r\xba 1-->输入学生成绩信息\xba 6-->学生成绩信息统计\xba");cprintf("\r\xba 2-->注销学生成绩信息\xba 7-->显示学生成绩信息\xba");cprintf("\r\xba 3-->查询学生成绩信息\xba 8-->保存学生成绩信息\xba");cprintf("\r\xba 4-->修改学生成绩信息\xba 9-->帮助学生成绩信息\xba");cprintf("\r\xba 5-->学生成绩信息排序\xba 0-->退出系统\xba");cprintf("\r\xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");}void wrong(){cprintf("\n\r输入错误!请验证后重新输入.\n");}void notfind(){cprintf("\n\r该学生信息不存在!请验证后重新输入.\n");}void printc() /* 此函数用于输出中文格式*/{cprintf("\r学号姓名班级英语数学C语言总分平均分\n ");}void printe(Node *p) /* 此函数用于输出英文格式*/{cprintf("\r%-4s%-4s%4s%5d%5d%8d%5d%7d\n\r",p->data.num,p->,p->data.cla,p->dat a.score3,p->data.score2,p->data.score1,p->data.total,p->data.ave);}Node* Locate(L l,char findinfo[],char nameornum[]) /* 该函数用于定位连表中符合要求的接点,并返回该指针*/{Node *r;if(strcmp(nameornum,"num")==0)/* 按学号查询*/{r=l->next;while(r!=NULL){if(strcmp(r->data.num,findinfo)==0)return r;r=r->next;}}else if(strcmp(nameornum,"name")==0) /* 按姓名查询*/{r=l->next;while(r!=NULL){if(strcmp(r->,findinfo)==0)return r;r=r->next;}}return 0;}void input(L l) /* 增加学生*/{Node *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next;/* 将指针置于最末尾*/while(1){ cprintf("\r如果输入完毕,请按任意键返回主菜单\n");cprintf("\r如果你还想输入,请按y(yes)继续\n\r");scanf("%s",num);if(strcmp(num,"y")==0){ cprintf("请你输入学号:");scanf("%s",num); } else break;while(s){if(strcmp(s->data.num,num)==0){printf("\t学号为'%s'的学生已经存在,若要修改请你选择'4 修改'!\n",num);print1();printc();printe(s);print1();printf("\n");getch();return;}s=s->next;}p=(Node *)malloc(sizeof(Node));strcpy(p->data.num,num);cprintf("\r请你输入姓名:");scanf("%s",p->);getchar();cprintf("\r请你输入班级:");scanf("%s",p->data.cla);getchar();cprintf("\r请你输入c语言成绩(0-100):");scanf("%d",&p->data.score1);getchar();cprintf("\r请你输入数学成绩(0-100):");scanf("%d",&p->data.score2);getchar();cprintf("\r请你输入英语成绩(0-100):");scanf("%d",&p->data.score3);getchar();p->data.total=p->data.score3+p->data.score1+p->data.score2;p->data.ave=p->data.total / 3; /* 信息输入已经完成*/p->next=NULL;r=p;shoudsave=1;}}void query(L l) /* 查询学生信息*/{int select;char findinfo[20];Node *p;if(!l->next){cprintf("\n 没有信息可以查询!\n");return;}cprintf("\n1==>按学号查找\n\r2==>按姓名查找\n\r");scanf("%d",&select);if(select==1) /* 学号*/{cprintf("\r请你输入要查找的学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){cprintf(" 查找结果\n\r");print1();printc();printe(p);print1();}elsenotfind();}else if(select==2) /* 姓名*/{cprintf("\r请你输入要查找的姓名:");scanf("%s",findinfo);p=Locate(l,findinfo,"name");if(p){cprintf(" 查找结果\n\r");print1();printc();print1();}elsenotfind();}elsewrong();}void Delete(L l) /* 删除学生信息*/{int select;Node *p,*r;char findinfo[20];if(!l->next){cprintf("\n 没有信息可以删除!\n");return;}cprintf("\n1==>按学号删除\n\r2==>按姓名删除\n\r");scanf("%d",&select);if(select==1){cprintf("\r请你输入要删除的学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);cprintf("\n\r该学生已经成功删除!\n");shoudsave=1;}elsenotfind();}else if(select==2){cprintf("\r请你输入要删除的姓名:");scanf("%s",findinfo);p=Locate(l,findinfo,"name");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);cprintf("\n\r该学生已经成功删除!\n");shoudsave=1;}elsenotfind();}else wrong();}void modify(L l) /*修改学生信息*/{Node *p;char findinfo[20];if(!l->next){cprintf("\n\r没有信息可以修改!\n");return;}cprintf("\r请你输入要修改的学生学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){cprintf("\r请你输入新学号(原来是%s):",p->data.num);scanf("%s",p->data.num);cprintf("\r请你输入新姓名(原来是%s):",p->);scanf("%s",p->);getchar();cprintf("\r请你输入新班级(原来是%s):",p->data.cla);scanf("%s",p->data.cla);cprintf("\r请你输入新的c语言成绩(原来是%d分):",p->data.score1);scanf("%d",&p->data.score1);getchar();cprintf("\r请你输入新的数学成绩(原来是%d分):",p->data.score2);scanf("%d",&p->data.score2);getchar();cprintf("\r请你输入新的英语成绩(原来是%d分):",p->data.score3);scanf("%d",&p->data.score3);p->data.total=p->data.score3+p->data.score1+p->data.score2;p->data.ave=p->data.total/3;cprintf("\n\r信息修改成功!\n");shoudsave=1;}elsenotfind();}void display(L l){/*显示全部学生信息*/int count=0;Node *p;p=l->next;if(!p){cprintf("\n\r 没有信息可以显示!\n");return;}cprintf(" 显示结果");print1();printc();while(p){ if(count%5==0) getch();printe(p);p=p->next;count++;}print1();cprintf("\n");}void Statistic(L l) /*统计学生信息*/{Node *pm_max,*pe_max,*pc_max,*pt_max,*pa_max; /* 用于指向分数最高的接点*/ Node *pm_min,*pe_min,*pc_min,*pt_min,*pa_min;Node *r=l->next;if(!r){cprintf("\n\r 没有信息可以统计!\n");return ;}pm_max=pe_max=pc_max=pt_max=pa_max=pm_min=pe_min=pc_min=pt_min=pa_min=r; while(r!=NULL){if(r->data.score1>=pc_max->data.score1)pc_max=r;if(r->data.score1<=pc_min->data.score1)pc_min=r;if(r->data.score2>=pm_max->data.score2)pm_max=r;if(r->data.score2<=pm_min->data.score2)pm_min=r;if(r->data.score3>=pe_max->data.score3)pe_max=r;if(r->data.score3<=pe_min->data.score3)pe_min=r;if(r->data.total>=pt_max->data.total)pt_max=r;if(r->data.total<=pt_min->data.total)pt_min=r;if(r->data.ave>=pa_max->data.ave)pa_max=r;if(r->data.ave<=pa_min->data.ave)pa_min=r;r=r->next;}cprintf("====================================统计结果====================================\n");cprintf("\r总分最高者: %-16s %d分\n",pt_max->,pt_max->data.total); cprintf("\r平均分最高者: %-16s %d分\n",pa_max->,pa_max->data.ave); cprintf("\r英语最高者: %-16s %d分\n",pe_max->,pe_max->data.score3); cprintf("\r数学最高者: %-16s %d分\n",pm_max->,pm_max->data.score2); cprintf("\rc语言最高者: %-16s %d分\n\r",pc_max->,pc_max->data.score1); cprintf("\r总分最低者: %-16s %d分\n",pt_min->,pt_min->data.total); cprintf("\r平均分最低者: %-16s %d分\n",pa_min->,pa_min->data.ave); cprintf("\r英语最低者: %-16s %d分\n",pe_min->,pe_min->data.score3); cprintf("\r数学最低者: %-16s %d分\n",pm_min->,pm_min->data.score2); cprintf("\rc语言最低者: %-16s %d分\n\r",pc_min->,pc_min->data.score1); print1();}void Sort(L l){L ll;Node *p,*rr,*s;ll=(L)malloc(sizeof(Node)); /* 用于做新的连表*/ll->next=NULL;if(l->next==NULL){cprintf("\n\r 没有信息可以排序!\n");return ;}p=l->next;while(p){s=(Node*)malloc(sizeof(Node)); /* 新建接点用于保存信息*/s->data=p->data;s->next=NULL;rr=ll;while(rr->next!=NULL && rr->next->data.total>=p->data.total)rr=rr->next;if(rr->next==NULL)rr->next=s;else{s->next=rr->next;rr->next=s;}p=p->next;}free(l);l->next=ll->next;cprintf("\n\r 排序已经完成!\n");}void Save(L l) /* */{FILE* fp;Node *p;int flag=1,count=0;fp=fopen("c:\\student","wb");if(fp==NULL){cprintf("\n\r 重新打开文件时发生错误!\n");exit(1);}p=l->next;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next;count++;}else{flag=0;break;}}if(flag){cprintf("\n\r 文件保存成功.(有%d条信息已经保存.)\n\r",count);shoudsave=0;}fclose(fp);}void main() /* */{L l; /* 链表*/FILE *fp; /* 文件指针*/int count=0 ,i,menu_select; /*菜单选择*/char ch ,creat;Node *p,*r;time_t it;clrscr();textmode(C80);window(1,1,80,25);textbackground(1); clrscr();textcolor(10);printf("\r 学生成绩管理系统");printf("\r -------扬州大学信息工程学院软件0902班") ;printf("\r 设计人员:李天鹏");l=(Node*)malloc(sizeof(Node));l->next=NULL;r=l;fp=fopen("c:\\student","rb");if(fp==NULL){cprintf("\n\r 该文件还未存在,是否需要创建?(y/n,Y/N)\n\r");scanf("%c",&creat);if(creat=='y'||creat=='Y'){fp=fopen("c:\\student","wb");}elseexit(0);}gotoxy(9,11); textcolor(12);cprintf("\n\r 文件已经打开,系统正在导入信息");for(i=0;i<6;i++){ cprintf(".");sleep(1);}textcolor(10);gotoxy(9,11); cprintf("\n ");while(!feof(fp)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp)) /* 将文件的内容放入接点中*/{p->next=NULL;r->next=p;r=p; /* 将该接点挂入连中*/count++;}}fclose(fp);/* 关闭文件*/gotoxy(1,3);cprintf("\n\r信息导入完毕,系统共导入%d条信息",count);sleep(1);while(1){ menu();textcolor(12);cprintf("\r现在时间: "); it=time(NULL);cprintf(ctime(&it));cprintf("\r左边数字对应功能选择,请按0--9选择操作:\n\r");textcolor(10) ;scanf("%d",&menu_select);if(menu_select==0){if(shoudsave==1){ getchar(); textcolor(128+12);cprintf("\n\r 信息已经改动,是否将改动保存到文件中(y/n Y/N)?\n\r"); scanf("%c",&ch);if(ch=='y'||ch=='Y')Save(l);}cprintf("\n\r 你已经成功退出学生成绩信息系统,欢迎下次继续使用!\n"); break;}switch(menu_select){case 1: clrscr(); input(l); clrscr(); break; /* 输入学生*/case 2: clrscr(); Delete(l); PRINT1 /* 删除学生*/case 3: clrscr(); query(l); PRINT1 /* 查询学生*/case 4: clrscr(); modify(l); PRINT1 /* 修改学生*/case 5: clrscr(); Sort(l); PRINT1case 6: clrscr(); Statistic(l); PRINT1case 7: clrscr(); display(l); PRINT1case 8: clrscr(); Save(l); PRINT1 /* 保存学生*/case 9: clrscr(); cprintf(" ==========帮助信息==========\n");print2(); PRINT1 ;default: wrong(); getchar(); break;}}}。
学生信息管理系统源代码
#include<stdio.h>#include <stdlib.h>#include <string.h>typedef struct{long class_1; //班级long number; //学号char name[20]; //姓名float math; //数学float c_program; //C语言float physics; //大学物理float english; //大学英语float polity; //政治float sport; //体育float summary; //总分float average; //平均分}Student;Student stud[100]; //定义结构体数组变量的大小int i=0; //i用于记录输入的学生的个数int menu() //菜单函数{int a;printf("***********************学生信息管理系统*************************\n");//菜单选择printf("\t\t【1】输入学生信息\n");printf("\t\t【2】显示所有学生的信息\n");printf("\t\t【3】按平均分升降排序\n");printf("\t\t【4】根据学生的学号查找学生的信息\n");printf("\t\t【5】插入学生的信息\n");printf("\t\t【6】删除学生的信息\n");printf("\t\t【7】修改学生的信息\n");printf("\t\t【8】从文件中读入数据\n");printf("\t\t【9】将所有记录写入文件\n");printf("\t\t【0】退出本系统\n");printf("***********************学生信息管理系统*************************\n");printf("请选择你要的操作【0-9】:");scanf("%d",&a); //读入一个数while(a<0 || a>9){printf("输入错误!请重新输入。
[工学]学生信息管理系统完整源码
学生信息管理系统完整源代码注:本系统采用C/S结构,运用Java GUI知识编写,数据库为SQL SERVER 2005,没有采用典型的三级框架结构,所以代码有冗余,仅供参考。
一、数据表及数据源首先创建数据库,包含数据表如下:数据库创建完成后,新建一个名为SIMS的数据源,不会建数据源的同学可以在去搜索创建数据源的详细步骤,这里的数据名称一定要为SIMS,否则在以后程序连接数据库的语句中会出现错误。
二、操作演示三、代码部分创建Java工程,创建名称为SIMS的包,一下Java类均包含在一个包内。
1.登录界面package SIMS;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.text.SimpleDateFormat;import java.util.*;import java.util.Date;public class login extends JFrame implements ActionListener{String userID; //保留用户输入IDString password; //保留用户输入passwordJLabel jlID=new JLabel("用户ID:"); //使用文本创建标签对象 JLabel jlPwd=new JLabel("密码:");JTextField jtID=new JTextField(); //创建ID输入框JPasswordField jpPwd=new JPasswordField(); //创建密码输入框ButtonGroup bg=new ButtonGroup(); //创建ButtonGroup组件对象JPanel jp=new JPanel(); //创建Panel容器JLabel jl=new JLabel();JRadioButton jrb1=new JRadioButton("管理员");JRadioButton jrb2=new JRadioButton("教师");JRadioButton jrb3=new JRadioButton("学生",true);JButton jb1=new JButton("登录");JButton jb2=new JButton("重置");public login(){this.setLayout(null); //设置窗口布局管理器this.setTitle("学生信息管理系统"); //设置窗口标题this.setBounds(200,150,500,300); //设置主窗体位置大小和可见性this.setVisible(true); //设置窗口的可见性this.setResizable(false);jlID.setBounds(150,60,100,20); //设置ID框属性jtID.setBounds(220,60,100,20); //设置ID输入框属性jlPwd.setBounds(150,90,100,20); //设置密码框属性jpPwd.setBounds(220,90,100,20); //设置密码输入框属性jp.setBounds(35,120,400,250); //设置JPanel容器属性jb1.setBounds(160,170,60,20); //设置登录按钮属性jb2.setBounds(250,170,60,20); //设置取消按钮属性jb1.addActionListener(this); //设置登录按钮监听器jb2.addActionListener(this); //设置取消按钮监听器jl.setBounds(340,75,130,20); //设置提示框属性bg.add(jrb1); //将所有空间加入窗体bg.add(jrb2);bg.add(jrb3);this.add(jlID);this.add(jlPwd);this.add(jtID);this.add(jpPwd);this.add(jb1);this.add(jb2);this.add(jl);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);this.add(jp);centerShell(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(( (screenWidth - shellWidth) / 2),((screenHeight - shellHeight) / 2) );}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(userID);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入IDpassword=jpPwd.getText(); //获取用户输入密码if(e.getSource()==jb1){ //处理登录事件if(userID.equals("") || password.equals("")){jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("请输入用户ID和密码");}else{Connection con=null;try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"","");//获取连接字符串Statement stat=con.createStatement();if(jrb1.isSelected())//如果登录选中的管理员{ResultSet rs=stat.executeQuery("select * from Admin"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectAdmin_Pwd,Admin_Name from Admin where Admin_ID='"+userID+"'");//从表Admin获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new admin(rss.getString(2));//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb2.isSelected()){ResultSet rs=stat.executeQuery("select * from Teacher_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectTea_Pwd,Tea_Names from Teacher_Info where Tea_ID='"+userID+"'");//从表Teacher_Info获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new teacher(rss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb3.isSelected()){ResultSet rs=stat.executeQuery("select * from Student_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rsss=stat.executeQuery("selectStu_Pwd,Stu_Name from Student_Info where Stu_ID='"+userID+"'");//从表Student_Info获取信息while(rsss.next()){String str=rsss.getString(1);if(str.equals(password)){new student(rsss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}}catch(Exception ex){ex.getStackTrace();}finally{try{con.close();}catch(Exception exc){exc.printStackTrace();}}}}else if(e.getSource()==jb2){ //处理登录事件jtID.setText("");jpPwd.setText("");jrb3.setSelected(true);jl.setText("");}}public static void main(String[] args){new login();}}2.添加课程package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_course extends JFrame implements ActionListener{ static add_course ss;String courseID=""; //课程名String coursename=""; //课程名String count=""; //课时JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlcoursename=new JLabel("课程名:");JLabel jlcount=new JLabel("课时:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtcoursename=new JTextField();JTextField jtcount=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_course(){ //添加教师账号信息this.setTitle("添加课程信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(title);this.add(jlcoursename);this.add(jlcount);this.add(jtcourseID);this.add(jtcoursename);this.add(jtcount);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加课程信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlcoursename.setBounds(180,140,100,20);jlcount.setBounds(180,200,100,20);jtcourseID.setBounds(250,80,140,20);jtcoursename.setBounds(250,140,140,20);jtcount.setBounds(250,200,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容coursename=jtcoursename.getText();count=jtcount.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || coursename.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){warning.setText("课程ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!count.equals("")){temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name,Course_Count)values('"+courseID+"','"+coursename+"','"+count+"')");}else{temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name) values('"+courseID+"','"+coursename+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");warning.setText("");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtcourseID.setT ext("");jtcoursename.setText("");jtcount.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}}3.添加学生package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_student extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("学号:"); //创建文本框对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField();JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_student(){this.setTitle("添加学生账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加学生账号信息");title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20);submit.addActionListener(this);reset.addActionListener(this);this.setSize(600,400);centerShell(this);this.setVisible(true);this.setResizable(false); //设置窗体不可变大小this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){ //判断是否已输入必填信息warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否相同warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Stu_ID from Student_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd) values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){ //重置所有控件warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}//public static void main(String args[]){// new add_student();//}}4.添加教师package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_teacher extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("教工号:"); //使用文本框创建标签对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField(); //创建文本框对象JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_teacher(){ //添加教师账号信息this.setTitle("添加教师账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加教师账号信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否一致warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Tea_ID from Teacher_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd)values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}// public static void main(String[] args){// new add_teacher();// }}5.添加授课信息package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_tc extends JFrame implements ActionListener{static add_tc ss;String courseID=""; //课程名String teachername=""; //课程名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlteachername=new JLabel("教师号:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtteachername=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_tc(){ //添加授课信息this.setTitle("添加授课信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(jlteachername);this.add(title);this.add(jtcourseID);this.add(jtteachername);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加授课信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlteachername.setBounds(180,140,100,20);jtcourseID.setBounds(250,80,140,20);jtteachername.setBounds(250,140,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,250,60,20);reset.setBounds(300,250,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容teachername=jtteachername.getText();int temp=0,flag1=0,flag2=0,flag3=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || teachername.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){flag1=1; //判断课程ID存在break;}}ResultSet rss=stat.executeQuery("select Tea_ID fromTeacher_Info");while(rss.next()){if(rss.getString(1).equals(teachername)){flag2=1; //判断教师ID存在break;}}if(flag1!=1){warning.setText("课程ID不存在");}else if(flag2!=1){warning.setText("教师ID不存在");}ResultSet rsss=stat.executeQuery("select Course_ID,T ea_ID from tc");while(rsss.next()){if(rsss.getString(1).equals(courseID) &&rsss.getString(2).equals(teachername)){flag3=1;warning.setText("授课信息重复");。
学生成绩管理系统源代码
学生成绩管理系统源代码#include<stdio.h>#include<stdlib.h>int main(){typedef struct LNode{char name[6];int no;int yw;int sx;int yy;struct LNode *next;}LinkList;struct NameNo{int no;int yw;int sx;int total;char name[6];}st[10];FILE *fp,*fp1;char ch,sname[6];int x,i,j;NameNo tmp;LinkList *p,*s;printf("\n");printf("-------------------------------");printf("学生成绩管理系统");printf("--------------------------------");printf("\n\n");printf("在您的C盘根目录下是否有cj1.txt和cj2.txt文件?如果有请输入,1");printf("否则输入0;如果没有,那么程序将终止!1 or 0?");scanf("%d",&i);if(i==0) return 0;printf("\n\n");printf("对cj1.txt和cj2.txt进行合成请按‘1’");scanf("%d",&i);if(i!=1) return 0;printf("正在把cj1.txt和cj2.txt中的数据进行合并\n");printf("......\n.....\n....\n...\n..\n.\n");if((fp=fopen("c:\\cj1.txt","rt"))==NULL){printf("无cj1.txt文本文件,程序结束。
c++语言学生成绩管理系统源代码
我是电大的学生,这是struct 类型的c 语言学生成绩管理系统代码,大家交流一下#include<stdio.h>#include<string.h> #include<stdlib.h>#define MAXN 100 //#define MAXN 100 //一个班最多的人数一个班最多的人数#define MAXM 2 //#define MAXM 2 //成绩的课程门数成绩的课程门数int R;void input(); //1.void input(); //1.学生成绩新建学生成绩新建void sort(); //2.void sort(); //2.学生成绩插入学生成绩插入void load(); //3.void load(); //3.学生成绩修改学生成绩修改void print(); //4.void print(); //4.学生成绩删除学生成绩删除void total(); //5.void total(); //5.学生成绩统计学生成绩统计void search(); //6.void search(); //6.学生成绩查询学生成绩查询void save(); //7.void save(); //7.学生成绩保存学生成绩保存void end(); //8.void end(); //8.结束结束struct student{char name[20]; //char name[20]; //保存全班姓名保存全班姓名保存全班姓名char num[12]; // char num[12]; //保存全班学号保存全班学号保存全班学号char man[20]; //char man[20]; //保存全班性别保存全班性别保存全班性别float score[MAXM]; //float score[MAXM]; //保存全班所有课程成绩保存全班所有课程成绩保存全班所有课程成绩 float sum; //float sum; //保存全班每个人的总成绩保存全班每个人的总成绩保存全班每个人的总成绩float avg; // float avg; //保存每个人的平均成绩保存每个人的平均成绩保存每个人的平均成绩};struct student s[MAXN];struct http{char subject[20]; //char subject[20]; //保存全班所有课程保存全班所有课程保存全班所有课程};struct http c[MAXM];void main() //void main() //欢迎首界面欢迎首界面欢迎首界面{ int select,l;system("color fC");printf("\n");printf("\n");printf("\n");printf("\n");printf(" printf(" ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥\n"); \n"); printf(" * *\n"); printf(" * *\n"); printf(" * printf(" * 欢迎进入终极一班学生管理系统欢迎进入终极一班学生管理系统欢迎进入终极一班学生管理系统 *\n"); *\n"); printf(" * *\n"); printf(" * ︻┳═一︻┳═一︻┳═一 cf ... *\n"); cf ... *\n"); printf(" * printf(" * ┈━═☆甘总管的多塔生活∝╬══→┈━═☆甘总管的多塔生活∝╬══→┈━═☆甘总管的多塔生活∝╬══→ *\n"); *\n"); printf(" * *\n"); printf(" * printf(" * 凸凸^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸 *\n"); printf(" printf(" ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥\n"); \n"); printf(" printf(" ╭ ╭ ╭ v v v╮╮ ╔══╗╔╗╔══╗╔╗ ╔╗╔╗╔╗╔╗╔╗╔╗ ╭╭''''''╮╮\n");printf(" (@ ^o^ @)╚╗╔╝║║╔═╦╦╦═╗║╚╝╠═╦╦╗(~ : : ~~)\n");printf(" (~) : (~)╔╝╚╗║╚╣║║║║╠╣╚╗╔╣║║║║(~) v (~)\n");printf(" ╚══╝╚═╩═╩═╩═╝ ╚╝╚═╩═╝ \n");printf("\n");printf("\n");printf(" printf(" 请按任意键进入下一界面请按任意键进入下一界面请按任意键进入下一界面\n"); \n");printf("------------------------------------------------------------------\n"); system("pause");system("color f2");system("color f1");system("color f3"); system("color fE");system("color fB");system("color f5");system("color f9");system("color f6");system("color f1");system("color f3");system("color fE");system("color fB");system("color f5");system("color f9"); system("color f6");system("color f1");system("color f3");system("color f5");system("color f9");system("color f6");system("color fD");system("pause");system("color fC");system("cls"); // system("cls"); //上面是第一个界面上面是第一个界面上面是第一个界面while(1){system("cls");printf(" ****************欢迎进入终极一班学生管理系统****************\n");printf(" ******************************************************\n");printf(" * ∝╬══→ 1.学生成绩新建 囧rz 欢 *\n");printf(" * ::======>> 2. 2.学生成绩插入学生成绩插入学生成绩插入 迎迎 *\n"); printf(" * printf(" * ┈━═☆┈━═☆┈━═☆ 3. 3.学生成绩修改学生成绩修改学生成绩修改 来来 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 4. 4.学生成绩删除学生成绩删除学生成绩删除 到到 *\n"); printf(" * ∝╬══→∝╬══→ 5. 5.学生成绩统计学生成绩统计学生成绩统计 英英 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 6. 6.学生成绩查询学生成绩查询学生成绩查询 雄雄 *\n"); printf(" * printf(" * ▄︻┻═┳▄︻┻═┳▄︻┻═┳ 7. 7.学生成绩保存学生成绩保存学生成绩保存 联联 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 8. 8.退出退出退出//撒拉嘿撒拉嘿 盟盟 *\n"); printf(" * ( printf(" * (⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙) *\n"); ) *\n");printf(" ******************************************************\n"); printf("\n"); printf("\n printf("\n"); printf("\n 请输入您的选择编号请输入您的选择编号请输入您的选择编号,,回车键继续:回车键继续:\n"); \n");printf("---------------------------------------------------------------------------\n"); scanf("%d",&select);do {if(select<1||select>8){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&select);}l=select;}while(l<1||l>8);switch(select) {case 1:input();break; //1. case 1:input();break; //1.学生成绩新建学生成绩新建学生成绩新建case 2:sort(); break; //2. case 2:sort(); break; //2.学生成绩插入学生成绩插入学生成绩插入case 3:load(); break; //3. case 3:load(); break; //3.学生成绩修改学生成绩修改学生成绩修改case 4:print(); break; //4. case 4:print(); break; //4.学生成绩删除学生成绩删除学生成绩删除case 5:total();break; //5. case 5:total();break; //5.学生成绩统计学生成绩统计学生成绩统计case 6:search();break; //6. case 6:search();break; //6.学生成绩查询学生成绩查询学生成绩查询case 7:save();break; //7. case 7:save();break; //7.学生成绩保存学生成绩保存学生成绩保存case 8: end();break; //8. case 8: end();break; //8.结束结束结束default:printf(" default:printf(" 请按相应数学选择系统功能:请按相应数学选择系统功能:请按相应数学选择系统功能:"); ");}}}void input() //1学生成绩输入成绩模块成绩输入成绩模块{int i,j,b;float a=0;printf(" printf(" 请输入该班同学的人数:请输入该班同学的人数:请输入该班同学的人数:\n"); \n");printf(" printf(" 班同学的人数在班同学的人数在1~%d 之间:之间:\n",MAXN); \n",MAXN);scanf("%d",&R);do{if(R<1||R>100){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&R);}b=R;} while(b<1||b>100);for(i=0;i<MAXM;i++){printf(" printf(" 请输入该班同学的第请输入该班同学的第请输入该班同学的第%d %d 门课程名称为:门课程名称为:\n",(i+1)); \n",(i+1));scanf("%s", &c[i].subject);}for(i=0;i<R;i++){printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的姓名:个同学的姓名:\n",(i+1)); \n",(i+1)); scanf("%s",&s[i].name);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的学号:个同学的学号:\n",(i+1)); \n",(i+1));scanf("%s",&s[i].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(i+1)); scanf("%s",&s[i].man);printf(" printf(" 请依次输入请依次输入请依次输入%d %d 门学科的成绩:门学科的成绩:\n",MAXM); \n",MAXM);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",c[j].subject); \n",c[j].subject);scanf("%f",&s[i].score[j]);a=a+s[i].score[j];}s[i].sum=a;s[i].avg=s[i].sum/MAXM;a=0;}}void sort() //2学生成绩插入成绩模块模块{int i,j,k,b;float a=0;printf(" printf(" 请输入要插入的学生的位置请输入要插入的学生的位置1~%d 号:号:\n",R); \n",R);printf(" printf(" 第几个学生的位置之后:第几个学生的位置之后:第几个学生的位置之后:\n"); \n");scanf("%d",&k);do{if(k<1||k>R){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&k);}b=k;}while(b<1||b>R);R=R+1;for(i=R;i>k;i--){strcpy(s[i].name,s[i-1].name);strcpy(s[i].num,s[i-1].num);strcpy(s[i].man,s[i-1].man);s[i].sum=s[i-1].sum;s[i].avg=s[i-1].avg;for(j=0;j<MAXM;j++) {s[i].score[j]=s[i-1].score[j];}}printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的姓名:个同学的姓名:\n",(k+1)); \n",(k+1));scanf("%s",&s[k].name);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的学号:个同学的学号:\n",(k+1)); \n",(k+1));scanf("%s",&s[k].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(k+1)); scanf("%s",&s[k].man);printf(" printf(" 请依次输入请依次输入请依次输入%d %d 门学科的成绩:门学科的成绩:\n",MAXM); \n",MAXM);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",&c[j].subject); \n",&c[j].subject);scanf("%f", &s[k].score[j]);a=a+s[k].score[j];}s[k].sum=a;s[k].avg=s[k].sum/MAXM;}void load() //3学生成绩修改学生成绩修改 {int load1(); int load2();int select,index,b;while(1){printf("*************************************************************\n");printf(" * 1.按学号修改按学号修改 * * \n");printf(" * 2.按姓名修改按姓名修改 * * \n"); printf(" * 0.返回返回 * * \n");printf(" * 请输入您的选择编号:请输入您的选择编号: * * \n");printf("*************************************************************\n");scanf("%d",&select);do{if(select<0||select>2){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&select);}b=select;}while(b<0||b>2);switch(select){case 1:index=load1(); break;case 2:index=load2();break;case 0:return;}if(index!=-1){int i,j;float a=0,h[MAXM];i=index;printf(" printf(" 请输入请输入请输入%d %d 号的新学号:号的新学号: \n",i+1); \n",i+1);scanf("%s",&s[i].name);printf(" printf(" 请输入请输入请输入%d %d 号的新姓名:号的新姓名: \n",i+1); \n",i+1); scanf("%s",&s[i].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(i+1)); scanf("%s",&s[i].man);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",&c[j].subject); \n",&c[j].subject);scanf("%f",&h[j]);s[i].score[j] =h[j];a=a+s[i].score[j];}s[i].sum=a;s[i].avg=s[i].sum/MAXM;printf(" printf(" 修改成功。
简单学生管理信息系统源代码
package xsgl;import java.awt。
*;import java.awt。
event。
*;import java。
sql。
*;import java。
util.*;import javax。
swing。
*;import java。
util。
Vector;import javax.swing。
table.*;import java。
awt。
event.*;public class Xsglxt extends JFrame implements ActionListener//继承JFrame 并实现接口ActionListener{JPanel mb1,mb2;JLabel bq1;JTextField wbk1;JButton an1,an2,an3,an4;JTable bg1; //定义表格对象JScrollPane gd1;Xsxx xsxx2;//定义Xsxx类的一个对象xsxx2 public static void main(String[] args){Xsglxt xs=new Xsglxt();}public Xsglxt() //XSGLXT构造方法,用于对象初始化。
{mb1=new JPanel();bq1=new JLabel(”请输入姓名”);wbk1=new JTextField(10);an1=new JButton(”查询”);an1.addActionListener(this); //对按钮1添加监听an1。
setActionCommand(”chaxun”);//设置按钮1的监听信息mb1.add(bq1);mb1.add(wbk1); mb1.add(an1);mb2=new JPanel();an2=new JButton("添加”);an2。
addActionListener(this);an2。
setActionCommand("tianjia”);an3=new JButton(”修改”);an3.addActionListener(this);an3。
Pb学生管理系统源代码
PowerBuilder的创始人米歇尔克茨曼.PowerBuilder奠基人大卫李特瓦克。
1991年6月。
Powersoft公司发布了其旗标式客户/服务器硬功开发工具。
1995年PowerBuilder1.01996年PowerBuilder5。
02003年PowerBuilder9.0PowerBuilder特点:面向对象的编程和时间去懂的应用开发程序开发工具,支持跨平台开发可以轻松编写语句人性化设计。
拥有独特的库文件画板和层次清晰的系统资源库.提供了丰富多样不同风格的数据窗口PowerBuilder9.0新特性。
支持快速开发的jsp编辑器。
支持xml、PBNI(PowerBuilder Native Interface)、EJB Client、PB9。
0与Web Service 的关系,PB9。
0与.NET、其他增强功能。
建立应用对象建立Student的工作区和目标,然后建立一个名为student的对象在其Open事件中加入如下脚本:登录窗口在用户名的单行编辑框的ue_enterkey事件中加入如下脚本:在密码单行编辑框的ue_enterkey事件中加入如下脚本:菜单设计在学生管理菜单项的Clicked事件中加入如下脚本:MDI主窗口在主窗口的Open事件中加入如下脚本:学生管理窗口在学生管理窗口的Open事件中加入如下脚本:在学生管理窗口的ue_filter事件中加入如下脚本:在学生管理窗口的ue_sortasc事件中加入如下脚本:在学生管理窗口的ue_sortdesc事件中加入如下脚本:在数据窗口控件dw_stu的ue_enterkey 事件中加入如下脚本:成绩录入窗口在查询按钮的Clicked事件中加入如下脚本:入学生学号时,自动从学生基本情况表中找到该学生的姓名,并填入姓名列表中。
页面设置窗口在页面设置窗口的Open事件中加入如下脚本:打印预览窗口在打印预览窗口的Open事件中加入如下脚本:打印设置窗口在打印设置窗口的Open事件中加入如下脚本:在全部单选按钮(rb_all_page)的Clicked事件中加入如下脚本:在确定按钮的Clicked 事件中加入如下脚本:查询窗口在查询窗口中声明如下的实例变量:查选窗口在查询窗口中声明如下的实例变量:在查询按钮的Clicked事件中加入如下脚本:专业选择窗口在窗口的Open事件中加入如下脚本:String zyddlb_1.AddItem("全部”)//声明游标DECLARE mycursor CURSOR FOR SELECT DISTINCT zy //读出各个专业名FROM "xs”OPEN mycursor;If SQLCA.SQLCode〈0 ThenMessageBox(”数据库错”,”游标无法打开")ReturnEnd IfFETCH mycursor INTO :zy;//如果执行成功则SQLCode的值为0DO WHILE SQLCA.SQLCode=0ddlb_1。
学生管理系统c语言源代码
学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。
python学生成绩管理系统代码开源代码
Python 学生成绩管理系统代码开源代码一、介绍1. Python 学生成绩管理系统是一款使用 Python 编程语言开发的学生成绩管理系统,旨在帮助教师和学生更轻松地管理学生成绩信息,提高教学和学习效率。
2. 该系统具有管理学生信息、录入成绩、查询成绩等功能,操作简单方便,适合各类学校和教育机构使用。
二、功能1. 学生信息管理- 实现学生信息的录入、删除、修改等操作,包括学号、尊称、性别、芳龄、班级等基本信息。
2. 成绩录入- 支持教师录入学生成绩信息,包括各科目成绩、总成绩等,方便进行成绩分析和统计。
3. 成绩查询- 学生和教师可以通过系统进行成绩查询,快速准确地了解个人或班级成绩情况。
4. 数据分析- 系统提供成绩分析功能,支持各类成绩报表的生成和导出,方便教师进行成绩分析和评估。
三、代码开源1. 该学生成绩管理系统的代码完全开源,任何人都可以获取并自由使用、修改和分发。
2. 欢迎各类开发者参与进来,为系统的改进和完善贡献自己的力量,共同推动教育信息化的发展。
四、使用方法1. 下载安装 Python 开发环境2. 获取学生成绩管理系统的源代码3. 打开 Python 集成开发环境(IDE),导入系统代码4. 运行系统代码,即可在本地搭建起学生成绩管理系统五、系统截图[这里可以插入系统界面截图,展示系统的操作界面和功能模块]六、未来展望1. 在系统开源的基础上,期待引入更多先进的技术和功能,例如人脸识别、智能推荐等,实现更智能、更便捷的学生成绩管理。
2. 不断优化系统的用户体验和操作界面,提高系统的稳定性和安全性,为广大教育工作者和学生提供更好的服务。
七、结语1. Python 学生成绩管理系统代码开源,是为了促进科技和教育的良性互动,让技术更好地服务于教育事业。
2. 愿我们的努力能够为教育信息化的进步和发展贡献自己的一份力量,让教学和学习变得更加高效和便捷。
以上是关于 Python 学生成绩管理系统代码开源代码的介绍,欢迎大家下载使用,并提出宝贵的意见和建议,让我们一同推动教育信息化事业的发展。
课程设计:学生学籍管理系统源代码
#include”stdio。
h”#include"conio。
h”#include"stdlib。
h”#include”string。
h"#define N 1000 //N为可输入的学生总人数,可根据需要更改#define M 2 //M为宏定义的(在创建密码函数中)可建立的登陆用户个数,可更改struct student //定义学生信息结构体数组{char num[9]; //学号char name[20]; //姓名char depar[15]; //院系char zhuanye[15];//专业char classes[5]; //班级char age[3];//年龄char sex[4]; //性别char nation[5]; //民族char birth[9]; //出生日期char add[10];//籍贯};struct code //定义密码结构体数组{char name[20];char code[7];}co[M],s0;//确认是否新创建密码文件模块int code(){FILE *fp;if((fp=fopen("学生学籍管理系统__code。
txt","rt"))==NULL){printf(”密码文件不存在,请输入新的用户名及密码:\n");//若不存在此密码文件,则提示用户创建密码printf("请输入任意键继续!”);getch();system("cls");return 1; //无密码文件返回1 }elsereturn 0; //已有密码文件返回0 }//新创建初始密码void code_input(){FILE *fp;int i;if((fp=fopen(”学生学籍管理系统__code。
txt”,"wt"))==NULL);//当建立密码文件成功时,进入for循环for(i=0;i〈M;i++) //M为宏定义的可建立的登陆用户个数,可更改{printf("请录入第%d个用户名:",i+1);//创建不同的用户名及密码scanf(”%s",co[i]。
学生成绩管理系统(数据结构C语言版源代码)
学生成绩管理系统(数据结构C语言版源代码)-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII#include<stdio.h>#include<string.h>#include<stdlib.h>struct students{char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *next; /*用与构建连表指向下一结点*/};FILE *fp; /*定义全局变量fp*/void Revisemenu();/*修改菜单*/void Sortmenu();/*排序菜单*/void menu();/*主菜单*/void secret();/*安全验证*/struct students * Input();/*新建学生信息*/void fprint(struct students *head);/*将信息导入文件可追加*/void fprint_(struct students *head);/*将信息导入文件并覆盖*/void Browse(struct students *head);/*浏览全部学生信息*/struct students * create(struct students *head,int *n);/*从tushu_list中读取数据构建链表*/void FindofNum(struct students *head);/*按学号查询学生信息*/void FindofNname(struct students *head);/*按姓名查询学生信息*/void SortEnglish(struct students * head);/*按英语成绩排序*/void SortJava(struct students * head);/*按Java成绩排序*/void SortSjjg(struct students * head);/*按数据结构成绩排序*/void SortSzdl(struct students * head);/*按数字逻辑电路成绩排序*/void SortJsj(struct students * head);/*按计算机组成原理成绩排序*/struct students * Delete(struct students * head,char m[15]);/*按学号删除学生成绩信息*/struct students * Revise();/*修改学生信息(按编号修改)*//*主菜单*/void menu(){printf("\n\n");printf("***************************************************\n");printf(" 学生成绩管理系统 \n");printf("---------------------------------------------------\n");printf(" 1-添加新同学 2-浏览学生信息 \n");printf(" 3-按学号查询 4-按姓名查询 \n");printf(" 5-按成绩排序 6-修改学生信息 \n");printf(" 7-删除学生信息 0-退出系统 \n");printf("---------------------------------------------------\n");printf("___________________________________________________\n");}/*排序菜单*/void Sortmenu(){printf("\n\n");printf("***************************************************\n");printf(" 按成绩排序 \n");printf(" 1-大学英语 2-JAVA编程 \n");printf(" 3-数据结构 4-数字逻辑电路 \n");printf(" 5-计算机组成原理 0-返回上级菜单 \n");printf("***************************************************\n");}/*修改菜单*/void Revisemenu(){printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf(" 1--修改学生姓名 2--修改学生学号 \n");printf(" 3--修改学生性别 4--修改英语成绩 \n");printf(" 5--修改JAVA成绩 6--修改数据结构 \n");printf(" 7--修改数字电路 8--修改计算计 \n");printf(" 0--返回上级菜单 \n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}/*安全验证*/void secret(){char a[20];printf("**欢迎来到学生信息管理系统,进入系统前请先进行密码验证---");printf(" ");do{gets(a); /*输入密码*/system("cls"); /*调用库函数清屏*/printf("对不起!您输入的密码有误,请重新输入---");}while(strcmp(a,"0605")!=0); /*单一密码"0605"*/system("cls");}/*新建学生信息*/struct students * Input(){struct students *p1,*p2,*head; /*建立辅助结点及头结点*/char Name;int n=0,x;printf("\n请按对应项输入学生信息以#结束:\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机组成原理\n");p1=(struct students *)malloc(sizeof(struct students));head=p2=p1;do{ /*使用do while语句输入学生信息*/scanf("%s",&p1->Name);if(strcmp(p1->Name,"#")==0)break; /*判断结束符*/elsescanf("%s%s%lf%lf%lf%lf%lf",p1->Num,p1->Sex,&p1->English,&p1->Java,&p1->Sjjg,&p1->Szdl,&p1->Jsj);Name='#';p1=(struct students *)malloc(sizeof(struct students));p2->next=p1;p2=p1;n++;}while(1);p1->next=NULL;printf("学生信息输入结束!\n");getchar();printf("是否保存学生信息(1.是/2.否):");scanf("%d",&x);if(x==1)fprint(head); /*调用函数保存至文件*/elseprintf("\n文件没有被保存!\n");return head; /*返回头指针*/}/*将信息导入文件可追加*/void fprint(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","a"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1->next!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/printf("\n学生信息已成功保存到文件 students_list.txt 中!\n");getchar();}/*将信息导入文件并覆盖*/void fprint_(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","w"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/;getchar();}/*浏览全部学生信息*/void Browse(struct students *head){char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}printf("-------------------------------------------------------------\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(!feof(fp))/*读取并输出*/{fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",Name,Num,Sex,&English,&Java,&Sjjg,&Sz dl,&Jsj);printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",Name,Num,Sex,English,Java,Sjjg,Szdl,Jsj);};if(fclose(fp)){printf("Can not close the file!\n");exit(0);}}/*从tushu_list中读取数据构建链表*/struct students * create(struct students * head,int *n){FILE *fp;struct students*p,*p1,*p2;if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}while(!feof(fp)){(*n)++;p=(struct students *)malloc(sizeof(struct students));fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",p->Name,p->Num,p->Sex,&p->English,&p->Java,&p->Sjjg,&p->Szdl,&p->Jsj);if(head==NULL){head=p;p1=p;}else{p1->next=p;p2=p1;p1=p;}}p2->next=NULL;free(p);(*n)--;fclose(fp);return head;}/*按姓名查询学生信息*/void FindofName(struct students *head){int i=0,n=0;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生姓名:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Name,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到名为“%s”的学生信息!\n",b);}/*按学号查询学生信息*/void FindofNum(struct students *head){int i=0,n;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生学号:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Num,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到学号为“%s”学生信息!\n",b);}/*按英语成绩排序*/void SortEnglish(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double English;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;English=p->English; /*将链表中第一个成绩赋给English*/while(p!=NULL){if((p->English)>English)/*比较*/English=p->English;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->English==English){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->English==English){ /*分数相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按英语成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按JAVA成绩排序*/void SortJava(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Java;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Java=p->Java; /*将链表中第一个成绩赋给Java*/while(p!=NULL){if((p->Java)>Java)/*比较*/Java=p->Java;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Java==Java){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Java==Java){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按Java成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数据结构排序*/void SortSjjg(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Sjjg;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Sjjg=p->Sjjg; /*将链表中第一个成绩赋给Sjjg*/while(p!=NULL){if((p->Sjjg)>Sjjg)/*比较*/Sjjg=p->Sjjg;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Sjjg==Sjjg){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Sjjg==Sjjg){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数据结构成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数字电路排序*/void SortSzdl(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Szdl;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Szdl=p->Szdl; /*将链表中第一个成绩赋给Szdl*/while(p!=NULL){if((p->Szdl)>Szdl)/*比较*/Szdl=p->Szdl;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Szdl==Szdl){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Szdl==Szdl){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数字电路成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按计算机组成原理排序*/void SortJsj(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Jsj;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Jsj=p->Jsj; /*将链表中第一个成绩赋给Jsj*/while(p!=NULL){if((p->Jsj)>Jsj)/*比较*/Jsj=p->Jsj;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Jsj==Jsj){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Jsj==Jsj){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按计算机组成原理成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按学号删除学生成绩信息*/struct students * Delete(struct students * head,char m[15]){struct students *ptr1,*ptr2;int n;printf("\n所有学生信息如下:\n");Browse(head);printf("\n请输入想要删除的学生学号:");scanf("%s",m);head=create(head,&n);if(head==NULL){printf("无学生信息!\n");return head;}if((strcmp(head->Num,m)==0)&&head!=NULL){ptr2=head;head=head->next;free(ptr2);}if(strcmp(head->Num,m)!=0){ptr1=head;ptr2=head->next;while(ptr2!=NULL){if(strcmp(ptr2->Num,m)==0){ptr1->next=ptr2->next;free(ptr2);}elseptr1=ptr2;ptr2=ptr1->next;}}fprint_(head);printf("\n学号为' %s '学生信息已被删除,并保存至文件!\n",m);return head;}/*修改学生信息(按编号修改)*/struct students * Revise(){int n=0,t;char num[10];char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *head=NULL;struct students *p;printf("\n所有学生信息如下:\n");Browse(head);head=create(head,&n);printf("\n输入需要修改的学生的学号:");scanf("%s",num);p=head;while(head!=NULL){if(strcmp(p->Num,num)==0){system("cls");Revisemenu();printf("编号为%s的学生信息如下:\n",num);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);while(1){printf("请选择需要修改的信息:");scanf("%d",&t);switch(t){case 1:printf("请输入新姓名:");scanf("%s",Name);strcpy(p->Name,Name);break;case 2:printf("请输入新学号:");scanf("%s",&Num);strcpy(p->Num,Num);break;case 3:printf("请输入新性别:");scanf("%s",Sex);strcpy(p->Sex,Sex);break;case 4:printf("请输入新英语成绩:");scanf("%lf",&English);p->English=English;break;case 5:printf("请输入新Java成绩:");scanf("%lf",&Java);p->Java=Java;break;case 6:printf("请输入新数据结构成绩:");scanf("%lf",&Sjjg);p->Sjjg=Sjjg;break;case 7:printf("请输入新数字电路成绩:");scanf("%lf",&Szdl);p->Szdl=Szdl;break;case 8:printf("请输入新计算机组成原理成绩:");scanf("%lf",&Jsj);p->Jsj=Jsj;break;case 0:system("cls");menu();goto lab;break;default:printf("对不起,输入有误!");break;}}}elsep=p->next;}lab:fprint_(head);printf("修改完成,并储存至文件!\n");return head;}/*主函数*/void main(){int choice,ch;char m[15];struct students *head=NULL;secret();menu();while(1){printf("请输入选项:");scanf("%d",&choice);switch(choice){case 1:Input();break;case 2:system("cls");menu();Browse(head);break;case 3:system("cls");menu();FindofNum(head);break;case 4:system("cls");menu();FindofName(head);break;case 5:system("cls");Sortmenu();do{printf("请输入您的选择:");scanf("%d",&ch);switch(ch){case 1:system("cls");Sortmenu();SortEnglish(head);break;case 2:system("cls");Sortmenu();SortJava(head);break;case 3:system("cls");Sortmenu();SortSjjg(head);break;case 4:system("cls");Sortmenu();SortSzdl(head);break;case 5:system("cls");Sortmenu();SortJsj(head);break;}}while(ch!=0);system("cls");menu();break;case 6:system("cls");menu();Revise();break;case 7:system("cls");menu();head=Delete(head,m);break;case 0:system("cls");printf("\t\t欢迎下次再来!");exit(0);default:printf("对不起,输入有误!");break;}}return ;}。
管理系统登陆界面源代码
printf("\n\t\t\t按任意键继续...");
getch();
login();
}
void login() /*登录界面*/
{
int select;
system("CLS");
system("color A");
system("CLS");
system("color B");
printf("\t\t\t⊙ 欢迎使用学生成绩管理系统 ⊙\n");
printf("\t\t\t⊙ ⊙\n");
printf("\t\t\t⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙\n");
printf("\n\t\t\t系统开始启动.........\n");
for(isleep=1;isleep<=100000000;isleep++)
{}
system("CLS");
printf("\n\n\n\n\n\n\n\n\n\t\t\t⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙\n");
printf("\t\t\t⊙ ⊙\n");
printf("\n\n\n\n\n\t\t\t※※※※※※※※※※※※\n");
printf("\t\t\t※ ※\n");
printf("\t\t\t※ 1.注册用户 ※\n");
printf("\t\t\t※--------------------※\n");
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<iostream>#include<stdlib.h>#include<string.h>#include<malloc.h>#define INIT_SIZE 10#define INCRE_SIZE 10#define SUBJECT_NUM 3#define LEN 3void show_Start();void show_Table();void addRecord();void Info_delete();void deleteRecord();void delete_Num(int);void delete_Name(char tarName[]);void Info_modify();void modifyRecord();void modify_Num(int);void modify_Name(char[]);void Info_query();void queryRecord();void query_Num(int);void query_Name(char[]);void display();void quit();void menu_CMD();char *subject[SUBJECT_NUM] = struct STUDENT{int num;char name[20];char sex;float score[SUBJECT_NUM];};//struct STUDENT stu[LEN + 1];//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);int static stuNum = 0;//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);;int main(){//record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);/*record[1].num = 1001;strcpy(record[1].name,"Jason");record[1].sex = 'M';record[1].score[0] = 85.0;record[1].score[1] = 90.0;record[1].score[2] = 95.0;record[2].num = 1002;strcpy(record[2].name,"Jerry");record[2].sex = 'M';record[2].score[0] = 85.0;record[2].score[1] = 90.0;record[2].score[2] = 95.0;record[3].num = 1003;strcpy(record[3].name,"Jessie");record[3].sex = 'F';record[3].score[0] = 85.0; record[3].score[1] = 90.0; record[3].score[2] = 95.0;*//*Info_modify();int key;cout<cin>>key;if(key == 1){int targetNum;coutcin>>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(){//cout<<endl;cout<<" **************************************** "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" Made by Jason "<<endl; cout<<" **************************************** "<<endl;}//.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;}}}/////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////void addRecord(){if(stuNum == 0){cout<< <<endl;stuNum++;}else{cout<<" <<endl;stuNum++;}//if(stuNum > INIT_SIZE){cout<< "<<endl;record = (STUDENT*)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT));cout<<" !"<<endl;}cout<<" <<endl;cout<<" (Y/N) : ";char choi;cin>>choi;if((choi == 'Y')||(choi == 'y')){cout<<" : ";cin>>record[stuNum].num;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<<" !"<<endl; cout<<endl;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \//deleteRecordvoid Info_delete(){cout<<" : "<<endl;cout<<"1. "<<endl;cout<<"2. <<endl;cout<<"3. "<<endl; }//void deleteRecord(){int key;cout<<endl;Info_delete();cout<<" : "; cin>>key;if(key == 1){int targetNum;cout<<" : ";cin>>targetNum;//delete_Num(targetNum);cout<<endl;}if(key == 2){char targetName[20];cout<<" : "; cin>>targetName;delete_Name(targetName); cout<<endl;}if(key == 3){while(1){menu_CMD();}}}//void delete_Num(int tarNum){int i;for(i = 1;i <= stuNum;i++){if(record[i].num == tarNum){////1.//2.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;*/}//2.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];}//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 delete_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,tarName) == 0){////1.//2.//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;}}/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];}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;}cout<<endl;void delete_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){////1.//2.// if(strcmp(record[i].name,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;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].score[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;//if(key == 1){int targetNum;cout<< : ";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){while(1){menu_CMD();}}}//void modify_Num(int tarNum) {int i;for(i = 1;i <= stuNum;i++) {if(record[i].num == 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; }//queryRecordvoid queryRecord(){int key;cout<<endl;Info_query();cout<<" ";cin>>key;if(key == 1){int targetNum;cout<<" : ";cin>>targetNum;query_Num(targetNum);cout<<endl;}if(key == 2){char targetName[20];cout<<" : ";cin>>targetName;query_Name(targetName);cout<<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){// 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"<<record[i].score[ 2];cout<<endl;}}}//void query_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,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"<<record[i].score[ 2];cout<<endl;}}}//void display(){show_Table();int i,j;for(i = 1;i <= stuNum;i++){//cout<<"学号"<<"\t"<<"姓名"<<"\t"<<"性别";cout<<record[i].num<<"\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();.。