private void btnPost_Click(object sender, EventArgs e) { #region 获取当前登录用户ID LoginUIBLL objLoginUIBLL = new LoginUIBLL(); LoginUserModel objLoginUserModel = new LoginUserModel(); SqlDataReader SqlRead; SqlRead = objLoginUIBLL.LoginUserRead(); if (SqlRead.Read() == true) { objLoginUserModel.UserId = SqlRead["UserId"].ToString(); } #endregion string SqlString="Insert into V_StuWebComment"; #region 类型选择 if (rdbSuggest.Checked == true) { SqlString += "(学号,建议) Values('" + objLoginUserModel.UserId + "','" + txtComment.Text + "')"; } if (rdbCriticism.Checked == true) { SqlString += "(学号,批评) Values('" + objLoginUserModel.UserId + "','" + txtComment.Text + "')"; } if (rdbconsult.Checked == true) { SqlString += "(学号,咨询) Values('" + objLoginUserModel.UserId + "','" + txtComment.Text + "')"; } #endregion DataBaseOperateClass2 objDataBaseOperateClass2 = new DataBaseOperateClass2(); #region 异常处理 try { if (objDataBaseOperateClass2.GetExecute(SqlString) == true) MessageBox.Show("成功提交!谢谢参与!"); else MessageBox.Show("抱歉!提交失败!请查看错误消息:"); } catch (Exception e1) { MessageBox.Show("抱歉!提交失败!请查看错误消息:"); MessageBox.Show("错误消息:" + e1); } #endregion }
private void StuWebEvaluation_Load(object sender, EventArgs e) { textBox1.Text = "请用精简的文字对教师的教学情况进行评价!"; rdbGood.Checked = true; #region 获取当前使用用户id LoginUIBLL objLoginUIBLL = new LoginUIBLL(); //LoginUserModel objLoginUserModel = new LoginUserModel(); SqlDataReader SqlRead; SqlRead = objLoginUIBLL.LoginUserRead(); if (SqlRead.Read()) { objLoginUserModel.UserId = SqlRead["UserId"].ToString(); } #endregion ShowEvalInfo(); }