private void Roll2_FormClosed(object sender, FormClosedEventArgs e) { if (checkBox1.Checked) { absence.Add(long.Parse(label1.Text)); cell.mark(long.Parse(label1.Text)); } if (checkBox2.Checked) { absence.Add(long.Parse(label3.Text)); cell.mark(long.Parse(label3.Text)); } if (thd1 != null) { if (thd1.IsAlive) { thd1.Abort(); } } MainForm form1 = (MainForm)this.Owner; form1.Visible = true; form1.absset(absence); cell.settime(); Random.clear(); cell.save(); this.pictureBox1.Dispose(); this.pictureBox2.Dispose(); }
private void button1_Click(object sender, EventArgs e) { ArrayList abssttdbydate = new ArrayList(); if (dateselect.CheckedItems.Count != 0) { int first = dateselect.CheckedIndices[0]; int last = dateselect.CheckedIndices.IndexOf(dateselect.CheckedIndices.Count - 1); if ((last - first) >= dateselect.CheckedItems.Count) { MessageBox.Show("暂只支持连续输出"); return; } foreach (ComboBoxItem date in dateselect.CheckedItems) { ArrayList absstdbysn = new ArrayList(); foreach (student st in cell.getabsstu((int)date.Value + 9, first, last)) { absstdbysn.Add(st); } if (absstdbysn.Count != 0) { abssttdbydate.Add(new KeyValuePair <ArrayList, KeyValuePair <String, int> >(absstdbysn, new KeyValuePair <String, int>(date.Text, dateselect.Items.IndexOf(date)))); } }//将旧表信息提取 Workbook workbook = cell.newworkbook(); cell = cell.newcells(workbook); int j = 1, k = 3; cell.setstr("序号", 1, 0); cell.setstr("学号", 1, 1); cell.setstr("姓名", 1, 2); cell.setstr("缺勤次数", 1, 3); foreach (KeyValuePair <ArrayList, KeyValuePair <String, int> > absstdbysns in abssttdbydate) { ArrayList absstdbysn = absstdbysns.Key; KeyValuePair <String, int> dates = absstdbysns.Value; cell.setstr("第" + (dates.Value + 1) + "次", 0, k + 1); cell.setstr(dates.Key, 1, k + 1); foreach (student st in absstdbysn) { if (cell.find(st.Sn) != null) { int temp = j; j = cell.find(st.Sn)[0]; cell.setstr(st.Serial.ToString(), j, 0); cell.setstr(st.Sn.ToString(), j, 1); cell.setstr(st.Name, j, 2); cell.setstr("缺勤", j, k + 1); j = temp; } else { j++; cell.setstr(st.Abs.ToString(), j, 3); cell.setstr(st.Serial.ToString(), j, 0); cell.setstr(st.Sn.ToString(), j, 1); cell.setstr(st.Name, j, 2); cell.setstr("缺勤", j, k + 1); } } k++; } k = 0; /*foreach (ComboBoxItem date in dateselect.CheckedItems) * { * cell.setstr(date.Text, 1, k+4); * k++; * }*/ cell.sort(3); cell.save(Application.StartupPath + "\\" + classname + "_点名记录.xls"); MessageBox.Show("导出成功"); cell.openfile(filePath); this.Close(); } else { MessageBox.Show("未选则输出日期"); } }