예제 #1
0
        /// <summary>
        /// ��������
        /// </summary>
        /// <param name="mMessageLeft">����ӵ����Զ���Ӧ�������������Id�����Ե����ݣ����Ե�ʱ�䣬�����ߵ��������û���</param>
        /// <returns>����Ƿ�ɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
        public bool AddMessage(MessageLeftInfo mMessageLeft)
        {
            SqlParameter[] parms = {
                new SqlParameter("@subjectID",mMessageLeft.ISubjectId),
                new SqlParameter("@contents",mMessageLeft.StrContents),
                new SqlParameter("@releasePsnName",mMessageLeft.StrReleasePsnName),
                new SqlParameter("@releaseTime",mMessageLeft.DtReleaseTime),
            };

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

            if (affectedRows > 0)
            {
                isSuccess = true;
            }
            return isSuccess;
        }
 /// <summary>
 /// 绑定RepeaterSearch_Item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void RepeaterSearch_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     //用户控件的使用
     UserControl_MessageBox msgBox = (UserControl_MessageBox)e.Item.FindControl("MessageBox1");
     //new一个MessageLeftInfo并且初始化
     MessageLeftInfo msg = new MessageLeftInfo();
     msg.DtReleaseTime = Convert.ToDateTime(DataBinder.Eval(e.Item.DataItem, "releaseTime"));
     msg.IMessageLeftId = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ID"));
     msg.ISubjectId = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "subjectID"));
     msg.StrContents = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "contents"));
     msg.StrReleasePsnName = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "releasePsnName"));
     msgBox.AMsg = msg;
     //用来计算留言条数的
     msgBox.Index = index++;
     floor.Value = index.ToString();
 }
 /// <summary>
 /// 发表留言
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void submitMsg_Click(object sender, EventArgs e)
 {
     //new MessageLeftInfo、Forum、Search、Teacher对象
     Model.MessageLeftInfo msg = new Model.MessageLeftInfo();
     Forum forum = new Forum();
     Search s = new Search();
     Teacher t = new Teacher();
     //初始化msg
     msg.DtReleaseTime = System.DateTime.Now;
     msg.ISubjectId = Convert.ToInt32(id);
     msg.StrContents = tbxMsgContent.Text;
     //匿名发表
     //胡媛媛修改,将&&改成||,2010-6-10
     if (Session["UserName"] == null||checkbox.Checked)
     //胡媛媛修改,将&&改成||,2010-6-10
     {
         msg.StrReleasePsnName = "匿名用户";
     }
      /*未登陆用户
     else if (Session["UserName"]==null&&(checkbox.Checked==false))
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
            "<script>alert('对不起,你还未登录!')</script>");
         return;
     }*/
     else
     {
         //学生用户
         if (Convert.ToString(Session["Type"]) == "Student")
         {
             msg.StrReleasePsnName = s.GetStudentByUsername(Convert.ToString(Session["UserName"])).StrStudentName;
         }
         //教师用户
         else
         {
             msg.StrReleasePsnName = t.GetTeacherByUserName(Convert.ToString(Session["UserName"])).StrTeacherName;
         }
     }
     msg.StrUserName = Convert.ToString(Session["UserName"]);
     //添加留言
     if (forum.AddMessage(msg))
     {
         Response.Redirect("MessageInfo.aspx?id=" + msg.ISubjectId);
     }
 }
예제 #4
0
 /// <summary>
 /// ��������
 /// </summary>
 /// <param name="mMessageLeft">����ӵ����Զ���Ӧ�������������Id�����Ե����ݣ����Ե�ʱ�䣬�����ߵ��������û���</param>
 /// <returns>����Ƿ�ɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
 public bool AddMessage(MessageLeftInfo mMessageLeft)
 {
     return dal.AddMessage(mMessageLeft);
 }
예제 #5
0
        /// <summary>
        /// �������Ե�Id�õ����ԵĶ���
        /// </summary>
        /// <param name="iMessageId">���Ե�Id</param>
        /// <returns>���ԵĶ���</returns>
        public MessageLeftInfo GetMessageById(int iMessageId)
        {
            SqlParameter param = new SqlParameter("@msgID", iMessageId);

            MessageLeftInfo messageleft = new MessageLeftInfo();
            using (SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "SP_GetMessageByID", param))
            {
                if (dr.Read())
                {
                    messageleft.IMessageLeftId = dr.GetInt32(0);
                    messageleft.ISubjectId = dr.GetInt32(1);
                    messageleft.StrContents = dr.GetString(2);
                    messageleft.StrReleasePsnName = dr.GetString(3);
                    messageleft.DtReleaseTime = dr.GetDateTime(4);
                    messageleft.StrUserName = dr.GetString(5);
                }
            }
            return messageleft;
        }