Пример #1
0
    protected void btnSchoolworkCommit_Click(object sender, EventArgs e)
    {
        int SchoolNotifyId = int.Parse(Request["schoolworkNotifyId"]);
        UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo();
        SchoolWorks schoolwork = new SchoolWorks
        {
            updateTime = DateTime.Now,
            schoolWorkNofityId = SchoolNotifyId,
            studentNo = UserCookiesInfo.userNo,
            isCheck = false,
            isExcellent = false,
            remark = "",
            checkTime = DateTime.Now,
            excellentTime = DateTime.Now,

        };
        if (hidAttachmentId.Value.CompareTo(string.Empty) != 0)
        {
            schoolwork.attachmentId = hidAttachmentId.Value;
        }
        else
        {
            Javascript.GoHistory(-1, "请上传附件!", Page);
            return;
        }
        DalOperationAboutSchoolWorks dalOperationAboutSchoolworks = new DalOperationAboutSchoolWorks();
        dalOperationAboutSchoolworks.SubmitSchoolWork(schoolwork);

        Javascript.AlertAndRedirect("提交成功!", "CInfoSchoolwork.aspx?schoolworkNotifyId=" + schoolwork.schoolWorkNofityId + "&courseNo=" + Request["courseNo"] + "&classID=" + Server.UrlEncode(Server.UrlDecode(Request["classID"])) + "&termtag=" + Request["termtag"], Page);
    }
        /// <summary>
        /// 插入一条作业提交
        /// </summary>
        /// <param name="schoolwork">提交作业的实体</param>
        public void AddSchoolWork(SchoolWorks schoolwork)
        {
            try
            {
                string cmdstring = "INSERT INTO [USTA].[dbo].[usta_SchoolWorks] ([schoolWorkNofityId],[studentNo] ,[updateTime] ,[attachmentId],[remark]) VALUES ( @schoolWorkNofityId,@studentNo,@updateTime,@attachmentId,@remark)";

                SqlParameter[] parameters = {
                    new SqlParameter("@updateTime", SqlDbType.DateTime),
                    new SqlParameter("@schoolWorkNofityId", SqlDbType.Int,4),
                    new SqlParameter("@studentNo", SqlDbType.NChar,10),
                    new SqlParameter("@attachmentId", SqlDbType.Int,4),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    };
                parameters[0].Value = schoolwork.updateTime;
                parameters[1].Value = schoolwork.schoolWorkNofityId;
                parameters[2].Value = schoolwork.studentNo;
                parameters[3].Value = schoolwork.attachmentId;
                parameters[4].Value = schoolwork.remark;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Пример #3
0
    protected void btnAddSchoolworkNotify_Click(object sender, EventArgs e)
    {
        if (txtTitle.Text.Trim().Length != 0)
        {
            UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo();
            DateTime deadline_t = Convert.ToDateTime(datepicker.Value);
            if (deadline_t.CompareTo(DateTime.Now) > 0)
            {
                SchoolWorkNotify SchoolWorkNotify = new SchoolWorkNotify
                {
                    schoolWorkNotifyTitle=CommonUtility.JavascriptStringFilter(txtTitle.Text),
                    updateTime=DateTime.Now,
                    schoolWorkNotifyContent = Textarea1.Value,
                    deadline=deadline_t,
                    courseNo = Request["courseNo"],
                    isOnline = Convert.ToBoolean(ddltOnline.SelectedValue),
                    attachmentIds = hidAttachmentId.Value,
                    classID=Server.UrlDecode(Request["classID"].Trim()),
                    termTag=Request["termtag"].Trim()

                };

                using (TransactionScope scope = new TransactionScope())
                {

                    try
                    {
                        //添加课程作业并返回作业的自增长主键
                        DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses();
                        SchoolWorkNotify = dalOperationAboutCourses.AddSchoolworkNotify(SchoolWorkNotify);

                        //添加了课程作业以后,往作业提交表中添加记录
                        DalOperationAboutSchoolWorks dalOperationAboutSchoolworks = new DalOperationAboutSchoolWorks();

                        //查询出选课学生记录
                        DataTable dt = dalOperationAboutCourses.FindStudentInfoByCourseNo(Request["courseNo"].ToString().Trim(),Server.UrlDecode(Request["classID"]),Request["termtag"]).Tables[0];
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            SchoolWorks schoolwork = new SchoolWorks
                            {
                                updateTime = DateTime.Now,
                                schoolWorkNofityId = SchoolWorkNotify.schoolWorkNotifyId,
                                studentNo = dt.Rows[i]["studentNo"].ToString().Trim(),
                                isCheck = false,
                                isExcellent = false,
                                remark = "",
                                checkTime = DateTime.Now,
                                excellentTime = DateTime.Now,
                                attachmentId = "0"

                            };
                            dalOperationAboutSchoolworks.AddSchoolWork(schoolwork);
                        }
                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        MongoDBLog.LogRecord(ex);
                        CommonUtility.RedirectUrl();
                    }
                }
                Javascript.RefreshParentWindow(Page);
            }
            else
            {
                Javascript.Alert("截止时间不能在当前时间之前", Page);
            }
        }
        else
        {
            Javascript.Alert("标题不能为空!", Page);
        }
    }
        /// <summary>
        /// 新提交的作业
        /// </summary>
        /// <param name="schoolwork">提交的作业实体</param>
        public void UpdateSchoolWork(SchoolWorks schoolwork)
        {
            try
            {
                string cmdstring = "UPDATE [USTA].[dbo].[usta_SchoolWorks] SET [schoolWorkNofityId] = @schoolWorkNofityId,[studentNo] = @studentNo,[isCheck] = @isCheck,[updateTime] = @updateTime,[checkTime] = @checkTime,[attachmentId] = @attachmentId WHERE schoolWorkId=@schoolWorkId";

                SqlParameter[] parameters = {
                    new SqlParameter("@schoolWorkId", SqlDbType.Int,4),
                    new SqlParameter("@updateTime", SqlDbType.DateTime),
                    new SqlParameter("@schoolWorkNofityId", SqlDbType.Int,4),
                    new SqlParameter("@studentNo", SqlDbType.NChar,10),
                    new SqlParameter("@isCheck", SqlDbType.Bit,1),
                    new SqlParameter("@checkTime", SqlDbType.DateTime),
                    new SqlParameter("@attachmentId", SqlDbType.NVarChar,50)
                    };
                parameters[0].Value = schoolwork.schoolWorkId;
                parameters[1].Value = schoolwork.updateTime;
                parameters[2].Value = schoolwork.schoolWorkNofityId;
                parameters[3].Value = schoolwork.studentNo;
                parameters[4].Value = schoolwork.isCheck;
                parameters[5].Value = schoolwork.checkTime;
                parameters[6].Value = schoolwork.attachmentId;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
        /// <summary>
        /// 更新一条作业提交
        /// </summary>
        /// <param name="schoolwork">提交的作业实体</param>
        public void SubmitSchoolWork(SchoolWorks schoolwork)
        {
            try
            {
                string cmdstring = "UPDATE [USTA].[dbo].[usta_SchoolWorks] SET attachmentId=@attachmentId,remark=@remark,updateTime=@updateTime,isSubmit=1 WHERE schoolWorkNofityId=@schoolWorkNofityId AND studentNo=@studentNo";

                SqlParameter[] parameters = {

                    new SqlParameter("@updateTime", SqlDbType.DateTime),
                    new SqlParameter("@schoolWorkNofityId", SqlDbType.Int,4),
                    new SqlParameter("@studentNo", SqlDbType.NChar,10),

                    new SqlParameter("@attachmentId", SqlDbType.NVarChar,50),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500)
                    };

                parameters[0].Value = schoolwork.updateTime;
                parameters[1].Value = schoolwork.schoolWorkNofityId;
                parameters[2].Value = schoolwork.studentNo;

                parameters[3].Value = schoolwork.attachmentId;
                parameters[4].Value = schoolwork.remark;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
        /// <summary>
        /// 由主键获得提交的作业
        /// </summary>
        /// <param name="schoolWorkId">作业编号</param>
        /// <returns>作业实体</returns>
        public SchoolWorks GetSchoolWorkById(int schoolWorkId)
        {
            SchoolWorks schoolWorks = null;
            string sql = "SELECT [schoolWorkId] ,[updateTime] ,[schoolWorkNofityId] ,[studentNo] ,[isCheck] ,[checkTime] ,[attachmentId] ,[remark],[excellentTime],[isExcellent] FROM [USTA].[dbo].[usta_SchoolWorks]  WHERE schoolWorkId=@schoolWorkId";
            SqlParameter[] parameters = new SqlParameter[1]{
                new SqlParameter("@schoolWorkId",schoolWorkId)
            };
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql, parameters);
            if (dr.Read())
            {
                schoolWorks = new SchoolWorks
                {
                    schoolWorkId = int.Parse(dr["schoolWorkId"].ToString()),
                    updateTime = Convert.ToDateTime(dr["updateTime"].ToString()),
                    schoolWorkNofityId = int.Parse(dr["schoolWorkNofityId"].ToString()),
                    studentNo = dr["studentNo"].ToString(),
                    isCheck = bool.Parse(dr["isCheck"].ToString()),
                    attachmentId = dr["attachmentId"].ToString().Trim(),

                    isExcellent = bool.Parse(dr["isExcellent"].ToString()),
                    remark = dr["remark"].ToString()
                };
                if (dr["checkTime"].ToString() != "") schoolWorks.checkTime = Convert.ToDateTime(dr["checkTime"].ToString());
                if (dr["excellentTime"].ToString() != "") schoolWorks.excellentTime = Convert.ToDateTime(dr["excellentTime"].ToString());
            }
            conn.Close();
            return schoolWorks;
        }