码迷,mamicode.com
首页 > 其他好文 > 详细

冲刺阶段 day 6

时间:2016-05-16 17:19:56      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

项目进展:学生管理这部分已经进展的差不多了,调试了几遍,改了几个小Bug之后就没有什么问题了,基本完成,如若后续还有一些新的功能到时候再自行加入。明天开始教师部分。

存在问题:我觉得我们的项目还是比较课堂,比较中规中矩的,还需一些闪光点来加分,例如再加入一些功能。下次小组开会的时候再讨论一下。

实现的部分代码:

MainFrm 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GengdanContactsMIS_WinForm
{
    public partial class MainFrm : Form
    {
        public MainFrm()
        {
            InitializeComponent();
        }

        private void 系部管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DepartmentFrm f = new DepartmentFrm();
            f.ShowDialog();
        }

        private void 专业管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MajorFrm m = new MajorFrm();
            m.ShowDialog();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 班级管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClassFrm f = new ClassFrm();
            f.ShowDialog();
        }

        private void 学生管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StudentFrm f = new StudentFrm();
            f.ShowDialog();
        }

        private void 教师管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TeacherFrm f = new TeacherFrm();
            f.ShowDialog();
        }

        
    }
}

StudentFrm

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GengdanContactsMIS_WinForm
{
    public partial class StudentFrm : Form
    {
        public StudentFrm()
        {
            InitializeComponent();
            BindClass();
            BindStudent();
        }
        void BindClass()
        {
            string sql = "select ClassId ,ClassName from Class";
            DB db = new DB();
            DataSet ds = db.GetDataSet(sql, "Class");
            cbClass.DataSource = ds.Tables["Class"];
            cbClass.DisplayMember = "ClassName";
            cbClass.ValueMember = "ClassId";
        }
        void BindStudent()
        {
            string sql = "select SNo as 学号,SName as 姓名,Sex as 性别,ClassName as 班级,BirthDate as 出生年月日,Phone as 电话,Email as 邮箱,Adress as 地址 from Student,Class where Student.ClassId=Class.ClassId";
            DB db = new DB();
            DataSet ds = db.GetDataSet(sql,"Student");
            dataGridView1.DataSource = ds.Tables["Student"];
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            string sql = "insert into Student(SNo,SName,Sex,ClassId,BirthDate,Phone,Email,Adress)values("
                 + txtSNo.Text + ",‘" + txtSName.Text + "‘,‘" + txtSex.Text + "‘," + cbClass.SelectedValue + ",‘" + txtBirthDate.Text + "‘,‘" + txtPhone.Text + "‘,‘" + txtEmail.Text + "‘,‘" + txtAdress.Text + "‘)";
             DB db = new DB();
             if (db.ExecuteSQL(sql))
                 MessageBox.Show("学生增加成功");
             else
                 MessageBox.Show("学生增加失败,请检查学号是否已存在");
             BindStudent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string sql = "select SNo,SName,Sex,ClassName,BirthDate,Phone,Email,Adress from Class,Student where Class.ClassId=Student.ClassId and SName=‘" + txtSName.Text + "";
            DB db = new DB();
            DataSet ds = db.GetDataSet(sql, "a");
            dataGridView1.DataSource = ds.Tables["a"];
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

技术分享

记录人:秦文

冲刺阶段 day 6

标签:

原文地址:http://www.cnblogs.com/3214292940F5/p/5496197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!