Beispiel #1
0
        private void tsmAddDocumentEntry_Click(object sender, EventArgs e)
        {
            ExtDocuments addDocForm = new ExtDocuments();

            if (addDocForm.ShowDialog() == DialogResult.OK)
            {
                SettingsPoke("DocEntry" + Guid.NewGuid(), Convert.ToBase64String(Encoding.UTF8.GetBytes(addDocForm.DocumentName)) + "|" + Convert.ToBase64String(Encoding.UTF8.GetBytes(addDocForm.DocumentPath)));
                ReloadDocuments();
            }
        }
Beispiel #2
0
        private void EditDocument(string pDocID)
        {
            confConnection.Open();
            confCmd.CommandText = $"SELECT * FROM Settings WHERE Key = '{pDocID}'";

            string docName = "";
            string docPath = "";

            using (SQLiteDataReader reader = confCmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    string[] docInfo = Convert.ToString(reader["Value"]).Split('|');

                    docName = Encoding.UTF8.GetString(Convert.FromBase64String(docInfo[0]));
                    docPath = Encoding.UTF8.GetString(Convert.FromBase64String(docInfo[1]));
                }
            }

            confConnection.Close();

            ExtDocuments editDoc = new ExtDocuments();

            editDoc.DocumentName = docName;
            editDoc.DocumentPath = docPath;

            if (editDoc.ShowDialog() == DialogResult.OK)
            {
                confConnection.Open();
                confCmd.CommandText = $"UPDATE Settings SET Value = '{Convert.ToBase64String(Encoding.UTF8.GetBytes(editDoc.DocumentName)) + "|" + Convert.ToBase64String(Encoding.UTF8.GetBytes(editDoc.DocumentPath))}' WHERE Key = '{pDocID}'";
                confCmd.ExecuteNonQuery();
                confConnection.Close();
            }

            ReloadDocuments();
        }