protected void btnAdd_Click(object sender, EventArgs e) { DalOperationAboutGradeCheck dal = new DalOperationAboutGradeCheck(); string dtime = DateTime.Now.ToString(); using (TransactionScope scope = new TransactionScope()) { try { foreach (Control ctlTable in PlaceHolder1.Controls) { foreach (Control ctlTableRow in ctlTable.Controls) { foreach (Control ctlTableCell in ctlTableRow.Controls) { foreach (Control ctl in ctlTableCell.Controls) { if (ctl.GetType().ToString().Trim() == "System.Web.UI.WebControls.TextBox") { StudentsGradeCheckDetail model = new StudentsGradeCheckDetail(); model.studentNo = studentNo; model.updateTime = Convert.ToDateTime(dtime); model.gradeCheckDetailValue = ((TextBox)ctl).Text.Trim(); model.gradeCheckId = int.Parse(ctl.ID.Split("_".ToCharArray())[1]); dal.AddGradeCheckDetailByStudentNo(model); } } } } } StudentsGradeCheckConfirm model1 = new StudentsGradeCheckConfirm { studentNo = studentNo, updateTime = Convert.ToDateTime(dtime), isAccord = int.Parse(ddlIsAccord.SelectedValue), remark = remark.Text.Trim() }; dal.AddStudentGradeCheckConfirm(model1); scope.Complete(); Javascript.RefreshParentWindow("添加成绩审核记录成功!", "/Administrator/StudentManager.aspx?fragment=7&studentNo=" + studentNo, Page); } catch (Exception ex) { MongoDBLog.LogRecord(ex); Javascript.GoHistory(-1, "添加成绩审核记录失败!", Page); } finally { dal.conn.Close(); } } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddGradeCheckDetailByStudentNo(StudentsGradeCheckDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into usta_StudentsGradeCheckDetail("); strSql.Append("gradeCheckId,gradeCheckDetailValue,studentNo,updateTime)"); strSql.Append(" values ("); strSql.Append("@gradeCheckId,@gradeCheckDetailValue,@studentNo,@updateTime)"); SqlParameter[] parameters = { new SqlParameter("@gradeCheckId", SqlDbType.Int,4), new SqlParameter("@gradeCheckDetailValue", SqlDbType.NVarChar,200), new SqlParameter("@studentNo", SqlDbType.NChar,10), new SqlParameter("@updateTime", SqlDbType.DateTime)}; parameters[0].Value = model.gradeCheckId; parameters[1].Value = model.gradeCheckDetailValue; parameters[2].Value = model.studentNo; parameters[3].Value = model.updateTime; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateGradeCheckDetailByStudentNo(StudentsGradeCheckDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update usta_StudentsGradeCheckDetail set "); strSql.Append("gradeCheckDetailValue=@gradeCheckDetailValue"); strSql.Append(" where studentNo=@studentNo AND updateTime=@updateTime AND gradeCheckId=@gradeCheckId"); SqlParameter[] parameters = { new SqlParameter("@gradeCheckDetailValue", SqlDbType.NVarChar,200), new SqlParameter("@studentNo", SqlDbType.NChar,10), new SqlParameter("@updateTime", SqlDbType.DateTime), new SqlParameter("@gradeCheckId", SqlDbType.Int,4)}; parameters[0].Value = model.gradeCheckDetailValue; parameters[1].Value = model.studentNo; parameters[2].Value = model.updateTime; parameters[3].Value = model.gradeCheckId; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }