//签到功能 private void button5_Click(object sender, EventArgs e) { if (dataGridView4.CurrentRow == null) { return; } int clsid = Convert.ToInt32(dataGridView4.CurrentRow.Cells[0].Value); string ip = GetLocalIPAddress(); string time = DateTime.Now.ToString(); string status = "成功"; if ((int)SignManager.CheckSignUp(student.Id, clsid) == 0) { if (SignManager.SignUp(student, student.Name, clsid, ip, time, status)) { MessageBox.Show( "签到成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); Fill(); } else { MessageBox.Show("签到失败!请重新选择!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("该节课已签到!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//退课功能 private void button1_Click(object sender, EventArgs e) { int Cla; try { Cla = Convert.ToInt32(dataGridView2.CurrentRow.Cells[0].Value); Console.WriteLine(Cla); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (MessageBox.Show("确定要退课吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } if ((int)SignManager.CheckSignUp(student.Id, Cla) == 0) { if (CourseManager.DropCourse(Cla)) { MessageBox.Show( "退课成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); int num = Convert.ToInt32(dataGridView2.CurrentRow.Cells[7].Value) + 1; CourseManager.UpdateCourse(num, Cla); Fill(); } else { MessageBox.Show("该课程已有成绩,退课失败!请重新选择!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("已有签到记录,退课失败!请重新选择!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }