Example #1
0
        private void manageFilesButton_Click(object sender, EventArgs e)
        {
            FileManagementHub filePermissions = new FileManagementHub();

            filePermissions.Show();
            Hide();
        }
Example #2
0
        //public Boolean UpdateTextFileToDb(string textToUpdate, string fileName)
        //{
        //    byte[] fileBytes = null;
        //    Boolean success = false;
        //    using (MySqlConnection con = new MySqlConnection("server = 35.240.129.112; user id = asguarduser; database = da_schema"))
        //    {
        //        con.Open();
        //        try
        //        {
        //            fileBytes = File.ReadAllBytes(readFile);
        //            String executeQuery = "UPDATE da_schema.fileInfo SET file = @fileParam WHERE fileName = @fileName";
        //            MySqlCommand myCommand = new MySqlCommand(executeQuery, con);
        //            myCommand.Parameters.AddWithValue("@fileParam", fileBytes);
        //            myCommand.Parameters.AddWithValue("@fileName", fileName);
        //            myCommand.ExecuteNonQuery();
        //            success = true;
        //        }
        //        catch (IOException)
        //        {
        //            MessageBox.Show("Error file could not be read, please try again.");
        //            success = false;
        //        }
        //        con.Close();
        //    }

        //    //if (success)
        //    //{
        //    //    dblog.fileLog("File '" + fileName + "' uploaded to database.", "FileActions", Logininfo.userid.ToString(), Logininfo.email.ToString(), fileID.ToString());
        //    //}

        //    return success;
        //}

        private async void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Do you want to overwrite the existing file?", "Save File", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (StreamWriter sw = new StreamWriter(this.GetReadFile))
                {
                    await sw.WriteLineAsync(rtfBox.Text);

                    MessageBox.Show("File Saved!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                FileManagementHub fm = new FileManagementHub();
                fm.UpdateFileToDb(this.GetReadFile, this.GetSaveFile);
            }
            else if (dialogResult == DialogResult.No)
            {
                //do something else
            }
        }