If e.DataCol.Name = "存货编码" AndAlso e.NewValue <> Nothing AndAlso e.NewValue.Length = 8 Then Dim cmd As New SQLCommand Dim dt As DataTable Dim dr As DataRow = e.DataRow
cmd.CommandText = "SELECT * F rom {存货BOM} Where [存货编码] = '" & dr("存货编码") & "'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr("存货编码") = dt.DataRows(0)("存货编码") dr("存货名称") = dt.DataRows(0)("存货名称") dr("存货规格") = dt.DataRows(0)("存货规格") dr("存货单位") = dt.DataRows(0)("存货单位") cmd.CommandText = "SELECT * F rom {存货BOM} Where [存货编码] = '" & e.NewValue.Substring(0,2) & "'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr("存货大类") = dt.DataRows(0)("存货名称") End If cmd.CommandText = "SELECT * F rom {存货BOM} Where [存货编码] = '" & e.NewValue.Substring(2,4) & "'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr("存货二类") = dt.DataRows(0)("存货名称") End If cmd.CommandText = "SELECT * F rom {存货BOM} Where [存货编码] = '" & e.NewValue.Substring(6,2) & "'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr("存货三类") = dt.DataRows(0)("存货名称") End If Else dr("存货名称") = Nothing dr("存货规格") = Nothing dr("存货单位") = Nothing 'dr("存货大类") = Nothing 'dr("存货二类") = Nothing 'dr("存货三类") = Nothing End If End If
|