예제 #1
0
 private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.MainView.SelectedItems[0].Text != "")
     {
         NewObj Editor = new NewObj(this.MainView.SelectedItems[0].Text, this.MainView.SelectedItems[0].SubItems[3].Text);
         if (Editor.ShowDialog() == DialogResult.OK)
         {
             Db     Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");
             string SQL   = @"UPDATE Objects SET ObjectName = '" + Editor.ObjectName.Text + "',  OPC_Name = '" + Editor.ObjectTag.Text + "', CurrentOPC = '" + Editor.ObjectCurrent.Text + "', QOPC = '" +
                            Editor.ObjectQ.Text + "', PowerOPC = '" + Editor.ObjectPower.Text + "', Inversion = " + ((Editor.Inversion.Checked == true) ? "1" : "0").ToString() +
                            ", Active = 1 WHERE ObjectName = '" + this.MainView.SelectedItems[0].Text + "'";
             //MessageBox.Show(SQL);
             if (!Dbase.AddToDB(SQL))
             {
                 MessageBox.Show("Ошибка изменения объекта");
             }
         }
     }
 }
예제 #2
0
        private void добавитьОбъектToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewObj frm = new NewObj();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Db     Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");
                string SQL   = "INSERT INTO Objects(ObjectName, OPC_Name, CurrentOPC, QOPC, PowerOPC, Inversion, Active) VALUES('" + frm.ObjectName.Text + "','" + frm.ObjectTag.Text + "', '" + frm.ObjectCurrent.Text +
                               "', '" + frm.ObjectQ.Text + "', '" + frm.ObjectPower.Text + "', " + ((frm.Inversion.Checked == true)? "1":"0") + ", 1)";
                //MessageBox.Show(SQL);
                if (!Dbase.AddToDB(SQL))
                {
                    MessageBox.Show("Ошибка добавления объекта");
                }
                else
                {
                    UpdateList();
                }
            }
        }