Example #1
0
        protected void rptPricebf_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandArgument.Equals("btnCom"))
            {
                TextBox txtCom = e.Item.FindControl("txtCom") as TextBox;
                Label labOid = e.Item.FindControl("LabOid") as Label;
                Label labCid = e.Item.FindControl("labCid") as Label;
                Label labMid = e.Item.FindControl("labMid") as Label;
                if (txtCom == null || txtCom.Text == null || labOid == null || labMid == null)
                {
                    return;
                }
                int oid = int.Parse(labOid.Text);
                int cid = int.Parse(labCid.Text);

                Model.Tao.Comment commodel = new Model.Tao.Comment();
                commodel.OrderID = oid;
                commodel.CourseID = cid;
                commodel.ModuleID = int.Parse(labMid.Text);
                commodel.UserID = CurrentUser.UserID;
                commodel.Comments = txtCom.Text;
                commodel.CommentDate = DateTime.Now;
                commodel.Status = 1;
                BLL.Tao.Comment combll = new BLL.Tao.Comment();
                if (combll.Add(commodel) > 0)
                {
                    BindDatabf();
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["UserInfo"] != null)
            {
                if (!string.IsNullOrEmpty(this.txtComment.Text.Trim()))
                {
                    Maticsoft.Accounts.Bus.User user = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
                    Model.Tao.Comment commentModel = new Model.Tao.Comment();
                    commentModel.CourseID = (int)this.CourseID;
                    commentModel.UserID = user.UserID;
                    commentModel.CommentDate = DateTime.Now;
                    if (!string.IsNullOrEmpty(HiddenField1.Value))
                    {
                        commentModel.ParentID = int.Parse(HiddenField1.Value);
                    }
                    commentModel.Comments = this.txtComment.Text.Trim();

                    BLL.Tao.Comment commentBll = new BLL.Tao.Comment();
                    if (commentBll.Add(commentModel) > 0)
                    {
                        BindData();
                    }
                }
                else
                {
                    this.lblComment.Visible = true;
                }
            }
            else
            {
                Common.CommonCode.GoLoginPage();
            }
        }
Example #3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (!PageValidate.IsNumber(txtCourseID.Text))
            {
                strErr += "课程格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtModuleID.Text))
            {
                strErr += "节次格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUserID.Text))
            {
                strErr += "评论人格式错误!\\n";
            }
            if (this.txtComment.Text.Trim().Length == 0)
            {
                strErr += "内容不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtCommentDate.Text))
            {
                strErr += "评论时间格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "评论分值格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int CommentID = int.Parse(this.lblCommentID.Text);
            int CourseID = int.Parse(this.txtCourseID.Text);
            int ModuleID = int.Parse(this.txtModuleID.Text);
            int UserID = int.Parse(this.txtUserID.Text);
            string Comment = this.txtComment.Text;
            DateTime CommentDate = DateTime.Parse(this.txtCommentDate.Text);
            int Score = int.Parse(this.txtScore.Text);

            Model.Tao.Comment model = new Model.Tao.Comment();
            model.CommentID = CommentID;
            model.CourseID = CourseID;
            model.ModuleID = ModuleID;
            model.UserID = UserID;
            model.Comments = Comment;
            model.CommentDate = CommentDate;
            model.Score = Score;
            model.Status = 1;
            CommentBLL.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #4
0
        private void InsertComment(HttpContext context)
        {
            JsonObject json = new JsonObject();
            string strMid = context.Request.Params["Mid"];
            string strCid = context.Request.Params["Cid"];
            string strUid = context.Request.Params["Uid"];
            string strPid = context.Request.Params["Pid"];//
            string strCtype = context.Request.Params["Ctype"];

            string strContent = context.Request.Params["Con"];
            if (!string.IsNullOrEmpty(strMid) && !string.IsNullOrEmpty(strCid) && !string.IsNullOrEmpty(strUid) && !string.IsNullOrEmpty(strPid))
            {
                Model.Tao.Comment model = new Model.Tao.Comment();
                model.CourseID = int.Parse(strCid);
                if (strMid != "null")
                {
                    model.ModuleID = int.Parse(strMid);
                }
                model.UserID = int.Parse(strUid);
                model.ParentID = int.Parse(strPid);
                model.Comments = strContent;
                model.Status = 1;
                model.CommentDate = DateTime.Now;
                model.Type = Common.Globals.SafeInt(strCtype, 0);
                int comId = bll.Add(model);
                if (comId > 0)
                {
                    List<Maticsoft.Model.Tao.Comment> list = bll.GetModelList(comId);
                    if (list.Count > 0)
                    {
                        JsonArray data = new JsonArray();
                        list.ForEach(info => data.Add(new JsonObject(
                            new string[] { "CommentID", "OrderID", "CourseID", "ModuleID", "UserID", "CommentInfo", "CommentDate", "ParentID", "Score", "Status" },
                            new object[] { info.CommentID, info.OrderID, info.CourseID, info.ModuleID, info.UserID, info.Comments, info.CommentDate.ToString("yyyy-MM-dd HH:mm:ss"), info.ParentID, info.Score, info.Status }
                            )));
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                        json.Put(TAO_KEY_DATA, data);
                    }
                    else
                    {
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
                    }
                }
                else
                {
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
                }
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
            }
            context.Response.Write(json.ToString());
        }