以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  问题,自动退出系统  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=68670)

--  作者:yongxuanchen
--  发布时间:2015/5/22 10:48:00
--  问题,自动退出系统

If e.DataCol.Name = "出厂编号" Then
    Dim dr As DataRow
    dr = e.DataTable.Find("出厂编号= \'" & e.NewValue & "\'")
    If dr IsNot Nothing Then
        MessageBox.Show("此出厂编号号已经存在!")
        e.Cancel = True
    End If
End If

我在datarowchanging那里写了这段代码,当出厂编号列不为空,当进行复制当前行时,出现系统自动退出,请问什么问题?


--  作者:Bin
--  发布时间:2015/5/22 10:49:00
--  
这段代码没问题, 把剩下的代码发出来.

或者你DataColChanged的代码.

--  作者:yongxuanchen
--  发布时间:2015/5/22 12:33:00
--  这是datacolchanged的代码

Dim a As Integer = Rand.Next(3,60)
Dim s5 As String = a
If e.DataRow("设备名称") ="无机房客梯" Or e.DataRow("设备名称") ="无机房货梯" Then
      e.DataRow("紧急电动") ="/"
      e.DataRow("共用机房") ="/"    
      e.DataRow("机房结果") ="/"
      e.DataRow("机房结论") ="/"
      e.DataRow("机房门高") ="/"
      e.DataRow("机房门宽") ="/"  
       e.DataRow("直梯梯高") ="/"
      e.DataRow("直梯通道高") ="/"
      e.DataRow("直梯梯夹角") ="/"
      e.DataRow("机房高度差") ="/" 
      e.DataRow("圈框") ="/"
      e.DataRow("机深度") ="/"
      e.DataRow("机宽度") ="/"
      e.DataRow("机高度") ="/"
      e.DataRow("无机房结果") ="符合"
      e.DataRow("无机房结论") ="合格"
End If
If e.DataRow("消防功能") ="大众消防" Then
      e.DataRow("消防结果") ="符合"
      e.DataRow("消防结论") ="合格"
Else
      e.DataRow("消防结果") ="/"
      e.DataRow("消防结论") ="/"
End If

If e.DataRow("轿厢缓冲器型式") ="液压缓冲器" Then
      e.DataRow("液压结果") ="符合"
      e.DataRow("液压结论") ="合格"
      e.DataRow("复位时间") =s5
Else
      e.DataRow("液压结果") ="/"
      e.DataRow("液压结论") ="/"
      e.DataRow("复位时间")="/"
End If
\'If e.Col.name="门高" Then
 \'  If e.Row(e.Col.name)="你设置代替\\的值" Then
  \'     e.text="\\"
   \'End If
\'End If

 

Vars("ping1")=10*0.01*Math.Abs(e.DataRow("平衡系数电流上行30")-e.DataRow("平衡系数电流下行30"))/(Math.Abs(e.DataRow("平衡系数电流上行30")-e.DataRow("平衡系数电流下行30"))+Math.Abs(e.DataRow("平衡系数电流上行40")-e.DataRow("平衡系数电流下行40")))+0.3
Vars("ping2")= 5*0.01*Math.Abs(e.DataRow("平衡系数电流上行40")-e.DataRow("平衡系数电流下行40"))/(Math.Abs(e.DataRow("平衡系数电流上行40")-e.DataRow("平衡系数电流下行40"))+Math.Abs(e.DataRow("平衡系数电流上行45")-e.DataRow("平衡系数电流下行45")))+0.4
Vars("ping3")= 5*0.01*Math.Abs(e.DataRow("平衡系数电流上行45")-e.DataRow("平衡系数电流下行45"))/(Math.Abs(e.DataRow("平衡系数电流上行45")-e.DataRow("平衡系数电流下行45"))+Math.Abs(e.DataRow("平衡系数电流上行50")-e.DataRow("平衡系数电流下行50")))+0.45
Vars("ping4")=10*0.01*Math.Abs(e.DataRow("平衡系数电流上行50")-e.DataRow("平衡系数电流下行50"))/(Math.Abs(e.DataRow("平衡系数电流上行50")-e.DataRow("平衡系数电流下行50"))+Math.Abs(e.DataRow("平衡系数电流上行60")-e.DataRow("平衡系数电流下行60")))+0.5

If e.DataRow("平衡系数电流上行30") >= e.DataRow("平衡系数电流下行30") And e.DataRow.isnull("平衡系数电流上行30") Then
 \'    MessageBox.Show("平衡系数值小于0.30,不符合要求,请加对重块或检查数据是否录完")
  \'  Return
ElseIf e.DataRow("平衡系数电流上行40") >= e.DataRow("平衡系数电流下行40") Then
              e.DataRow("平衡系数值") =Vars("ping1")
ElseIf e.DataRow("平衡系数电流上行45") >= e.DataRow("平衡系数电流下行45") Then
   e.DataRow("平衡系数值") =Vars("ping2")
ElseIf e.DataRow("平衡系数电流上行50") >= e.DataRow("平衡系数电流下行50") Then
   e.DataRow("平衡系数值") =Vars("ping3")
Else
     MessageBox.Show("平衡系数值大于0.50,不符合要求,请减少对重块或检查数据是否录完")
    Return
End If

Dim dr As DataRow = e.DataRow
Dim pf As String = ""

pf = Format(dr("竣工日期"),"yyMM-") \'否则获得编号的前缀,两位年,两位月
dr("报告编号") =  pf & e.DataRow("出厂编号")


--  作者:Bin
--  发布时间:2015/5/22 14:24:00
--  
DataColChanged的代码一定要加入 列名判断.绝对不可以没有
if e.datacol.name ="设备名称" then
Dim a As Integer = Rand.Next(3,60) 
Dim s5 As String = a
If e.DataRow("设备名称") ="无机房客梯" Or e.DataRow("设备名称") ="无机房货梯" Then
      e.DataRow("紧急电动") ="/"
      e.DataRow("共用机房") ="/"     
      e.DataRow("机房结果") ="/"
      e.DataRow("机房结论") ="/"
      e.DataRow("机房门高") ="/"
      e.DataRow("机房门宽") ="/"   
       e.DataRow("直梯梯高") ="/"
      e.DataRow("直梯通道高") ="/"
      e.DataRow("直梯梯夹角") ="/"
      e.DataRow("机房高度差") ="/"  
      e.DataRow("圈框") ="/" 
      e.DataRow("机深度") ="/" 
      e.DataRow("机宽度") ="/" 
      e.DataRow("机高度") ="/" 
      e.DataRow("无机房结果") ="符合"
      e.DataRow("无机房结论") ="合格"
End If
end if


你其余的代码,也应该根据对应情况,全部加上 列名判断

--  作者:大红袍
--  发布时间:2015/5/22 14:25:00
--  

http://www.foxtable.com/help/topics/1522.htm