增加单位
***********************************************
cViewName=THISFORM.cViewName2
SELECT (cViewName)
&&视图中存放有单位编码和名称等
IF LEN(TRIM(THIS.parent.Inputcode1.Text2.value))<>2
WAIT "代码位数不对,不能增加!" WINDOWS
RETURN
ENDIF
CASE cXmjb="r"
lcdm=TRIM(THIS.parent.Inputcode1.Text2.value)+"000000"
CASE cXmjb="A"
lcdm=SUBS(THISFORM.nodekey,2,2)+TRIM(THIS.parent.Inputcode1.Text2.value)+"0000"
CASE cXmjb="B"
lcdm=SUBS(THISFORM.nodekey,2,4)+TRIM(THIS.parent.Inputcode1.Text2.value)+"00"
CASE cXmjb="C" OR cXmjb="D"
lcdm=SUBS(THISFORM.nodekey,2,6)+TRIM(THIS.parent.Inputcode1.Text2.value)
ENDCASE
WAIT "代码已存在,不能增加!" WINDOWS
RETURN
ENDIF
nMaxID=newid(cViewName)
INSERT INTO (cViewName) (N_ID,sjdm1,sjdm2,sjdm3,sjdm4,c_unitcode,C_UNITNAME,c_jjlx,c_tjfl,n_rxl) VALUES ;
(nMaxID, SUBS(lcdm,1,2),SUBS(lcdm,3,2),SUBS(lcdm,5,2),SUBS(lcdm,7,2),lcdm,TRIM(THIS.parent.text2.value),;
THIS.parent.Codecobmobox1.value,THIS.parent.Codecobmobox2.value,THIS.parent.text3.value)
IF TABLEUPDATE()
*插入节点
DO CASE
CASE cXmjb="r"
nodesx=.nodes.ADD("r", 4,"A"+LEFT(lcdm,2),TRIM(THIS.parent.text2.value)+"("+LEFT(lcdm,2)+")","closebook")
WAIT cXmjb WINDOWS
CASE cXmjb="A"
nodesx=.nodes.ADD("A"+LEFT(lcdm,2), 4,"B"+LEFT(lcdm,4),TRIM(THIS.parent.text2.value)+"("+LEFT(lcdm,4)+")","closebook")
CASE cXmjb="B"
nodesx=.nodes.ADD("B"+LEFT(lcdm,4), 4,"C"+LEFT(lcdm,6),TRIM(THIS.parent.text2.value)+"("+LEFT(lcdm,6)+")","closebook")
CASE cXmjb="C" OR cXmjb="D"
nodesx=.nodes.ADD("C"+LEFT(lcdm,6), 4,"D"+LEFT(lcdm,8),TRIM(THIS.parent.text2.value)+"("+LEFT(lcdm,8)+")","closebook")
ENDCASE
.SELECTEDITEM=nodesx
THISFORM.NODEKEY=nodesx.Key
ELSE
=TABLEREVERT()
MESSAGEBOX("代码增加失败, 请重新操作!",48,"操作提示")
THISFORM.NODEKEY=.SELECTEDITEM.KEY
ENDIF
DO CASE
CASE THISFORM.nodekey="r"
THISFORM.pageframe1.page2.inputcode1.initformat("","00")
CASE LEFT(THISFORM.nodekey,1)="A"
THISFORM.pageframe1.page2.inputcode1.initformat(SUBS(THISFORM.nodekey,2,2),"00")
CASE LEFT(THISFORM.nodekey,1)="B"
THISFORM.pageframe1.page2.inputcode1.initformat(SUBS(THISFORM.nodekey,2,4),"00")
CASE LEFT(THISFORM.nodekey,1)="C"
THISFORM.pageframe1.page2.inputcode1.initformat(SUBS(THISFORM.nodekey,2,6),"00")
CASE LEFT(THISFORM.nodekey,1)="D"
THISFORM.pageframe1.page2.inputcode1.initformat(SUBS(THISFORM.nodekey,2,6),SUBS(THISFORM.nodekey,8,2))
ENDCASE
lcNodeText=.nodes.ITEM(THISFORM.NODEKEY).TEXT
THIS.parent.text2.value=LEFT(lcNodeText,ATC("(",lcNodeText)-1)
ENDWITH