FrmDepartment.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmDepartment">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="公司部门设置";
  9. GetSchema();
  10. DepartTree.RootNodeName = GetCurrentCompany();
  11. Search("SearchAllDepartment");
  12. ]]>
  13. </Load>
  14. <EndLoad>
  15. <![CDATA[
  16. ChangeMode("Search");
  17. ]]>
  18. </EndLoad>
  19. <Closing>
  20. ;
  21. </Closing>
  22. <Closed>
  23. ;
  24. </Closed>
  25. </Events>
  26. <Mode>
  27. <Search>
  28. <Lable name="Search" />
  29. </Search>
  30. <New>
  31. <Lable name="New" />
  32. </New>
  33. <View>
  34. <Lable name="View" />
  35. </View>
  36. <Modify>
  37. <Lable name="Modify" />
  38. </Modify>
  39. </Mode>
  40. <Controls>
  41. <IKTextButton name="tbNo" DataSource="Department.No_Department">
  42. <Events>
  43. <Enter>
  44. <![CDATA[
  45. if(tbNo.ReadOnly == false)
  46. {
  47. if(tbNo.CValue != StringEmpty())
  48. {
  49. UpdateForm(false, "");
  50. if(Search("SearchDepartmentWithNo", tbNo.CValue))
  51. {
  52. ChangeMode("View");
  53. }
  54. else
  55. {
  56. if(GetRight(@Title,"新增"))
  57. {
  58. ChangeMode("New");
  59. }
  60. else
  61. MessageBox("您没有新增公司部门设置的权限!",@Title);
  62. }
  63. }
  64. else
  65. {
  66. MessageBox("请输入部门编号!",@Title);
  67. }
  68. }
  69. ]]>
  70. </Enter>
  71. <Click>
  72. @Temp = ShowSearchBox("DepartmentSearch","INFOMATION",tbNo.CValue);
  73. if(@Temp != StringEmpty())
  74. {
  75. tbNo.CValue = @Temp;
  76. UpdateForm(false, "");
  77. if(Search("SearchDepartmentWithNo", tbNo.CValue))
  78. {
  79. ChangeMode("View");
  80. }
  81. }
  82. </Click>
  83. </Events>
  84. </IKTextButton>
  85. <IKTextBox name="txtName" DataSource="Department.Name_Department"/>
  86. <IKComboBoxEx name="cbSubjection" ValueSource="Department.SubjectionID_Department" DisplaySource="Department.Name_SubDepartment" NoSource="Department.No_SubDepartment"
  87. DataSource="AllDepartment" ValueMember="ID_DepartmentAll" DisplayMember="Name_DepartmentAll" NoMember="No_DepartmentAll">
  88. <Events>
  89. <Reload>
  90. UpdateForm(false, "cbSubjection");
  91. Search("SearchAllDepartment");
  92. UpdateForm(true, "cbSubjection");
  93. </Reload>
  94. </Events>
  95. </IKComboBoxEx>
  96. <IKTextBox name="txtCreator" DataSource="Department.CreateName"/><!--Declare-->
  97. <IKDateTimeText name="dttCreateDate" DataSource="Department.CreateDate_Department"/>
  98. <IKTextBox name="txtMender" DataSource="Department.LastModUser_DepartmentName"></IKTextBox>
  99. <IKDateTimeText name="dttMendeDate" DataSource="Department.LastModDate_Department"></IKDateTimeText>
  100. <IKTextBox name="txtComment" DataSource="Department.Comment_Department"/>
  101. <IKFormToolBar name="toolBar">
  102. <Events>
  103. <ClickFirst>
  104. if(Search("SearchDepartmentFirst", tbNo.CValue))
  105. {
  106. ChangeMode("View");
  107. }
  108. </ClickFirst>
  109. <ClickPrev>
  110. if(Search("SearchDepartmentPrevious", tbNo.CValue))
  111. {
  112. ChangeMode("View");
  113. }
  114. </ClickPrev>
  115. <ClickNext>
  116. if(Search("SearchDepartmentNext", tbNo.CValue))
  117. {
  118. ChangeMode("View");
  119. }
  120. </ClickNext>
  121. <ClickLast>
  122. if(Search("SearchDepartmentLast", tbNo.CValue))
  123. {
  124. ChangeMode("View");
  125. }
  126. </ClickLast>
  127. <ClickNew>
  128. ;
  129. </ClickNew>
  130. <ClickEmpty>
  131. ChangeMode("Search");
  132. </ClickEmpty>
  133. <ClickSubmit>
  134. <Lable name="SubmitButtonClick" />
  135. </ClickSubmit>
  136. <ClickModify>
  137. ChangeMode("Modify");
  138. </ClickModify>
  139. <ClickDelete>
  140. if(Search("SearchSubDepartment", tbNo.CValue))
  141. {
  142. if(MessageBox("该部门有下属部门,若删除此部门资料其所有下属部门的资料均会被删除,确定要删除此部门资料吗?",@Title,MB_YESNO)==DialogResult("YES"))
  143. {
  144. Delete();
  145. ChangeMode("Search");
  146. }
  147. }
  148. else
  149. {
  150. Delete();
  151. ChangeMode("Search");
  152. }
  153. </ClickDelete>
  154. <ClickPrint>
  155. PrintReport();
  156. </ClickPrint>
  157. <ClickAudit>
  158. ;
  159. </ClickAudit>
  160. <ClickUnAudit>
  161. ;
  162. </ClickUnAudit>
  163. <ClickImport>
  164. ;
  165. </ClickImport>
  166. <ClickExport>
  167. ;
  168. </ClickExport>
  169. <ClickClose>
  170. ;
  171. </ClickClose>
  172. <ClickExpand>
  173. if(toolBar.ExpandForm==true)
  174. {
  175. pnRight.Visible=true;<!--PanelRight is not existed-->
  176. }
  177. else
  178. {
  179. pnRight.Visible=false;
  180. }
  181. </ClickExpand>
  182. </Events>
  183. </IKFormToolBar>
  184. <IKHiberaTree name="DepartTree" DisplayMember="Name_Department" ValueMember="ID_Department" NoMember="No_Department" SubjectValueMember="SubjectionID_Department" DataSource="treeDep">
  185. <Events>
  186. <DoubleClick>
  187. if( !Equals(DepartTree.SelectNodeNo, tbNo.CValue) )
  188. {
  189. ChangeMode("Search");
  190. tbNo.CValue = DepartTree.SelectNodeNo;
  191. ActiveControlEvent("tbNo", "Enter");
  192. }
  193. </DoubleClick>
  194. <RightClickItem>
  195. if(DepartTree.MenuItemText == "新增下属部门")
  196. {
  197. ChangeMode("Search");
  198. }
  199. else if(DepartTree.MenuItemText == "删除")
  200. {
  201. ShowMessageBox("确定要删除当前记录?","YesNo","Question");
  202. if(Search("SearchSubDepartment", DepartTree.SelectNodeNo))
  203. {
  204. if(MessageBox("该部门有下属部门,若删除此部门资料其所有下属部门的资料均会被删除,确定要删除此部门资料吗?",@Title,MB_YESNO)==DialogResult("YES"))
  205. {
  206. Delete();
  207. ChangeMode("Search");
  208. }
  209. }
  210. else
  211. {
  212. Delete();
  213. ChangeMode("Search");
  214. }
  215. }
  216. else if(DepartTree.MenuItemText == "查看资料")
  217. {
  218. ChangeMode("Search");
  219. tbNo.CValue = DepartTree.SelectNodeNo;
  220. ActiveControlEvent("tbNo", "Enter");
  221. }
  222. </RightClickItem>
  223. </Events>
  224. </IKHiberaTree>
  225. </Controls>
  226. <Tables>
  227. ;<!--TODO-->
  228. </Tables>
  229. <LockInfomation LockID="ID_Department" LockNO="No_Department" LockSearchFunction="SearchDepartmentWithNo"/>
  230. <ChildForms>
  231. <ChildForm name="DepartmentSearch" DataSource="Department" SearchFunction="SearchAllDepartmentofsub" SearchFunctionByNo="SearchDepartmentWithNo" MappingName="部门">
  232. <DataColumn Index="0" MappingName="#Department.No_Department" HeaderText="部门编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  233. <DataColumn Index="1" MappingName="#Department.Name_Department" HeaderText="部门名称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  234. </ChildForm>
  235. </ChildForms>
  236. </Client>
  237. <Server>
  238. <Tables>
  239. <Table name="Department" Type="Parent">
  240. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  241. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  242. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  243. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User">
  244. </GetSchema>
  245. <New CmdType="Text" CmdText=" INSERT INTO Department (ID_Department, No_Department, Name_Department, SubjectionID_Department, Level_Department, ID_Creator, CreateDate_Department, Comment_Department, SuspendDate_Department,LastModDate_Department,LastModUser_Department)
  246. VALUES(@ID_Department, @No_Department, @Name_Department, @SubjectionID_Department, @Level_Department, @ID_Creator, @CreateDate_Department, @Comment_Department, @SuspendDate_Department,@LastModDate_Department,@LastModUser_Department)">
  247. <Params>
  248. <Param name="@ID_Department" type="Department.ID_Department" sourceColumn="ID_Department" />
  249. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  250. <Param name="@Name_Department" type="Department.Name_Department" sourceColumn="Name_Department" />
  251. <Param name="@SubjectionID_Department" type="Department.SubjectionID_Department" sourceColumn="SubjectionID_Department" />
  252. <Param name="@Level_Department" type="Department.Level_Department" sourceColumn="Level_Department" />
  253. <Param name="@ID_Creator" type="Department.ID_Creator" sourceColumn="ID_Creator" />
  254. <Param name="@CreateDate_Department" type="Department.CreateDate_Department" sourceColumn="CreateDate_Department" />
  255. <Param name="@Comment_Department" type="Department.Comment_Department" sourceColumn="Comment_Department" />
  256. <Param name="@SuspendDate_Department" type="Department.SuspendDate_Department" sourceColumn="SuspendDate_Department" />
  257. <Param name="@LastModUser_Department" type="Department.LastModUser_Department" sourceColumn="LastModUser_Department" />
  258. <Param name="@LastModDate_Department" type="Department.LastModDate_Department" sourceColumn="LastModDate_Department" />
  259. </Params>
  260. </New>
  261. <Update CmdType="Text" CmdText="UPDATE Department SET
  262. Name_Department=@Name_Department,
  263. ID_Creator=@ID_Creator,
  264. CreateDate_Department=@CreateDate_Department,
  265. Comment_Department=@Comment_Department,
  266. SuspendDate_Department=@SuspendDate_Department,
  267. LastModUser_Department=@LastModUser_Department,
  268. LastModDate_Department=@LastModDate_Department
  269. WHERE ID_Department=@ID_Department">
  270. <Params>
  271. <Param name="@ID_Department" type="Department.ID_Department" sourceColumn="ID_Department" />
  272. <Param name="@Name_Department" type="Department.Name_Department" sourceColumn="Name_Department" />
  273. <Param name="@ID_Creator" type="Department.ID_Creator" sourceColumn="ID_Creator" />
  274. <Param name="@CreateDate_Department" type="Department.CreateDate_Department" sourceColumn="CreateDate_Department" />
  275. <Param name="@Comment_Department" type="Department.Comment_Department" sourceColumn="Comment_Department" />
  276. <Param name="@SuspendDate_Department" type="Department.SuspendDate_Department" sourceColumn="SuspendDate_Department" />
  277. <Param name="@LastModUser_Department" type="Department.LastModUser_Department" sourceColumn="LastModUser_Department" />
  278. <Param name="@LastModDate_Department" type="Department.LastModDate_Department" sourceColumn="LastModDate_Department" />
  279. </Params>
  280. </Update>
  281. <Delete CmdType="Text" CmdText="IF Object_ID(N'tempdb..#DELETE') IS Not NULL
  282. DROP TABLE #DELETE
  283. CREATE TABLE #DELETE
  284. (
  285. ID_DELETE UNIQUEIDENTIFIER,
  286. LEV_DELETE INT
  287. )
  288. DECLARE @ID_LOC UNIQUEIDENTIFIER
  289. DECLARE @LEV INT
  290. DECLARE @TEMPLEV INT
  291. DECLARE @STR NVARCHAR(100)
  292. DECLARE @COUNTS INT
  293. DECLARE @COUNT INT
  294. SELECT @ID_LOC = A.ID_Department,@LEV = A.LEVEL_Department FROM Department A
  295. LEFT JOIN Department B ON A.ID_Department = B.SUBJECTIONID_Department
  296. WHERE A.ID_Department = @ID_Department
  297. SET @STR = N'INSERT INTO #DELETE VALUES(@TID_LOC,@TLEV)'
  298. EXECUTE sp_executesql @STR,N'@TID_LOC UNIQUEIDENTIFIER,@TLEV INT',@ID_LOC,@LEV
  299. DECLARE CUR CURSOR FOR SELECT B.ID_Department ,B.LEVEL_Department FROM Department A
  300. INNER JOIN Department B ON A.ID_Department = B.SUBJECTIONID_Department
  301. WHERE A.ID_Department = @ID_Department
  302. OPEN CUR
  303. FETCH NEXT FROM CUR INTO @ID_LOC,@LEV
  304. WHILE @@FETCH_STATUS = 0
  305. BEGIN
  306. SET @STR = N'INSERT INTO #DELETE VALUES(@TID_LOC,@TLEV)'
  307. EXECUTE sp_executesql @STR,N'@TID_LOC UNIQUEIDENTIFIER,@TLEV INT',@ID_LOC,@LEV
  308. FETCH NEXT FROM CUR INTO @ID_LOC,@LEV
  309. END
  310. CLOSE CUR
  311. DEALLOCATE CUR
  312. SET @TEMPLEV = @LEV
  313. SELECT @COUNTS = COUNT(*) FROM (SELECT * FROM #DELETE WHERE LEV_DELETE = @TEMPLEV) COUNTS
  314. WHILE @COUNTS &gt; 0
  315. BEGIN
  316. DECLARE CUR CURSOR FOR SELECT L.ID_Department,L.LEVEL_Department FROM #DELETE T
  317. INNER JOIN Department L ON T.ID_DELETE = L.SUBJECTIONID_Department
  318. WHERE T.LEV_DELETE = @TEMPLEV
  319. OPEN CUR
  320. FETCH NEXT FROM CUR INTO @ID_LOC,@LEV
  321. WHILE @@FETCH_STATUS = 0
  322. BEGIN
  323. SET @STR = N'INSERT INTO #DELETE VALUES(@TID_LOC,@TLEV)'
  324. EXECUTE sp_executesql @STR,N'@TID_LOC UNIQUEIDENTIFIER,@TLEV INT',@ID_LOC,@LEV
  325. FETCH NEXT FROM CUR INTO @ID_LOC,@LEV
  326. END
  327. CLOSE CUR
  328. DEALLOCATE CUR
  329. SET @TEMPLEV = @TEMPLEV + 1
  330. SELECT @COUNTS = COUNT(*) FROM (SELECT * FROM #DELETE WHERE LEV_DELETE = @TEMPLEV) COUNTS
  331. END
  332. SELECT @COUNTS = COUNT(*) FROM #DELETE
  333. DECLARE CUR CURSOR FOR SELECT ID_DELETE FROM #DELETE ORDER BY LEV_DELETE DESC
  334. OPEN CUR
  335. FETCH NEXT FROM CUR INTO @ID_LOC
  336. WHILE @@FETCH_STATUS = 0
  337. BEGIN
  338. IF @COUNTS != 1
  339. BEGIN
  340. SELECT @COUNT=COUNT(*) FROM LockInfoTable WHERE LockInfoTable.RecordID_LockInfoTable = @ID_LOC
  341. IF @COUNT != 0
  342. BEGIN
  343. CLOSE CUR
  344. DEALLOCATE CUR
  345. DROP TABLE #DELETE
  346. RAISERROR('子部门正在被使用,无法执行删除操作!',18,1)
  347. RETURN
  348. END
  349. INSERT INTO LockInfoTable (RecordID_LockInfoTable,Funcode_LockInfoTable,LoginID_LockInfoTable,UserID_LockInfoTable) VALUES (@ID_LOC,'FrmDepartment',NEWID(),NEWID())
  350. SET @COUNTS = @COUNTS-1
  351. END
  352. DECLARE @COU DEC(14,4) SELECT @COU = COUNT(*) FROM (SELECT * FROM Employee WHERE Employee.ID_Department=@ID_LOC) C
  353. IF @COU &gt; 0
  354. BEGIN
  355. CLOSE CUR
  356. DEALLOCATE CUR
  357. DROP TABLE #DELETE
  358. RAISERROR('存在员工',18,19)
  359. RETURN
  360. END
  361. DELETE FROM Employee WHERE Employee.ID_Department=@ID_LOC
  362. DELETE FROM Department WHERE Department.ID_Department = @ID_LOC
  363. DELETE FROM LockInfoTable WHERE LockInfoTable.RecordID_LockInfoTable = @ID_LOC AND LockInfoTable.Funcode_LockInfoTable = 'FrmDepartment'
  364. FETCH NEXT FROM CUR INTO @ID_LOC
  365. END
  366. CLOSE CUR
  367. DEALLOCATE CUR
  368. DROP TABLE #DELETE">
  369. <Params>
  370. <Param name="@ID_Department" type="Department.ID_Department" sourceColumn="ID_Department" />
  371. </Params>
  372. </Delete>
  373. <FKErrorReport ErrorMessage="该部门已被引用,删除失败!"/>
  374. <UNIQUEErrorReport ErrorMessage="该部门编号或名称已存在,提交失败!"/>
  375. </Table>
  376. </Tables>
  377. <Search>
  378. <SearchAllDepartmentofsub CmdType="Text" CmdText="SELECT Department.No_Department,Department.Name_Department FROM Department ">
  379. <Tables>
  380. <Table name="Alldepartment" />
  381. </Tables>
  382. </SearchAllDepartmentofsub>
  383. <SearchTree CmdType="Text" CmdText="Select ID_Department,No_Department,'('+No_Department+')'+Name_Department As Name_Department, SubjectionID_Department From Department">
  384. <Tables>
  385. <Table name="treeDep" />
  386. </Tables>
  387. </SearchTree>
  388. <SearchDepartmentWithNo CmdType="Text" CmdText="SELECT A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  389. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  390. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  391. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User
  392. WHERE A.No_Department = @No_Department">
  393. <Params>
  394. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  395. </Params>
  396. <Tables>
  397. <Table name="Department" />
  398. </Tables>
  399. </SearchDepartmentWithNo>
  400. <SearchAllDepartment CmdType="Text" CmdText="SELECT A.ID_Department as ID_DepartmentAll,A.Name_Department as Name_DepartmentAll,A.No_Department as No_DepartmentAll FROM Department A order by No_Department">
  401. <Tables>
  402. <Table name="AllDepartment"/>
  403. </Tables>
  404. </SearchAllDepartment>
  405. <SearchDepartmentFirst CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  406. SET @NextNo = @No_Department
  407. SELECT TOP 1 @NextNo = Department.No_Department FROM Department ORDER BY Department.No_Department
  408. SELECT A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  409. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  410. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  411. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User
  412. WHERE A.No_Department = @NextNo">
  413. <Params>
  414. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  415. </Params>
  416. <Tables>
  417. <Table name="Department" />
  418. </Tables>
  419. </SearchDepartmentFirst>
  420. <SearchDepartmentPrevious CmdType="Text" CmdText="DECLARE @NextNo nvarchar(64)
  421. SET @NextNo = @No_Department
  422. SELECT TOP 1 @NextNo = Department.No_Department FROM Department WHERE Department.No_Department &lt; @No_Department ORDER BY Department.No_Department Desc
  423. SELECT A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  424. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  425. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  426. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User
  427. WHERE A.No_Department = @NextNo">
  428. <Params>
  429. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  430. </Params>
  431. <Tables>
  432. <Table name="Department" />
  433. </Tables>
  434. </SearchDepartmentPrevious>
  435. <SearchDepartmentNext CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  436. SET @NextNo = @No_Department
  437. SELECT TOP 1 @NextNo = Department.No_Department FROM Department WHERE Department.No_Department &gt; @No_Department ORDER BY Department.No_Department
  438. SELECT A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  439. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  440. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  441. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User
  442. WHERE A.No_Department = @NextNo">
  443. <Params>
  444. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  445. </Params>
  446. <Tables>
  447. <Table name="Department" />
  448. </Tables>
  449. </SearchDepartmentNext>
  450. <SearchDepartmentLast CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  451. SET @NextNo = @No_Department
  452. SELECT TOP 1 @NextNo = Department.No_Department FROM Department ORDER BY Department.No_Department DESC
  453. SELECT A.*,B.Name_Department AS Name_SubDepartment, B.No_Department AS No_SubDepartment,Y.Name_User as LastModUser_DepartmentName, U.Name_User AS CreateName FROM Department A
  454. LEFT JOIN Department B ON A.SubjectionID_Department = B.ID_Department
  455. LEFT JOIN AppUser U ON A.ID_Creator = U.ID_User
  456. LEFT JOIN AppUser Y ON A.LastModUser_Department = Y.ID_User
  457. WHERE A.No_Department = @NextNo">
  458. <Params>
  459. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  460. </Params>
  461. <Tables>
  462. <Table name="Department" />
  463. </Tables>
  464. </SearchDepartmentLast>
  465. <SearchSubDepartment CmdType="Text" CmdText="SELECT * FROM Department A
  466. INNER JOIN Department B ON A.ID_Department = B.SubjectionID_Department
  467. WHERE A.No_Department = @No_Department">
  468. <Params>
  469. <Param name="@No_Department" type="Department.No_Department" sourceColumn="No_Department" />
  470. </Params>
  471. <Tables>
  472. <Table name="DepartmentSub" />
  473. </Tables>
  474. </SearchSubDepartment>
  475. <SearchLevelByName CmdType="Text" CmdText="SELECT Level_Department FROM Department WHERE Name_Department = @Name_Department">
  476. <Params>
  477. <Param name="@Name_Department" type="Department.Name_Department" sourceColumn="Name_Department" />
  478. </Params>
  479. <Tables>
  480. <Table name="DepartmentLevel" />
  481. </Tables>
  482. </SearchLevelByName>
  483. </Search>
  484. </Server>
  485. <Lables>
  486. <Search>
  487. Empty();
  488. NewInstance();
  489. tbNo.ReadOnly=false;
  490. txtName.ReadOnly=true;
  491. txtComment.ReadOnly=true;
  492. cbSubjection.Enabled=false;
  493. toolBar.EnableSubmit=false;
  494. toolBar.EnableModify=false;
  495. toolBar.EnableDelete=false;
  496. #Department.CreateDate_Department=DBNull();
  497. #Department.LastModDate_Department=DBNull();
  498. #Department.LastModUser_Department=DBNull();
  499. Search("SearchTree");
  500. UpdateForm(true, "");
  501. tbNo.Focus();
  502. @Status=0;
  503. </Search>
  504. <New>
  505. Empty();
  506. NewInstance();
  507. tbNo.ReadOnly=true;
  508. txtName.ReadOnly=false;
  509. txtComment.ReadOnly=false;
  510. cbSubjection.Enabled=true;
  511. toolBar.EnableSubmit=GetRight(@Title,"新增");
  512. toolBar.EnableModify=false;
  513. toolBar.EnableDelete=false;
  514. #Department.No_Department = tbNo.CValue;
  515. #Department.SubjectionID_Department=DBNull();
  516. #Department.ID_Department=NewGuid();
  517. #Department.CreateName=GetCurrentUser();
  518. #Department.ID_Creator=GetLoginUserID();
  519. #Department.CreateDate_Department=DateTimeNow();
  520. #Department.LastModDate_Department=DBNull();
  521. #Department.LastModUser_Department=DBNull();
  522. #Department.SuspendDate_Department=DBNull();
  523. Search("SearchTree");
  524. UpdateForm(true, "");
  525. DepartTree.SetCurrentNode("("+tbNo.CValue+")"+txtName.CValue);
  526. txtName.Focus();
  527. @Status=1;
  528. </New>
  529. <View>
  530. tbNo.ReadOnly=false;
  531. txtName.ReadOnly=true;
  532. txtComment.ReadOnly=true;
  533. cbSubjection.Enabled=false;
  534. toolBar.EnableSubmit=false;
  535. toolBar.EnableModify=GetRight(@Title,"修改");
  536. toolBar.EnableDelete=GetRight(@Title,"删除");
  537. Search("SearchTree");
  538. UpdateForm(true, "");
  539. DepartTree.SetCurrentNode("("+tbNo.CValue+")"+txtName.CValue);
  540. @Status=2;
  541. </View>
  542. <Modify>
  543. tbNo.ReadOnly=true;
  544. txtName.ReadOnly=false;
  545. txtComment.ReadOnly=false;
  546. cbSubjection.Enabled=false;
  547. toolBar.EnableSubmit=GetRight(@Title,"新增");
  548. toolBar.EnableModify=false;
  549. toolBar.EnableDelete=GetRight(@Title,"删除");
  550. #Department.LastModUser_DepartmentName=GetCurrentUser();
  551. #Department.LastModDate_Department=DateTimeNow();
  552. #Department.LastModUser_Department=GetLoginUserID();
  553. Search("SearchTree");
  554. UpdateForm(true, "");
  555. DepartTree.SetCurrentNode("("+tbNo.CValue+")"+txtName.CValue);
  556. txtName.Focus();
  557. @Status=3;
  558. </Modify>
  559. <SubmitButtonClick>
  560. <![CDATA[
  561. if(txtName.CValue==StringEmpty())
  562. {
  563. MessageBox("请输入部门名称!",@Title);
  564. txtName.Focus();
  565. return;
  566. }
  567. if(!cbSubjection.CheckSelectedItem())
  568. {
  569. MessageBox("请选择有效的隶属部门!",@Title);
  570. cbSubjection.Focus();
  571. return;
  572. }
  573. UpdateForm(false, "");
  574. if(@Status==1)
  575. {
  576. if(Search("SearchLevelByName",cbSubjection.SelectedName))
  577. {
  578. #Department.Level_Department=#DepartmentLevel.Level_Department+1;
  579. }
  580. else
  581. {
  582. #Department.Level_Department=0;
  583. }
  584. New();
  585. }
  586. if(@Status == 3)
  587. {
  588. #Department.LastModDate_Department=DateTimeNow();
  589. Update();
  590. }
  591. ChangeMode("View");
  592. ]]>
  593. </SubmitButtonClick>
  594. </Lables>
  595. </Form>
  596. </Forms>