comm.Parameters.Add(\身份\comm.Parameters[\身份\try{
r = comm.ExecuteNonQuery(); }
catch (Exception e1){
MessageBox.Show(\用户名插入重复,请重新输入!\}
conn.Close();
修改代码
SqlConnection conn = new SqlConnection();
conn.ConnectionString = \学生综合测评管理系统;Integrated Security=True\conn.Open();
SqlCommand comm = new SqlCommand(); comm.Connection = conn;
string sql = \登录表 set 密码=@密码,身份=@身份 where 学号=@学号\comm.CommandText = sql;
comm.Parameters.Add(\学号\comm.Parameters[\学号\comm.Parameters.Add(\密码\comm.Parameters[\密码\comm.Parameters.Add(\身份\comm.Parameters[\身份\int r = comm.ExecuteNonQuery(); if (r == 1) {
MessageBox.Show(\修改成功!\}
conn.Close();
删除代码
SqlConnection conn = new SqlConnection();
conn.ConnectionString = \学生综合测评管理系统;Integrated Security=True\; conn.Open();
SqlCommand comm = new SqlCommand(); comm.Connection = conn;
string sql = \登录表 where 学号=@学号\; comm.CommandText = sql;
comm.Parameters.Add(\学号\, SqlDbType.NVarChar); comm.Parameters[\学号\].Value = textBox1.Text; int r = comm.ExecuteNonQuery(); if (r == 1) {
MessageBox.Show(\删除成功!\); }
29
conn.Close();
综合测评计算代码
string strConn = \学生综合测评管理系统;Integrated Security=True\;
SqlConnection objConn = new SqlConnection(strConn); objConn.Open();
string strSql = \成绩表.学号,成绩表.学期,成绩表.成绩,成绩表.学分,综合测评表.文体表现,综合测评表.学业表现,综合测评表.品德表现 From 成绩表 JOIN 综合测评表 ON 成绩表.学号=综合测评表.学号 where 成绩表.学号= \ + textBox1.Text + \成绩表.学期=\ + comboBox22.Text + \;
SqlDataAdapter objAdap = new SqlDataAdapter(strSql, objConn); objConn.Close();
DataSet objDSet = new DataSet(); objAdap.Fill(objDSet, \);
int cj, xf,zcj=0,zxf=0,jqcj,pdbx=0, xybx=0, wtbx=0; for (int i = 0; i < n; i++){ jqcj=0;
cj =Convert.ToInt16( objDSet.Tables[0].Rows[i][\成绩\].ToString()); xf =Convert.ToInt16( objDSet.Tables[0].Rows[i][\学分\].ToString());
wtbx = Convert.ToInt16(objDSet.Tables[0].Rows[0][\文体表现\].ToString()); xybx = Convert.ToInt16(objDSet.Tables[0].Rows[0][\学业表现\].ToString()); pdbx = Convert.ToInt16(objDSet.Tables[0].Rows[0][\品德表现\].ToString()); jqcj = cj * xf; zcj += jqcj; zxf += xf; }
jqcp = Convert.ToInt16(zcj / zxf) * 0.60 + wtbx*0.15 + xybx*0.2 + pdbx*0.05; int r = 0;
if (textBox1.Text != \ && comboBox1.Text != \ && comboBox22.Text != \){ SqlConnection conn = new SqlConnection();
conn.ConnectionString = \学生综合测评管理系统;Integrated Security=True\; conn.Open();
SqlCommand comm = new SqlCommand(); comm.Connection = conn;
string sql = \加权测评表(学号,学期,综合测评)values(@学号,@学期,@综合测评)\; comm.CommandText = sql;
comm.Parameters.Add(\学号\, SqlDbType.NVarChar); comm.Parameters[\学号\].Value = textBox1.Text; comm.Parameters.Add(\学期\, SqlDbType.NVarChar); comm.Parameters[\学期\].Value = comboBox22.Text; comm.Parameters.Add(\综合测评\, SqlDbType.NVarChar); comm.Parameters[\综合测评\].Value = jqcp; try{
30
r = comm.ExecuteNonQuery(); }catch (Exception e1) {
MessageBox.Show(\计算重复,请计算下一个!\); }if (r == 1) {
MessageBox.Show(\计算成功!\); }
conn.Close(); } } }
31