Exemplo n.º 1
0
        /// <summary>
        /// 插入一条课程归档记录
        /// </summary>
        /// <param name="archives">课程归档实体</param>
        public void AddArchives(Archives archives)
        {
            try
            {
                string cmdstring = "INSERT INTO [USTA].[dbo].[usta_Archives] ([attachmentIds],[courseNo],classID,termTag,teacherType,archiveItemId)  VALUES ( @attachmentIds,@courseNo,@classId,@termtag,@teacherType,@archiveItemId)";

                SqlParameter[] parameters = {
                    new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200),
                    new SqlParameter("@courseNo", SqlDbType.NChar,20),
                    new SqlParameter("@classId", SqlDbType.NVarChar,50),
                    new SqlParameter("@termtag", SqlDbType.NVarChar,50),
                    new SqlParameter("@teacherType", SqlDbType.NChar,10) ,
                    new SqlParameter("@archiveItemId", SqlDbType.Int,4)
                };

                parameters[0].Value = archives.attachmentIds;
                parameters[1].Value = archives.courseNo;
                parameters[2].Value = archives.classID;
                parameters[3].Value = archives.termTag;
                parameters[4].Value = archives.teacherType;
                parameters[5].Value = archives.archiveItemId;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新课程归档
        /// </summary>
        /// <param name="archives">课程归档实体</param>
        public void UpdateArchives(Archives archives)
        {
            try
            {
               string cmdstring = "UPDATE [USTA].[dbo].[usta_Archives] SET [attachmentIds] = @attachmentIds WHERE archiveId=@archiveId";

               SqlParameter[] parameters = {
                    new SqlParameter("@archiveId", SqlDbType.Int,4),
                    new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200)
                                           };
               parameters[0].Value = archives.archiveId;
               parameters[1].Value = archives.attachmentIds;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取课程归档()
        /// </summary>
        /// <param name="courseNo">课程编号</param>
        /// <param name="classId">classId</param>
        /// <param name="termtag">termtag</param>
        /// <param name="termtag">teacherType</param>
        /// <returns>课程归档实体</returns>
        public Archives FindArchivesByCourseNoCompatible(string courseNo, string classId, string termtag)
        {
            Archives archives = new Archives { attachmentIds = string.Empty };
            string cmdstring = "SELECT [archiveId],[archiveItemId],[attachmentIds],[courseNo],[teacherType],[classID],[termTag] FROM [USTA].[dbo].[usta_Archives] WHERE courseNo=@courseNo AND classID=@classID AND termTag=@termTag";
            SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@courseNo",courseNo),
                new SqlParameter("@classID",classId),
                new SqlParameter("@termTag",termtag)
            };

            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, cmdstring, parameters);
            if (dr.Read())
            {

                archives = new Archives
                {
                    archiveId = int.Parse(dr["archiveId"].ToString()),
                    attachmentIds = dr["attachmentIds"].ToString().Trim(),
                    courseNo = dr["courseNo"].ToString().Trim(),
                    classID = dr["classID"].ToString().Trim(),
                    termTag = dr["termTag"].ToString().Trim()
                };
            }
            dr.Close();
            conn.Close();
            return archives;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获得课程归档
        /// </summary>
        /// <param name="archiveId">课程归档主键</param>
        /// <returns>课程归档对象</returns>
        public Archives FindArchivesById(int archiveId)
        {
            Archives archives = null;
            string cmdstring = "SELECT [archiveId],[attachmentIds],[usta_Archives].[courseNo],[courseName] FROM [USTA].[dbo].[usta_Archives],usta_Courses WHERE archiveId=@archiveId AND usta_Courses.courseNo=usta_Archives.courseNo";
            SqlParameter[] parameters = new SqlParameter[1]{
                new SqlParameter("@archiveId",archiveId)
            };

            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, cmdstring, parameters);
            if (dr.Read())
            {

                archives = new Archives
                {
                    archiveId = int.Parse(dr["archiveId"].ToString()),
                    attachmentIds = dr["attachmentIds"].ToString().Trim(),
                    courseNo = dr["courseNo"].ToString().Trim(),
                };
            }
            dr.Close();
            conn.Close();
            return archives;
        }
        //结课资料
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            List<int> listArchiveItemIds = new List<int>();
            List<string> listArchivesAttachmentIds = new List<string>();

            DalOperationAboutArchives doaa = new DalOperationAboutArchives();

            foreach (Control ctlTable in phUpload.Controls)
            {
                foreach (Control ctlTableRow in ctlTable.Controls)
                {
                    foreach (Control ctlTableCell in ctlTableRow.Controls)
                    {
                        foreach (Control ctl in ctlTableCell.Controls)
                        {
                            string _type = ctl.GetType().ToString();

                            if (_type == "System.Web.UI.WebControls.HiddenField")
                            {
                                if (ctl.ID.StartsWith("hid_"))
                                {
                                    listArchiveItemIds.Add(int.Parse(ctl.ID.Split("_".ToCharArray())[1]));
                                }
                                else if (ctl.ID.StartsWith("hidAttachmentId"))
                                {
                                    listArchivesAttachmentIds.Add(((HiddenField)ctl).Value);
                                }
                            }
                        }
                    }
                }
            }

            Archives archives = new Archives
            {
                courseNo = Request["courseNo"],
                classID = Server.UrlDecode(Request["classID"]),
                termTag = Request["termTag"].Trim(),
                teacherType = teacherType
            };

            for (int i = 0; i < listArchiveItemIds.Count; i++)
            {
                archives.archiveItemId = listArchiveItemIds[i];
                archives.attachmentIds = listArchivesAttachmentIds[i];

                //判断是否存在课程结课资料记录,并返回archiveId
                int archiveId = doaa.IsExistArchivesBycourseNo(courseNo, classID, termtag, teacherType, archives.archiveItemId);

                if (archiveId != 0)
                {
                    archives.archiveId = archiveId;
                    doaa.UpdateArchives(archives);
                    Javascript.RefreshParentWindow("上传成功!", "/Administrator/ArchivesManage.aspx?fragment=1&termTag=" + termtag + "&locale=" + Server.UrlEncode(locale) + "&keyword=" + Server.UrlEncode(keyword) + "#archive_" + anchor, Page);
                }
                else
                {
                    doaa.AddArchives(archives);
                    Javascript.RefreshParentWindow("上传成功!", "/Administrator/ArchivesManage.aspx?fragment=1&termTag=" + termtag + "&locale=" + Server.UrlEncode(locale) + "&keyword=" + Server.UrlEncode(keyword) + "#archive_" + anchor, Page);
                }
            }
        }