以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  政治面貌 、入党时间、党龄的逻辑关系  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=124565)

--  作者:susu312
--  发布时间:2018/9/9 15:37:00
--  政治面貌 、入党时间、党龄的逻辑关系

老师,我在政治面貌的validating事件中写如下代码,但是党龄老是写不上去,我大概应该写在入党时间的validating事件下?

 

Dim txt As String = e.Sender.Text
\'If txt <> Nothing Then
If  txt > "" Then
     If txt.Length > 20 Then 
         e.Sender.Error = "政治面貌长度不允许超过20"
     Else
         e.Sender.Text= txt.Replace(" ","")
          If e.Form.Controls("politicalStatus").Value ="中共党员" Then
             If e.Form.Controls("partyTime").Value ="" Then
                e.Form.Controls("PartyTime").Error= "入党时间不允许为空"
             Else
                e.Form.Controls("PartyTime").Error= ""
                Dim d As Date = e.Form.Controls("partyTime").Value
                Dim y As Integer = d.year
                If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then
                    y = Date.Today.Year - y-1
                Else
                    y = 0
                End If
                If y < 0 Then
                     e.Form.Controls("partyStanding").Value = 0
                 End If
             End If   
         End If
     End If
End If


--  作者:有点甜
--  发布时间:2018/9/9 16:47:00
--  

改成

 

Dim txt As String = e.Sender.Text
\'If txt <> Nothing Then
If  txt > "" Then
     If txt.Length > 20 Then 
         e.Sender.Error = "政治面貌长度不允许超过20"
     Else
         e.Sender.Text= txt.Replace(" ","")
          If e.Form.Controls("politicalStatus").Value ="中共党员" Then
             If e.Form.Controls("partyTime").Value ="" Then
                e.Form.Controls("PartyTime").Error= "入党时间不允许为空"
             Else
                e.Form.Controls("PartyTime").Error= ""
                Dim d As Date = e.Form.Controls("partyTime").text
                Dim y As Integer = d.year
                If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then
                    y = Date.Today.Year - y-1
                Else
                    y = 0
                End If

msgbox(d)
                If y < 0 Then
                     e.Form.Controls("partyStanding").Value = 0

                 End If

e.Form.Controls("partyStanding").Value = y

e.Form.Controls("partyStanding").WriteValue
             End If   
         End If
     End If
End If


--  作者:shenyl0211
--  发布时间:2018/9/9 22:32:00
--  
入党时间为空=政治面貌为群众
入党时间不为空=政治面貌为党员,并计算党龄

--  作者:有点甜
--  发布时间:2018/9/9 22:53:00
--  
实例发上来测试。