/// <summary> /// 获得数据列表 /// </summary> public List <TFXK.Model.Articles> DataTableToList(DataTable dt) { List <TFXK.Model.Articles> modelList = new List <TFXK.Model.Articles>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { TFXK.Model.Articles model; for (int n = 0; n < rowsCount; n++) { model = new TFXK.Model.Articles(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["parentId"].ToString() != "") { model.parentId = int.Parse(dt.Rows[n]["parentId"].ToString()); } model.title = dt.Rows[n]["title"].ToString(); model.source = dt.Rows[n]["source"].ToString(); model.publisher = dt.Rows[n]["publisher"].ToString(); if (dt.Rows[n]["createTime"].ToString() != "") { model.createTime = DateTime.Parse(dt.Rows[n]["createTime"].ToString()); } model.description = dt.Rows[n]["description"].ToString(); if (dt.Rows[n]["isOutlLink"].ToString() != "") { model.isOutlLink = int.Parse(dt.Rows[n]["isOutlLink"].ToString()); } if (dt.Rows[n]["isSlideOn"].ToString() != "") { model.isSlideOn = int.Parse(dt.Rows[n]["isSlideOn"].ToString()); } if (dt.Rows[n]["state"].ToString() != "") { model.state = int.Parse(dt.Rows[n]["state"].ToString()); } if (dt.Rows[n]["clicks"].ToString() != "") { model.clicks = int.Parse(dt.Rows[n]["clicks"].ToString()); } if (dt.Rows[n]["orderId"].ToString() != "") { model.orderId = int.Parse(dt.Rows[n]["orderId"].ToString()); } model.imgPath = dt.Rows[n]["imgPath"].ToString(); model.outLinkPath = dt.Rows[n]["outLinkPath"].ToString(); model.fysmDes = dt.Rows[n]["fysmDes"].ToString(); model.wxtsDes = dt.Rows[n]["wxtsDes"].ToString(); model.ydxzDes = dt.Rows[n]["ydxzDes"].ToString(); modelList.Add(model); } } return(modelList); }
protected void ibtnAdd_Click(object sender, EventArgs e) { //验证代码 try { TFXK.Model.Articles model = new TFXK.Model.Articles(); try { model.id = int.Parse(Request.QueryString["id"].ToString()); } catch { model.id = 0; } model.title = txtTitle.Text; model.source = this.txtSource.Text; model.orderId = int.Parse(this.txtOrderby.Text.Equals("") ? "0" : this.txtOrderby.Text); model.parentId = int.Parse(this.ddlType.SelectedValue + ""); model.isSlideOn = 0; model.createTime = this.txtDate.Date; model.clicks = int.Parse(this.txtClick.Text.Equals("") ? "0" : this.txtClick.Text); model.description = this.txtContent.Value; try { model.publisher = bllUser.GetModelByUserName(Context.User.Identity.Name).trueName; } catch { } model.isOutlLink = ddlOutLink.SelectedIndex; model.outLinkPath = txtOutLink.Text; model.state = int.Parse(this.ddlState.SelectedValue); if (hdfImgPath.Value.Length > 10) { model.imgPath = hdfImgPath.Value; } string type = this.hdfAction.Value.Trim(); // 判断动作 switch (type) { case "add": Add(model); break; case "modify": Modify(model); break; } } catch (Exception ex) { log.Error(ex.Message); Msg.Show("网络错误!原因:" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string ids = Request.QueryString["id"] + ""; int id = 0; if (string.IsNullOrEmpty(ids) || !int.TryParse(ids, out id) || id <= 0) { Response.Redirect("/Default.aspx"); } articles = bllArticles.GetModel(id); if (articles == null) { Response.Redirect("/Default.aspx"); } bllArticles.UpdateClick(id); currentCategory = bllCategory.GetModel(articles.parentId); if (currentCategory != null) { LeftNavControl.navParentID = currentCategory.parentID; LeftNavControl.navCode = currentCategory.codeNo; LocationControl.currentCategory = currentCategory; parentCategory = bllCategory.GetModel(currentCategory.parentID); if (parentCategory != null) { LocationControl.parentCategory = parentCategory; LeftNavControl.navTitle = parentCategory.title; Page.Title = articles.title + "-" + currentCategory.title + "-" + parentCategory.title; activeNav = LocationControl.GetNavName(); } else { LeftNavControl.navTitle = currentCategory.title; Page.Title = articles.title + "-" + currentCategory.title; } } else { Response.Redirect("~/"); } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TFXK.Model.Articles model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TFXK.Model.Articles model) { return(dal.Add(model)); }