コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref experimentResourceId))
            {
                if (Request["courseNo"] == null)
                {
                    Javascript.GoHistory(-1, Page);
                    return;
                }
                DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources();
                experimentResources = DalOperationAboutExperimentResources.GetExperimentResourcesbyId(experimentResourceId);
                txtTitle.Text = experimentResources.experimentResourceTitle;
                Textarea1.Value = experimentResources.experimentResourceContent;
                datepicker.Value = experimentResources.deadLine.ToString("yyyy-MM-dd HH:mm:ss");

                hidAttachmentId.Value = experimentResources.attachmentIds;
                if (experimentResources.attachmentIds.Length > 0)
                {
                    DalOperationAttachments dalOperationAttachments = new DalOperationAttachments();
                    ltlAttachment.Text = dalOperationAttachments.GetAttachmentsList(experimentResources.attachmentIds, ref iframeCount, true,string.Empty);
                }
            }
        }
    }
コード例 #2
0
    protected void btnEditExperimentResource_Click(object sender, EventArgs e)
    {
        if (txtTitle.Text.Trim().Length != 0)
        {
            UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo();
            DateTime deadline_t = Convert.ToDateTime(datepicker.Value);

            ExperimentResources ExperimentResources = new ExperimentResources
            {
                courseNo = Request["courseNo"],
                experimentResourceTitle = CommonUtility.JavascriptStringFilter(txtTitle.Text),
                experimentResourceContent = Textarea1.Value,
                deadLine = deadline_t,
                updateTime = DateTime.Now,
                attachmentIds = hidAttachmentId.Value,
                experimentResourceId = (Request["experimentResourceId"] != null ? int.Parse(Request["experimentResourceId"]) : 0)

            };

            DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources();
            DalOperationAboutExperimentResources.UpdateExperimentResources(ExperimentResources);
            Javascript.RefreshParentWindow("修改成功!", "CInfoExperimentResource.aspx?courseNo=" + ExperimentResources.courseNo, Page);
        }
        else
        {
            Javascript.Alert("标题不能为空!", Page);
        }
    }
