日期:2014-05-17 浏览次数:20976 次
delegate bool MyDelete(TreeNodeCollection node); bool prrelust = false; bool xzjh = false; bool prrelust = false; bool xzjh = false; public bool PrintTreeViewNode(TreeNodeCollection node) { foreach (TreeNode n in node) { if (n.Checked &&(Convert.ToInt32(n.Tag)==30 )) { xzjh = true; string fanode = n.Parent.Parent.Text; string time = cbTimeDelay.Text.Trim().Substring(0, cbTimeDelay.Text.Trim().Length - 1); //延时 int jihao = Convert.ToInt32(fanode.Substring(fanode.IndexOf("(") + 1, fanode.IndexOf(")") - fanode.IndexOf("(") - 1));//机号 int menhao;//门号 GCR.DoorSedBll bl = new GCR.DoorSedBll(); if (n.Parent.Text != "主机") { menhao = Convert.ToInt32(n.Parent.Tag) * 8 + 4 + n.Index; } else { menhao = n.Index;//门号 } prrelust = bl.OpenDoorTimedelaySet(jihao, menhao, Convert.ToInt32(time)); if (!prrelust) { label3.Text = ""; break; } } PrintTreeViewNode(n.Nodes); } return prrelust; } #endregion private void btOpenDoorTimeSet_Click(object sender, EventArgs e) { label3.Text = "延时加载中,请稍等......."; MyDelete Dele = new MyDelete(PrintTreeViewNode); Dele.BeginInvoke(this.tvDevc.Nodes, new AsyncCallback(AfterMyMothod), null); } #endregion #region 异步传参回调函数 public void AfterMyMothod(IAsyncResult result) { AsyncResult async = (AsyncResult)result; MyDelete DelegateInstance = (MyDelete)async.AsyncDelegate; bool rt = DelegateInstance.EndInvoke(result); if (xzjh) { if (rt) { MessageBox.Show("延时加载成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("延时加载失败!,请重新加载!", "错误提示&