Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                annModle.AnnContent = Request.Form["editor1"];
                annModle.Title = Request.Form["title"];

                annModle.AdminId = 1;//要用Session中的值来进行替代 

                if (Convert.ToInt32(Request.Form["id"]) == 0)
                {
                    //说明是增加
                    annModle.AddTime = DateTime.Now;
                    annBll.Add(annModle);
                }
                else
                {
                    //说明是更新
                    annModle.Id = Convert.ToInt32(Request.Form["id"]);
                    annModle.AddTime = Convert.ToDateTime(Request.Form["date"]);
                    annBll.Update(annModle);
                }
                Response.Redirect("/Admin/Announce/Announce.aspx");
            }
            else
            {
                string action = Request.QueryString["action"];
                if (action == "update")
                {
                    int id1 = Convert.ToInt32(Request.QueryString["id"]);
                    annModle = annBll.GetModel(id1);
                    id = annModle.Id;
                    title = annModle.Title;
                    context = annModle.AnnContent;
                    date = annModle.AddTime;
                }

            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public shaoqi.Model.Announce DataRowToModel(DataRow row)
 {
     shaoqi.DAL.Admin adminDal = new Admin();
     shaoqi.Model.Announce model = new shaoqi.Model.Announce();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["AnnContent"] != null)
         {
             model.AnnContent = row["AnnContent"].ToString();
         }
         if (row["AdminId"] != null && row["AdminId"].ToString() != "")
         {
             model.AdminId =int.Parse(row["AdminId"].ToString());
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = DateTime.Parse(row["AddTime"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public shaoqi.Model.Announce GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,Title,AnnContent,AdminId,AddTime from Announce ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
            parameters[0].Value = Id;

            shaoqi.Model.Announce model = new shaoqi.Model.Announce();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string id = Request.QueryString["id"];
     shaoqi.BLL.Announce annbll = new shaoqi.BLL.Announce();
     modle = annbll.GetModel(Convert.ToInt32(id));
 }