以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  字符型转大写  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=92995)

--  作者:有点蓝
--  发布时间:2016/11/18 8:34:00
--  
参考:http://www.foxtable.com/webhelp/scr/2616.htm
--  作者:有点蓝
--  发布时间:2016/11/18 15:02:00
--  
Dim str As String = "6月"
Output.Show(CLNum(val(str)) & "月")

--  作者:有点蓝
--  发布时间:2016/11/18 17:06:00
--  
如果是手工录的,DataColChanging事件

If e.DataCol.Name = "月份" Then 
    If e.NewValue > "" Then 
        e.NewValue = CLNum(val(e.NewValue)) & "月"
    End If
End If

如果是从日期列转换来的,DataColChanged事件

If e.DataCol.Name = "日期" Then 
    If e.DataRow.IsNull("日期") = False Then 
        e.DataRow("月份") = CLNum(e.DataRow("日期").Month) & "月"
    End If
End If

--  作者:有点青
--  发布时间:2016/11/20 18:34:00
--  

参考代码

 

dim str as string = "12月”
Dim months() As String = {"一","", "", "", "", "", "七", "八", "", "十", "十一", "十二"}
str = months(str.replace("月", "")-1) & "月"

msgbox(str)


--  作者:有点青
--  发布时间:2016/11/21 9:15:00
--  
以下是引用ZJZK2015在2016/11/21 0:46:00的发言:
有点青老师:
能否这个代码写完整,我是一个新手,十分感谢!

 

看懂,理解代码。根本不知道你要用到哪个地方。


--  作者:有点蓝
--  发布时间:2016/11/28 8:48:00
--  
这段代码没有问题,还有没有其它代码?
--  作者:有点蓝
--  发布时间:2016/11/28 14:11:00
--  
改到DataColChanging事件

If e.DataCol.Name = "月份" AndAlso e.NewValue > "" Then
    Dim months() As String = {"一","", "", "", "", "", "七", "八", "", "十", "十一", "十二"}
    Dim m As Integer = val(e.NewValue.replace("月", ""))
    If m >= 1 AndAlso m <= 12 Then
        e.NewValue = months(m-1) & "月"
    Else
        e.Cancel = True
    End If
End If

--  作者:有点色
--  发布时间:2016/11/29 16:51:00
--  

改一下,如果报错,说出来报什么错。

 

Dim dt As DataRow = e.DataRow
Select Case e.DataCol.Name
       Case "姓名" ,"年度"
        Dim dr As DataRow = DataTables("工资年度结算").Find("姓名 = \'" &  dt("姓名")  & "\' And 年度 = \'" & dt("年度") & "\'")
        If dr Is Nothing Then
            dr = DataTables("工资年度结算").AddNew()
            dr("姓名") = dt("姓名")
            dr("年度") = dt("年度")
        Else
            dr("姓名") = dt("姓名")
       End If
End Select


--  作者:有点蓝
--  发布时间:2016/11/29 20:35:00
--  
Dim dt As DataRow = e.DataRow
Select Case e.DataCol.Name
    Case "姓名" ,"年度"
        If dt.IsNull("姓名") = False AndAlso dt.IsNull("年度") = False
            Dim dr As DataRow = DataTables("工资年度结算").Find("姓名 = \'" &  dt("姓名")  & "\'And 年度 = \'" & dt("年度")) & "\'"
            If dr Is Nothing Then
                dr = DataTables("工资年度结算").AddNew()
                dr("姓名") = dt("姓名")
                dr("年度") = dt("年度")
            End If
        End If
End Select

--  作者:有点色
--  发布时间:2016/12/1 14:10:00
--  
 Dim rst As DialogResult
rst = MessageBox.Show("请确认无误后,点击确定", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If rst = DialogResult.Yes Then
    For Each dt As DataRow In DataTables("工资月报表").DataRows
        Dim months() As String = {"一","二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
        Dim m As String = months(val(dt("月份").replace("月", ""))-1) & "月"
        Dim y As Integer = dt("年度")
        Dim gz As DataRow = DataTables("当年工资库").Find("年度 = \'" & y & "\' And 月份 = \'" & m & "\'")
        If gz Is Nothing Then
            gz = DataTables("当年工资库").AddNew
            For Each dc As DataCol In DataTables("当年工资库").DataCols
                gz(dc.Name) = dt(dc.Name)
            Next
        Else
            MessageBox.Show("你要转结的工资月报表已存在,请再次核对后转结.","提示")
        End If
    Next
End If