日期:2014-05-20 浏览次数:20923 次
Dim dt1 As New DataTable ' 编号 Dim id As DataColumn = New DataColumn() id.DataType = System.Type.GetType("System.String") id.ColumnName = "编号" dt1.Columns.Add(id) ' 姓名 Dim name As DataColumn = New DataColumn() name.DataType = System.Type.GetType("System.String") name.ColumnName = "姓名" dt1.Columns.Add(name) ' 性别 Dim sex As DataColumn = New DataColumn() sex.DataType = System.Type.GetType("System.String") sex.ColumnName = "性别" dt1.Columns.Add(sex) ' 医生 Dim doctor As DataColumn = New DataColumn() doctor.DataType = System.Type.GetType("System.String") doctor.ColumnName = "医生" dt1.Columns.Add(doctor) ' 项目 Dim project As DataColumn = New DataColumn() project.DataType = System.Type.GetType("System.String") project.ColumnName = "项目" dt1.Columns.Add(project) ' 疗程 Dim time As DataColumn = New DataColumn() time.DataType = System.Type.GetType("System.String") time.ColumnName = "疗程" dt1.Columns.Add(time) ' 检查费 Dim examineMoney As DataColumn = New DataColumn() examineMoney.DataType = System.Type.GetType("System.Double") examineMoney.ColumnName = "检查费" dt1.Columns.Add(examineMoney) ' 中药费 Dim midMoney As DataColumn = New DataColumn() midMoney.DataType = System.Type.GetType("System.Double") midMoney.ColumnName = "中药费" dt1.Columns.Add(midMoney) Dim ds As New DataSet ds.ReadXml(New System.Xml.XmlTextReader("C:\Documents and Settings\0122bl\デスクトップ\test.xml")) For i As Integer = 0 To ds.Tables(0).Rows.Count - 1 dt1.Rows.Add(ds.Tables(0).Rows(i).ItemArray) Next '查询条件:1、根据编号对检查费、中药费求和 Dim query = From data In dt1.AsEnumerable() _ Group data By id1 = data.Field(Of String)(dt1.Columns(0).ColumnName) _ Into g = Group _ Select New With _ { _ .Jianchafei = g.Sum(Function(order) order.Field(Of Double)(dt1.Columns(6).ColumnName)), _ .zhongyaofei = g.Sum(Function(order) order.Field(Of Double)(dt1.Columns(7).ColumnName)) _ }