コード例 #1
0
        private void EditItem()
        {
            if (listView.SelectedItems.Count > 0)
            {
                FormRecord formRecord = new FormRecord();

                formRecord.addr     = listView.SelectedItems[0].Text;
                formRecord.login    = listView.SelectedItems[0].SubItems[1].Text;
                formRecord.password = (String)listView.SelectedItems[0].SubItems[2].Tag;

                var id = (String)listView.SelectedItems[0].Tag;

                if (formRecord.ShowDialog() == DialogResult.OK)
                {
                    var sql = String.Format(
                        "UPDATE [records]" + "" +
                        "  SET [equipment] = '{0}', [cabinet] = '{1}', [nameUser] = '{2}'" +
                        "  WHERE [rowid] = {3}",
                        formRecord.addr, formRecord.login, formRecord.password, id);

                    SQLiteCommand command = new SQLiteCommand(sql, connection);
                    command.ExecuteNonQuery();

                    UpdateList();
                }
            }
        }
コード例 #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormRecord formRecord = new FormRecord();

            if (formRecord.ShowDialog() == DialogResult.OK)
            {
                var sql = String.Format("INSERT INTO [records]([equipment], [cabinet], [nameUser]) VALUES ('{0}', '{1}', '{2}')",
                                        formRecord.addr, formRecord.login, formRecord.password);

                SQLiteCommand command = new SQLiteCommand(sql, connection);
                command.ExecuteNonQuery();

                UpdateList();
            }
        }