Exemplo n.º 1
0
        private void LoadData()
        {
            var        data = context.layDanhSachQuanLyNguoiDan();
            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("Dân tộc", typeof(string));
            DataColumn dc5  = new DataColumn("Tôn giáo", typeof(string));
            DataColumn dc6  = new DataColumn("Nghề nghiệp", typeof(string));
            DataColumn dc7  = new DataColumn("Số điện thoại", typeof(string));
            DataColumn dc8  = new DataColumn("Mã căn hộ", typeof(string));
            DataColumn dc9  = new DataColumn("Tầng", 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);
            dt.Columns.Add(dc8);
            dt.Columns.Add(dc9);
            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.dantoc.ToString().Trim();
                row[5] = item.tongiao.ToString().Trim();
                row[6] = item.nghenghiep.ToString().Trim();
                row[7] = item.sodienthoai.ToString().Trim();
                row[8] = item.macanho.ToString().Trim();
                row[9] = item.tang.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;
            gridView1.Columns[8].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        }