| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 12007 人关注过本帖, 2 人收藏
标题:如何做楼房的房号展示界面
只看楼主 加入收藏
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11857
专家分:43421
注 册:2006-5-13
收藏
得分:0 
T版还不如做一个这样的小程序,让用户按照你的设计去录入数据,可能还会更简单些。

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2014-08-23 18:55
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
回复 111 楼 hu9jj
那等于做一个系统给他了,不干。

授人以渔,不授人以鱼。
2014-08-23 20:11
caolp
Rank: 1
等 级:新手上路
帖 子:160
专家分:5
注 册:2014-7-12
收藏
得分:0 
    因办公室电脑出现了一些问题,一直开不了机,刚刚借用同事的电脑,发现TonyDeng老师牺牲这么多的时间,为我做了这么的事情,我打心里感谢这位好心人。
    其他老师对我的VFP水平不管怎么怀疑,我也很感谢。感谢他们曾经帮助过我。的确我是一个初学者,利用论坛这个平台,我虚心向老师们学到了不少的知识,对于我这个初学者,当我遇到困难时,我恳请一些老师能否在真心再帮我一把,在此叩谢了!
    因为是借用同事电脑,许多数据以及系统无法支持,只有等办公室电脑修好后再按照老师提供的方法去做。
2014-08-23 20:40
caolp
Rank: 1
等 级:新手上路
帖 子:160
专家分:5
注 册:2014-7-12
收藏
得分:0 
以下是引用TonyDeng在2014-8-23 13:39:49的发言:

现在有点小麻烦,是不知道他的房屋状态怎么反映,要琢磨一下他的数据才知道,今天没多少时间了,明天再弄。他的数据是刻意改乱的,有些问题不是那么好判断,所以我一直要真实数据就是这个原因。
非常感谢TonyDeng老师能善解人意。的确我的数据是刻意做的虚拟数据,并非“不诚意”,希望老师能谅解,谢谢!
2014-08-23 20:54
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
你先解释一下怎么判断房间状态

授人以渔,不授人以鱼。
2014-08-23 20:54
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
新图:
图片附件: 游客没有浏览图片的权限,请 登录注册


授人以渔,不授人以鱼。
2014-08-24 12:01
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
目录结构:
图片附件: 游客没有浏览图片的权限,请 登录注册


程序放在第一个文件夹,数据放在第二个文件夹。

程序代码:
程序代码:
#include "FoxPro.h"

SET DEFAULT TO "E:\我的文檔\項目\測試\VFP\test - caolp"     && 程序执行根目录,即上图的文件夹位置
SET PATH TO "数据"                                          && 程序搜索数据的文件夹
CLEAR ALL
Main()
CLEAR ALL
RETURN

*---------------------------
* 程序主入口
*---------------------------
PROCEDURE Main()
    LOCAL loForm
    loForm = CREATEOBJECT("C_MainForm")
    WITH loForm
        .Caption = "XXX小区住户平面图"
        .WindowState = WINDOWSTATE_MAXIMIZED
        .MinWidth = 800
        .MinHeight = 600
        .Show
    ENDWITH
    READ EVENTS
ENDPROC

