Beispiel #1
0
        public static List <NormalInstituteRecord> ExportToList(DataTable table, bool all = false)
        {
            List <NormalInstituteRecord> list = new List <NormalInstituteRecord>();

            if (all)
            {
                foreach (DataRow row in table.Rows)
                {
                    NormalInstituteRecord record = new NormalInstituteRecord();
                    record.一级机构 = row["一级机构"] != null ? row["一级机构"].ToString() : null;
                    record.二级机构 = row["二级机构"] != null ? row["二级机构"].ToString() : null;
                    record.学科规范 = row["学科规范"] != null ? row["学科规范"].ToString() : null;
                    record.学院规范 = row["学院规范"] != null ? row["学院规范"].ToString() : null;
                    record.学校规范 = row["学校规范"] != null ? row["学校规范"].ToString() : null;
                    list.Add(record);
                }
            }
            else
            {
                foreach (DataRow row in table.Rows)
                {
                    if (row["学科规范"] != null && row["学科规范"].ToString().Trim().Length > 0)
                    {
                        NormalInstituteRecord record = new NormalInstituteRecord();
                        record.一级机构 = row["一级机构"] != null ? row["一级机构"].ToString() : null;
                        record.二级机构 = row["二级机构"] != null ? row["二级机构"].ToString() : null;
                        record.学科规范 = row["学科规范"] != null ? row["学科规范"].ToString() : null;
                        record.学院规范 = row["学院规范"] != null ? row["学院规范"].ToString() : null;
                        record.学校规范 = row["学校规范"] != null ? row["学校规范"].ToString() : null;
                        list.Add(record);
                    }
                }
            }
            return(list);
        }
Beispiel #2
0
        public static List <NormalInstituteRecord> ExportToList(DataGridView dgvInstituteDataTable)
        {
            List <NormalInstituteRecord> list = new List <NormalInstituteRecord>();

            foreach (DataGridViewRow row in dgvInstituteDataTable.Rows)
            {
                if (row.Cells[2].Value != null && row.Cells[2].Value.ToString().Trim().Length > 0)
                {
                    NormalInstituteRecord record = new NormalInstituteRecord();
                    record.一级机构 = row.Cells[0].Value != null ? row.Cells[0].Value.ToString() : null;
                    record.二级机构 = row.Cells[1].Value != null ? row.Cells[1].Value.ToString() : null;
                    record.学科规范 = row.Cells[2].Value != null ? row.Cells[2].Value.ToString() : null;
                    record.学院规范 = row.Cells[3].Value != null ? row.Cells[3].Value.ToString() : null;
                    record.学校规范 = row.Cells[4].Value != null ? row.Cells[4].Value.ToString() : null;
                    list.Add(record);
                }
            }
            return(list);
        }