Exemplo n.º 1
0
        /// <summary>
        /// Khởi tạo dữ liệu cho ChecedComboBoxEdit
        /// </summary>
        /// <param name="ckb">CheckedComboBoxEdit càn khởi tạo</param>
        /// <param name="checkMode">ChecState: check hay không</param>
        /// <param name="loai">LoaiDuLieu cần khởi tạo</param>
        public static void InitCheckedComboBoxEdit(CheckedComboBoxEdit ckb, CheckState checkMode, LoaiDuLieu loai, string ma_truong)
        {
            ckb.Properties.NullText             = "(Chưa chọn)";
            ckb.Properties.SelectAllItemCaption = "[Tất cả]";
            ckb.Properties.TextEditStyle        = TextEditStyles.Standard;
            ckb.Properties.Items.Clear();

            List <CheckedListBoxItem> _list = new List <CheckedListBoxItem>();

            switch (loai)
            {
            case LoaiDuLieu.Bac_LoaiHinh:
                VList <ViewBacDaoTaoLoaiHinh> _vListBacDaoTaoLoaiHinh = DataServices.ViewBacDaoTaoLoaiHinh.GetAll();
                _vListBacDaoTaoLoaiHinh.Sort("MaBacLoaiHinh");
                foreach (ViewBacDaoTaoLoaiHinh v in _vListBacDaoTaoLoaiHinh)
                {
                    _list.Add(new CheckedListBoxItem(v.MaBacLoaiHinh, v.TenBacLoaiHinh, checkMode, true));
                }
                break;

            case LoaiDuLieu.HocHam:
                TList <HocHam> _tListHocHam;
                _tListHocHam = DataServices.HocHam.GetAll();
                foreach (HocHam hh in _tListHocHam)
                {
                    _list.Add(new CheckedListBoxItem(hh.MaHocHam, hh.TenHocHam, checkMode, true));
                }
                break;

            case LoaiDuLieu.KhoaDonVi:
                VList <ViewKhoa> _vListKhoa;
                _vListKhoa = DataServices.ViewKhoa.GetAll();
                _vListKhoa.Sort("TenKhoa");
                foreach (ViewKhoa v in _vListKhoa)
                {
                    _list.Add(new CheckedListBoxItem(v.MaKhoa, v.TenKhoa, checkMode, true));
                }
                break;

            case LoaiDuLieu.NgachLuong:
                TList <NgachCongChuc> _tListNgachCongChuc;
                _tListNgachCongChuc = DataServices.NgachCongChuc.GetAll();
                foreach (NgachCongChuc ngach in _tListNgachCongChuc)
                {
                    _list.Add(new CheckedListBoxItem(ngach.MaQuanLy, ngach.TenNgach, checkMode, true));
                }
                break;

            default:
                return;
            }

            ckb.Properties.Items.AddRange(_list.ToArray());
            ckb.Properties.SeparatorChar = ';';
        }
Exemplo n.º 2
0
        public static void Init(RepositoryItemCheckedComboBoxEdit repo, CheckState check, LoaiDuLieu loai)
        {
            repo.SelectAllItemCaption = "[Tất cả]";
            repo.TextEditStyle        = TextEditStyles.Standard;
            repo.Items.Clear();
            List <CheckedListBoxItem> _list = new List <CheckedListBoxItem>();

            _list.Add(new CheckedListBoxItem(-1, "[Không xét]"));

            switch (loai)
            {
            case LoaiDuLieu.BacDaoTao:
                VList <ViewBacDaoTao> _vBacDaoTao = new VList <ViewBacDaoTao>();
                _vBacDaoTao = DataServices.ViewBacDaoTao.GetAll();
                _vBacDaoTao.Sort("TenBacDaoTao");
                foreach (ViewBacDaoTao v in _vBacDaoTao)
                {
                    _list.Add(new CheckedListBoxItem(v.MaBacDaoTao, v.TenBacDaoTao, check, true));
                }
                break;

            case LoaiDuLieu.ChucVu:
                TList <ChucVu> _tChucVu = new TList <ChucVu>();
                _tChucVu = DataServices.ChucVu.GetAll();
                _tChucVu.Sort("TenChucVu");
                foreach (ChucVu t in _tChucVu)
                {
                    _list.Add(new CheckedListBoxItem(t.MaChucVu, t.TenChucVu, check, true));
                }
                break;

            case LoaiDuLieu.HocHam:
                TList <HocHam> _tHocHam = new TList <HocHam>();
                _tHocHam = DataServices.HocHam.GetAll();
                _tHocHam.Sort("TenHocHam");
                foreach (HocHam t in _tHocHam)
                {
                    _list.Add(new CheckedListBoxItem(t.MaHocHam, t.TenHocHam, check, true));
                }
                break;

            case LoaiDuLieu.HocVi:
                TList <HocVi> _tHocVi = new TList <HocVi>();
                _tHocVi = DataServices.HocVi.GetAll();
                _tHocVi.Sort("TenHocVi");
                foreach (HocVi t in _tHocVi)
                {
                    _list.Add(new CheckedListBoxItem(t.MaHocVi, t.TenHocVi, check, true));
                }
                break;

            case LoaiDuLieu.HinhThucDangKy:
                TList <HinhThucDaoTao> _tHinhThucDangKy = new TList <HinhThucDaoTao>();
                _tHinhThucDangKy = DataServices.HinhThucDaoTao.GetAll();
                _tHinhThucDangKy.Sort("TenHinhThucDaoTao");
                foreach (HinhThucDaoTao t in _tHinhThucDangKy)
                {
                    _list.Add(new CheckedListBoxItem(t.MaHinhThucDaoTao, t.TenHinhThucDaoTao, check, true));
                }
                break;

            case LoaiDuLieu.LoaiGiangVien:
                TList <LoaiGiangVien> _tLoaiGiangVien = new TList <LoaiGiangVien>();
                _tLoaiGiangVien = DataServices.LoaiGiangVien.GetAll();
                _tLoaiGiangVien.Sort("TenLoaiGiangVien");
                foreach (LoaiGiangVien t in _tLoaiGiangVien)
                {
                    _list.Add(new CheckedListBoxItem(t.MaLoaiGiangVien, t.TenLoaiGiangVien, check, true));
                }
                break;

            case LoaiDuLieu.LoaiNhanVien:
                TList <LoaiNhanVien> _tLoaiNhanVien = new TList <LoaiNhanVien>();
                _tLoaiNhanVien = DataServices.LoaiNhanVien.GetAll();
                _tLoaiNhanVien.Sort("TenLoaiNhanVien");
                foreach (LoaiNhanVien t in _tLoaiNhanVien)
                {
                    _list.Add(new CheckedListBoxItem(t.MaLoaiNhanVien, t.TenLoaiNhanVien, check, true));
                }
                break;

            case LoaiDuLieu.NgachLuong:
                TList <NgachCongChuc> _tNgachCongChuc = new TList <NgachCongChuc>();
                _tNgachCongChuc = DataServices.NgachCongChuc.GetAll();
                _tNgachCongChuc.Sort("MaQuanLy");
                foreach (NgachCongChuc t in _tNgachCongChuc)
                {
                    _list.Add(new CheckedListBoxItem(t.MaQuanLy, t.MaQuanLy + " - " + t.TenNgach, check, true));
                }
                break;

            default:
                return;
            }

            repo.Items.AddRange(_list.ToArray());
            repo.SeparatorChar = ';';

            //Toàn bộ repo đều có chung kiểu Validate:
            repo.Validating += new System.ComponentModel.CancelEventHandler(repositoryItemCheckedComboBoxEditLoaiNhanVien_Validating);
        }