-
Notifications
You must be signed in to change notification settings - Fork 1
/
UploadPage.cs
202 lines (192 loc) · 7.35 KB
/
UploadPage.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
using System;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace DataArmor
{
public partial class UploadPage : Form
{
static public string csvPath = "";
static public string[] columnNames;
static public DataTable data=new DataTable();
public UploadPage()
{
InitializeComponent();
if (data.Rows.Count != 0)
{
Next.Visible = true;
dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.RowHeadersDefaultCellStyle.Font = new Font("Times New Roman", 15, FontStyle.Bold);
dataGridView1.RowHeadersDefaultCellStyle.ForeColor = Color.White;
dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.Black;
dataGridView1.Font = new Font("Times New Roman", 12, FontStyle.Bold);
dataGridView1.CellFormatting += DataGridView1_CellFormatting;
dataGridView1.BorderStyle = BorderStyle.FixedSingle;
dataGridView1.Visible = true;
dataGridView1.DataSource = data;
}
}
public void loadform(object Form)
{
if (this.mainloop2.Controls.Count > 0)
this.mainloop2.Controls.RemoveAt(0);
Form f = Form as Form;
f.FormBorderStyle = FormBorderStyle.None;
f.TopLevel = false;
f.Dock = DockStyle.Fill;
this.mainloop2.Controls.Clear();
this.mainloop2.Controls.Add(f);
this.mainloop2.Tag = f;
f.Show();
}
public void Column_name(ref string[] col_name)
{
string filePath = csvPath;
using (StreamReader reader = new StreamReader(filePath, Encoding.UTF8))
{
string headerLine = reader.ReadLine();
if (headerLine != null)
{
col_name = headerLine.Split(',');
}
}
}
private void upload1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Title = "Open CSV File",
Filter = "csv files (*.csv)|*.csv",
CheckFileExists = true,
CheckPathExists = true
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
// MessageBox.Show(openFileDialog.FileName);
csvPath = openFileDialog.FileName;
}
if (csvPath != "")
{
ClassificationPage.EID.Clear();
ClassificationPage.QID.Clear();
ClassificationPage.num_QID.Clear();
ClassificationPage.cat_QID.Clear();
ClassificationPage.SA.Clear();
Column_name(ref columnNames);
Next.Visible = true;
dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.RowHeadersDefaultCellStyle.Font = new Font("Times New Roman", 15, FontStyle.Bold);
dataGridView1.RowHeadersDefaultCellStyle.ForeColor = Color.White;
dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.Black;
dataGridView1.Font = new Font("Times New Roman", 12, FontStyle.Bold);
dataGridView1.CellFormatting += DataGridView1_CellFormatting;
dataGridView1.BorderStyle = BorderStyle.FixedSingle;
pictureBox5.Visible = false;
dataGridView1.Visible = true;
data = csv_Binding.csv_opening(csvPath);
dataGridView1.DataSource = data;
}
}
private void Next_Click(object sender, EventArgs e)
{
button1.BackColor = Color.FromArgb(155, 152, 190);
button1.ForeColor = Color.FloralWhite;
button2.BackColor = Color.FloralWhite;
button2.ForeColor = Color.FromArgb(155, 152, 190);
loadform(new ClassificationPage());
}
private void button1_Click(object sender, EventArgs e)
{
loadform(new UploadPage());
}
private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
dataGridView1.Columns[e.ColumnIndex].Width = 170;
}
private void button2_Click(object sender, EventArgs e)
{
if (csvPath.Length > 0)
{
if (ClassificationPage.num_QID != null)
{
loadform(new ClassificationPage());
}
else
{
loadform(new ClassificationPage());
}
}
else
{
MessageBox.Show("You must upload a file");
}
}
private void button3_Click(object sender, EventArgs e)
{
if (csvPath == "")
{
MessageBox.Show("You must upload a file");
}
else if ((ClassificationPage.num_QID == null|| ClassificationPage.num_QID.Count == 0)&& (ClassificationPage.cat_QID ==null || ClassificationPage.cat_QID.Count==0))
{
MessageBox.Show(text:"You Must Visit classification page");
}
else
{
loadform(new K_AnonymityPage( ));
}
}
private void DataArmor_Click(object sender, EventArgs e)
{
loadform(new DataArmor());
}
private void button4_Click(object sender, EventArgs e)
{
if (csvPath == "")
{
MessageBox.Show("You must upload a file");
}
else if (ClassificationPage.EID == null || ClassificationPage.EID.Count == 0)
{
MessageBox.Show("You Must Visit classification page");
}
else
{
}
}
private void button5_Click(object sender, EventArgs e)
{
if (csvPath == "")
{
MessageBox.Show("You must upload a file");
}
else if (ClassificationPage.EID == null || ClassificationPage.EID.Count == 0)
{
MessageBox.Show("You Must Visit classification page");
}
else
{
loadform(new de_identification1());
}
}
private void button6_Click(object sender, EventArgs e)
{
if (csvPath == "")
{
MessageBox.Show("You must upload a file");
}
else if ((ClassificationPage.num_QID == null || ClassificationPage.num_QID.Count == 0) && (ClassificationPage.cat_QID == null || ClassificationPage.cat_QID.Count == 0))
{
MessageBox.Show(text: "You Must Visit classification page");
}
else
{
loadform(new de_identification1());
}
}
}
}