两只小熊队高级软件工程第七次作业敏捷冲刺4

团队的作业:学生信息管理系统

  • 队员学号:

    周菲(队长) 201810812007

    孔繁燕    201810812001

Alpha敏捷冲刺:

1、 站立式会议照片

 

2、每个人的工作:

周菲:

今天已完成:学生信息管理窗体创建,实现添加学生信息功能

遇到的问题:无

明天计划完成:实现修改学生信息功能;

孔繁燕:

今天已完成:学生信息管理窗体创建,实现添加学生信息功能。

遇到的问题;暂无

明天计划完成:实现修改学生信息功能测试。

3、项目燃尽图

 

4、部分项目代码和截图:

 

package ui.internal.students;

import java.awt.Font;
import java.util.Vector;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import entity.Grade;
import entity.Student;
import service.GradeService;
import service.StudentService;
import util.IReload;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import java.awt.Color;

public class StudentAddDialog extends JInternalFrame {

	private static final long serialVersionUID = 1L;
	private JTextField txtId;
	private JTextField txtName;
	private JTextField txtAge;
	private JTextField txtPhone;
	private JComboBox<Grade> comboBox;
	private GradeService gradeService = new GradeService();
	private StudentService studentService = new StudentService();
	private IReload reload = null;

	
	public StudentAddDialog(String title,IReload reload) {
		super(title);
		this.reload=reload;
		init();
	}
	
	public StudentAddDialog() {
		getContentPane().setBackground(new Color(176, 224, 230));
		getContentPane().setForeground(new Color(240, 248, 255));
		setForeground(new Color(173, 216, 230));
		setIconifiable(true);
		setFrameIcon(new ImageIcon(StudentAddDialog.class.getResource("/com/sun/javafx/scene/web/skin/FontBackgroundColor_16x16_JFX.png")));
		setTitle("增加一条学生记录...");
		init();
	}

	private void init() {
		setClosable(true);
		setBounds(100, 100, 411, 387);
		getContentPane().setLayout(null);
		
		JLabel label = new JLabel("学号:");
		label.setForeground(Color.GRAY);
		label.setFont(new Font("微软雅黑", Font.BOLD, 16));
		label.setBounds(55, 10, 101, 36);
		getContentPane().add(label);
		
		txtId = new JTextField();
		txtId.setBounds(140, 19, 171, 21);
		getContentPane().add(txtId);
		txtId.setColumns(10);
		
		JLabel label_1 = new JLabel("姓名:");
		label_1.setForeground(Color.GRAY);
		label_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
		label_1.setBounds(55, 56, 101, 36);
		getContentPane().add(label_1);
		
		txtName = new JTextField();
		txtName.setColumns(10);
		txtName.setBounds(140, 65, 171, 21);
		getContentPane().add(txtName);
		
		JLabel label_2 = new JLabel("年龄");
		label_2.setForeground(new Color(128, 128, 128));
		label_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
		label_2.setBounds(55, 113, 101, 36);
		getContentPane().add(label_2);
		
		txtAge = new JTextField();
		txtAge.setColumns(10);
		txtAge.setBounds(140, 122, 171, 21);
		getContentPane().add(txtAge);
		
		JLabel label_3 = new JLabel("班级:");
		label_3.setForeground(Color.GRAY);
		label_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
		label_3.setBounds(55, 159, 101, 36);
		getContentPane().add(label_3);
		
		comboBox = new JComboBox<>();
		comboBox.setBackground(new Color(255, 255, 255));
		comboBox.setForeground(Color.DARK_GRAY);
		comboBox.setFont(new Font("微软雅黑", Font.PLAIN, 12));
		comboBox.setBounds(140, 168, 171, 21);
		getContentPane().add(comboBox);
		
		txtPhone = new JTextField();
		txtPhone.setColumns(10);
		txtPhone.setBounds(140, 221, 171, 21);
		getContentPane().add(txtPhone);
		
		JButton btnSave = new JButton("保存");
		btnSave.setBackground(new Color(255, 255, 255));
		

		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				

				int id =  Integer.parseInt(txtId.getText());
				String name = txtName.getText();
				int age =  Integer.parseInt(txtAge.getText());
				Grade g = (Grade)(comboBox.getSelectedItem());
				int gradeId = g.getGradeId();
				String phone = txtPhone.getText();
				Student stu = new Student(id,name,age,gradeId,phone);
				

				boolean isSave = studentService.add(stu);
				

				if(isSave){
					reload.reload();
					StudentAddDialog.this.dispose();
				}else{
					System.out.println("保存失败");
				}
				 
				
			}
		});
		btnSave.setBounds(40, 299, 93, 23);
		getContentPane().add(btnSave);
		
		JButton btnCancel = new JButton("取消");

		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				StudentAddDialog.this.dispose();
			}
		});
		btnCancel.setBounds(237, 299, 93, 23);
		getContentPane().add(btnCancel);
		
		JLabel label_4 = new JLabel("手机号:");
		label_4.setForeground(Color.GRAY);
		label_4.setFont(new Font("微软雅黑", Font.BOLD, 16));
		label_4.setBounds(55, 212, 101, 36);
		getContentPane().add(label_4);
		

		
		loadAllGrades();
	}


	private void loadAllGrades() {
		Vector<Grade> grades = new Vector<>(gradeService.getAllGrades());
		comboBox.setModel(new DefaultComboBoxModel<Grade>(grades));
	}
}

 

posted on 2018-11-27 22:42  小雪zzz  阅读(179)  评论(0编辑  收藏  举报