Пример #1
0
        private void loadDataGridView()
        {
            dgvDiemDanh.Columns.Clear();
            if (!string.IsNullOrEmpty(cboLop.Text))
            {
                string datetime = dtNgayDiemDanh.Value.ToString("yyyy-MM-dd");
                dgvDiemDanh.DataSource = DiemDanhBLL.LaySoDiemDanhLop(
                    LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                    datetime.Split(' ')[0]);

                TaoPhieuTrong();

                if (dgvDiemDanh.RowCount <= 0)
                {
                    lbThongBao.Text        = "Ngày " + dtNgayDiemDanh.Value.ToString("dd-MM-yyyy") + " chưa có điểm danh";
                    lbThongBao.Visible     = true;
                    btnLuuDiemDanh.Enabled = false;
                }
                else
                {
                    lbThongBao.Visible     = false;
                    btnLuuDiemDanh.Enabled = true;

                    for (int i = 0; i < dgvDiemDanh.RowCount; i++)
                    {
                        DataGridViewCheckBoxCell chkBoxCell = (DataGridViewCheckBoxCell)dgvDiemDanh.Rows[i].Cells["HienDienCheckbox"];
                        if (dgvDiemDanh.Rows[i].Cells["HienDien"].Value.ToString() == "1")
                        {
                            chkBoxCell.Value = "true";
                        }
                        else
                        {
                            chkBoxCell.Value = "false";
                        }
                    }
                }
            }
        }