局部 E-R 图:
学号
班级
性别
备注
姓名
年龄
学生
电话
年级
监护人
课程号
课程名
课程
班号
班主任
班级
班长
所属年级
代号
年级主任
年级
1
整体 E-R 图
学生
n
属于
1
m
班级
1
m
选课
课程
开设
1
m
属于
属于
m
m
年级
课程表:
离校学生表:
用户表:
班级表:
学生基本信息表:
年级表:
成绩表:
代码
一:
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;
using System.Data.SqlClient;
namespace data
{
public partial class Form1 : Form
{
public Form1()
{
}
InitializeComponent();
public static string con()
{
}
string connString = "server=IDEA-PC\\SQLEXPRESS1;" +
"database=student;uid=sa;pwd=sjm;";
return connString;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
this.Close();
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
string name;
string psd1;
string job1;
name = textBox1.Text;
psd1 = textBox2.Text;
job1 = textBox3.Text;
string con1 = con();
string strSql = "SELECT psd FROM [use] where [user]='" + name + "'";
SqlConnection conn = new SqlConnection(con1);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = strSql;
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
string str = dr[0].ToString();
if (!Equals(psd1,str))
{
}
MessageBox.Show("the pass word is wrong!!!");
else
{
this.Hide();
if(job1=="教务主任")
{
}
Form2 f2 = new Form2();
f2.Show();
else if (job1 == "班主任")
{
Form3 f3 = new Form3();
f3.Show();
}
else if (job1 == "任课老师")
{
}
Form4 f4 = new Form4();
f4.Show();
else if (job1 == “学生”?)
{
}
Form5 f5 = new Form5();
f5.Show();
else if (job1 == "家长")
{
}
Form6 f6 = new Form6();
f6.Show();
else
this.Close();
{
}
}
}
}
conn.Close();
}
}
}
二:
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;
using System.Data.SqlClient;
namespace data
{
public partial class Form2 : Form
{
public Form2()
{
}
InitializeComponent();
private void Form2_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string num;
string cnum;
int nscore;
num=textBox1.Text;
cnum=textBox2.Text;
nscore=(int)Convert.ToUInt32(textBox3.Text);
string con2 = Form1.con();
string strSql ="update score set mark="+nscore+" where sno='"+num+"' and
cno='"+ cnum +"'";
SqlConnection conn = new SqlConnection(con2);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = strSql;
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("修T改?成é绩¨成é功|");
conn.Close();
}
private void button5_Click(object sender, EventArgs e)
{
string num;
string cnum;
int nscore;
num = textBox1.Text;
cnum = textBox2.Text;
nscore = (int)Convert.ToUInt32(textBox3.Text);
string con2 = Form1.con();
string
strSql
=
"insert
into
score(sno,cno,mark)
values"+"('"+num+"','"+cnum+"','"+nscore+"')";
SqlConnection conn = new SqlConnection(con2);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = strSql;
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("插?入?成é绩¨成é功|");
conn.Close();
}
private void button6_Click(object sender, EventArgs e)
+ "'";
{
}
string num;
string cnum;
num = textBox1.Text;
cnum = textBox2.Text;
string con2 = Form1.con();
string strSql = "delete from score where sno='" + num + "' and cno='" + cnum
SqlConnection conn = new SqlConnection(con2);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = strSql;
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("删?除y成é绩¨成é功|");
conn.Close();
private void button7_Click(object sender, EventArgs e)//删?除y学§生Θ?