private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach(DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox) item.FindControl("chkList"); if (chkList!=null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { AccessUser clsAccessUser = new AccessUser(); clsAccessUser.Delete(stIDs.Substring(0,stIDs.Length-1)); clsAccessUser.CommitAndDispose(); } return boRetValue; }
protected void lstItem_ItemCommand(object sender, DataListCommandEventArgs e) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList"); string stParam = string.Empty; switch(e.CommandName) { case "imgItemDelete": AccessUser clsAccessUser = new AccessUser(); clsAccessUser.Delete(chkList.Value); clsAccessUser.CommitAndDispose(); LoadList(); break; case "imgItemEdit": stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect("Default.aspx" + stParam); break; case "imgItemAccessRights": stParam = "?task=" + Common.Encrypt("accessrights", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect("Default.aspx" + stParam); break; case "imgResetPassword": ResetPassword(long.Parse(chkList.Value)); break; case "imgReloadAccessRights": ReloadAccessRights(long.Parse(chkList.Value)); stParam = "?task=" + Common.Encrypt("list", Session.SessionID); try { stParam += "&search=" + Common.Encrypt(Request.QueryString["search"].ToString(), Session.SessionID); } catch { } Response.Redirect("Default.aspx" + stParam); break; case "imgPrintBarCodeAccess": Label lblPasswordReadable = (Label)e.Item.FindControl("lblPasswordReadable"); Label lblUserName = (Label)e.Item.FindControl("lblUserName"); HyperLink lnkName = (HyperLink)e.Item.FindControl("lnkName"); ThermalBarCodePrinter clsThermalBarCodePrinter = new ThermalBarCodePrinter(); try { clsThermalBarCodePrinter.PrintUserAccess(lnkName.Text, lblUserName.Text + "|" + lblPasswordReadable.Text); } catch { } break; } }