Exemplo n.º 1
0
        private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView lb    = (ListView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            Db       Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");

            string[] res   = new string[10];
            int      count = 0;

            if (lb.Name == "listViewSHR_LR")
            {
                if (listViewSHR_LR.SelectedIndices.Count > 0)
                {
                    string SQL = "SELECT * FROM SHR_LR WHERE id = " + listViewSHR_LR.Items[listViewSHR_LR.SelectedIndices[0]].SubItems[2].Text;
                    Dbase.GetDB(SQL, ref res, ref count);
                    InputZNLR frm = new InputZNLR();
                    frm.Text = "Редактирование " + listViewSHR_LR.Items[listViewSHR_LR.SelectedIndices[0]].Text;
                    frm.OPC_Name_Text.Text        = res[0].Split((char)1)[1];
                    frm.OPC_Tag.Text              = res[0].Split((char)1)[2];
                    frm.checkBoxInversion.Checked = (res[0].Split((char)1)[3] == "1") ? true : false;

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        SQL = "UPDATE SHR_LR SET OPC_name = '" + frm.OPC_Name_Text.Text + "', OPC_Tag = '" + frm.OPC_Tag.Text + "', inversion = " + ((frm.checkBoxInversion.Checked) ? "1" : "0") +
                              " WHERE id = " + listViewSHR_LR.Items[listViewSHR_LR.SelectedIndices[0]].SubItems[2].Text;
                        //MessageBox.Show(SQL);
                        Dbase.AddToDB(SQL);
                        UpdateSHR_LR(this.Tag.ToString());
                    }
                }
            }
            else
            {
                if (listViewZN.SelectedIndices.Count > 0)
                {
                    string SQL = "SELECT * FROM ZN WHERE id = " + listViewZN.Items[listViewZN.SelectedIndices[0]].SubItems[2].Text;
                    Dbase.GetDB(SQL, ref res, ref count);
                    InputZNLR frm = new InputZNLR();
                    frm.Text = "Редактирование " + listViewZN.Items[listViewZN.SelectedIndices[0]].Text;
                    frm.OPC_Name_Text.Text        = res[0].Split((char)1)[1];
                    frm.OPC_Tag.Text              = res[0].Split((char)1)[2];;
                    frm.checkBoxInversion.Checked = (res[0].Split((char)1)[3] == "1") ? true : false;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        SQL = "UPDATE ZN SET OPC_name = '" + frm.OPC_Name_Text.Text + "', OPC_Tag = '" + frm.OPC_Tag.Text + "', inversion = " + ((frm.checkBoxInversion.Checked) ? "1" : "0") +
                              " WHERE id = " + listViewZN.Items[listViewZN.SelectedIndices[0]].SubItems[2].Text;
                        //MessageBox.Show(SQL);
                        Dbase.AddToDB(SQL);
                        UpdateZN(this.Tag.ToString());
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void buttonZN_Click(object sender, EventArgs e)
        {
            InputZNLR frm = new InputZNLR();

            frm.Text = "Добавление нового ЗН";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string SQL = "INSERT INTO ZN(OPC_name,  OPC_Tag, inversion, TC_id) VALUES('" + frm.OPC_Name_Text.Text + "', '" + frm.OPC_Tag.Text + "'," +
                             (frm.checkBoxInversion.Checked ? 1 : 0).ToString() + ", " + this.Tag.ToString() + ");";
                Db Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");
                Dbase.AddToDB(SQL);
                UpdateZN(this.Tag.ToString());
            }
        }
Exemplo n.º 3
0
        private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView lb = (ListView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;

            if (lb.Name == "listViewSHR_LR")
            {
                InputZNLR frm = new InputZNLR();
                frm.Text = "Добавление нового ШР/ЛР";
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    string SQL = "INSERT INTO SHR_LR(OPC_name,  OPC_Tag, inversion, TC_id) VALUES('" + frm.OPC_Name_Text.Text + "', '" + frm.OPC_Tag.Text + "'," +
                                 (frm.checkBoxInversion.Checked ? 1 : 0).ToString() + ", " + this.Tag.ToString() + ");";
                    MessageBox.Show(SQL);
                    Db Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");
                    if (!Dbase.AddToDB(SQL))
                    {
                        MessageBox.Show("Error LR");
                    }
                    else
                    {
                        UpdateSHR_LR(this.Tag.ToString());
                    }
                }
            }
            else
            {
                InputZNLR frm = new InputZNLR();
                frm.Text = "Добавление нового ЗН";
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    string SQL = "INSERT INTO ZN(OPC_name,  OPC_Tag, inversion, TC_id) VALUES('" + frm.OPC_Name_Text.Text + "', '" + frm.OPC_Tag.Text + "'," +
                                 (frm.checkBoxInversion.Checked ? 1 : 0).ToString() + ", " + this.Tag.ToString() + ");";
                    Db Dbase = new Db("OPCLogger", "192.168.100.16", "sa", "dvddecrypter");
                    Dbase.AddToDB(SQL);
                    UpdateZN(this.Tag.ToString());
                }
            }
        }