-- 作者:zhuxin
-- 发布时间:2016/11/5 11:57:00
--
这个不知怎样解决,检查了很多次都不知哪里出错了
If e.DataCol.Name = "产品名称" Then Dim dr As DataRow = e.DataRow Dim dt As DataTable = DataTables("周转卡明细") Dim frm As WinForm.Form = Forms("损耗率计算") If frm.Opened Then Dim d1 = frm.Controls("DateTimePicker1").value Dim d2 = frm.Controls("DateTimePicker2").value If d1 IsNot Nothing And d2 IsNot Nothing dr("压铸") = dt.Compute("Sum(压铸良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控1良品数") = dt.Compute("Sum(数控1良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控2良品数") = dt.Compute("Sum(数控2良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控3良品数") = dt.Compute("Sum(数控3良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加1良品数") = dt.Compute("Sum(机加1良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加2良品数") = dt.Compute("Sum(机加2良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加3良品数") = dt.Compute("Sum(机加3良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加4良品数") = dt.Compute("Sum(机加4良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加5良品数") = dt.Compute("Sum(机加5良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加6良品数") = dt.Compute("Sum(机加6良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加7良品数") = dt.Compute("Sum(机加7良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加8良品数") = dt.Compute("Sum(机加8良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加9良品数") = dt.Compute("Sum(机加9良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加10良品数") = dt.Compute("Sum(机加10良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("毛刺良品数") = dt.Compute("Sum(毛刺良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("抛光良品数") = dt.Compute("Sum(抛光良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("震光良品数") = dt.Compute("Sum(震光良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("品管良品数") = dt.Compute("Sum(品管良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("仓库良品数") = dt.Compute("Sum(仓库良品数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("压铸不良数") = dt.Compute("Sum(压铸不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控1不良数") = dt.Compute("Sum(数控1不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控2不良数") = dt.Compute("Sum(数控2不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控3不良数") = dt.Compute("Sum(数控3不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控4不良数") = dt.Compute("Sum(数控4不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加1不良数") = dt.Compute("Sum(机加1不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加2不良数") = dt.Compute("Sum(机加2不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加3不良数") = dt.Compute("Sum(机加3不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加4不良数") = dt.Compute("Sum(机加4不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加5不良数") = dt.Compute("Sum(机加5不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加6不良数") = dt.Compute("Sum(机加6不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加7不良数") = dt.Compute("Sum(机加7不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加8不良数") = dt.Compute("Sum(机加8不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加9不良数") = dt.Compute("Sum(机加9不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("机加10不良数") = dt.Compute("Sum(机加10不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("毛刺不良数") = dt.Compute("Sum(毛刺不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("抛光不良数") = dt.Compute("Sum(抛光不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("震光不良数") = dt.Compute("Sum(震光不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("品管不良数") = dt.Compute("Sum(品管不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("仓库不良数") = dt.Compute("Sum(仓库不良数)","[产品名称] = \'" & dr("产品名称") & "\' and 日期 >= \'" & d1 & "\' and 日期 <= \'" & d2 & "\' ") dr("数控耗损") = dr("数控1不良数") + dr("数控2不良数") + dr("数控3不良数") + dr("数控4不良数") dr("机加耗损") = dr("机加1不良数") + dr("机加2不良数") + dr("机加3不良数") + dr("机加4不良数") + dr("机加5不良数") + dr("机加6不良数") + dr("机加7不良数") + dr("机加8不良数") + dr("机加9不良数") + dr("机加10不良数") dr("毛刺耗损") = dr("毛刺不良数") dr("总耗损") = dr("数控耗损") + dr("机加耗损") + dr("毛刺耗损") + dr("抛光不良数") + dr("震光不良数") + dr("品管不良数") + dr("仓库不良数") If dr("数控耗损") = 0 Or dr("数控1良品数") + dr("数控1不良数") = 0 Then dr("数控良品率") = "" Else dr("数控良品率") = dr("数控耗损") / (dr("数控1良品数") + dr("数控1不良数") ) End If If dr("机加耗损") = 0 Or dr("机加1不良数") + dr("机加1良品数") = 0 Then dr("机加良品率") = "" Else dr("机加良品率") = dr("机加耗损") / (dr("机加1不良数") + dr("机加1良品数") ) End If If dr("毛刺耗损") = 0 Or dr("毛刺耗损") + dr("毛刺良品数") Then dr("毛刺不良率") = "" Else dr("毛刺不良率") = dr("毛刺耗损") / (dr("毛刺耗损") + dr("毛刺良品数") ) End If If dr("抛光不良数") = 0 Or dr("抛光不良数") + dr("抛光良品数") Then dr("抛光不良率") = "" Else dr("抛光不良率") = dr("抛光不良数") / (dr("抛光不良数") + dr("抛光良品数") ) End If If dr("品管不良数") = 0 Or dr("品管不良数") + dr("品管良品数") Then dr("品管良品率") = "" Else dr("品管良品率") = dr("品管不良数") / (dr("品管不良数") + dr("品管良品数") ) End If If dr("压铸") IsNot Nothing Then If (dr("压铸") - dr("仓库良品数") ) = 0 Then dr("报废率") = "" Else dr("报废率") = (dr("压铸") - dr("仓库良品数") ) / dr("压铸") End If ElseIf dr("数控1良品数") IsNot Nothing Then If (dr("数控1良品数") - dr("仓库良品数") ) = 0 Then dr("报废率") = "" Else dr("报废率") = (dr("数控1良品数") - dr("仓库良品数") ) / dr("数控1良品数") End If
|
-- 作者:zhuxin
-- 发布时间:2016/11/5 11:58:00
--
ElseIf dr("机加1良品数") IsNot Nothing Then If (dr("机加1良品数") - dr("仓库良品数") ) = 0 Then dr("报废率") = "" Else dr("报废率") = (dr("机加1良品数") - dr("仓库良品数") ) / dr("机加1良品数") End If ElseIf dr("毛刺良品数") IsNot Nothing Then If (dr("毛刺良品数") - dr("仓库良品数") ) = 0 Then dr("报废率") = "" Else dr("报废率") = (dr("毛刺良品数") - dr("仓库良品数") ) / dr("毛刺良品数") End If Else If dr("抛光良品数") - dr("仓库良品数") = 0 Or dr("抛光良品数") = "" Then dr("报废率") = "" Else dr("报废率") = (dr("抛光良品数") - dr("仓库良品数") ) / dr("抛光良品数") End If End If End If Else dr("压铸") = dt.Compute("Sum(压铸良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控1良品数") = dt.Compute("Sum(数控1良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控2良品数") = dt.Compute("Sum(数控2良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控3良品数") = dt.Compute("Sum(数控3良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加1良品数") = dt.Compute("Sum(机加1良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加2良品数") = dt.Compute("Sum(机加2良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加3良品数") = dt.Compute("Sum(机加3良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加4良品数") = dt.Compute("Sum(机加4良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加5良品数") = dt.Compute("Sum(机加5良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加6良品数") = dt.Compute("Sum(机加6良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加7良品数") = dt.Compute("Sum(机加7良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加8良品数") = dt.Compute("Sum(机加8良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加9良品数") = dt.Compute("Sum(机加9良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加10良品数") = dt.Compute("Sum(机加10良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("毛刺良品数") = dt.Compute("Sum(毛刺良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("抛光良品数") = dt.Compute("Sum(抛光良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("震光良品数") = dt.Compute("Sum(震光良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("品管良品数") = dt.Compute("Sum(品管良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("仓库良品数") = dt.Compute("Sum(仓库良品数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("压铸不良数") = dt.Compute("Sum(压铸不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控1不良数") = dt.Compute("Sum(数控1不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控2不良数") = dt.Compute("Sum(数控2不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控3不良数") = dt.Compute("Sum(数控3不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("数控4不良数") = dt.Compute("Sum(数控4不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加1不良数") = dt.Compute("Sum(机加1不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加2不良数") = dt.Compute("Sum(机加2不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加3不良数") = dt.Compute("Sum(机加3不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加4不良数") = dt.Compute("Sum(机加4不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加5不良数") = dt.Compute("Sum(机加5不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加6不良数") = dt.Compute("Sum(机加6不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加7不良数") = dt.Compute("Sum(机加7不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加8不良数") = dt.Compute("Sum(机加8不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加9不良数") = dt.Compute("Sum(机加9不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("机加10不良数") = dt.Compute("Sum(机加10不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("毛刺不良数") = dt.Compute("Sum(毛刺不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("抛光不良数") = dt.Compute("Sum(抛光不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("震光不良数") = dt.Compute("Sum(震光不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("品管不良数") = dt.Compute("Sum(品管不良数)","[产品名称] = \'" & dr("产品名称") & "\'") dr("仓库不良数") = dt.Compute("Sum(仓库不良数)","[产品名称] = \'" & dr("产品名称") & "\'") End If End If
|