private void btnTaoPhieuMoi_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult confirm = new DialogResult();
         if (dgvPhieuBeNgoan.RowCount > 0)
         {
             confirm = MessageBox.Show("Tháng này đã có dữ liệu. Bạn có chắc muốn xóa để tạo mới hoàn toàn?",
                                       "Cân nhắc", MessageBoxButtons.YesNo);
         }
         if (confirm == DialogResult.Yes || dgvPhieuBeNgoan.RowCount <= 0)
         {
             XoaPhieuCu();
             dgvPhieuBeNgoan.Columns.Clear();
             if (!string.IsNullOrEmpty(cboLop.Text))
             {
                 dgvPhieuBeNgoan.DataSource = PhieuBeNgoanBLL.TaoPhieuBeNgoanMoi(
                     LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                     dtThangLapPhieu.Text);
                 TaoPhieuTrong();
                 MessageBox.Show("Một phiếu mới hoàn toàn vừa được tạo", "Thông báo");
                 btnLuuPhieu.Enabled = true;
             }
         }
         else if (confirm == DialogResult.No)
         {
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi");
     }
 }
Exemple #2
0
        private void btnTaoBangMoi_Click(object sender, EventArgs e)
        {
            DialogResult confirm = new DialogResult();

            if (dgvDiemDanh.RowCount > 0)
            {
                confirm = MessageBox.Show("Ngày này đã có dữ liệu điểm danh. Bạn có chắc muốn xóa để tạo mới hoàn toàn?",
                                          "Cân nhắc", MessageBoxButtons.YesNo);
            }
            if (confirm == DialogResult.Yes || dgvDiemDanh.RowCount <= 0)
            {
                XoaPhieuCu();
                dgvDiemDanh.Columns.Clear();
                if (!string.IsNullOrEmpty(cboLop.Text))
                {
                    dgvDiemDanh.DataSource = DiemDanhBLL.TaoBangDiemDanhMoi(
                        LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                        dtNgayDiemDanh.Text);
                    TaoPhieuTrong();
                    MessageBox.Show("Một phiếu mới hoàn toàn vừa được tạo", "Thông báo");
                    btnLuuDiemDanh.Enabled = true;
                }
            }
            else if (confirm == DialogResult.No)
            {
                return;
            }
        }
        private void loadDataGridView()
        {
            dgvPhieuBeNgoan.Columns.Clear();
            if (!string.IsNullOrEmpty(cboLop.Text))
            {
                string datetime = dtThangLapPhieu.Text;
                dgvPhieuBeNgoan.DataSource = PhieuBeNgoanBLL.LayPhieuBeNgoanTheoLop(
                    LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                    datetime);
                TaoPhieuTrong();
                if (dgvPhieuBeNgoan.RowCount <= 0)
                {
                    lbThongBao.Text     = "Tháng " + dtThangLapPhieu.Value.ToString("MM-yyyy") + " chưa tạo phiếu bé ngoan";
                    btnLuuPhieu.Enabled = false;
                    lbThongBao.Visible  = true;
                }
                else
                {
                    lbThongBao.Visible  = false;
                    btnLuuPhieu.Enabled = true;

                    for (int i = 0; i < dgvPhieuBeNgoan.Rows.Count; i++)
                    {
                        for (int j = 1; j < 5; j++)
                        {
                            DataGridViewCheckBoxCell chkBoxCell = (DataGridViewCheckBoxCell)dgvPhieuBeNgoan.Rows[i].Cells["cbPhieu" + j];
                            if (dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan" + j].Value.ToString() == "1")
                            {
                                chkBoxCell.Value = "true";
                            }
                            else
                            {
                                chkBoxCell.Value = "false";
                            }
                        }
                        if (dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanThang"].Value.ToString() == "1")
                        {
                            dgvPhieuBeNgoan.Rows[i].Cells["cbPhieuThang"].Value = "true";
                        }
                        else
                        {
                            dgvPhieuBeNgoan.Rows[i].Cells["cbPhieuThang"].Value = "false";
                        }
                    }
                }
            }
            //(dgvPhieuBeNgoan as DataGridView).CellClick
            //                += new DataGridViewCellEventHandler(cb_CheckedChange);
        }
Exemple #4
0
 // Có thêm ngày bắt đầu & ngày kết thúc là để khởi tạo thông tin sức khoẻ
 void XepLop(List <string> listMaTre, string maLop, DateTime ngayBatDau, DateTime ngayKetThuc)
 {
     if (TreBLL.XepLop(listMaTre, maLop))
     {
         KhoiTaoSucKhoe(listMaTre, ngayBatDau, ngayKetThuc);
         KhoiTaoHocPhi(listMaTre, ngayBatDau, ngayKetThuc);
         LoadDGVDanhSach();
         LoadDGVKetQua();
         MessageBox.Show("Thêm " + listMaTre.Count + " trẻ vào lớp " +
                         LopBLL.GetInfoLop(maLop).TenLop +
                         " thành công!",
                         "Thông báo",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
Exemple #5
0
        void LoadDGVKetQua()
        {
            if (cboLop.SelectedItem != null)
            {
                string maLop = KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString());
                dgvKetQua.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(maLop));

                dgvKetQua.Columns[2].HeaderText = "Họ tên trẻ";
                dgvKetQua.Columns[3].HeaderText = "Ngày sinh";
                dgvKetQua.Columns[9].HeaderText = "Mã tình trạng";

                dgvKetQua.Columns[0].Width = 50;
                dgvKetQua.Columns[2].Width = 140;
                dgvKetQua.Columns[3].Width = 120;
                dgvKetQua.Columns[9].Width = 120;

                for (int i = 0; i < dgvKetQua.Rows.Count; i++)
                {
                    dgvKetQua.Rows[i].Cells[0].Value = i + 1;
                    string maTinhTrang = dgvKetQua.Rows[i].Cells[9].Value.ToString().Trim();

                    if (string.Compare(maTinhTrang, "0") == 0)
                    {
                        dgvKetQua.Rows[i].Cells[9].Value             = "Đang học";
                        dgvKetQua.Rows[i].DefaultCellStyle.BackColor = Color.AliceBlue;
                    }
                    else if (string.Compare(maTinhTrang, "1") == 0)
                    {
                        dgvKetQua.Rows[i].Cells[9].Value             = "Đã lên lớp";
                        dgvKetQua.Rows[i].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
                    }
                    else
                    {
                        dgvKetQua.Rows[i].Cells[9].Value             = "Đã thôi học";
                        dgvKetQua.Rows[i].DefaultCellStyle.BackColor = Color.HotPink;
                    }
                }
                string[] listProp = { "STT", "HoTenTre", "NgaySinh", "MaTinhTrang" };
                ControlFormat.DataGridViewFormat(dgvKetQua, listProp);
            }
        }
Exemple #6
0
        // Trẻ có lớp rồi -> chuyển lớp
        void ChuyenLop(List <string> listMaTre, string maLop, string maLopCu)
        {
            if (string.Compare(maLop, maLopCu) != 0)
            {
                int treDuocChuyen      = 0;
                int treKhongDuocChuyen = 0;
                foreach (string maTre in listMaTre)
                {
                    if (ChuyenLop(maTre, maLop, maLopCu))
                    {
                        treDuocChuyen++;
                    }
                    else
                    {
                        treKhongDuocChuyen++;
                    }
                }

                if (treKhongDuocChuyen > 0)
                {
                    MessageBox.Show("Không chuyển được lớp cho " + treKhongDuocChuyen + " trẻ, vì không còn học trong lớp!",
                                    "Thông báo",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }

                if (treDuocChuyen > 0)
                {
                    LoadDGVDanhSach();
                    LoadDGVKetQua();

                    MessageBox.Show("Chuyển " + treDuocChuyen + " trẻ vào lớp " +
                                    LopBLL.GetInfoLop(maLop).TenLop +
                                    " thành công!",
                                    "Thông báo",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
Exemple #7
0
        // Có thêm ngày bắt đầu & ngày kết thúc là để khởi tạo thông tin sức khoẻ
        void LenLop(List <string> listMaTre, string maLop, string maLopCu, DateTime ngayBatDau, DateTime ngayKetThuc)
        {
            int treDuocChuyen      = 0;
            int treKhongDuocChuyen = 0;

            foreach (string maTre in listMaTre)
            {
                if (LenLop(maTre, maLop, maLopCu))
                {
                    KhoiTaoSucKhoe(maTre, ngayBatDau, ngayKetThuc);
                    KhoiTaoHocPhi(maTre, ngayBatDau, ngayKetThuc);
                    treDuocChuyen++;
                }
                else
                {
                    treKhongDuocChuyen++;
                }
            }

            if (treKhongDuocChuyen > 0)
            {
                MessageBox.Show("Không lên lớp được cho " + treKhongDuocChuyen + " trẻ, vì không còn học trong lớp!",
                                "Thông báo",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }

            if (treDuocChuyen > 0)
            {
                LoadDGVDanhSach();
                LoadDGVKetQua();

                MessageBox.Show("Chuyển " + treDuocChuyen + " trẻ lên lớp " +
                                LopBLL.GetInfoLop(maLop).TenLop +
                                " thành công!",
                                "Thông báo",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Exemple #8
0
 void ThoiHoc(List <string> listMaTre, string maLop)
 {
     if (TreBLL.ThoiHoc(listMaTre, maLop))
     {
         if (listMaTre.Count > 0)
         {
             MessageBox.Show("Thôi học " + listMaTre.Count + " trẻ trong lớp " +
                             LopBLL.GetInfoLop(maLop).TenLop +
                             " thành công!",
                             "Thông báo",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Không thể thôi học trẻ đang không học ở lớp " + LopBLL.GetInfoLop(maLop).TenLop,
                         "Thông báo",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Warning);
     }
 }
Exemple #9
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";
                        }
                    }
                }
            }
        }
Exemple #10
0
        private void loadDataGirdView()
        {
            if (string.IsNullOrEmpty(cboLop.Text) && string.IsNullOrEmpty(txtKeyWord.Text) && !chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre();
            }
            else if (string.IsNullOrEmpty(cboLop.Text) && !string.IsNullOrEmpty(txtKeyWord.Text) && !chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(null, txtKeyWord.Text.Trim());
            }
            else if (!string.IsNullOrEmpty(cboLop.Text) && string.IsNullOrEmpty(txtKeyWord.Text) && !chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())));
            }
            else if (string.IsNullOrEmpty(cboLop.Text) && string.IsNullOrEmpty(txtKeyWord.Text) && chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(null, null, rdoTimKiem_Nam.Checked ? "1" : "0");
            }
            else if (!string.IsNullOrEmpty(cboLop.Text) && string.IsNullOrEmpty(txtKeyWord.Text) && chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                                                         null,
                                                         rdoTimKiem_Nam.Checked ? "1" : "0");
            }
            else if (string.IsNullOrEmpty(cboLop.Text) && !string.IsNullOrEmpty(txtKeyWord.Text) && chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(null,
                                                         txtKeyWord.Text.Trim(),
                                                         rdoTimKiem_Nam.Checked ? "1" : "0");
            }
            else if (!string.IsNullOrEmpty(cboLop.Text) && !string.IsNullOrEmpty(txtKeyWord.Text) && !chkTimTheoGioiTinh.Checked)
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())), txtKeyWord.Text);
            }
            else
            {
                dgvKetQua.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                                                         txtKeyWord.Text.Trim(),
                                                         rdoTimKiem_Nam.Checked ? "1" : "0");
            }

            dgvKetQua.Columns["MaTre"].DisplayIndex       = 0;
            dgvKetQua.Columns["HoTenTre"].DisplayIndex    = 1;
            dgvKetQua.Columns["NgaySinh"].DisplayIndex    = 2;
            dgvKetQua.Columns["GioiTinhCol"].DisplayIndex = 3;
            dgvKetQua.Columns["HoTenCha"].DisplayIndex    = 4;
            dgvKetQua.Columns["HoTenMe"].DisplayIndex     = 5;
            dgvKetQua.Columns["DiaChi"].DisplayIndex      = 6;
            dgvKetQua.Columns["SDTLienLac"].DisplayIndex  = 7;

            dgvKetQua.Columns["MaTre"].HeaderText      = "Mã trẻ";
            dgvKetQua.Columns["HoTenTre"].HeaderText   = "Họ tên trẻ";
            dgvKetQua.Columns["NgaySinh"].HeaderText   = "Ngày sinh";
            dgvKetQua.Columns["HoTenCha"].HeaderText   = "Họ tên cha";
            dgvKetQua.Columns["HoTenMe"].HeaderText    = "Họ tên mẹ";
            dgvKetQua.Columns["DiaChi"].HeaderText     = "Địa chỉ";
            dgvKetQua.Columns["SDTLienLac"].HeaderText = "SDT";

            dgvKetQua.Columns["MaTre"].Width      = 100;
            dgvKetQua.Columns["HoTenTre"].Width   = 150;
            dgvKetQua.Columns["NgaySinh"].Width   = 120;
            dgvKetQua.Columns["HoTenCha"].Width   = 150;
            dgvKetQua.Columns["HoTenMe"].Width    = 150;
            dgvKetQua.Columns["DiaChi"].Width     = 200;
            dgvKetQua.Columns["SDTLienLac"].Width = 100;

            string[] listProp = { "MaTre", "HoTenTre", "NgaySinh", "GioiTinhCol", "HoTenCha", "HoTenMe", "DiaChi", "SDTLienLac" };
            ControlFormat.DataGridViewFormat(dgvKetQua, listProp);
        }
 private void cboLop_SelectedIndexChanged(object sender, EventArgs e)
 {
     txtSiSo.Text = LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())).SiSo.ToString();
     LoadDataGirdView();
     ClearAllField();
 }
