//加载 public void LoadDataBind() { int ID = CommonClass.ReturnRequestInt("id", 0); if (ID > 0) { TB_Info_Links model = InfoService.LinksService.Get(ID); TbTitle.Text = model.Title; CheckBoxIsHidden.Checked = model.IsHIdden; ImgUrl.Url = model.ImgUrl; TbLinkUrl.Text = model.Url; ViewState["id"] = model.ID; } }
//状态设置 protected void BtnStateSet_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in RepList.Items) { CheckBox cb = ((CheckBox)ri.FindControl("CheckBoxChoose")); int ID = Convert.ToInt32(((HiddenField)ri.FindControl("HiddenFieldID")).Value); if (cb.Checked == true) { TB_Info_Links model = InfoService.LinksService.Get(ID); model.IsHIdden = CkIsHidden.Checked; InfoService.LinksService.Update(model); } } //重新加载 LoadDataBind(); }
//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_Info_Links model = new TB_Info_Links(); if (ViewState["id"] != null) { model = InfoService.LinksService.Get(ViewState["id"]); } model.Title = TbTitle.Text; model.ImgUrl = ImgUrl.Url; model.Url = TbLinkUrl.Text; model.IsHIdden = CheckBoxIsHidden.Checked; model.Creater = AdminUserName; IInfo_Links Links = InfoService.LinksService; if (ViewState["id"] == null) { model.AddDate = DateTime.Now; if (Links.Insert(model) == 1) { //操作日志 AdminService.LogService.Insert(OperationType.用户操作, 0, "添加友情连接" + model.Title); MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (Links.Update(model) == 1) { //操作日志 AdminService.LogService.Insert(OperationType.用户操作, 0, "修改友情连接" + model.Title); MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }