-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathANNOYINGGARBAGE
226 lines (164 loc) · 6.27 KB
/
ANNOYINGGARBAGE
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class JaredLynch : Form
{
DataSet dsXMLInput = new DataSet();
bool boolValue;
public JaredLynch()
{
InitializeComponent();
}
private void InitializeUI()
{
txtSourceFile.Text = "";
txtSourceFile.Enabled = false;
cboColumns.Enabled = false;
cboTables.Enabled = false;
txtValue.Enabled = false;
cboColumns.Text = "";
cboTables.Text = "";
txtValue.Text = "";
btnColumnsEdit.Enabled = false;
btnTablesEdit.Enabled = false;
btnSave.Enabled = false;
}
private void JaredLynch_Load(object sender, EventArgs e)
{
InitializeUI();
}
private void btnDone_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
InitializeUI();
//DataSet dsXMLInput = new DataSet();
OpenFileDialog browseFileDialog = new OpenFileDialog();
browseFileDialog.DefaultExt = "xml";
browseFileDialog.Filter = "XML File (*.xml) |*.xml|All Files (*.*)| (*.*)";
browseFileDialog.Title = "Please select source file:";
browseFileDialog.FileName = "";
if (browseFileDialog.ShowDialog() == DialogResult.OK)
{
if (browseFileDialog.FileName.Trim().IndexOf(".xml") != -1)
{
txtSourceFile.Text = browseFileDialog.FileName.Trim();
dsXMLInput.ReadXml(browseFileDialog.FileName.Trim());
}
else
{
MessageBox.Show(browseFileDialog.FileName + "\n does not appear to be a valid XML file.", "Invalid Source File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (txtSourceFile.Text != "")
{
cboTables.Enabled = true;
}
DataTableCollection Tables = dsXMLInput.Tables;
foreach (DataTable Table in Tables)
{
DataRowCollection TableRows = Table.Rows;
object[] objTableRows = new object[TableRows.Count];
TableRows.CopyTo(objTableRows, 0);
DataRow dr = (DataRow)objTableRows[0];
object[] RowValues = new object[dr.ItemArray.GetLength(0)];
RowValues = dr.ItemArray;
cboTables.Items.Add(Table.TableName);
//Below is failed attempts at making this work. lol
/*cboTables.DataSource = dsXMLInput.Tables[0];
cboTables.BindingContext = this.BindingContext;
cboTables.DisplayMember = dsXMLInput.Tables.ToString();*/
}
}
}
/* public void PopulateDataSet(ref DataSet dsXMLInput)
{
DataColumnCollection Columns = dsXMLInput.Tables.Columns;
foreach (DataColumn Column in Columns)
{
DataColumnCollection TableColumns = Table.Columns;
object[] objTableColumns = new object[TableColumns.Count];
TableColumns.CopyTo(objTableColumns, 0);
DataRow dr = (DataRow)objTableColumns[0];
object[] ColumnValues = new object[dr.ItemArray.GetLength(0)];
ColumnValues = dr.ItemArray;
cboColumns.Items.Add(Table.TableName);
}
}
*/
private void PopulateDataSet(ref DataSet dsXMLInput)
{
cboColumns.Items.Clear();
int intTableIndex = dsXMLInput.Tables.IndexOf(cboTables.Text);
DataColumnCollection Columns = dsXMLInput.Tables[intTableIndex].Columns;
foreach(DataColumn Column in Columns)
{
cboColumns.Items.Add(Column.ToString());
}
}
private void btnTablesEdit_Click(object sender, EventArgs e)
{
}
private void cboTables_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboTables.Text != "" && cboColumns.Text == "")
{
cboColumns.Enabled = true;
PopulateDataSet(ref dsXMLInput);
txtValue.Text = "";
}
else
{
cboColumns.Text = "";
cboColumns.Enabled = true;
txtValue.Enabled = false;
txtValue.Text = "";
}
}
private void cboColumns_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboColumns.Text != "" && txtValue.Text == "")
{
txtValue.Enabled = true;
int intTableIndex = dsXMLInput.Tables.IndexOf(cboTables.Text);
txtValue.Text = dsXMLInput.Tables[intTableIndex].Rows[0][cboColumns.Text].ToString();
}
else
{
txtValue.Text = "";
txtValue.Enabled = false;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.DefaultExt = "xml";
saveFileDialog.Filter = "XML File (*.xml) | *.xml|All Files (*.*)|(*.*)";
saveFileDialog.Title = "Save File As...";
saveFileDialog.FileName = "";
saveFileDialog.ShowDialog();
}
private void txtValue_TextChanged(object sender, EventArgs e)
{
if((txtValue.Enabled) && (boolValue == true))
{
btnSave.Enabled = true;
boolValue = false;
return;
}
else
{
boolValue = true;
}
}
}
}