private void dataGridViewStudentRecord_CellClick(object sender, DataGridViewCellEventArgs e) { int col = e.ColumnIndex, row = e.RowIndex; if (col == 5) { data.dayInfoList.Remove(currentStudentInfo[row]); currentStudentInfo.Remove(currentStudentInfo[row]); data.SaveChanges(); dataGridViewStudentRecord.Rows.Clear(); foreach (var rec in currentStudentInfo) { string date = rec.date.Day.ToString() + "/" + rec.date.Month.ToString() + "/" + rec.date.Year.ToString(); dataGridViewStudentRecord.Rows.Add(date, rec.mark, rec.absent == true ? "حاضر" : "غائب", rec.note); } } else if (col == 4) { tabControl.SelectedIndex = 8; currentEditInfo = currentStudentInfo[row]; checkBoxEditRecordAbsent.Checked = !currentEditInfo.absent; textBoxEditRecordMark.Text = currentEditInfo.mark.ToString(); textBoxEditRecordNote.Text = currentEditInfo.note; } }
private void buttonAbsentSave_Click(object sender, EventArgs e) { Groups group = data.groups.ToList()[comboBoxAbsentGroup.SelectedIndex]; List <Student> stus = data.students.Where(st => st.groupID == group.ID).ToList(); for (int i = 0; i < dataGridViewAbsent.Rows.Count; i++) { dayInformation info = new dayInformation(); info.date = dateTimePickerAbsent.Value; if (dataGridViewAbsent[1, i].Value != null) { info.mark = int.Parse(dataGridViewAbsent[1, i].Value.ToString()); } else { info.mark = 0; } if (dataGridViewAbsent[3, i].Value != null) { info.note = dataGridViewAbsent[3, i].Value.ToString(); } else { info.note = ""; } if (dataGridViewAbsent[2, i].Value != null) { info.absent = !bool.Parse(dataGridViewAbsent[2, i].Value.ToString()); } else { info.absent = true; } info.studentID = stus[i].ID; data.dayInfoList.Add(info); } data.SaveChanges(); MessageBox.Show("تم الحفظ"); }