Пример #1
0
 private void AddFav(HttpRequest Request, HttpResponse Response)
 {
     if (!string.IsNullOrEmpty(Request.Form["uid"]))
     {
         if (!string.IsNullOrEmpty(Request.Form["cid"]))
         {
             Model.Tao.Favorite model = new Model.Tao.Favorite();
             int courseID = int.Parse(Request.Form["cid"]);
             if (!coursesBLL.Exists(courseID))
             {
                 Response.Write("0");//错误的课程ID
             }
             model.CourseID = courseID;
             if (!string.IsNullOrEmpty(Request.Form["mid"]) && PageValidate.IsNumber(Request.Form["mid"]))
             {
                 model.ModuleID = int.Parse(Request.Form["mid"]);
             }
             else
             {
                 model.ModuleID = courseModuleBLL.GetFirstModuleID(int.Parse(Request.Form["mid"]));
             }
             model.Remark = string.Empty;
             model.Tags = string.Empty;
             model.UserID = int.Parse(Request.Form["uid"]);
             if (!favoriteBLL.ExistsFavorite(Convert.ToInt32(model.CourseID), int.Parse(Request.Form["uid"])))
             {
                 if (0 < favoriteBLL.Add(model))
                 {
                     Response.Write("1");//收藏成功
                 }
                 else
                 {
                     Response.Write("2");//收藏shibai
                 }
             }
             else
             {
                 Response.Write("3");//已经收藏了该课程
             }
         }
         else
         {
             Response.Write("0");//错误的课程ID
         }
     }
     else
     {
         Response.Write("-1");//未登录
     }
 }
Пример #2
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.txtTags.Text.Trim().Length == 0)
            {
                strErr += "关键字不能为空!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int FavoriteID = int.Parse(this.lblFavoriteID.Text);
            int CourseID = int.Parse(this.txtCourseID.Text);
            int ModuleID = int.Parse(this.txtModuleID.Text);
            int UserID = int.Parse(this.txtUserID.Text);
            string Tags = this.txtTags.Text;
            string Remark = this.txtRemark.Text;

            Model.Tao.Favorite model = new Model.Tao.Favorite();
            model.FavoriteID = FavoriteID;
            model.CourseID = CourseID;
            model.ModuleID = ModuleID;
            model.UserID = UserID;
            model.Tags = Tags;
            model.Remark = Remark;

            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }