-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReview.cs
110 lines (91 loc) · 4 KB
/
Review.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ChoreAssigner
{
public partial class Review : Form
{
public Review()
{
InitializeComponent();
}
private void btnSetFileLocation_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
FileFormatting.FilePath = dialog.SelectedPath;
MessageBox.Show($"Location set to {FileFormatting.FilePath}");
}
}
private void Review_Load(object sender, EventArgs e)
{
Dictionary<string, string> randomChoresDict = EventList.RandomizeChores(EventListStorage.ToDo, EventListStorage.WorkerNames);
//need to add rewards prior to displaying
StringBuilder sb = new StringBuilder();
sb.AppendLine(EventList.DiplayRandomChores(randomChoresDict));
sb.AppendLine(EventList.DisplayApproveRewards(EventListStorage.EligibleRewards));
richTextBox1.Text =sb.ToString();
}
private void btn_Save_Draft_Click(object sender, EventArgs e)
{
string text=FileFormatting.FileFormat(txtEventTitle.Text, richTextBox1.Text,"DRAFT",monthCalendar1.SelectionStart.ToString("dd MMM yyyy")) ;
string path = "";
try
{
path = System.IO.Path.Combine(FileFormatting.FilePath, FileFormatting.FileNameConverter(txtEventTitle.Text + "_DRAFT"));
}
catch(Exception)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
FileFormatting.FilePath = dialog.SelectedPath;
MessageBox.Show($"Location set to {FileFormatting.FilePath}");
path = System.IO.Path.Combine(FileFormatting.FilePath, FileFormatting.FileNameConverter(txtEventTitle.Text + "_DRAFT"));
}
else if (result == DialogResult.Cancel)
{
return;
}
}
System.IO.File.WriteAllText($@"{path}.txt", text);
MessageBox.Show($"DRAFT File Created: {path}.txt");
}
private void btn_Approve_Save_Click(object sender, EventArgs e)
{
string text = FileFormatting.FileFormat(txtEventTitle.Text, richTextBox1.Text, "APPROVED", monthCalendar1.SelectionStart.ToString("dd MMM yyyy"));
string path = "";
try
{
path = System.IO.Path.Combine(FileFormatting.FilePath, FileFormatting.FileNameConverter(txtEventTitle.Text + "_APPROVED"));
}
catch (Exception)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
FileFormatting.FilePath = dialog.SelectedPath;
MessageBox.Show($"Location set to {FileFormatting.FilePath}");
path = System.IO.Path.Combine(FileFormatting.FilePath, FileFormatting.FileNameConverter(txtEventTitle.Text + "_APPROVED"));
}
else if (result == DialogResult.Cancel)
{
return;
}
}
System.IO.File.WriteAllText($@"{path}.txt", text);
MessageBox.Show($"APPROVED File Created: {path}.txt");
}
}
}