コード例 #3
0
        /// <summary>
        /// 更新布置的实验信息
        /// </summary>
        /// <param name="experimentResources">实验实体</param>
        public void UpdateExperimentResources(ExperimentResources experimentResources)
        {
            try
            {
                string commandString = "UPDATE [USTA].[dbo].[usta_ExperimentResources] SET [courseNo] = @courseNo ,[attachementIds] = @attachementIds,[experimentResourceTitle] = @experimentResourceTitle  ,[experimentResourceContent] = @experimentResourceContent ,[deadLine] = @deadLine ,[updateTime] = @updateTime WHERE experimentResourceId=@experimentResourceId";

                SqlParameter[] parameters = {
                    new SqlParameter("@experimentResourceId", SqlDbType.Int,4),
                    new SqlParameter("@courseNo", SqlDbType.NChar,20),
                    new SqlParameter("@attachementIds", SqlDbType.NVarChar,200),
                    new SqlParameter("@experimentResourceTitle", SqlDbType.NChar,50),
                    new SqlParameter("@experimentResourceContent", SqlDbType.NText),
                    new SqlParameter("@deadLine", SqlDbType.DateTime),
                    new SqlParameter("@updateTime", SqlDbType.DateTime)};
                parameters[0].Value = experimentResources.experimentResourceId;
                parameters[1].Value = experimentResources.courseNo;
                parameters[2].Value = experimentResources.attachmentIds;
                parameters[3].Value = experimentResources.experimentResourceTitle;
                parameters[4].Value = experimentResources.experimentResourceContent;
                parameters[5].Value = experimentResources.deadLine;
                parameters[6].Value = experimentResources.updateTime;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandString, parameters);
            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #4
0
        /// <summary>
        /// 添加一条布置实验
        /// </summary>
        /// <param name="experimentResources">实验实体</param>
        /// <returns>实体实体</returns>
        public ExperimentResources InsertExperimentResources(ExperimentResources experimentResources)
        {
            try
            {
                using (SqlCommand cmd = new SqlCommand("spExperimentResourcesAdd", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = conn;

                    conn.Open();
                    cmd.Parameters.Add(new SqlParameter("@courseNo", experimentResources.courseNo));
                    cmd.Parameters.Add(new SqlParameter("@attachementIds", experimentResources.attachmentIds));
                    cmd.Parameters.Add(new SqlParameter("@experimentResourceTitle", experimentResources.experimentResourceTitle));
                    cmd.Parameters.Add(new SqlParameter("@experimentResourceContent", experimentResources.experimentResourceContent));
                    cmd.Parameters.Add(new SqlParameter("@deadLine", experimentResources.deadLine));
                    cmd.Parameters.Add(new SqlParameter("@updateTime", experimentResources.updateTime));
                    cmd.Parameters.Add(new SqlParameter("@classId", experimentResources.classID));
                    cmd.Parameters.Add(new SqlParameter("@termtag", experimentResources.termTag));
                    cmd.Parameters.Add(new SqlParameter("@experimentResourceId", 0));
                    cmd.Parameters["@experimentResourceId"].Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    experimentResources.experimentResourceId = int.Parse(cmd.Parameters["@experimentResourceId"].Value.ToString());
                }
            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
            return experimentResources;
        }
コード例 #5
0
 /// <summary>
 /// 通过布置的实验主键获得布置实验
 /// </summary>
 /// <param name="experimentResourcesId">实验编号</param>
 /// <returns>课程实验实体</returns>
 public ExperimentResources GetExperimentResourcesbyId(int experimentResourcesId)
 {
     ExperimentResources ExperimentResources = null;
     string commandString = "SELECT [experimentResourceId],[courseNo] ,[attachementIds],[experimentResourceTitle] ,[experimentResourceContent],[deadLine],[updateTime]  FROM [USTA].[dbo].[usta_ExperimentResources] WHERE experimentResourceId=@experimentResourceId";
     SqlParameter[] parameters = new SqlParameter[1]{new SqlParameter("@experimentResourceId",experimentResourcesId)
     };
     SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, commandString, parameters);
     if (dr.Read())
     {
         ExperimentResources = new ExperimentResources
         {
             experimentResourceId = int.Parse(dr["experimentResourceId"].ToString()),
             courseNo = dr["courseNo"].ToString().Trim(),
             attachmentIds = dr["attachementIds"].ToString().Trim(),
             experimentResourceTitle = dr["experimentResourceTitle"].ToString().Trim(),
             experimentResourceContent = dr["experimentResourceContent"].ToString().Trim(),
             deadLine = Convert.ToDateTime(dr["deadLine"].ToString()),
             updateTime = Convert.ToDateTime(dr["updateTime"].ToString())
         };
     }
     dr.Close();
     conn.Close();
     return ExperimentResources;
 }
コード例 #6
0
    protected void btnAddExperimentResource_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)
            {
                ExperimentResources ExperimentResources = new ExperimentResources
                {
                    courseNo = Request["courseNo"].Trim(),
                    classID = Server.UrlDecode(Request["classID"].Trim()),
                    termTag = Request["termtag"].Trim(),
                    experimentResourceTitle = CommonUtility.JavascriptStringFilter(txtTitle.Text),
                    experimentResourceContent = Textarea1.Value,
                    deadLine = deadline_t,
                    updateTime = DateTime.Now,
                    attachmentIds = hidAttachmentId.Value
                };
                //添加课程实验并返回作业的自增长主键

                using (TransactionScope scope = new TransactionScope())
                {
                    DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources();
                    ExperimentResources = DalOperationAboutExperimentResources.InsertExperimentResources(ExperimentResources);

                    //添加了课程实验以后,往提交表中添加记录

                    //查询出选课学生记录
                    DalOperationAboutExperiment doae = new DalOperationAboutExperiment();
                    DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses();
                    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++)
                    {
                        Experiments experiment = new Experiments
                        {
                            experimentResourceId = ExperimentResources.experimentResourceId,
                            studentNo = dt.Rows[i]["studentNo"].ToString().Trim(),
                            updateTime = DateTime.Now,
                            checkTime = DateTime.Now,
                            isExcellent = false,
                            remark = "",
                            excellentTime = DateTime.Now,
                            attachmentId = "0"
                        };
                        doae.InsertExperiment(experiment);
                    }
                    scope.Complete();
                }
                Javascript.RefreshParentWindow("添加成功!", "CInfoExperimentResource.aspx?courseNo=" + Request["courseNo"]+"&classID="+Server.UrlEncode(Server.UrlDecode(Request["classID"]))+"&termtag="+Request["termtag"], Page);

            }
            else
            {
                Javascript.Alert("截止时间不能在当前时间之前", Page);
            }
        }
        else
        {
            Javascript.Alert("标题不能为空!", Page);
        }
    }