Exemplo n.º 1
0
        private void FrmNhanVien_Load(object sender, EventArgs e)
        {
            model = new NhanVienModel();
            model.setControl(dataGridView1, lblMessage);

            TreeNode nodefirst = new TreeNode("Tất Cả");

            nodefirst.Tag = "0";

            tvPhongBan.Nodes.Add(nodefirst);
            nodefirst     = new TreeNode("Tất Cả");
            nodefirst.Tag = "0";
            tvChucVu.Nodes.Add(nodefirst);

            List <DataItem> lpb = model.getList("select MAPB,TEN_PB from PHONG_BAN order by TEN_PB");

            foreach (DataItem item in lpb)
            {
                TreeNode node = new TreeNode(item.Name);
                node.Tag = item.Value;


                tvPhongBan.Nodes.Add(node);
            }



            lpb.Clear();

            List <DataItem> lcv = model.getList("select MACV,TEN_CV from CHUC_VU order by TEN_CV");

            foreach (DataItem item in lcv)
            {
                TreeNode node = new TreeNode(item.Name);
                node.Tag = item.Value;


                tvChucVu.Nodes.Add(node);
            }

            lcv.Clear();

            LoadDataToCombobox(cbbDanToc, "select MADT,TEN_DT from DAN_TOC");
            LoadDataToCombobox(cbbTonGiao, "select MATG,TEN_TG from TON_GIAO");
            LoadDataToCombobox(cbbTrinhDo, "select MAHV,TENHV+'('+CHUYEN_NGANH+')' as TEN from HOC_VAN");
            LoadDataToCombobox(cbbPhong, "select MAPB,TEN_PB from PHONG_BAN");
            LoadDataToCombobox(cbbChucVu, "select MACV,TEN_CV+'('+substring(convert(varchar(15),cast(PHU_CAP as money),-1),0,LEN(convert(varchar(15),cast(PHU_CAP as money),-1))-2)+')' as TEN from CHUC_VU");
            LoadDataToCombobox(cbbLuong, "select BACLUONG,substring(convert(varchar(15),cast(LUONG_CO_BAN as money),-1),0,LEN(convert(varchar(15),cast(LUONG_CO_BAN as money),-1))-2) as luong from LUONG");

            tableTN = model.getDataThanNhan();
            dataGridView2.DataSource = tableTN;

            model.getAllData();

            HiddenColumnGridView();

            model.ShowDetail(ShowDetail);

            ShowDetail(dataGridView1.CurrentRow);

            foreach (Control ct in groupBox4.Controls)
            {
                if (ct is TextBox || ct is RichTextBox || ct is ComboBox)
                {
                    ct.KeyPress += new KeyPressEventHandler(ct_KeyPress);
                }
            }

            EnableButton(false);
        }