/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("del")) { int id = Convert.ToInt32(e.CommandArgument); SearchKeyWordService.Delete(id); sp.InitBindData(this.repInfo, pager1, "SearchKeyWord", "id", sear()); } if (e.CommandName.Equals("mod")) { this.hidId.Value = e.CommandArgument.ToString(); SearchKeyWord nt = SearchKeyWordService.GetModel(Convert.ToInt32(e.CommandArgument)); if (nt != null) { txtTitle.Text = nt.seaTitle; txtOrderNum.Text = nt.status.ToString(); } } }
/// <summary> /// 批量删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { string ids = selInfo(); int num = 0; if (ids.Length == 0) { Jscript.Alert("请选择要删除的记录!", this.Page); return; } string[] arr = ids.TrimEnd(',').Split(','); for (int i = 0; i < arr.Length; i++) { if (SearchKeyWordService.Delete(Convert.ToInt32(arr[i]))) { num++; } } ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('成功删除" + num + "条记录!');", true); sp.InitBindData(this.repInfo, pager1, "SearchKeyWord", "id", sear()); }
/// <summary> /// 添加事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { lblError.Text = ""; SearchKeyWord item = new SearchKeyWord(); item.typeId = 0; item.typeName = ""; item.seaTitle = txtTitle.Text.Trim(); item.status = Convert.ToInt32(txtOrderNum.Text); item.remark = ""; item.addTime = DateTime.Now; item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } item.infoType = 0; string hidId = this.hidId.Value; if (hidId != "") { item.id = Convert.ToInt32(hidId); SearchKeyWordService.Update(item); } else { SearchKeyWordService.Add(item); txtTitle.Text = ""; } this.hidId.Value = ""; sp.InitBindData(this.repInfo, pager1, "SearchKeyWord", "id", sear()); }