[csharp]
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("延時加載失敗!,請重新加載!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("請選擇控制機號", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
label3.Text = "";
}
#endregion
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("延時加載失敗!,請重新加載!", "錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("請選擇控制機號", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
label3.Text = "";
}
#endregion