Example #1
0
        private async void FrmMain_Load(object sender, EventArgs e)
        {
            root                  = new TreeNode("仪器-(" + hwFile.HWName + ")");
            root.Tag              = hwFile.HWName;
            root.ImageIndex       = 0;
            root.ContextMenuStrip = rootContextMenuStrip;
            tvTree.Nodes.Add(root);

            dgModel.TopLeftHeaderCell.Value  = "Device No.";
            dgModule.TopLeftHeaderCell.Value = "Model No.";

            //加载仪器
            instrumentList = await AccessDBHelper.GetInstrumentModelList(hwFile.HWName);

            modelList = await AccessDBHelper.HWCfgModelListByHWName(hwFile.HWName);

            //await AccessDBHelper.HWCfgModelListByInstrumentName(hwFile.HWName, item.InstrumentName);
            foreach (var item in instrumentList)
            {
                var node = new TreeNode(item.InstrumentName);
                node.Tag = hwFile.HWName + splitchar + item.InstrumentName;
                node.ContextMenuStrip = GetSecondContextMenuStrip(node);
                root.Nodes.Add(node);

                var subList = modelList.Where(s => s.HWName == hwFile.HWName && s.InstrumentName == item.InstrumentName);
                foreach (var device in subList)
                {
                    var subnode = new TreeNode(device.ModelName);
                    subnode.Tag = device;
                    subnode.ContextMenuStrip = GetDeleteContextMenuStrip(subnode);
                    node.Nodes.Add(subnode);
                }
            }
            root.Expand();

            moduleList = await AccessDBHelper.HWCfgModuleListByHWName(hwFile.HWName);
        }