毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 数据库 >> 正文

VFP的Grid控件跟财务软件的格式类似 第2页

更新时间:2012-6-12:  来源:毕业论文
    Add Object cmd_cancel As CommandButton With ;
        Top = 13, ;
        Left = 308, ;
        Height = 25, ;
        Width = 60, ;
        Caption = "取消", ;
        Enabled = .F., ;
        TabIndex = 6, ;
        Name = "CMD_CANCEL"

    Procedure Load
        Public aMyCurrentRow(1)
        Create Cursor T1 (名称 C(10),数量 I,单价 I,金额 I)
        Select T1
        For m.lnI=1 To 9
            Append Blank
        Endfor
        Insert Into T1 Values ("    合  计",0,0,0)
        Locate
    Endproc

    Procedure Init
        Thisform.AddProperty("MyGridAddModi",0)
        Thisform.Grid1.SetAll("DynamicForeColor","Iif(Empty(名称),Thisform.Grid1.BackColor,Thisform.Grid1.ForeColor)","Column")
        m.lnGridColumns=Thisform.Grid1.ColumnCount
        For m.lnI=2 To m.lnGridColumns
            Thisform.Grid1.Columns(m.lnI).Format="Z"
        Endfor
    Endproc

    Procedure grid1.AfterRowColChange
        Lparameters nColIndex,nRecno
        If Thisform.MyGridAddModi>0
            Update T1 Set 金额=数量*单价 Where Strtran(名称,Space(1),"")<>"合计" And !Empty("名称")
            Select Sum(数量) As 数量S,Avg(单价) As 单价A,Sum(金额) As 金额S Into Cursor T2 From T1 Where Strtran(名称,Space(1),"")<>"合计" And !Empty("名称")
            If !Isnull(T2.数量S)
                Update T1 Set 数量=T2.数量S,单价=T2.单价A,金额=T2.金额S Where Strtran(名称,Space(1),"")=="合计"
            Else
                Update T1 Set 数量=0,单价=0,金额=0 Where Strtran(名称,Space(1),"")=="合计"
            Endif
            This.Refresh
        Endif
        If Type("nRecno")="N"
            Select T1
            Go (nRecno)
        Endif
    Endproc

    Procedure grid1.BeforeRowColChange
        Lparameters nColIndex
        If (This.RowColChange=1 Or This.RowColChange=3) And Thisform.MyGridAddModi>0
            Nodefault
        Endif
    Endproc

    Procedure cmd_add.Click
        Select T1
        Scan
            If Empty(名称)
                Exit
            Endif
        Endscan
        If !Eof()
            Store .F. To Thisform.CMD_ADD.Enabled,Thisform.CMD_DEL.Enabled,Thisform.CMD_MODIFY.Enabled
            Store .T. To Thisform.Grid1.AllowCellSelection,Thisform.CMD_SAVE.Enabled,Thisform.CMD_CANCEL.Enabled
            Thisform.MyGridAddModi=1
            Thisform.Grid1.ActivateCell(Recno("T1"),1)
            Thisform.Grid1.SetFocus()
        Else
            Messagebox("此单据已填写满!"+Space(3),48,"信息提示")
        Endif
    Endproc

    Procedure cmd_save.Click
        Thisform.Grid1.AfterRowColChange(,Recno())
        Store .T. To Thisform.CMD_ADD.Enabled,Thisform.CMD_DEL.Enabled,Thisform.CMD_MODIFY.Enabled
        Store .F. To Thisform.Grid1.AllowCellSelection,Thisform.CMD_SAVE.Enabled,Thisform.CMD_CANCEL.Enabled
        Thisform.MyGridAddModi=0
    Endproc

    Procedure cmd_modify.Click
        Select T1
        If Strtran(名称,Space(1),"")=="合计" Or Empty(名称)
            Return
        Endif
        Scatter To aMyCurrentRow
        Store .F. To Thisform.CMD_ADD.Enabled,Thisform.CMD_DEL.Enabled,Thisform.CMD_MODIFY.Enabled
        Store .T. To Thisform.Grid1.AllowCellSelection,Thisform.CMD_SAVE.Enabled,Thisform.CMD_CANCEL.Enabled
        Thisform.MyGridAddModi=2
        Thisform.Grid1.ActivateCell(Recno("T1"),1)
        Thisform.Grid1.SetFocus()
    Endproc

    Procedure cmd_del.Click
        Select T1
        If Strtran(名称,Space(1),"")=="合计" Or Empty(名称)
            Return
        Endif
        Blank
        m.lnRecno=Recno()
        Thisform.MyGridAddModi=1
        Thisform.Grid1.AfterRowColChange(,Recno())
        Thisform.MyGridAddModi=0
        Go (m.lnRecno)
        Thisform.Grid1.Refresh
    Endproc

    Procedure cmd_cancel.Click
        Select T1
        If Thisform.MyGridAddModi=1
            Blank
        Else
            Gather From aMyCurrentRow
        Endif
        Thisform.Grid1.AfterRowColChange(,Recno())
        Store .T. To Thisform.CMD_ADD.Enabled,Thisform.CMD_DEL.Enabled,Thisform.CMD_MODIFY.Enabled
        Store .F. To Thisform.Grid1.AllowCellSelection,Thisform.CMD_SAVE.Enabled,Thisform.CMD_CANCEL.Enabled
        Thisform.MyGridAddModi=0
        Thisform.Grid1.Refresh
    Endproc

Enddefine

上一页  [1] [2] 

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。