/// <summary> /// Attendance_Load 폼 로드시 /// 1. DataGridView에 Column 추가 /// 2. SetData()호출 => LoadCounselingData() 호출 /// 3. DB에 있는 LoadCounselingData()에서 Binding 할 Data 가져오기 /// 4. 공통 코드 가져오는 메서드 GetCommonCode() /// 5. BindingComboBox()로 콤보박스에 공통코드 바인딩 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frnAttendance_Load(object sender, EventArgs e) { try { DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn(); col.Name = "chk"; col.HeaderText = ""; col.Width = 30; AttDataGridView.Columns.Add(col); Point headerCellLocation = AttDataGridView.GetCellDisplayRectangle(0, -1, true).Location; //헤더부분의 체크박스 headerCheckBox.Location = new Point(headerCellLocation.X + 8, headerCellLocation.Y + 2); headerCheckBox.Size = new Size(18, 18); headerCheckBox.BackColor = Color.Transparent; headerCheckBox.Click += HeaderCheckBox_Click; AttDataGridView.Controls.Add(headerCheckBox); //3 CommonUtil.SetInitGridView(AttDataGridView); CommonUtil.AddGridTextColumn(AttDataGridView, "출결 번호", "attendanceNum", 70, false); //index[1] CommonUtil.AddGridTextColumn(AttDataGridView, "학생ID", "stuID", 65); //index[2] CommonUtil.AddGridTextColumn(AttDataGridView, "이름", "stuName", 65); //3 CommonUtil.AddGridTextColumn(AttDataGridView, "강의코드", "lessonCode", 70); //4 CommonUtil.AddGridTextColumn(AttDataGridView, "출결날짜", "attendanceDate", 100); //5 CommonUtil.AddGridTextColumn(AttDataGridView, "입실 시간", "enteringTime", 100); //6 CommonUtil.AddGridTextColumn(AttDataGridView, "퇴실 시간", "entranceTime", 100); //7 CommonUtil.AddGridTextColumn(AttDataGridView, "지각 여부", "lateness", 75); //8 CommonUtil.AddGridTextColumn(AttDataGridView, "결석 여부", "absence", 75); //9 CommonUtil.AddGridTextColumn(AttDataGridView, "조퇴 여부", "early_Leave", 75); //10 CommonUtil.AddGridTextColumn(AttDataGridView, "기록사항", "recordContent", 10, false); //11 this.AttDataGridView.Font = new Font("나눔바른고딕", 10, FontStyle.Regular); SetData(); string[] codes = { "LessonType" }; MemberDB db = new MemberDB(); DataSet ds = db.GetCommonCode(codes); CommonUtil.BindingComboBox(comboBox1, ds.Tables["LessonType"], "lessonCode", "Code"); SetMemberText st = new SetMemberText(comboBox1.Text); } catch (Exception err) { throw err; } }
/// <summary> /// DataGridView 헤더 체크박스 클릭 이벤트 ☆★수정 필요☆★ /// 1. EndEdit()을 통해 현재 셀의 편집모드 종료(Commit) /// 2. foreach를 통해 체크/ 체크해제 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HeaderCheckBox_Click(object sender, EventArgs e) { try { AttDataGridView.EndEdit(); foreach (DataGridViewRow row in AttDataGridView.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells["chk"]; chk.Value = headerCheckBox.Checked; AttDataGridView.SelectAll(); } } catch (Exception err) { throw err; } }