Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                list = cateBll.GetModelList(" ");
                if (!string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    catrinfo = catrBll.GetModel(Convert.ToInt32(Request.QueryString["id"]));
                }
            }
            else
            {

                catrinfo.CartoonName = Request.Form["CartName"];
                catrinfo.CartoonIntroduce = Request.Form["CartoonIntroduce"];
                catrinfo.CategoriesId = Convert.ToInt32(Request.Form["CategoriesId"]);
                catrinfo.CartoonImage = Request.Form["hiddenfile"];
                if (Convert.ToInt32(Request.Form["id"]) == 0)
                {
                    catrinfo.AddDateTime = DateTime.Now;
                    catrBll.Add(catrinfo);
                }
                else
                {
                    catrinfo.Id = Convert.ToInt32(Request.Form["id"]);
                    catrinfo.AddDateTime = Convert.ToDateTime(Request.Form["data"]);
                    catrBll.Update(catrinfo);
                }


                Response.Redirect("/Admin/Cartonn/CartoonInfo.aspx");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public shaoqi.Model.CatroonInfo DataRowToModel(DataRow row)
 {
     shaoqi.Model.CatroonInfo model = new shaoqi.Model.CatroonInfo();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["CartoonName"] != null)
         {
             model.CartoonName = row["CartoonName"].ToString();
         }
         if (row["CartoonIntroduce"] != null)
         {
             model.CartoonIntroduce = row["CartoonIntroduce"].ToString();
         }
         if (row["CartoonImage"] != null)
         {
             model.CartoonImage = row["CartoonImage"].ToString();
         }
         if (row["CategoriesId"] != null && row["CategoriesId"].ToString() != "")
         {
             model.CategoriesId = int.Parse(row["CategoriesId"].ToString());
         }
         if (row["AddDateTime"] != null && row["AddDateTime"].ToString() != "")
         {
             model.AddDateTime = DateTime.Parse(row["AddDateTime"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public shaoqi.Model.CatroonInfo GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,CartoonName,CartoonIntroduce,CartoonImage,CategoriesId,AddDateTime from CatroonInfo ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
            parameters[0].Value = Id;

            shaoqi.Model.CatroonInfo model = new shaoqi.Model.CatroonInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }