private void ItemAddChannel_Click(object sender, EventArgs e) { try { XAddServer chFrm = new XAddServer(objServerManager); chFrm.eventSQLServerChanged += ch => { try { TreeNode chNode = new TreeNode(ch.ServerName) { StateImageIndex = 0 }; treeViewSI.Nodes.Add(chNode); IsDataChanged = true; } catch (Exception ex) { EventscadaException?.Invoke(GetType().Name, ex.Message); } }; chFrm.ShowDialog(); } catch (Exception ex) { EventscadaException?.Invoke(GetType().Name, ex.Message); } }
private void treeViewSI_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { try { if (e.Button != System.Windows.Forms.MouseButtons.Left) { return; } int Level = treeViewSI.SelectedNode.Level; string selectedNode = treeViewSI.SelectedNode.Text; Server chCurrent = null; DataBase dvCurrent = null; Table dbCurrent = null; switch (Level) { case 0: chCurrent = objServerManager.GetBySQLServerName(selectedNode); XAddServer chFrm = new XAddServer(objServerManager, chCurrent); chFrm.eventSQLServerChanged += ch => { treeViewSI.SelectedNode.Text = ch.ServerName; }; chFrm.StartPosition = FormStartPosition.CenterScreen; chFrm.ShowDialog(); break; case 1: chCurrent = objServerManager.GetBySQLServerName(treeViewSI.SelectedNode.Parent.Text); dvCurrent = DataBaseManager.GetByDataBaseName(chCurrent, selectedNode); XAddDataBase dvFrm = new XAddDataBase(chCurrent, dvCurrent); dvFrm.eventDataBaseChanged += dv => { treeViewSI.SelectedNode.Text = dv.DataBaseName; }; dvFrm.StartPosition = FormStartPosition.CenterScreen; dvFrm.ShowDialog(); break; case 2: chCurrent = objServerManager.GetBySQLServerName(treeViewSI.SelectedNode.Parent.Parent.Text); dvCurrent = DataBaseManager.GetByDataBaseName(chCurrent, treeViewSI.SelectedNode.Parent.Text); dbCurrent = TableManager.GetByTableName(dvCurrent, selectedNode); XAddTable dbFrm = new XAddTable(chCurrent, dvCurrent, dbCurrent); dbFrm.eventTableChanged += db => { treeViewSI.SelectedNode.Text = db.TableName; DGMonitorForm.Rows.Clear(); foreach (Column item in dbCurrent.Columns) { string[] row = { string.Format("{0}", item.ColumnId), item.ColumnName, item.TagName, item.DataBlock, item.Device, item.Channel, item.Cycle, item.Description }; DGMonitorForm.Rows.Add(row); } }; dbFrm.StartPosition = FormStartPosition.CenterScreen; dbFrm.ShowDialog(); break; default: break; } } catch (Exception ex) { EventscadaException?.Invoke(GetType().Name, ex.Message); } }