private void sbtnDelete_Click(object sender, EventArgs e) { sbtnDelete.Enabled = false; if (treeView1.SelectedNode == null) { MessageUtil.ShowTips("请选择需要删除的内容"); sbtnDelete.Enabled = true; return; } else { if (treeView1.SelectedNode.GetNodeCount(true) > 0) { if (MessageUtil.ShowYesNoAndTips("将删除该节点及所属该节点下的所有工具,删除后不可恢复,请谨慎操作,确定删除?") == DialogResult.Yes) { frmExitUser.userPower = UserPower.系统用户; frmExitUser frm = new frmExitUser(); frm.ShowDialog(this); frm.Dispose(); if (frmExitUser.blOk) { DeleteChildNode(treeView1.SelectedNode); treeView1.SelectedNode.Remove(); } else { sbtnDelete.Enabled = true; return; } } else { sbtnDelete.Enabled = true; return; } } else { string str = treeView1.SelectedNode.Text.ToString(); string strSql = "select ID from tb_Tools where ToolName='" + str + "' "; DataTable dt = datalogic.GetDataTable(strSql); if (dt.Rows.Count > 0) { if (MessageUtil.ShowYesNoAndTips("将删除该节点及所属该节点下的所有工具,删除后不可恢复,请谨慎操作,确定删除?") == DialogResult.Yes) { frmExitUser.userPower = UserPower.系统用户; frmExitUser frm = new frmExitUser(); frm.ShowDialog(this); frm.Dispose(); if (frmExitUser.blOk) { str = treeView1.SelectedNode.Name.ToString(); string strsql = "delete from tb_TypeAndName where tvChildId='" + str + "'"; datalogic.SqlComNonQuery(strsql); str = treeView1.SelectedNode.Text.ToString(); treeView1.SelectedNode.Remove(); strsql = "delete from tb_Tools where ToolName='" + str + "'"; datalogic.SqlComNonQuery(strsql); } else { sbtnDelete.Enabled = true; return; } } else { sbtnDelete.Enabled = true; return; } } else { if (MessageUtil.ShowYesNoAndTips("确定删除该选中节点?") == DialogResult.Yes) { str = treeView1.SelectedNode.Name.ToString(); string strsql = "delete from tb_TypeAndName where tvChildId='" + str + "'"; datalogic.SqlComNonQuery(strsql); str = treeView1.SelectedNode.Text.ToString(); treeView1.SelectedNode.Remove(); } else { sbtnDelete.Enabled = true; return; } } } ShowNew(); } }
private void sbtnDelete_Click(object sender, EventArgs e) { sbtnDelete.Enabled = false; if (treeView1.SelectedNode == null) { MessageUtil.ShowTips("请选择需要删除的内容"); } else { int iImage = treeView1.SelectedNode.ImageIndex; string strName = treeView1.SelectedNode.Text; bool blDelect = false; if (iImage == 0 || iImage == 1)//区域 { if (MessageUtil.ShowYesNoAndTips("将删除“" + strName + "”区域" + "及该区域内的所有工具,删除后不可恢复请谨慎操作,确定删除?") == DialogResult.Yes) { blDelect = true; } } else if (iImage == 2)//存放点 { if (MessageUtil.ShowYesNoAndTips("将删除“" + strName + "”存放点" + "及该存放点下的所有工具,删除后不可恢复请谨慎操作,确定删除?") == DialogResult.Yes) { blDelect = true; } } else if (iImage == 3)//工具 { if (MessageUtil.ShowYesNoAndTips("将删除“" + strName + "”工器具" + ",删除后不可恢复请谨慎操作,确定删除?") == DialogResult.Yes) { blDelect = true; } } else if (iImage == 4)//工具柜 { if (MessageUtil.ShowYesNoAndTips("将删除“" + strName + "”工具柜" + "及该工具柜内的所有工具,删除后不可恢复请谨慎操作,确定删除?") == DialogResult.Yes) { blDelect = true; } } if (blDelect) { frmExitUser.userPower = UserPower.系统用户; frmExitUser frm = new frmExitUser(); frm.ShowDialog(this); frm.Dispose(); if (frmExitUser.blOk) { if (iImage == 4) { string str = treeView1.SelectedNode.Name.ToString(); string strsql = "delete from tb_BoxIcPower where BoxChildId='" + str + "'"; datalogic.SqlComNonQuery(strsql); } if (treeView1.SelectedNode.GetNodeCount(true) > 0) { DeleteChildNode(treeView1.SelectedNode); treeView1.SelectedNode.Remove(); } else { string str = treeView1.SelectedNode.Name.ToString(); string strsql = "delete from tb_Tools where tvChildId='" + str + "'"; datalogic.SqlComNonQuery(strsql); treeView1.SelectedNode.Remove(); } ShowNew(); } } } sbtnDelete.Enabled = true; }