private void btnDelectePunishment_Click(object sender, EventArgs e) { int success = 0; int error = 0; //判断是否选中行 if (dgvPunishments.SelectedRows.Count > 0) { //循环 foreach (DataGridViewRow row in dgvPunishments.SelectedRows) { string punishmentid = row.Cells[0].Value.ToString(); int i = StudentsInfoBLL.DeletePunishment(punishmentid); if (i > 0) { success++; } else { error++; } } int sum = success + error; MessageBox.Show("共操作了" + sum + "行;成功" + success + "行,失败" + error + "行!"); BinderPunishment(); } }
void BinderStudentInfo() { try { DataTable student = StudentsInfoBLL.GetStudentInfoByID(StudentID); if (student == null) { MessageBox.Show("没数据!"); return; } DataRow row = student.Rows[0]; string classid = row["Student_Class"].ToString(); DataTable students = StudentsInfoBLL.GetStudentsInfoByClassID(classid); DataRow stu = students.Rows[0]; this.labelName.Text = row["Student_Name"].ToString(); this.labelIDCardNum.Text = row["StudentCard"].ToString(); this.labelBirthday.Text = row["StudentBirthDay"].ToString(); this.labelEnterYear.Text = row["StudentEnterYear"].ToString(); this.labelNative.Text = row["StudentOrigin"].ToString(); this.labelHomeTel.Text = row["FamilyTel"].ToString(); this.labelHomeAdd.Text = row["StudentAddress"].ToString(); this.labelFlatTel.Text = row["DormTel"].ToString(); this.labelMobile.Text = row["Mobile"].ToString(); this.labelEmail.Text = row["Email"].ToString(); this.labStuType.Text = stu["SpeYears_Name"].ToString(); this.labelClass.Text = stu["Classes_Name"].ToString(); this.labelSpeciality.Text = stu["Speciality_Name"].ToString(); this.labelCollege.Text = stu["College_Name"].ToString(); if (row["Student_Sex"].ToString() == "男") { this.labelSex.Text = "男"; } else { this.labelSex.Text = "女"; } if (!string.IsNullOrEmpty(row["StudentNum"].ToString())) { labelStuID.Text = row["StudentNum"].ToString(); } else { labelStuID.Text = ""; } } catch (Exception) { throw; } }
private void toolStripButton4_Click(object sender, EventArgs e) { //获取学生ID if (lvStudentsInfo.SelectedItems.Count > 0) { int success = 0; int error = 0; foreach (ListViewItem item in lvStudentsInfo.SelectedItems) { string studentid = item.Name; //写删除方法 int i = StudentsInfoBLL.DeleteStudent(studentid); if (i > 0) { success++; } else { error++; } } //统计共执行多少行 int sum = success + error; MessageBox.Show("共操作了" + sum + "行;成功" + success + "行,失败" + error + "行!"); //清空listview选中行 lvStudentsInfo.Items.Clear(); } else { MessageBox.Show("请选择一行或多行!"); } }
void BinderPunishmentAwardType() { DataTable punishmentawardtype = StudentsInfoBLL.GetPunishmentAwardType(); cmbPunishmentType.DataSource = punishmentawardtype; cmbPunishmentType.DisplayMember = "PunishmentAwardTypes_Name"; cmbPunishmentType.ValueMember = "PunishmentAwardTypes_ID"; }
void BinderAwardType() { DataTable AwardType = StudentsInfoBLL.GetAwardType(); cmbAwardType.DataSource = AwardType; cmbAwardType.DisplayMember = "PunishmentAwardTypes_Name"; cmbAwardType.ValueMember = "PunishmentAwardTypes_ID"; }
void BinderChangeType() { DataTable changetype = StudentsInfoBLL.GetChangeType(); cmbChangeType.DataSource = changetype; cmbChangeType.DisplayMember = "ChangeTypes_Name"; cmbChangeType.ValueMember = "ChangeTypes_ID"; }
private void BinderStudents(string classid) { islock = true; DataTable students = StudentsInfoBLL.GetStudentByClassid(classid); cmbBoxName.DataSource = students; cmbBoxName.DisplayMember = "Student_Name"; cmbBoxName.ValueMember = "Student_ID"; islock = false; }
private void btnAddPunishment_Click(object sender, EventArgs e) { try { //获取id最小值 object obj = StudentsInfoBLL.GetMinPunishment(); int ii = Convert.ToInt32(obj); int id = -1; //表记录为空 if (obj == null) { id = -1; } //只有奖励,没有处分 if (Convert.ToInt32(obj) > -1) { id = -1; } else { id = ii - 1; } int Recode_ID = id; string Type_ID = cmbPunishmentType.SelectedValue.ToString(); string Content = cmbPunishmentType.Text; string Reason = txtPunishmentReason.Text; string Date = dateTimePunishment.Value.ToString(); int r = StudentsInfoBLL.InsertPunishment(id, Type_ID, StudentID, Content, Reason, Date); if (r > 0) { MessageBox.Show("成功!"); BinderPunishment(); } else { MessageBox.Show("失败!"); } } catch (Exception) { throw; } }
private void btnAddAward_Click(object sender, EventArgs e) { try { //获取id最大值 object obj = StudentsInfoBLL.GetMaxAward(); int id = 1; //最大值为空,数据表没记录 if (obj == null) { id = 1; } //只有处分,没有奖励 if (Convert.ToInt32(obj) < 1) { id = 1; } else { id = Convert.ToInt32(obj) + 1; } int Recode_ID = id; string Type_ID = cmbAwardType.SelectedValue.ToString(); string Content = txtAwardContent.Text; string Reason = txtAwardReason.Text; string Date = dateTimeAward.Value.ToString(); int r = StudentsInfoBLL.InsertAwards(id, Type_ID, StudentID, Content, Reason, Date); if (r > 0) { MessageBox.Show("成功!"); BinderAward(); } else { MessageBox.Show("失败!"); } } catch (Exception) { throw; } }
private void btnAddChange_Click(object sender, EventArgs e) { string typeid = cmbChangeType.SelectedValue.ToString(); string changedate = dateTimeChange.Value.ToString(); string studentid = StudentID; string changeReason = txtChangeReason.Text; int i = StudentsInfoBLL.InsertChange(typeid, changeReason, studentid, changedate); if (i > 0) { MessageBox.Show("成功!"); BinderChange(); } else { MessageBox.Show("失败!"); } }
private void cmbBoxName_SelectedIndexChanged_1(object sender, EventArgs e) { if (islock) { return; } //当选择学生后显示该学生的编号 string studentid = "0"; if (cmbBoxName.SelectedValue != null) { studentid = cmbBoxName.SelectedValue.ToString(); //根据学生id获取学生信息 DataTable student = StudentsInfoBLL.GetStudentInfoByID(studentid); if (student.Rows.Count > 0) { labelStuID.Text = student.Rows[0]["StudentNum"].ToString(); } else { labelStuID.Text = "0"; } } else { labelStuID.Text = "0"; } islock = false; //如果该学生已经录入成绩则显示成绩 DataTable scoredt = ScoreBLL.GetScoreByStudentid(studentid); for (int i = 0; i < scoredt.Rows.Count; i++) { Subject sj = (Subject)gbSubjects.Controls[i]; sj.txtScore.Text = scoredt.Rows[i]["ExamScore"].ToString(); //btnSubmit.Enabled = false; } }
/// <summary> /// 提交数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { if (!checkIsTextNULL()) { return; } Students s = new Students(); s.Student_Name = this.TxtBoxName.Text; s.Student_Sex = this.rdoBtnMale.Checked ? "男" : "女"; s.StudentClass = cmbBoxClass.SelectedValue.ToString(); s.StudentNum = cmbBoxClass.SelectedValue.ToString() + txtBoxStuID.Text; s.StudentEnterYear = dtpEnterYear.Value; s.StudentOrigin = txtBoxNative.Text; s.StudentBirthDay = dateTimePickerBirth.Value; s.StudentCard = txtBoxIDCardNum.Text; s.StudentAddress = txtBoxHomeAdd.Text; s.FamilyTel = txtBoxHomeTel.Text; s.DormTel = txtBoxflatTel.Text; s.Mobile = txtBoxEmail.Text; s.Email = txtBoxMobile.Text; bool b = StudentsInfoBLL.InsertStudentsInfo(s); if (b) { MessageBox.Show("成功"); this.Close(); } else { MessageBox.Show("失败"); } }
private void btnOK_Click(object sender, EventArgs e) { if (!checkIsTextNULL()) { return; } Students s = new Students(); s.StudentID = Convert.ToInt32(StudentID); s.Student_Name = this.txtBoxName.Text; s.Student_Sex = this.rdoBtnMale.Checked ? "男" : "女"; s.StudentClass = cmbBoxClass.SelectedValue.ToString(); s.StudentNum = cmbBoxClass.SelectedValue.ToString() + txtBoxNum.Text; s.StudentEnterYear = dateTimePickerDate.Value; s.StudentOrigin = txtBoxNative.Text; s.StudentBirthDay = dateTimePickerBirth.Value; s.StudentCard = txtBoxIDCardNum.Text; s.StudentAddress = txtBoxHomeAdd.Text; s.FamilyTel = txtBoxHomeTel.Text; s.DormTel = txtBoxflatTel.Text; s.Mobile = txtBoxEmail.Text; s.Email = txtBoxMobile.Text; int i = StudentsInfoBLL.UpdateStudentInfo(s); if (i > 0) { MessageBox.Show("成功!"); this.Close(); } else { MessageBox.Show("失败!"); } }
private void tvColleges_AfterSelect(object sender, TreeViewEventArgs e) { try { if (e == null) { return; } if (e.Node.Tag.ToString() == "Classes")//表示选中班级 { DataTable dt = StudentsInfoBLL.GetStudentsInfoByClassID(e.Node.Name); lvStudentsInfo.Items.Clear(); foreach (DataRow stu in dt.Rows) { ListViewItem lvi = new ListViewItem(); lvi.Text = stu["Student_Name"].ToString(); lvi.Name = stu["Student_ID"].ToString(); lvi.SubItems.Add(stu["StudentNum"].ToString()); lvi.SubItems.Add(stu["Student_Sex"].ToString()); lvi.SubItems.Add(stu["College_Name"].ToString()); lvi.SubItems.Add(stu["Speciality_Name"].ToString()); lvi.SubItems.Add(stu["StudentEnterYear"].ToString()); lvi.SubItems.Add(stu["SpeYears_Name"].ToString()); lvi.SubItems.Add(stu["StudentOrigin"].ToString()); lvStudentsInfo.Items.Add(lvi); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 学制 /// </summary> /// <param name="SpecialityID"></param> private void BinderSpeYears(string SpecialityID) { labStuID.Text = StudentsInfoBLL.GetSpeYearName(SpecialityID); }
private void BinderSpeYears(string SpecialityID) { LableBoxStuType.Text = StudentsInfoBLL.GetSpeYearName(SpecialityID); }
void BinderPunishment() { DataTable punishment = StudentsInfoBLL.GetPunishment(StudentID); dgvPunishments.DataSource = punishment; }
void BinderAward() { DataTable award = StudentsInfoBLL.GetAward(StudentID); dgvAwards.DataSource = award; }
void BinderChange() { DataTable change = StudentsInfoBLL.GetChange(StudentID); dgvChanges.DataSource = change; }
void BinderStudentInfo() { try { DataTable student = StudentsInfoBLL.GetStudentInfoByID(StudentID); if (student == null) { MessageBox.Show("没数据!"); return; } DataRow row = student.Rows[0]; this.txtBoxName.Text = row["Student_Name"].ToString(); this.txtBoxNum.Text = row["StudentNum"].ToString(); this.txtBoxIDCardNum.Text = row["StudentCard"].ToString(); this.txtBoxNative.Text = row["StudentOrigin"].ToString(); this.txtBoxHomeTel.Text = row["FamilyTel"].ToString(); this.txtBoxHomeAdd.Text = row["StudentAddress"].ToString(); this.txtBoxflatTel.Text = row["DormTel"].ToString(); this.txtBoxMobile.Text = row["Mobile"].ToString(); this.txtBoxEmail.Text = row["Email"].ToString(); /*DataTable dt=StudentsInfoBLL. * BinderColleges(); * BinderSpeciality(CollegeID); * BinderClasses(SpecialityID); * string classID=row["StudentClass"].ToString(); * if(cmbBoxCollege.Items.Count>0) * { * cmbBoxCollege.SelectedValue=college * }*/ if (row["Student_Sex"].ToString() == "男") { rdoBtnMale.Checked = true; } else { rdoBtnFemale.Checked = true; } if (!string.IsNullOrEmpty(row["StudentBirthDay"].ToString())) { this.dateTimePickerBirth.Value = (DateTime)row["StudentBirthDay"]; } else { this.dateTimePickerBirth.Value = DateTime.Now; } //学号 if (!string.IsNullOrEmpty(row["StudentNum"].ToString())) { string num = row["StudentNum"].ToString(); txtBoxNum.Text = num.Substring(num.Length - 4); } else { txtBoxNum.Text = ""; } if (!string.IsNullOrEmpty(row["StudentEnterYear"].ToString())) { this.dateTimePickerDate.Value = (DateTime)row["StudentEnterYear"]; } else { this.dateTimePickerDate.Value = DateTime.Now; } } catch (Exception ex) { throw new Exception(ex.Message); } }