Example #1
0
        private void button_save_edit_planner_note_Click(object sender, EventArgs e)
        {
            int          count    = Form_main.number;
            StreamReader file     = new StreamReader(Form_main.file_name);
            StreamWriter new_file = new StreamWriter("new_note.txt", false);
            string       line;

            for (int i = 0; i < count; ++i)
            {
                while ((line = file.ReadLine()) != "---###---")
                {
                    new_file.WriteLine(line);
                }
                new_file.WriteLine(line);
            }

            new_file.WriteLine((textBox_title.Text).Replace(Environment.NewLine, " "));
            new_file.WriteLine((textBox_date.Text).Replace(Environment.NewLine, " "));
            new_file.WriteLine((dateTimePicker_deadline.Text).Replace(Environment.NewLine, " "));
            new_file.WriteLine((richTextBox_text.Text).Replace(Environment.NewLine, " "));
            new_file.WriteLine("---###---");

            while ((line = file.ReadLine()) != "---###---")
            {
            }
            while (!file.EndOfStream)
            {
                line = file.ReadLine();
                new_file.WriteLine(line);
            }
            new_file.Close();

            file.Close();
            StreamWriter file_edit     = new StreamWriter(Form_main.file_name, false);
            StreamReader new_file_edit = new StreamReader("new_note.txt");

            while (!new_file_edit.EndOfStream)
            {
                line = new_file_edit.ReadLine();
                file_edit.WriteLine(line);
            }
            file_edit.Close();
            new_file_edit.Close();
            File.Delete("new_note.txt");
            MessageBox.Show(this, "Заметка успешно отредактирована", "Редактирование заметки", MessageBoxButtons.OK, MessageBoxIcon.None);
            this.Hide();
            Form_main form = new Form_main();

            form.Show();
        }
Example #2
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show(this, "Вы действительно хотите удалить заметку?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialog == DialogResult.Yes)
            {
                int          count    = Form_main.number;
                StreamReader file     = new StreamReader(Form_main.file_name);
                StreamWriter new_file = new StreamWriter("new_note.txt", false);
                string       line;
                for (int i = 0; i < count; ++i)
                {
                    while ((line = file.ReadLine()) != "---###---")
                    {
                        line = file.ReadLine();
                        new_file.WriteLine(line);
                    }
                }

                while ((line = file.ReadLine()) != "---###---")
                {
                }
                while (!file.EndOfStream)
                {
                    line = file.ReadLine();
                    new_file.WriteLine(line);
                }
                new_file.Close();
                file.Close();
                StreamWriter file_edit     = new StreamWriter(Form_main.file_name, false);
                StreamReader new_file_edit = new StreamReader("new_note.txt");
                while (!new_file_edit.EndOfStream)
                {
                    line = new_file_edit.ReadLine();
                    file_edit.WriteLine(line);
                }
                file_edit.Close();
                new_file_edit.Close();
                --Form_main.count_notes;
            }
            MessageBox.Show(this, "Заметка успешно удалена", "Удаление заметки", MessageBoxButtons.OK, MessageBoxIcon.None);
            this.Hide();
            Form_main form = new Form_main();

            form.Show();
        }
Example #3
0
        private void button_save_planner_Click(object sender, EventArgs e)
        {
            ++Form_main.count_planner;
            StreamWriter sw = new StreamWriter("new_note.txt", false, Encoding.UTF8);

            sw.WriteLine(textBox_title.Text);
            sw.WriteLine(textBox_date.Text);
            sw.WriteLine(dateTimePicker_deadline.Text);
            sw.WriteLine(richTextBox_text.Text);
            sw.WriteLine("---###---");
            textBox_title.Text    = "";
            richTextBox_text.Text = "";
            StreamReader file = new StreamReader(Form_main.file_name, Encoding.UTF8);
            string       line;

            while (!file.EndOfStream)
            {
                line = file.ReadLine();
                sw.WriteLine(line);
            }
            sw.Close();
            file.Close();
            StreamWriter new_file      = new StreamWriter(Form_main.file_name, false, Encoding.UTF8);
            StreamReader new_edit_file = new StreamReader("new_note.txt", Encoding.UTF8);

            while (!new_edit_file.EndOfStream)
            {
                line = new_edit_file.ReadLine();
                new_file.WriteLine(line);
            }
            new_file.Close();
            new_edit_file.Close();
            File.Delete("new_note.txt");
            this.Hide();
            Form_main form = new Form_main();

            form.Show();
        }
Example #4
0
        private void Planner_note_closed(object sender, FormClosedEventArgs e)
        {
            Form_main form = new Form_main();

            form.Show();
        }
Example #5
0
        private void Form_main_Closed(object sender, FormClosedEventArgs e)
        {
            Form_main form = new Form_main();

            form.Show();
        }