Ejemplo n.º 1
0
 /// <summary>
 /// 确定提交按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btSubmitSubject_Click(object sender, EventArgs e)
 {
     Forum thisForum = new Forum();
     Search search = new Search();
     SubjectInfo subject = new SubjectInfo();
     Teacher t = new Teacher();
     if (Session["UserName"] != null)
     {
         //课程名
         subject.StrCourseName = course;
         //提交时间
         subject.DtReleaseTime = DateTime.Now;
         //提交内容
         subject.StrContents = tbxSubjectContent.Text.Replace("\r\n", "<br/>");
         //用户名
         if (Convert.ToString(Session["Type"]) == "Student")
         {
             subject.StrReleasePsnName = search.GetStudentByUsername(Convert.ToString(Session["UserName"])).StrStudentName;
         }
         else
         {
             subject.StrReleasePsnName = t.GetTeacherByUserName(Convert.ToString(Session["UserName"])).StrTeacherName;
         }
         //主题
         subject.StrTheme = subjectname.Text.Trim();
         if (thisForum.AddSubeject(subject))
         {
             //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert","<script>alert('发表成功!')</script>");
             Response.Redirect("SubjectList.aspx");
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('发表失败!')</script>");
         }
     }
     else
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('您还未登录!')</script>");
         //胡媛媛添加,当匿名用户添加留言时清空内容,2009-10-30
         subjectname.Text = null;
         tbxSubjectContent.Text = null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// ��������
        /// </summary>
        /// <param name="mSubject">����ӵ��������</param>
        /// <returns>�Ƿ���ӳɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
        public bool AddSubeject(SubjectInfo mSubject)
        {
            SqlParameter[] parms = {
                new SqlParameter("@theme",mSubject.StrTheme),
                new SqlParameter("@contents",mSubject.StrContents),
                new SqlParameter("@realeasePsnName",mSubject.StrReleasePsnName),
                new SqlParameter("@releaseTime",mSubject.DtReleaseTime),
                new SqlParameter("@courseName",mSubject.StrCourseName)
            };

            bool isSuccess = false;
            int affectedRows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "SP_AddSubject", parms);

            if (affectedRows > 0)
            {
                isSuccess = true;
            }
            return isSuccess;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// ��������
 /// </summary>
 /// <param name="mSubject">����ӵ��������</param>
 /// <returns>�Ƿ���ӳɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
 public bool AddSubeject(SubjectInfo mSubject)
 {
     return dal.AddSubeject(mSubject);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// ���������Id�õ�����Ķ���
        /// </summary>
        /// <param name="iSubjectId">�����Id</param>
        /// <returns>����Ķ���</returns>
        public SubjectInfo GetSubjectById(int iSubjectId)
        {
            SqlParameter param = new SqlParameter("@subjectID", iSubjectId);

            SubjectInfo subject = new SubjectInfo();
            using (SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "SP_GetSubjectByID", param))
            {
                if (dr.Read())
                {
                    subject.ISubjectId = dr.GetInt32(0);
                    subject.StrTheme = dr.GetString(1);
                    subject.StrContents = dr.GetString(2);
                    subject.StrReleasePsnName = dr.GetString(3);
                    subject.DtReleaseTime = dr.GetDateTime(4);
                }
            }
            return subject;
        }