Exemple #12
0
        void LoadDGVDanhSach()
        {
            if (rdoXepLop.Checked)
            {
                switch (KeyHandle.GetKeyFromCombobox(cboDoTuoi.SelectedItem.ToString()))
                {
                case "mam":
                    dgvDanhSach.DataSource = TreBLL.GetListTreChuaCoLop(3, 4);
                    break;

                case "choi":
                    dgvDanhSach.DataSource = TreBLL.GetListTreChuaCoLop(4, 5);
                    break;

                case "la":
                    dgvDanhSach.DataSource = TreBLL.GetListTreChuaCoLop(5, 6);
                    break;
                }

                dgvDanhSach.Columns[1].HeaderText = "Họ tên trẻ";
                dgvDanhSach.Columns[2].HeaderText = "Ngày sinh";

                dgvDanhSach.Columns[0].Width = 50;
                dgvDanhSach.Columns[1].Width = 140;
                dgvDanhSach.Columns[2].Width = 120;

                for (int i = 0; i < dgvDanhSach.Rows.Count; i++)
                {
                    dgvDanhSach.Rows[i].Cells[0].Value = i + 1;
                }

                string[] listProp = { "STT", "HoTenTre", "NgaySinh" };
                ControlFormat.DataGridViewFormat(dgvDanhSach, listProp);
                txtSiSo_LuaChon.Text = "";
            }
            else
            {
                if (cboLopHoc_LuaChon.SelectedItem != null)
                {
                    string maLop = KeyHandle.GetKeyFromCombobox(cboLopHoc_LuaChon.SelectedItem.ToString());
                    dgvDanhSach.DataSource = TreBLL.GetListTre(LopBLL.GetInfoLop(maLop));

                    dgvDanhSach.Columns[1].HeaderText = "Họ tên trẻ";
                    dgvDanhSach.Columns[2].HeaderText = "Ngày sinh";
                    dgvDanhSach.Columns[9].HeaderText = "Mã tình trạng";

                    dgvDanhSach.Columns[0].Width = 50;
                    dgvDanhSach.Columns[1].Width = 140;
                    dgvDanhSach.Columns[2].Width = 120;
                    dgvDanhSach.Columns[9].Width = 120;

                    for (int i = 0; i < dgvDanhSach.Rows.Count; i++)
                    {
                        dgvDanhSach.Rows[i].Cells[0].Value = i + 1;
                        string maTinhTrang = dgvDanhSach.Rows[i].Cells[9].Value.ToString().Trim();

                        if (string.Compare(maTinhTrang, "0") == 0)
                        {
                            dgvDanhSach.Rows[i].Cells[9].Value             = "Đang học";
                            dgvDanhSach.Rows[i].DefaultCellStyle.BackColor = Color.AliceBlue;
                        }
                        else if (string.Compare(maTinhTrang, "1") == 0)
                        {
                            dgvDanhSach.Rows[i].Cells[9].Value             = "Đã lên lớp";
                            dgvDanhSach.Rows[i].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
                        }
                        else
                        {
                            dgvDanhSach.Rows[i].Cells[9].Value             = "Đã thôi học";
                            dgvDanhSach.Rows[i].DefaultCellStyle.BackColor = Color.HotPink;
                        }
                    }
                    string[] listProp = { "STT", "HoTenTre", "NgaySinh", "MaTinhTrang" };
                    ControlFormat.DataGridViewFormat(dgvDanhSach, listProp);
                }
            }
        }