*---------------------------
* 主窗体
*---------------------------
DEFINE CLASS C_MainForm AS myForm

    DIMENSION aList1[1]        && 楼栋清单
    DIMENSION aList2[1]        && 单元号
    DIMENSION aList3[1]        && 楼层号
    DIMENSION aList4[1]        && 户室号
   
    cList = ""                 && 筛选字符串
    PROCEDURE cList_Assign(tcValue)
        ThisForm.cList = RTRIM(tcValue)
    ENDPROC

    ADD OBJECT Selector AS C_Selector WITH Top = 5, Left = 5
    ADD OBJECT cnt_Map AS Container WITH BorderWidth = 0, BackStyle = 0

    PROCEDURE Load
        CLOSE DATABASES ALL
        USE "居民信息" IN 0
    ENDPROC
   
    PROCEDURE Unload
        CLOSE DATABASES ALL
    ENDPROC
   
    PROCEDURE Resize
        ThisForm.Go
    ENDPROC
   
    PROCEDURE Arrange
        WITH Top = ThisForm.Selector.Top + ThisForm.Selector.Height + 5
            .Left = 5
            .Height = ThisForm.Height - .Top - 5
            .Width = ThisForm.Width - .Left - 5
        ENDWITH
    ENDPROC
   
    PROCEDURE Init
        LOCAL lnIndex
       
        WITH ThisForm
            .Get_List1
            BINDEVENT(., "Click", This, "Change_List1")
            BINDEVENT(., "Click", This, "Change_List2")
            BINDEVENT(., "Click", This, "Change_List3")
            BINDEVENT(., "Click", This, "Change_List4")
            BINDEVENT(.Selector.btn_Go, "Click", This, "Go")
        ENDWITH
       
    ENDPROC
   
    * 获取楼栋清单
    FUNCTION Get_List1()
        LOCAL lcStr, lnIndex
       
        SELECT "居民信息"
        SET ORDER TO "Master"
        GOTO TOP
        lcStr = SPACE(LEN(楼栋号))
        lnIndex = 1
        DIMENSION ThisForm.aList1[lnIndex]
        ThisForm.aList1[lnIndex] = lcStr
        DO WHILE !EOF()
            IF 楼栋号 != lcStr
                lnIndex = lnIndex + 1
                lcStr = 楼栋号
                DIMENSION ThisForm.aList1[lnIndex]
                ThisForm.aList1[lnIndex] = lcStr
            ENDIF
            SKIP
        ENDDO
       
        WITH .FOR lnIndex = 1 TO ALEN(ThisForm.aList1, 1)
                .AddItem(ThisForm.aList1[lnIndex])
            NEXT
            .ListIndex = 1
        ENDWITH
       
    ENDFUNC
   
    * 获取单元清单
    FUNCTION Get_List2(tcNo1)
        LOCAL lcStr, lnIndex
       
        SELECT "居民信息"
        SET ORDER TO "Master"
        lcStr = SPACE(LEN(单元号))
        lnIndex = 1
        DIMENSION ThisForm.aList2[lnIndex]
        ThisForm.aList2[lnIndex] = lcStr
        IF !EMPTY(tcNo1) .AND. SEEK(tcNo1)
            DO WHILE 楼栋号 == tcNo1
                IF 单元号 != lcStr
                    lnIndex = lnIndex + 1
                    lcStr = 单元号
                    DIMENSION ThisForm.aList2[lnIndex]
                    ThisForm.aList2[lnIndex] = lcStr
                ENDIF
                SKIP
            ENDDO
        ENDIF
       
        WITH .FOR lnIndex = 1 TO ALEN(ThisForm.aList2, 1)
                .AddItem(ThisForm.aList2[lnIndex])
            NEXT
            .ListIndex = 1
        ENDWITH

    ENDFUNC
   
    * 获取楼层清单
    FUNCTION Get_List3(tcNo1, tcNo2)
        LOCAL lcStr, lnIndex
       
        SELECT "居民信息"
        SET ORDER TO "Master"
        lcStr = SPACE(LEN(楼层号))
        lnIndex = 1
        DIMENSION ThisForm.aList3[lnIndex]
        ThisForm.aList3[lnIndex] = lcStr
        IF !EMPTY(tcNo1) .AND. !EMPTY(tcNo2) .AND. SEEK(ThisForm.cList)
            DO WHILE (楼栋号 == tcNo1) .AND. (单元号 == tcNo2)
                IF 楼层号 != lcStr
                    lnIndex = lnIndex + 1
                    lcStr = 楼层号
                    DIMENSION ThisForm.aList3[lnIndex]
                    ThisForm.aList3[lnIndex] = lcStr
                ENDIF
                SKIP
            ENDDO
        ENDIF
       
        WITH .FOR lnIndex = 1 TO ALEN(ThisForm.aList3, 1)
                .AddItem(ThisForm.aList3[lnIndex])
            NEXT
            .ListIndex = 1
        ENDWITH

    ENDFUNC

    * 获取户室清单
    FUNCTION Get_List4(tcNo1, tcNo2, tcNo3)
        LOCAL lcStr, lnIndex
       
        SELECT "居民信息"
        SET ORDER TO "Master"
        lcStr = SPACE(LEN(户室号))
        lnIndex = 1
        DIMENSION ThisForm.aList4[lnIndex]
        ThisForm.aList4[lnIndex] = lcStr
        IF !EMPTY(tcNo1) .AND. !EMPTY(tcNo2) .AND. !EMPTY(tcNo3) .AND. SEEK(ThisForm.cList)
            DO WHILE (楼栋号 == tcNo1) .AND. (单元号 == tcNo2) .AND. (楼层号 == tcNo3)
                IF 户室号 != lcStr
                    lnIndex = lnIndex + 1
                    lcStr = 户室号
                    DIMENSION ThisForm.aList4[lnIndex]
                    ThisForm.aList4[lnIndex] = lcStr
                ENDIF
                SKIP
            ENDDO
        ENDIF
       
        WITH .FOR lnIndex = 1 TO ALEN(ThisForm.aList4, 1)
                .AddItem(ThisForm.aList4[lnIndex])
            NEXT
            .ListIndex = 1
        ENDWITH

    ENDFUNC

    * 改变楼栋
    PROCEDURE Change_List1
        WITH ThisForm
            .cList = .(.)
            .Get_List3(., .)
            .Get_List4(., ., .)
        ENDWITH
    ENDPROC
   
    * 改变单元
    PROCEDURE Change_List2
        WITH ThisForm
            .cList = . + .(., .)
            .Get_List4(., ., .)
        ENDWITH
    ENDPROC
   
    * 改变楼层
    PROCEDURE Change_List3
        WITH ThisForm
            .cList = . + . + .(., ., .)
        ENDWITH
    ENDPROC

    * 改变户室
    PROCEDURE Change_List4
        WITH ThisForm
            .cList = . + . + . + . ENDPROC
   
    PROCEDURE cnt_Map.Clear
        WITH This
            DO WHILE .ControlCount > 0
                .RemoveObject(.Controls(.ControlCount).Name)
            ENDDO
        ENDWITH
    ENDPROC
   
    * 确定
    PROCEDURE Go
        LOCAL lcStr, lcNumber, lcName, lnRow, lnCol
       
         
        SELECT "居民信息"
        SET ORDER TO "Master"
        IF SEEK(ThisForm.cList)
            lcStr = 楼栋号 + 单元号 + 楼层号 + 户室号
            DO WHILE (ThisForm.cList $ lcStr) .AND. !EOF()
                IF (楼栋号 + 单元号 + 楼层号 + 户室号 == lcStr) .AND. (ALLTRIM(户主关系) == "户主")
                    WITH  = STRTRAN(楼栋号 + 单元号 + 楼层号 + 户室号, ' ', '0')
                        lcName = "House_" + lcNumber
                        IF VARTYPE(.&lcName) != "O"
                            lnRow = INT(VAL(楼层号))
                            lnCol = INT(VAL(户室号))
                            .AddObject(lcName, "C_Household")
                            WITH .&lcName
                                .Arrange
                                .Top = .Parent.Height - lnRow * (.Height + 5)
                                .Left = (lnCol - 1) * (.Width + 5)
                                ._Number = lcNumber
                                ._Name = ALLTRIM(姓名)
                                .Visible = .T.
                            ENDWITH
                        ENDIF
                    ENDWITH
                ENDIF
                SKIP
                IF (楼栋号 + 单元号 + 楼层号 + 户室号) != lcStr
                    lcStr = 楼栋号 + 单元号 + 楼层号 + 户室号
                ENDIF
            ENDDO
        ENDIF
       
    ENDPROC

