protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                annModle.AtrContent = Request.Form["editor1"];
                annModle.Title = Request.Form["title"];

                annModle.UserId = 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/Atricle/AtrcleInfo.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.AtrContent;
                    date = annModle.AddTime;
                }

            }
        }
示例#2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public shaoqi.Model.Atricle GetModel(int Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 Id,Title,AtrContent,UserId,AddTime from Atricle ");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			shaoqi.Model.Atricle model=new shaoqi.Model.Atricle();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}
示例#3
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public shaoqi.Model.Atricle DataRowToModel(DataRow row)
		{
			shaoqi.Model.Atricle model=new shaoqi.Model.Atricle();
			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["AtrContent"]!=null)
				{
					model.AtrContent=row["AtrContent"].ToString();
				}
				if(row["UserId"]!=null && row["UserId"].ToString()!="")
				{
					model.UserId=int.Parse(row["UserId"].ToString());
				}
				if(row["AddTime"]!=null && row["AddTime"].ToString()!="")
				{
					model.AddTime=DateTime.Parse(row["AddTime"].ToString());
				}
			}
			return model;
		}
示例#4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string id = Request.QueryString["id"];
     shaoqi.BLL.Atricle annbll = new shaoqi.BLL.Atricle();
     modle = annbll.GetModel(Convert.ToInt32(id));
 }