/// <summary> /// 根据用户ID删除用户 /// </summary> /// <param name="userId"></param> private void DeleteUserInfo(int userId) { if (userInfoBll.Delete(userId)) { ScriptHelper.AlertRefresh("删除成功"); } else { ScriptHelper.Alert("删除失败"); } }
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del")//如果是删除命令 { int id = Convert.ToInt32(e.CommandArgument.ToString()); UserInfoBll bll = new UserInfoBll(); if (bll.Delete(id, null) > 0) { Response.Write("<script>alert('删除成功!');window.location.href='UserList.aspx'</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败!');</script>"); } } }
/// <summary> /// 右键删除用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { int index = dataGridView3.CurrentCell.RowIndex; string id = dataGridView3.Rows[index].Cells["id1"].Value.ToString(); if (MessageBox.Show("您确定要删除该信息吗?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (userInfobll.Delete(Convert.ToInt32(id))) { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } } }
public ActionResult Delete(string strId) { string result = "no"; string[] strIds = strId.Split(','); List <int> idList = new List <int>(); int temp; foreach (string item in strIds) { if (int.TryParse(item, out temp)) { idList.Add(temp); } } if (idList != null && UserInfoBll.Delete(idList)) { result = "ok"; } return(Content(result)); }
/// <summary> /// 删除按钮事件 /// </summary> private void btnDelete_Click(object sender, EventArgs e) { GetCurSelectRows(); if (_CurSelectRows.Count == 0) { lblMsg.Visible = true; lblMsg.Text = "Please select user item"; return; } List <string> users = new List <string>(); foreach (DataGridViewRow item in _CurSelectRows) { users.Add(item.Cells["colUserPin"].Value.ToString()); } lblMsg.Visible = false; if (_bll.Delete(users) > 0) { LoadAllUsers(); string basePath = System.Environment.CurrentDirectory; string path = string.Empty; foreach (var item in users) { path = basePath + "\\Photo\\" + item + ".jpg"; if (File.Exists(path)) { File.Delete(path); } } this.lblMsg.Visible = true; this.lblMsg.Text = "Operate successful."; } else { this.lblMsg.Visible = true; this.lblMsg.Text = "Operate fail."; } }