ENDDEFINE

*---------------------------
* 选择器控件
*---------------------------
DEFINE CLASS C_Selector AS Container

    BorderWidth = 0
    BackStyle = 0

    PROCEDURE Init
        LOCAL laItems[4], lnIndex
       
        laItems[1] = "楼栋: "
        laItems[2] = "单元: "
        laItems[3] = "楼层: "
        laItems[4] = "户室: "
       
        WITH This
            FOR lnIndex = 1 TO ALEN(laItems, 1)
                .AddObject("cnt_Get" + TRANSFORM(lnIndex), "myGet")
                WITH .Controls(lnIndex)
                    .AddObject("Label1", "Label")
                    WITH .Label1
                        .Caption = laItems[lnIndex]
                        .Width = 40
                        .Height = 25
                        .Alignment = 1
                    ENDWITH
                    .AddObject("Combo1", "ComboBox")
                    WITH .Combo1
                        .Style = 2
                        .Width = 60
                        .Height = 25
                    ENDWITH
                    .Arrange
                    .Top = 0
                    .Left = (lnIndex - 1) * (.Width + 5)
                ENDWITH
                .Width = .Controls(lnIndex).Left + .Controls(lnIndex).Width
            NEXT
            .AddObject("btn_Go", "CommandButton")
            WITH .btn_Go
                .Caption = "确定"
                .Width = 40
                .Height = 25
                .Top = 0
                .Left = This.Controls(ALEN(laItems, 1)).Left + This.Controls(ALEN(laItems, 1)).Width + 20
            ENDWITH
            .Height = 25
            .Width = .btn_Go.Left + .btn_Go.Width
            .SetAll("Visible", .T.)
        ENDWITH
       
    ENDPROC
   
