Exemplo n.º 1
0
        private void btn_Add_Click(object sender, System.EventArgs e)
        {
            EditOPCServerForm editOPCServerForm = new EditOPCServerForm();

            editOPCServerForm.tb_NameServer.Text = "OPCServer.WinCC";
            if (editOPCServerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SettingsOPCServer settingsOPCServer = new SettingsOPCServer();
                settingsOPCServer.IpAddressServer = editOPCServerForm.tb_IPAddrServer.Text;
                settingsOPCServer.NameServer      = editOPCServerForm.tb_NameServer.Text;
                Program.sL.tmp_listObject.OPCServers.Add(settingsOPCServer);
                if (Program.sL.tmp_listObject.DefaultOPCServer == null)
                {
                    Program.sL.tmp_listObject.DefaultOPCServer = new SettingsDefaultOPCServer();
                    Program.sL.tmp_listObject.DefaultOPCServer.IpAddressServer = settingsOPCServer.IpAddressServer;
                    Program.sL.tmp_listObject.DefaultOPCServer.NameServer      = settingsOPCServer.NameServer;
                }
                Program.sL.Save();
                this.Bind();
            }
        }
Exemplo n.º 2
0
 private void btn_Edit_Click(object sender, System.EventArgs e)
 {
     if (this.dataGridView1.CurrentRow != null)
     {
         try
         {
             EditOPCServerForm editOPCServerForm = new EditOPCServerForm();
             SettingsOPCServer settingsOPCServer = Program.sL.tmp_listObject.OPCServers[this.dataGridView1.CurrentRow.Index];
             editOPCServerForm.tb_IPAddrServer.Text = settingsOPCServer.IpAddressServer;
             editOPCServerForm.tb_NameServer.Text   = settingsOPCServer.NameServer;
             if (editOPCServerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 settingsOPCServer.IpAddressServer = editOPCServerForm.tb_IPAddrServer.Text;
                 settingsOPCServer.NameServer      = editOPCServerForm.tb_NameServer.Text;
                 Program.sL.Save();
                 this.Bind();
             }
         }
         catch (System.Exception e2)
         {
             Program.showErrorMessage(e2, this);
         }
     }
 }