protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string operate = Request.Params.Get("operate");
         if (operate == null || operate.Equals(""))
         {
             return ;
         }
         if (operate.Equals("editRecommendation"))
         {
             Session["recommendationId"] = Request.Params.Get("id");
         }
         else if (operate.Equals("deleteRecommendation"))
         {
             try
             {
                 int id = int.Parse(Request.Params.Get("id"));
                 CourseAccess.RemoveRecommendation(CourseAccess.GetRecommendationByID(id));
             }
             catch
             {
                 Response.Write("删除出错,请确认该项是否存在,可以刷新网页重试");
                 Response.End();
             }
             Response.Write("success");
             Response.End();
         }
         else if (operate.Equals("new"))
         {
             string title = Request.Params.Get("title");
             string des = Request.Params.Get("description");
             try
             {
                 RECOMMENDATION rec = new RECOMMENDATION();
                 rec.TITLE = title;
                 rec.DESCRIPTION = des;
                 CourseAccess.AddRecommendation(rec);
             }
             catch
             {
                 Response.Write("提交错误,请重试");
                 Response.End();
             }
             Response.Write("success");
             Response.End();
         }
     }
     catch
     {
     }
 }
        public bool Rec_Recommendation(Survey _surv)
        {
            int surveyID = Convert.ToInt32(_surv.S_ID);

            //  int Q_ID = Convert.ToInt32(_surv.ID);
            using (EventrixDBDataContext db = new EventrixDBDataContext())
            {
                try
                {
                    int _query = (from res in db.RECOMMENDATIONs
                                  where res.S_Id.Equals(surveyID)
                                  select res).Count();
                    if (_query == 0) //Create New Answer
                    {
                        RECOMMENDATION toinsert = new RECOMMENDATION();
                        toinsert.S_Id       = _surv.S_ID;
                        toinsert.Not_Likely = _surv.NotLikely;
                        toinsert.Neutral    = _surv.Neutral;
                        toinsert.Likey      = _surv.Likely;
                        toinsert.Very_Likey = _surv.VeryLikely;

                        db.RECOMMENDATIONs.InsertOnSubmit(toinsert);
                        db.SubmitChanges();
                        return(true);
                    }
                    else //Update Record
                    {
                        RECOMMENDATION query = (from res in db.RECOMMENDATIONs
                                                where res.S_Id.Equals(surveyID)
                                                select res).First();
                        query.Not_Likely += _surv.NotLikely;
                        query.Neutral    += _surv.Neutral;
                        query.Likey      += _surv.Likely;
                        query.Very_Likey += _surv.VeryLikely;

                        db.SubmitChanges();
                        return(true);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            };
        }
Beispiel #3
0
 public void AddToRECOMMENDATION(RECOMMENDATION rECOMMENDATION)
 {
     base.AddObject("RECOMMENDATION", rECOMMENDATION);
 }
Beispiel #4
0
 public static RECOMMENDATION CreateRECOMMENDATION(int ID, string tITLE)
 {
     RECOMMENDATION rECOMMENDATION = new RECOMMENDATION();
     rECOMMENDATION.ID = ID;
     rECOMMENDATION.TITLE = tITLE;
     return rECOMMENDATION;
 }