Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string   caid  = Request.QueryString["CaIdRe"];
         RecmdDAO redao = new RecmdDAO();
         Recmd    recmd = redao.recmdSelectRecmd(caid);
         lblTitle.Text = recmd.Title;
         string str = recmd.CreateTime;
         lblTime.Text    = Convert.ToDateTime(str).ToString("yyyy-MM-dd");
         lblMyName.Text  = recmd.PopName;
         lblContent.Text = recmd.Cont;
     }
 }
Пример #2
0
        /// <summary>
        /// 根据id查询内容
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Recmd recmdSelectRecmd(string id)
        {
            Recmd     recmd = new Recmd();
            DataTable dt    = new DataTable();
            string    sql   = "SELECT * FROM Recmd WHERE id=@id";

            SqlParameter[] par =
            {
                new SqlParameter("@id", id)
            };
            dt               = sqlhelper.GetDataTable(sql, CommandType.Text, par);
            recmd.Id         = id;
            recmd.Title      = dt.Rows[0]["title"].ToString();
            recmd.Cont       = dt.Rows[0]["cont"].ToString();
            recmd.CreateTime = dt.Rows[0]["createTime"].ToString();
            recmd.PopName    = dt.Rows[0]["popName"].ToString();
            return(recmd);
        }
Пример #3
0
        /// <summary>
        /// 插入内容
        /// </summary>
        /// <param name="recmd">实体类</param>
        /// <returns></returns>
        public bool insertRecmd(Recmd recmd)
        {
            bool   falg = false;
            string sql  = "INSERT INTO Recmd(title,cont,popName) VALUES(@title,@cont,@popName)";

            SqlParameter[] par =
            {
                new SqlParameter("@title",   recmd.Title),
                new SqlParameter("@cont",    recmd.Cont),
                new SqlParameter("@popName", recmd.PopName),
            };
            int res = sqlhelper.ExecuteNonQuery(sql, CommandType.Text, par);

            if (res > 0)
            {
                falg = true;
            }
            return(falg);
        }
Пример #4
0
        /// <summary>
        /// 精心推荐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_ClickTuiJian(object sender, EventArgs e)
        {
            Recmd    recmd    = new Recmd();
            RecmdDAO recmddao = new RecmdDAO();

            string titleTuiJian = TextJxTuijian.Text;
            string contTuiJian  = TxtJxTuijianTart.InnerText;
            string drTuiJian    = DropJxTuiJian.Text;

            if (titleTuiJian == "")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('标题不能为空');</script>");
                return;
            }
            else if (contTuiJian == "")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('内容不能为空');</script>");
                return;
            }

            recmd.Title   = titleTuiJian;
            recmd.Cont    = contTuiJian;
            recmd.PopName = drTuiJian;

            bool res = recmddao.insertRecmd(recmd);

            if (res)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('精心推荐插入成功');</script>");
                TextJxTuijian.Text         = "";
                TxtJxTuijianTart.InnerText = "";
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('精心推荐插入失败');</script>");
            }
        }