Ejemplo n.º 1
0
        private void LoadData()
        {
            var        data = context.layDanhSachNhanVien();
            DataTable  dt   = new DataTable();
            DataColumn dc0  = new DataColumn("Mã", typeof(string));
            DataColumn dc1  = new DataColumn("Họ và tên", typeof(string));
            DataColumn dc2  = new DataColumn("Giới tính", typeof(string));
            DataColumn dc3  = new DataColumn("Ngày sinh", typeof(string));
            DataColumn dc4  = new DataColumn("Địa chỉ", typeof(string));
            DataColumn dc5  = new DataColumn("Số điện thoại", typeof(string));
            DataColumn dc6  = new DataColumn("Mã quản lí", typeof(string));
            DataColumn dc7  = new DataColumn("Mã chức vụ", typeof(string));

            dt.Columns.Add(dc0);
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            dt.Columns.Add(dc3);
            dt.Columns.Add(dc4);
            dt.Columns.Add(dc5);
            dt.Columns.Add(dc6);
            dt.Columns.Add(dc7);

            foreach (var item in data)
            {
                DataRow row = dt.NewRow();
                row[0] = item.ma.ToString().Trim();
                row[1] = item.ten.ToString().Trim();
                row[2] = item.gioitinh.ToString().Trim();
                row[3] = item.ngaysinh.ToString("dd/MM/yyyy").Trim();
                row[4] = item.diachi.ToString().Trim();
                row[5] = item.sodienthoai.ToString().Trim();
                if (item.maquanly == null)
                {
                    row[6] = "";
                }
                else
                {
                    row[6] = item.maquanly.ToString().Trim();
                }
                if (item.machucvu == null)
                {
                    row[7] = "";
                }
                else
                {
                    row[7] = item.machucvu.ToString().Trim();
                }

                dt.Rows.Add(row);
            }
            gridControl.DataSource = dt;
            gridView1.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[2].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[3].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[4].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[5].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[6].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns[7].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        }
Ejemplo n.º 2
0
        private void LoadNhanVien()
        {
            var danhSachNhanVien = context.layDanhSachNhanVien();

            foreach (var nv in danhSachNhanVien)
            {
                cboNVitem item = new cboNVitem();
                item.MaNV  = nv.ma.ToString().Trim();
                item.TenNV = nv.ten.ToString().Trim();

                cboMaNhanVien.Items.Add(item);
                cboTenNhanVien.Items.Add(nv.ten.ToString().Trim());
            }
        }