public int TeacherCorrectStuHomeWork(Model_Student_HomeWork_Correct modelSHWCorrect, List <Model_Student_HomeWorkAnswer> listModel, Model_StatsHelper modelSH_HW) { new Dictionary <string, SqlParameter[]>(); StringBuilder builder = new StringBuilder(); builder = new StringBuilder(); builder.Append("update Student_HomeWork_Correct set "); builder.AppendFormat("Student_HomeWork_CorrectStatus='{0}'", modelSHWCorrect.Student_HomeWork_CorrectStatus); builder.AppendFormat(",CorrectTime='{0}'", modelSHWCorrect.CorrectTime.ToString()); builder.AppendFormat(",CorrectMode='{0}'", modelSHWCorrect.CorrectMode.ToString()); builder.AppendFormat(",CorrectUser='******'", modelSHWCorrect.CorrectUser.ToString()); builder.AppendFormat(" where Student_HomeWork_Id='{0}';", modelSHWCorrect.Student_HomeWork_Id); foreach (Model_Student_HomeWorkAnswer answer in listModel) { builder.Append("update Student_HomeWorkAnswer set "); builder.AppendFormat("Student_Score='{0}',", answer.Student_Score); builder.AppendFormat("Student_Answer_Status='{0}',", answer.Student_Answer_Status); builder.AppendFormat("Comment='{0}',", answer.Comment); builder.AppendFormat("isRead='{0}'", answer.isRead); builder.AppendFormat(" where Student_HomeWorkAnswer_Id='{0}'; ", answer.Student_HomeWorkAnswer_Id); } builder.AppendFormat("delete from Student_WrongHomeWork where Student_HomeWorkAnswer_Id in(select Student_HomeWorkAnswer_Id from Student_HomeWorkAnswer where Student_HomeWork_Id='{0}'); ", modelSHWCorrect.Student_HomeWork_Id); builder.AppendFormat("insert into Student_WrongHomeWork\r\nselect NEWID(),t.Student_HomeWorkAnswer_Id,getdate() from Student_HomeWorkAnswer t inner join TestQuestions_Score tq on tq.TestQuestions_Score_ID=t.TestQuestions_Score_ID\r\nwhere tq.TestQuestions_Score!=-1 and t.Student_Answer_Status<>'right' and t.Student_HomeWork_Id='{0}'; ", modelSHWCorrect.Student_HomeWork_Id); builder.AppendFormat("update StatsHelper set Correct_Time='{0}',Exec_Status='0' where (SType='1' or SType='3') and Homework_Id='{1}' ;", modelSH_HW.Correct_Time, modelSH_HW.Homework_Id); builder.AppendFormat("update StatsHelper set Correct_Time='{0}',Exec_Status='0' where SType='2' and ResourceToResourceFolder_Id='{1}' and GradeId='{2}' ;", modelSH_HW.Correct_Time, modelSH_HW.ResourceToResourceFolder_Id, modelSH_HW.GradeId); int num = DbHelperSQL.ExecuteSql(builder.ToString()); if (num > 0) { return(num); } return(0); }
public Model_Student_HomeWork_Correct DataRowToModel(DataRow row) { Model_Student_HomeWork_Correct correct = new Model_Student_HomeWork_Correct(); if (row != null) { if (row["Student_HomeWork_Id"] != null) { correct.Student_HomeWork_Id = row["Student_HomeWork_Id"].ToString(); } if ((row["Student_HomeWork_CorrectStatus"] != null) && (row["Student_HomeWork_CorrectStatus"].ToString() != "")) { correct.Student_HomeWork_CorrectStatus = new int?(int.Parse(row["Student_HomeWork_CorrectStatus"].ToString())); } if ((row["CorrectTime"] != null) && (row["CorrectTime"].ToString() != "")) { correct.CorrectTime = new DateTime?(DateTime.Parse(row["CorrectTime"].ToString())); } if (row["CorrectMode"] != null) { correct.CorrectMode = row["CorrectMode"].ToString(); } if (row["CorrectUser"] != null) { correct.CorrectUser = row["CorrectUser"].ToString(); } } return(correct); }
public bool Add(Model_Student_HomeWork_Correct model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Student_HomeWork_Correct("); builder.Append("Student_HomeWork_Id,Student_HomeWork_CorrectStatus,CorrectTime,CorrectMode,CorrectUser)"); builder.Append(" values ("); builder.Append("@Student_HomeWork_Id,@Student_HomeWork_CorrectStatus,@CorrectTime,@CorrectMode,@CorrectUser)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Student_HomeWork_Id", SqlDbType.Char, 0x24), new SqlParameter("@Student_HomeWork_CorrectStatus", SqlDbType.Int, 4), new SqlParameter("@CorrectTime", SqlDbType.DateTime), new SqlParameter("@CorrectMode", SqlDbType.Char, 1), new SqlParameter("@CorrectUser", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.Student_HomeWork_Id; cmdParms[1].Value = model.Student_HomeWork_CorrectStatus; cmdParms[2].Value = model.CorrectTime; cmdParms[3].Value = model.CorrectMode; cmdParms[4].Value = model.CorrectUser; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public List <Model_Student_HomeWork_Correct> DataTableToList(DataTable dt) { List <Model_Student_HomeWork_Correct> list = new List <Model_Student_HomeWork_Correct>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_Student_HomeWork_Correct item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public bool Update(Model_Student_HomeWork_Correct model) { StringBuilder builder = new StringBuilder(); builder.Append("update Student_HomeWork_Correct set "); builder.Append("Student_HomeWork_CorrectStatus=@Student_HomeWork_CorrectStatus,"); builder.Append("CorrectTime=@CorrectTime,"); builder.Append("CorrectMode=@CorrectMode,"); builder.Append("CorrectUser=@CorrectUser"); builder.Append(" where Student_HomeWork_Id=@Student_HomeWork_Id "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Student_HomeWork_CorrectStatus", SqlDbType.Int, 4), new SqlParameter("@CorrectTime", SqlDbType.DateTime), new SqlParameter("@CorrectMode", SqlDbType.Char, 1), new SqlParameter("@CorrectUser", SqlDbType.Char, 0x24), new SqlParameter("@Student_HomeWork_Id", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.Student_HomeWork_CorrectStatus; cmdParms[1].Value = model.CorrectTime; cmdParms[2].Value = model.CorrectMode; cmdParms[3].Value = model.CorrectUser; cmdParms[4].Value = model.Student_HomeWork_Id; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Add(Model_Student_HomeWork_Correct model) { return(this.dal.Add(model)); }
public bool Update(Model_Student_HomeWork_Correct model) { return(this.dal.Update(model)); }
private bool LoadData() { bool flag = false; try { Stream resStream = HttpContext.Current.Request.InputStream; StreamReader sr = new StreamReader(resStream, System.Text.Encoding.UTF8); string testJsion = sr.ReadToEnd(); string resInfo = testJsion; tchAssignModel modelAssign = JsonConvert.DeserializeObject <tchAssignModel>(resInfo); Model_HomeWork model = new Model_HomeWork(); model.SubjectId = modelAssign.SubjectId; #region 布置作业表 model.HomeWork_Id = modelAssign.HomeWork_Id; model.ResourceToResourceFolder_Id = modelAssign.ResourceToResourceFolder_Id; model.HomeWork_Name = modelAssign.HomeWork_Name; model.HomeWork_AssignTeacher = modelAssign.HomeWork_AssignTeacher; model.BeginTime = modelAssign.BeginTime; model.StopTime = modelAssign.StopTime; model.IsHide = modelAssign.IsHide; model.HomeWork_Status = modelAssign.HomeWork_Status; model.CreateTime = modelAssign.CreateTime; model.UserGroup_Id = modelAssign.UserGroup_Id; model.isTimeLimt = modelAssign.isTimeLimt; model.isTimeLength = modelAssign.isTimeLength; model.SubjectId = modelAssign.SubjectId; model.IsShowAnswer = modelAssign.IsShowAnswer; #endregion #region 学生作业表 List <Model_Student_HomeWork> listSHomwWork = new List <Model_Student_HomeWork>(); List <Model_Student_HomeWork_Submit> listSHomwWorkSubmit = new List <Model_Student_HomeWork_Submit>(); List <Model_Student_HomeWork_Correct> listSHomwWorkCorrect = new List <Model_Student_HomeWork_Correct>(); string strStudent = modelAssign.stuInfo; string[] strArrStudent = strStudent.Split(','); for (int i = 0; i < strArrStudent.Length; i++) { string ShwGuid = Guid.NewGuid().ToString(); Model_Student_HomeWork modelSHomeWork = new Model_Student_HomeWork(); modelSHomeWork.Student_HomeWork_Id = ShwGuid; modelSHomeWork.HomeWork_Id = modelAssign.HomeWork_Id; modelSHomeWork.Student_Id = strArrStudent[i]; modelSHomeWork.CreateTime = modelAssign.CreateTime; listSHomwWork.Add(modelSHomeWork); #region 作业提交状态 Model_Student_HomeWork_Submit modelSHomeWorkSubmit = new Model_Student_HomeWork_Submit(); modelSHomeWorkSubmit.Student_HomeWork_Id = ShwGuid; modelSHomeWorkSubmit.Student_HomeWork_Status = 0; listSHomwWorkSubmit.Add(modelSHomeWorkSubmit); #endregion #region 作业批改状态 Model_Student_HomeWork_Correct modelSHomeWorkCorrect = new Model_Student_HomeWork_Correct(); modelSHomeWorkCorrect.Student_HomeWork_Id = ShwGuid; modelSHomeWorkCorrect.Student_HomeWork_CorrectStatus = 0; listSHomwWorkCorrect.Add(modelSHomeWorkCorrect); #endregion } #endregion #region 统计帮助表 DataTable dtHWDetail = Rc.Common.DBUtility.DbHelperSQL.Query("select * from VW_ClassGradeSchool where ClassId='" + modelAssign.UserGroup_Id + "' and GradeId is not null and SchoolId is not null ").Tables[0]; Model_StatsHelper modelSH_HW = new Model_StatsHelper(); modelSH_HW.StatsHelper_Id = Guid.NewGuid().ToString(); modelSH_HW.ResourceToResourceFolder_Id = model.ResourceToResourceFolder_Id; modelSH_HW.Homework_Id = model.HomeWork_Id; modelSH_HW.Exec_Status = "0"; modelSH_HW.SType = "1"; modelSH_HW.CreateUser = modelAssign.HomeWork_AssignTeacher; modelSH_HW.SchoolId = dtHWDetail.Rows[0]["SchoolId"].ToString(); modelSH_HW.GradeId = dtHWDetail.Rows[0]["GradeId"].ToString(); modelSH_HW.ClassId = modelAssign.UserGroup_Id; modelSH_HW.TeacherId = modelAssign.HomeWork_AssignTeacher; modelSH_HW.HW_CreateTime = modelAssign.CreateTime; #endregion Rc.Common.SystemLog.SystemLog.AddLogFromBS(modelAssign.HomeWork_AssignTeacher, "", "布置作业(学校服务器):4开始写入数据123"); if (new BLL_HomeWork().AddHomework(model, listSHomwWork, listSHomwWorkSubmit, listSHomwWorkCorrect, modelSH_HW)) { Rc.Common.SystemLog.SystemLog.AddLogFromBS(modelAssign.HomeWork_AssignTeacher, "", "布置作业(学校服务器):4结束写入数据"); if (GenerateTestPaperFileForStudent(modelAssign.HomeWork_AssignTeacher, modelAssign.HomeWork_Id)) { flag = true; } else { //RevokeHW 生成学生作业文件失败 撤销作业 new BLL_HomeWork().RevokeHW(model.HomeWork_Id); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(modelAssign.HomeWork_AssignTeacher, "", "布置作业失败(学校服务器):生成学生作业文件失败"); } } else { //RevokeHW 写入数据失败 撤销作业 new BLL_HomeWork().RevokeHW(model.HomeWork_Id); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(modelAssign.HomeWork_AssignTeacher, "", "布置作业失败(学校服务器):写入数据失败"); } } catch (Exception ex) { Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", "", "布置作业失败(学校服务器):" + ex.Message.ToString()); } return(flag); }
public int TeacherCorrectStuHomeWork(Model_Student_HomeWork_Correct modelSHWCorrect, List <Model_Student_HomeWorkAnswer> listModel, Model_StatsHelper modelSH_HW) { return(this.dal.TeacherCorrectStuHomeWork(modelSHWCorrect, listModel, modelSH_HW)); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { Model_HomeWork model = new Model_HomeWork(); BLL_HomeWork bll = new BLL_HomeWork(); #region 布置作业表 string guid = HomeWork_Id; model = bll.GetModel(guid); model.StopTime = Convert.ToDateTime(txtStopTime.Text); #endregion #region 学生作业表 List <Model_Student_HomeWork> listSHomwWork = new List <Model_Student_HomeWork>(); List <Model_Student_HomeWork_Submit> listSHomwWorkSubmit = new List <Model_Student_HomeWork_Submit>(); List <Model_Student_HomeWork_Correct> listSHomwWorkCorrect = new List <Model_Student_HomeWork_Correct>(); string strStudent = Rc.Cloud.Web.Common.pfunction.CheckImp(hidStudentId.Value); strStudent = strStudent.TrimEnd(','); string[] strArrStudent = strStudent.Split(','); for (int i = 0; i < strArrStudent.Length; i++) { string ShwGuid = Guid.NewGuid().ToString(); Model_Student_HomeWork modelSHomeWork = new Model_Student_HomeWork(); modelSHomeWork.Student_HomeWork_Id = ShwGuid; modelSHomeWork.HomeWork_Id = guid; modelSHomeWork.Student_Id = strArrStudent[i]; modelSHomeWork.CreateTime = DateTime.Now; listSHomwWork.Add(modelSHomeWork); #region 作业提交状态 Model_Student_HomeWork_Submit modelSHomeWorkSubmit = new Model_Student_HomeWork_Submit(); modelSHomeWorkSubmit.Student_HomeWork_Id = ShwGuid; modelSHomeWorkSubmit.Student_HomeWork_Status = 0; listSHomwWorkSubmit.Add(modelSHomeWorkSubmit); #endregion #region 作业批改状态 Model_Student_HomeWork_Correct modelSHomeWorkCorrect = new Model_Student_HomeWork_Correct(); modelSHomeWorkCorrect.Student_HomeWork_Id = ShwGuid; modelSHomeWorkCorrect.Student_HomeWork_CorrectStatus = 0; listSHomwWorkCorrect.Add(modelSHomeWorkCorrect); #endregion } #endregion #region 统计帮助表 DataTable dtHWDetail = bll.GetHWDetail(HomeWork_Id).Tables[0]; Model_StatsHelper modelSH_HW = new Model_StatsHelper(); modelSH_HW.ResourceToResourceFolder_Id = model.ResourceToResourceFolder_Id; modelSH_HW.Homework_Id = model.HomeWork_Id; modelSH_HW.SchoolId = dtHWDetail.Rows[0]["SchoolId"].ToString(); modelSH_HW.GradeId = dtHWDetail.Rows[0]["GradeId"].ToString(); #endregion if (bll.UpdateHomework(model, listSHomwWork, listSHomwWorkSubmit, listSHomwWorkCorrect, modelSH_HW)) { string strJ = "layer.msg('布置作业成功',{time:1000,icon:1},function(){"; if (Request.QueryString["tp"] != "1") { strJ += "window.parent.loadData();"; } else { strJ += "window.parent.location.reload();"; } strJ += "parent.layer.close(parent.layer.getFrameIndex(window.name));});"; ClientScript.RegisterStartupScript(this.GetType(), "temp", strJ, true); Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业成功"); } else { ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('布置作业失败',{time:2000,icon:2});", true); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(FloginUser.UserId, "", "布置作业失败"); } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('布置作业失败',{time:2000,icon:2});", true); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(FloginUser.UserId, "", "布置作业失败:" + ex.Message.ToString()); } }