GX 16

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
※   新增、全选、删除、导入、查询
    (S      U   U   U       S)
※   浏览(使用自带的Standard Action)
 
    (↓ 复制到 Font Icon Theme Class)
※   对号:fas fa-check
※   编辑:fas fa-pen
※   生效:fa fa-share
※   撤销:fa fa-reply
※   浏览(S 自带)
 
※   获取时间时使用:    servernow()
 
※   页面start添加:(VarChar 40,VarChar 100,VarChar 40,VarChar 40,Numeric 4,VarChar 40)
GetSIAppPublicSession.Call(&DepartID,&DepartNam,&UserCod,&UserNam,&OPFlag,&syskey)
        (↑ 简易版登录授权)
 
 
 
 
※   更改web panel的描述——
    1、patterns——》(Grid)Selecttion——》(右侧)Description
    2、点击web panel——》(右侧)Description
 
 
 
 
※   更改 Grid 的排序方式——
    1、Selecttion ——》TableMain ——》TableHeader ——》TableRightHeader ——》TableFilters ——》Orders 下的变量 ——》选中那个变量(右侧)
    2、Attribute 填入想改成按照排序的字段,Ascending:true正排(123),false倒排(543)
 
 
 
 
※   单行删除时的提示——
    DVelop_ConfirmPanel_Delete.ConfirmationText = format('是否删除部门 %1 ?',HRM_EmpSalCteDptNam)
        (↑ DVelop_ConfirmPanel_Delete 取决于自动生成的部分:末尾的 Delete 不固定)
 
 
 
 
        (↓ 同一个 Grid 中存在两个不同的表时会出现报错)
※   对于引用的另一个表的数据进行下拉框编辑(放在grid中的)
            - 如:SAM_Company 所属公司(SAM_CompanyId 公司编号,SAM_CompanyNm 公司名称)
    1、自定义变量:选中TableActions,右键添加 ——》variable(name、Description)
    2、与数据库数据进行关联:(右侧)Control Info ——》Control Info:Custom,Control Type:Dynamic Combo Box ——》(对应字段)Item Values:SAM_CompanyId,Item Description:SAM_CompanyNm
    3、(设置必填 ← 后边记得调用)——》(最上边)Is required:true,(最下边)Cell theme class:DataContentCell
        (↑ 系统生成的命名通常是   'CheckRequiredFields'
    4、(设置这个变量的类型)右侧 type Definition ——》data type 和type (它们的依据是 Control Info 中 Item Values 中绑定的类型)
 
 
 
 
※   导出Excel(特指 Rules 中传递过来了用于筛选的变量时)
    1、接收的属性前添加p(如:用于筛选的属性为 &a,接收数据时应用 &pa接收)
        (↓ 注意是写在 Refresh 中,而不是写在 Start 中)
    2、在 Event 的 Refresh 中进行赋值( &a = &pa )和隐藏( &a.Visible = false )操作
        (↓ 创建筛选属性:那个绿色的沙漏)
    3、右键 Patterns 的 TableHeader ——》添加 ——》FilterAtrribute (选择 a )
    4、选中新增的 筛选属性 ——》右侧,condition:condition ——》内容更改为 a = &a
    5、在 'DoExport'中添加 Do 'SaveGridState' 语句
            (↑ 用于保存 grid 状态,不然导出的excel表的数据会为空)
 
 
 
※   同表数据作为查询条件(此处以 状态 REC_BankIntSts 为例)
    1、TableActions(右键)——》FilterAtrribute(选中数据)
    2、Control Info:Custom ——》Control Type:Combo Box
    3、Values(去掉多余变量)——》Empty Item:True ——》Empty Item Text :全部
                                (↑ 默认展示全部数据)
 
 
 
 
※   自动更新(但要下载插件后这段代码才能使用)       ↓ VarChar 400
Event Extensions.Web.Popup.OnPopupClosed(&PopupName)
 
    //自动更新
    Grid.Refresh()
 
EndEvent
 
 
 
 
※   多选删除——              (点选删除时注意,要设置 →      &retokflg = 1  时才  refresh  ← 通过if 判断实现)
1、
    &ok = 0             //成功的数量
    &notok = 0          //失败的数量
    &rowcount = 0       //总共操作次数
 
    For each line
        if &Selected
            &rowcount += 1          //计算操作的行数
            (调用单行删除的代码)
            do 'Commit'
        endif
    Endfor
     
    if &rowcount = 0
        msg('请打勾选择需要删除记录')
    else
        msg(format('操作完成,共%1笔,成功%2笔,失败%3笔',&rowcount,&ok,&notok))
        if &ok > 0
            refresh
        endif
    endif
2、
Sub 'Commit'
 
    if &retokflg = 1
        &ok += 1        //计算操作成功的行数
        commit
    else
        &notok += 1     //计算操作失败的行数
        msg(&retstr)
        rollback
    endif
 
EndSub
 
 
 
 
※   新增时设置主键id自增——
//倒排,第一个就是最大值
For each order(id)
    //(这里可以通过where限制,使id在自己的基础上自增,如 where a = &a)
        //(↑ 1班学生a在2班获得的第一名奖状,是a的在2班第 1 张奖状)
    &id = id + 1
    exit        //获取后退出
When none
    &id = 1
Endfor
 
 
 
 
※   删除主表a时连带删除其名下从表b——
For each
    where aid = &aid            //锁定主表
    For each (没有where条件时 defined by bb 可以写在这里)
        where 条件
        defined by bb       //数据库表字段不重复,所以随便一个字段就可以锁定从表
        delete              //删除从表
    Endfor
    delete                  //删除主表
    &retokflg = 1
When none
    &retokflg = 0
    &retstr = '删除失败'
Endfor
 
 
 
※   删除表b时判断是否被表a使用——
For each
    where bid = &bid
    For each
        where a_bid = &bid
        &retokflg = 0
        &retstr = format('操作失败,该数据:%1,已在销售发票中使用',name)
        return
    Endfor
Endfor

  

 

posted @   椰子灰  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
历史上的今天:
2023-02-13 软工大二下学期开学考的感悟
点击右上角即可分享
微信分享提示