//更新一条记录 protected void GVinfo_RowCommand(object sender, GridViewCommandEventArgs e) { int theRow = 0; //保存行号 string theCol = ""; //保存列位置信息 theRow = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; theCol = e.CommandName.ToString(); Id = Convert.ToInt32(GVinfo.DataKeys[theRow].Value); Maticsoft.Model.CMS_FriendLink mfl = new Maticsoft.Model.CMS_FriendLink(); Maticsoft.BLL.CMS_FriendLink bfl = new Maticsoft.BLL.CMS_FriendLink(); switch (e.CommandName) { case "MyEdit": { lbIns.Text = "编辑"; mfl = bfl.GetModel(Id); tbTitle.Text = mfl.Title; tbSort.Text = Convert.ToString(mfl.Sort); tbSiteUrl.Text = mfl.SiteUrl; btAbandon.Visible = true; break; } case "MyUp": { DAL.CMS_FriendLink.SetSort(Id, false); Flush(); break; } case "MyDown": { DAL.CMS_FriendLink.SetSort(Id, true); Flush(); break; } case "MyDel": { bfl.Delete(Id); btAbandon_Click(sender, e); //如果在编辑或添加完的状态下,点了删除 Flush(); break; } } }
/// <summary> /// 获得数据列表 /// </summary> public List <Maticsoft.Model.CMS_FriendLink> DataTableToList(DataTable dt) { List <Maticsoft.Model.CMS_FriendLink> modelList = new List <Maticsoft.Model.CMS_FriendLink>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Maticsoft.Model.CMS_FriendLink model; for (int n = 0; n < rowsCount; n++) { model = new Maticsoft.Model.CMS_FriendLink(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Title = dt.Rows[n]["Title"].ToString(); if (dt.Rows[n]["IsPic"].ToString() != "") { if ((dt.Rows[n]["IsPic"].ToString() == "1") || (dt.Rows[n]["IsPic"].ToString().ToLower() == "true")) { model.IsPic = true; } else { model.IsPic = false; } } model.PicUrl = dt.Rows[n]["PicUrl"].ToString(); model.SiteUrl = dt.Rows[n]["SiteUrl"].ToString(); if (dt.Rows[n]["Sort"].ToString() != "") { model.Sort = int.Parse(dt.Rows[n]["Sort"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.CMS_FriendLink model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.CMS_FriendLink model) { return(dal.Add(model)); }