ENDDEFINE

*---------------------------
* 住户信息显示控件
*---------------------------
DEFINE CLASS C_Household AS Container

    BorderWidth = 2
    SpecialEffect = 0

    _FontName = "微软雅黑"
    PROCEDURE _FontName_Assign(tcValue)
        IF VARTYPE(tcValue) != "C"
            tcValue = "微软雅黑"
        ENDIF
        WITH This
            ._FontName = tcValue
            .SetAll("FontName", ._FontName)
        ENDWITH
    ENDPROC
   
    _FontSize = 9
    PROCEDURE _FontSize_Assign(tnValue)
        IF (VARTYPE(tnValue) != "N") .OR. (tnValue < 9)
            tnValue = 9
        ENDIF
        WITH This
            ._FontSize = tnValue
            .Arrange
        ENDWITH
    ENDPROC

    _Width = 100
    PROCEDURE _Width_Assign(tnValue)
        IF (VARTYPE(tnValue) != "N") .OR. (tnValue < 100)
            tnValue = 100
        ENDIF
        WITH This
            ._Width = tnValue
            .Arrange
        ENDWITH
    ENDPROC
   
    _Height = 16
    PROCEDURE _Height_Assign(tnValue)
        IF (VARTYPE(tnValue) != "N") .OR. (tnValue < 16)
            tnValue = 16
        ENDIF
        WITH This
            ._Height = tnValue
            .Arrange
        ENDWITH
    ENDPROC
   
    * 房号
    _Number = ""
    PROCEDURE _Number_Assign(tcValue)
        IF VARTYPE(tcValue) != "C"
            tcValue = ""
        ENDIF
        WITH This
            ._Number = tcValue
            .lbl_HouseNumber.Caption = ._Number
        ENDWITH
    ENDPROC
   
    * 户主名
    _Name = ""
    PROCEDURE _Name_Assign(tcValue)
        IF VARTYPE(tcValue) != "C"
            tcValue = ""
        ENDIF
        WITH This
            ._Name = tcValue
            .lbl_HouseName.Caption = ._Name
        ENDWITH
    ENDPROC

    HIDDEN _Margin
    _Margin = 4

    ADD OBJECT PROTECTED lbl_Title1      AS Label WITH Caption = "房号: ",     Alignment = 1, Width = 50, Height = This._Height
    ADD OBJECT PROTECTED lbl_HouseNumber AS Label WITH Caption = This._Number, Alignment = 2, Width = This._Width, Height = This._Height
    ADD OBJECT PROTECTED lbl_Title2      AS Label WITH Caption = "户主名: ",   Alignment = 1, Width = 50, Height = This._Height
    ADD OBJECT PROTECTED lbl_HouseName   AS Label WITH Caption = This._Name,   Alignment = 2, Width = This._Width, Height = This._Height
   
    PROCEDURE Arrange
        WITH This
            .SetAll("FontSize", ._FontSize)
            WITH .lbl_Title1
                .Height = This._Height
                .Top = This._Margin
                .Left = This._Margin
            ENDWITH
            WITH This.lbl_HouseNumber
                .Width = This._Width
                .Height = This._Height
                .Top = This.lbl_Title1.Top
                .Left = This.lbl_Title1.Left + This.lbl_Title1.Width
            ENDWITH
            WITH This.lbl_Title2
                .Height = This._Height
                .Top = This.lbl_Title1.Top + This.lbl_Title1.Height + This._Margin
                .Left = This._Margin
            ENDWITH
            WITH This.lbl_HouseName
                .Width = This._Width
                .Height = This._Height
                .Top = This.lbl_Title2.Top
                .Left = This.lbl_Title2.Left + This.lbl_Title1.Width
            ENDWITH
            .Width = .lbl_HouseNumber.Left + .lbl_HouseNumber.Width + ._Margin
            .Height = .lbl_HouseName.Top + .lbl_HouseName.Height + ._Margin
        ENDWITH
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
   
