-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm3.cs
More file actions
115 lines (113 loc) · 4.09 KB
/
Form3.cs
File metadata and controls
115 lines (113 loc) · 4.09 KB
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
111
112
113
114
115
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace lil_JIRA
{
public partial class Form3 : Form
{
int user;
public Form3(int _user)
{
user = _user;
InitializeComponent();
}
private void button2_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
private void OnFocus3(object sender, EventArgs e)
{
textBox3.Text = "";
}
private void OnFocus4(object sender, EventArgs e)
{
textBox4.Text = "";
}
private void OnFocus5(object sender, EventArgs e)
{
textBox5.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
bool flag = true;
do
if (textBox3.Text == "not started" || textBox3.Text == "in work" || textBox3.Text == "done")
break;
else
{
textBox3.Text = "incorrect val";
flag = false;
break;
}
while (false);
for (int i = 0; i < textBox4.Text.Length; i++)
if (('0' < textBox4.Text[i] && '9' > textBox4.Text[i]) || textBox4.Text[i] == '.')
continue;
else
{
textBox4.Text = "incorrect val";
flag = false;
break;
}
do
if (textBox5.Text == "true" || textBox5.Text == "false")
{
break;
}
else
{
textBox5.Text = "incorrect val";
flag = false;
break;
}
while (false);
if (flag)
{
List<JObject> member_data = new List<JObject>();
string member_data_string;
int minLenInd = 0;
int minLenVal = 0;
for (int i = 1; i < 4; i++)
{
member_data.Add(JObject.Parse((string)File.ReadAllText("../../data/members/member" + i + ".json")));
if (i > 1)
{
if (member_data[i - 1]["tasks"].Count() < minLenVal)
{
minLenInd = i;
minLenVal = member_data[i - 1]["tasks"].Count();
}
}
else
{
minLenInd = i;
minLenVal = member_data[i-1]["tasks"].Count();
}
}
member_data_string = (string)File.ReadAllText("../../data/members/member" + minLenInd + ".json");
int index = member_data_string.IndexOf(']');
string newTask = ",{\"taskname\":\"" + (string)textBox1.Text +
"\",\"descr\":\"" + (string)textBox2.Text +
"\",\"status\":\"" + (string)textBox3.Text +
"\",\"time\":\"" + (string)textBox4.Text +
"\",\"priority\":\"" + (string)textBox5.Text + "\"}";
member_data_string = member_data_string.Insert(index, newTask);
StreamWriter file = new StreamWriter("../../data/members/member" + minLenInd + ".json", false, System.Text.Encoding.Default);
file.Write(member_data_string);
file.Close();
Form2 newForm = new Form2(user);
newForm.Show(this);
Hide();
}
}
private void button3_Click(object sender, EventArgs e)
{
Form2 newForm = new Form2(user);
newForm.Show(this);
Hide();
}
}
}