Ejemplo n.º 1
0
        private void ItemEditor_Click(object sender, EventArgs e)
        {
            try
            {
                if (treeViewSI.SelectedNode == null)
                {
                    return;
                }

                int    Level        = treeViewSI.SelectedNode.Level;
                string selectedNode = treeViewSI.SelectedNode.Text;

                if (Level == 2)
                {
                    Server   chCurrent = objServerManager.GetBySQLServerName(treeViewSI.SelectedNode.Parent.Parent.Text);
                    DataBase dvCurrent = DataBaseManager.GetByDataBaseName(chCurrent, treeViewSI.SelectedNode.Parent.Text);
                    Table    dbCurrent = TableManager.GetByTableName(dvCurrent, treeViewSI.SelectedNode.Text);

                    string channelName = chCurrent.ServerName;
                    string DeviceName  = dvCurrent.DataBaseName;

                    string DataBlockName = dbCurrent.TableName;



                    if (DGMonitorForm.SelectedRows.Count == 1)
                    {
                        string tgName    = (string)DGMonitorForm.SelectedRows[0].Cells[1].Value;
                        Column tgCurrent = ColumnManager.GetByTagName(dbCurrent, tgName);

                        XAddColumn tgFrm = new XAddColumn(chCurrent, dvCurrent, dbCurrent, tgCurrent);
                        tgFrm.eventColumnChanged += tg =>
                        {
                            IsDataChanged = true;
                        };
                        tgFrm.StartPosition = FormStartPosition.CenterScreen;
                        tgFrm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void ItemAddTag_Click(object sender, EventArgs e)
        {
            try
            {
                if (treeViewSI.SelectedNode == null)
                {
                    return;
                }

                Server     chCurrent = objServerManager.GetBySQLServerName(treeViewSI.SelectedNode.Parent.Parent.Text);
                DataBase   dvCurrent = DataBaseManager.GetByDataBaseName(chCurrent, treeViewSI.SelectedNode.Parent.Text);
                Table      dbCurrent = TableManager.GetByTableName(dvCurrent, treeViewSI.SelectedNode.Text);
                XAddColumn tgFrm     = new XAddColumn(chCurrent, dvCurrent, dbCurrent);
                tgFrm.eventColumnChanged += tg =>
                {
                    try
                    {
                        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);
                        }
                    }
                    catch (Exception ex)
                    {
                        EventscadaException?.Invoke(GetType().Name, ex.Message);
                    }
                };
                tgFrm.ShowDialog();
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }
        }