-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
336 lines (285 loc) · 12.3 KB
/
MainForm.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
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 VISAP商科应用
{
public partial class MainForm : Form
{
public static MainForm S = null;
public RichTextBox rtb = new RichTextBox();
//建立一个RichTextBox,以便于绑定数据
public int ReportIsOn = 0;
//这个开关用于记录Report窗口是否被打开
//************************************************
//以下内容是为了数据的分页显示
public static int pageSize = 1000; //每页显示行数
public static int nMax = 0; //总记录数(最大记录数)
public static int pageCount = 0; //页数=总记录数/每页显示行数
public static int pageCurrent = 0; //当前页号
public static int nCurrent = 0; //当前记录行
public static DataTable MainDT = new DataTable();
//以上内容是为了数据的分页显示
//************************************************
public MainForm()
{
InitializeComponent();
S = this;
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
MainDT.Clear();
//dataGridView1.DataSource = null;
MainDT = Tabulation.NewTable(50, 15);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void 导入ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void excelToolStripMenuItem_Click(object sender, EventArgs e)
{
SelectExcel SelectForm = new SelectExcel();
SelectForm.ShowDialog();
}
private void csv文件ToolStripMenuItem_Click(object sender, EventArgs e)
{
/*DataTable dt = new DataTable();
dt = Tabulation.ImportCSV();
if (dt != null)
{
MainDT = dt;
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage,pageSize);
//Tabulation.DataType(dataGridView1);
}*/
ImportCSV CSVForm = new ImportCSV();
CSVForm.ShowDialog();
}
private void excelxlsToolStripMenuItem_Click(object sender, EventArgs e)
{
Tabulation.ExportExcel(MainDT);
}
private void csvcsvToolStripMenuItem_Click(object sender, EventArgs e)
{
Tabulation.ExportCSV(MainDT);
}
private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
MainDT.Clear();
dataGridView1.DataSource = null;
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int rowIndex = dataGridView1.CurrentCell.RowIndex;
//label_Row.Text = (rowIndex + 1).ToString();
label_CurrentPageRow.Text = (rowIndex + 1).ToString();
label_Row.Text = ((Convert.ToInt32(label_CurrentPage.Text)-1) * pageSize + (rowIndex + 1)).ToString();
int columnIndex = dataGridView1.CurrentCell.ColumnIndex;
label_Column.Text = (columnIndex + 1).ToString();
}
private void 汇总ToolStripMenuItem_Click(object sender, EventArgs e)
{
Summary SummaryForm = new Summary();
SummaryForm.Show();
}
private void 简单图表ToolStripMenuItem_Click(object sender, EventArgs e)
{
EasyGraph GraphForm = new EasyGraph();
GraphForm.Show();
}
private void 检测变量类型ToolStripMenuItem_Click(object sender, EventArgs e)
{
Tabulation.DataType(dataGridView1);
}
private void 批量导入csvToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void 缺失值处理ToolStripMenuItem_Click(object sender, EventArgs e)
{
NAOperation NAOperForm = new NAOperation();
NAOperForm.Show();
}
private void 参数估计ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void 报告ToolStripMenuItem_Click(object sender, EventArgs e)
{
Report ReportForm = new Report();
ReportForm.Show();
}
private void button_PreviousPage_Click(object sender, EventArgs e)
{
if (pageCurrent - 1 <= 0)
{
MessageBox.Show("已经是第一页,请点击“下页”查看!");
return;
}
else
{
pageCurrent--;
nCurrent = pageSize * (pageCurrent - 1);
}
Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax,
ref pageSize, ref nCurrent, textBox_CurrentPage,
label_CurrentPage, label_TotalPage, dataGridView1);
}
private void button_NextPage_Click(object sender, EventArgs e)
{
if (pageCurrent + 1 > pageCount)
{
MessageBox.Show("已经是最后一页,请点击“上页”查看!");
return;
}
else
{
pageCurrent++;
nCurrent = pageSize * (pageCurrent - 1);
}
Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax,
ref pageSize, ref nCurrent, textBox_CurrentPage,
label_CurrentPage, label_TotalPage, dataGridView1);
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
int Rows = e.RowIndex;
int Columns = e.ColumnIndex;
MainDT.Rows[20 * (pageCurrent - 1) + Rows][Columns] = dataGridView1.Rows[Rows].Cells[Columns].Value;
}
private void button_FirstPage_Click(object sender, EventArgs e)
{
pageCurrent = 1;
nCurrent = pageSize * (pageCurrent - 1);
Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax,
ref pageSize, ref nCurrent, textBox_CurrentPage,
label_CurrentPage, label_TotalPage, dataGridView1);
}
private void button_LastPage_Click(object sender, EventArgs e)
{
pageCurrent = pageCount;
nCurrent = pageSize * (pageCurrent - 1);
Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax,
ref pageSize, ref nCurrent, textBox_CurrentPage,
label_CurrentPage, label_TotalPage, dataGridView1);
}
private void button_Skip_Click(object sender, EventArgs e)
{
int SkipPage = Convert.ToInt32(textBox_CurrentPage.Text);
if (SkipPage > 0 && SkipPage <= pageCount){
pageCurrent = SkipPage;
nCurrent = pageSize * (pageCurrent - 1);
Tabulation.LoadData(MainDT, ref pageCurrent, ref pageCount, ref nMax,
ref pageSize, ref nCurrent, textBox_CurrentPage,
label_CurrentPage, label_TotalPage, dataGridView1);
}
}
private void 所有内容ToolStripMenuItem_Click(object sender, EventArgs e)
{
//将所有内容转置
MainDT = Tabulation.Transposition(MainDT, MainDT,true);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void 选中行ToolStripMenuItem_Click(object sender, EventArgs e)
{
//将选中行转置
MainDT = Tabulation.Transposition(Tabulation.GetChosenTable(MainDT,dataGridView1), MainDT);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void 选中行ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Tabulation.DeleteContent(ref MainDT, dataGridView1, 0);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void 选中列ToolStripMenuItem_Click(object sender, EventArgs e)
{
Tabulation.DeleteContent(ref MainDT, dataGridView1, 1);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void dataGridView1_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
{
//这个事件的设置是为了禁止自动排序
e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
private void 选中单元格ToolStripMenuItem_Click(object sender, EventArgs e)
{
Tabulation.DeleteCellContent(ref MainDT, dataGridView1);
Tabulation.InitDataSet(MainDT, ref nMax, ref pageCount, ref pageCurrent,
ref nCurrent, label_CurrentPage, label_TotalPage,
dataGridView1, textBox_CurrentPage, pageSize);
}
private void 分列ToolStripMenuItem_Click(object sender, EventArgs e)
{
//dataGridView1.DataSource = Tabulation.DataTableSplit(ref MainDT,new char[] {','},0);
Split SplitForm = new Split();
SplitForm.ShowDialog();
}
public static int ColumnNameChange = 0;
//ColumnNameChange用于记录修改的列号
private void dataGridView1_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
ColumnNameChange=e.ColumnIndex;
VariableSet VariableSetForm = new VariableSet();
VariableSetForm.ShowDialog();
}
private void 朴素贝叶斯ToolStripMenuItem_Click(object sender, EventArgs e)
{
NaiveBayesian NaiveBayesianForm = new NaiveBayesian();
NaiveBayesianForm.Show();
}
private void 多选题拆分ToolStripMenuItem_Click(object sender, EventArgs e)
{
MultipleChoice MCQ = new MultipleChoice();
MCQ.Show();
}
private void 单样本估计ToolStripMenuItem_Click(object sender, EventArgs e)
{
ParameterEstimation ParaForm = new ParameterEstimation();
ParaForm.Show();
}
private void 单样本检验ToolStripMenuItem_Click(object sender, EventArgs e)
{
HypothesisTesting HTForm = new HypothesisTesting();
HTForm.ShowDialog();
}
private void 相关系数ToolStripMenuItem_Click(object sender, EventArgs e)
{
Correlation CorForm = new Correlation();
CorForm.Show();
}
private void 多元线性回归ToolStripMenuItem_Click(object sender, EventArgs e)
{
Regression RegForm = new Regression();
RegForm.Show();
}
private void 多选题拆分ToolStripMenuItem1_Click(object sender, EventArgs e)
{
MultipleChoice MCQ = new MultipleChoice();
MCQ.Show();
}
private void 二项单选题ToolStripMenuItem_Click(object sender, EventArgs e)
{
Binomial BinoForm = new Binomial();
BinoForm.Show();
}
private void 多项单选题ToolStripMenuItem_Click(object sender, EventArgs e)
{
Multinomial MultinomialForm = new Multinomial();
MultinomialForm.Show();
}
}
}