ENDDEFINE

*---------------------------
* 自定义窗体
*---------------------------
DEFINE CLASS myForm AS Form

    PROCEDURE Arrange
        * 虛方法
    ENDPROC
   
    PROCEDURE Activate
        ThisForm.Arrange
    ENDPROC
   
    PROCEDURE Resize
        ThisForm.Arrange
    ENDPROC

    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
ENDDEFINE

*----------------------
* 仿Get容器
*----------------------
DEFINE CLASS myGet AS Container

    BorderWidth = 0
    BackStyle = 0
   
    PROCEDURE Arrange
        LOCAL lnIndex
       
        WITH This
            .Height = 0
            .Width = 0
            FOR lnIndex = 1 TO .ControlCount
                WITH .Controls(lnIndex)
                    .Top = 0
                    IF .Height > This.Height
                        This.Height = .Height
                    ENDIF
                    IF lnIndex > 1
                        .Left = This.Controls(lnIndex - 1).Left + This.Controls(lnIndex - 1).Width + 5
                    ELSE
                        .Left = 0
                    ENDIF
                    This.Width = .Left + .Width
                ENDWITH
            NEXT
        ENDWITH
       
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
   
ENDDEFINE


test - caolp.zip (28.49 KB)


[ 本帖最后由 TonyDeng 于 2014-8-24 12:18 编辑 ]

授人以渔,不授人以鱼。
2014-08-24 12:11
caolp
Rank: 1
等 级:新手上路
帖 子:160
专家分:5
注 册:2014-7-12
收藏
得分:0 
刚刚又在同事的机子上看到TonyDeng老师又帮我写了这么多,实在感谢不尽。老师提到“房间状态”问题,我想用颜色表示,比如“常住户”用一种颜色;“暂住户”用一种颜色,无人住或空房用另一种颜色表示就可以了。再一次谢谢老师!
2014-08-24 18:50
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
我就是要知道你的表中哪里反映这几种状态,要各个样例都有。

授人以渔,不授人以鱼。
2014-08-24 19:33
xs591222
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:28
帖 子:682
专家分:1299
注 册:2009-3-1
收藏
得分:0 
能让TonyDeng出手写代码,看来楼主不简单……
2014-08-24 20:29
快速回复:如何做楼房的房号展示界面
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.098875 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved