w_post_propel_edit_ljfieb.srw 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. $PBExportHeader$w_post_propel_edit_ljfieb.srw
  2. forward
  3. global type w_post_propel_edit_ljfieb from w_publ_base
  4. end type
  5. type dw_1 from datawindow within w_post_propel_edit_ljfieb
  6. end type
  7. type cb_1 from uo_imflatbutton within w_post_propel_edit_ljfieb
  8. end type
  9. type dw_mx from u_dw_rbtnfilter within w_post_propel_edit_ljfieb
  10. end type
  11. type cb_cus_ch from uo_imflatbutton within w_post_propel_edit_ljfieb
  12. end type
  13. type cb_spt_ch from uo_imflatbutton within w_post_propel_edit_ljfieb
  14. end type
  15. type cb_delmx from uo_imflatbutton within w_post_propel_edit_ljfieb
  16. end type
  17. type dw_mx_ori from datawindow within w_post_propel_edit_ljfieb
  18. end type
  19. end forward
  20. global type w_post_propel_edit_ljfieb from w_publ_base
  21. integer width = 2309
  22. integer height = 2380
  23. string title = "发公告"
  24. boolean minbox = false
  25. windowtype windowtype = response!
  26. dw_1 dw_1
  27. cb_1 cb_1
  28. dw_mx dw_mx
  29. cb_cus_ch cb_cus_ch
  30. cb_spt_ch cb_spt_ch
  31. cb_delmx cb_delmx
  32. dw_mx_ori dw_mx_ori
  33. end type
  34. global w_post_propel_edit_ljfieb w_post_propel_edit_ljfieb
  35. type variables
  36. long ins_postid
  37. uo_ljfieb uo_fieb
  38. Transaction tr_eb_sqlca
  39. end variables
  40. on w_post_propel_edit_ljfieb.create
  41. int iCurrent
  42. call super::create
  43. this.dw_1=create dw_1
  44. this.cb_1=create cb_1
  45. this.dw_mx=create dw_mx
  46. this.cb_cus_ch=create cb_cus_ch
  47. this.cb_spt_ch=create cb_spt_ch
  48. this.cb_delmx=create cb_delmx
  49. this.dw_mx_ori=create dw_mx_ori
  50. iCurrent=UpperBound(this.Control)
  51. this.Control[iCurrent+1]=this.dw_1
  52. this.Control[iCurrent+2]=this.cb_1
  53. this.Control[iCurrent+3]=this.dw_mx
  54. this.Control[iCurrent+4]=this.cb_cus_ch
  55. this.Control[iCurrent+5]=this.cb_spt_ch
  56. this.Control[iCurrent+6]=this.cb_delmx
  57. this.Control[iCurrent+7]=this.dw_mx_ori
  58. end on
  59. on w_post_propel_edit_ljfieb.destroy
  60. call super::destroy
  61. destroy(this.dw_1)
  62. destroy(this.cb_1)
  63. destroy(this.dw_mx)
  64. destroy(this.cb_cus_ch)
  65. destroy(this.cb_spt_ch)
  66. destroy(this.cb_delmx)
  67. destroy(this.dw_mx_ori)
  68. end on
  69. event open;call super::open;ins_postid = Message.DoubleParm
  70. tr_eb_sqlca = sys_email_sqlca // 电子商务连接
  71. uo_fieb = Create uo_ljfieb
  72. uo_fieb.commit_transaction = tr_eb_sqlca
  73. dw_1.SetTransObject(sqlca)
  74. dw_mx.SetTransObject(sqlca)
  75. dw_mx_ori.SetTransObject(sqlca)
  76. If ins_postid = 0 Then
  77. dw_1.InsertRow(0)
  78. Else
  79. dw_1.Retrieve(ins_postid)
  80. dw_mx.retrieve(ins_postid)
  81. dw_mx_ori.retrieve(ins_postid)
  82. End If
  83. dw_1.SetFocus()
  84. end event
  85. event close;call super::close;destroy uo_fieb
  86. end event
  87. type cb_func from w_publ_base`cb_func within w_post_propel_edit_ljfieb
  88. boolean visible = false
  89. end type
  90. type cb_exit from w_publ_base`cb_exit within w_post_propel_edit_ljfieb
  91. integer x = 1170
  92. integer y = 2172
  93. integer picsize = 16
  94. end type
  95. type dw_1 from datawindow within w_post_propel_edit_ljfieb
  96. integer x = 23
  97. integer y = 16
  98. integer width = 2249
  99. integer height = 868
  100. integer taborder = 30
  101. boolean bringtotop = true
  102. string title = "none"
  103. string dataobject = "dw_post_propel_edit_ljfieb"
  104. boolean livescroll = true
  105. borderstyle borderstyle = stylelowered!
  106. end type
  107. event rbuttondown;Long ll_row,ll_column
  108. ll_row = This.GetRow()
  109. ll_column = This.GetColumn()
  110. If ll_row <= 0 Then Return
  111. If ll_column <= 0 Then Return
  112. If Left( This.Describe( dwo.Name+ ".coltype"),4) = 'date' Then
  113. s_calender_arg s_calender
  114. s_calender.PointerX = This.PointerX()
  115. s_calender.PointerY = This.PointerY()
  116. s_calender.X = This.X + Parent.X
  117. s_calender.Y = This.Y + Parent.Y
  118. OpenWithParm(w_calendar,s_calender)
  119. This.SetItem(ll_row,ll_column,id_date_selected)
  120. End If
  121. end event
  122. type cb_1 from uo_imflatbutton within w_post_propel_edit_ljfieb
  123. integer x = 731
  124. integer y = 2172
  125. integer width = 311
  126. integer height = 96
  127. integer taborder = 20
  128. boolean bringtotop = true
  129. string text = "提交"
  130. string normalpicname = "ok.bmp"
  131. integer picsize = 16
  132. end type
  133. event clicked;call super::clicked;Long ll_scid,ll_deptid,ll_postid,ll_newid
  134. DateTime ld_sdate,ld_edate
  135. String ls_dscrp
  136. String errmsg
  137. Long ll_i,ll_j
  138. String ls_commcode, ls_commsccode, ls_commname
  139. Int li_kind
  140. dw_1.AcceptText()
  141. dw_mx.AcceptText()
  142. Long ll_row
  143. ll_row = dw_1.GetRow()
  144. If ll_row <= 0 Then
  145. MessageBox('系统提示','没有可保存的内容')
  146. Return
  147. End If
  148. ll_postid = dw_1.Object.postid[ll_row]
  149. ld_sdate = dw_1.Object.sdate[ll_row]
  150. ld_edate = dw_1.Object.edate[ll_row]
  151. ls_dscrp = dw_1.Object.dscrp[ll_row]
  152. ld_sdate = DateTime(Date(ld_sdate),Time(0))
  153. ld_edate = DateTime(Date(ld_edate),Time('23:59:59'))
  154. If ld_edate < ld_sdate Then
  155. MessageBox('系统提示','结束日期不能早于开始日期')
  156. Return
  157. End If
  158. If Trim(ls_dscrp) = '' Then
  159. MessageBox('系统提示','请输入公告内容')
  160. Return
  161. End If
  162. If dw_mx.RowCount() = 0 Then
  163. MessageBox('系统提示','请先选择要推送公告的对象')
  164. Return
  165. End If
  166. If MessageBox('询问','是否确定要发布公告?',question!,yesno!) = 2 Then Return
  167. If ll_postid = 0 Then
  168. ll_newid = f_sys_scidentity(0,"u_post_propel","postid",errmsg,True,sqlca)
  169. If ll_newid <= 0 Then
  170. MessageBox(publ_operator,errmsg)
  171. Return
  172. End If
  173. Insert Into u_post_propel
  174. (postid, sdate, edate, dscrp, opemp, opdate)
  175. Values (:ll_newid, :ld_sdate, :ld_edate, :ls_dscrp,:publ_operator,getdate());
  176. If sqlca.SQLCode <> 0 Then
  177. Rollback;
  178. MessageBox('Error','新建公告失败,'+sqlca.SQLErrText)
  179. Return
  180. End If
  181. For ll_i = 1 To dw_mx.RowCount()
  182. ls_commcode = dw_mx.Object.commcode[ll_i]
  183. ls_commsccode = dw_mx.Object.commsccode[ll_i]
  184. ls_commname = dw_mx.Object.commname[ll_i]
  185. li_kind = dw_mx.Object.Kind[ll_i]
  186. Insert Into u_post_propel_mx
  187. (postid,
  188. commcode,
  189. commsccode,
  190. commname,
  191. kind)
  192. Values (:ll_newid,
  193. :ls_commcode,
  194. :ls_commsccode,
  195. :ls_commname,
  196. :li_kind);
  197. If sqlca.SQLCode <> 0 Then
  198. Rollback;
  199. MessageBox('Error','插入推送对象列表失败,'+sqlca.SQLErrText)
  200. Return
  201. End If
  202. Next
  203. Else
  204. Update u_post_propel
  205. Set sdate = :ld_sdate,
  206. edate = :ld_edate,
  207. dscrp = :ls_dscrp,
  208. opemp = :publ_operator,
  209. opdate = getdate()
  210. Where postid = :ll_postid;
  211. If sqlca.SQLCode <> 0 Then
  212. Rollback;
  213. MessageBox('Error','更新公告失败,'+sqlca.SQLErrText)
  214. Return
  215. End If
  216. Delete From u_post_propel_mx
  217. Where postid = :ll_postid;
  218. If sqlca.SQLCode <> 0 Then
  219. Rollback;
  220. MessageBox('Error','删除原推送对象列表失败,'+sqlca.SQLErrText)
  221. Return
  222. End If
  223. For ll_i = 1 To dw_mx.RowCount()
  224. ls_commcode = dw_mx.Object.commcode[ll_i]
  225. ls_commsccode = dw_mx.Object.commsccode[ll_i]
  226. ls_commname = dw_mx.Object.commname[ll_i]
  227. li_kind = dw_mx.Object.Kind[ll_i]
  228. Insert Into u_post_propel_mx
  229. (postid,
  230. commcode,
  231. commsccode,
  232. commname,
  233. kind)
  234. Values (:ll_postid,
  235. :ls_commcode,
  236. :ls_commsccode,
  237. :ls_commname,
  238. :li_kind);
  239. If sqlca.SQLCode <> 0 Then
  240. Rollback;
  241. MessageBox('Error','插入推送对象列表失败,'+sqlca.SQLErrText)
  242. Return
  243. End If
  244. Next
  245. End If
  246. Commit;
  247. //推送
  248. Long ll_sendcuscommid,ll_receivecuscommid
  249. String arg_msg_err,arg_msg_tmp
  250. DateTime server_dt
  251. Long ll_suc,ll_fail
  252. s_post_ljfieb arg_s_post
  253. String ls_RelatedCode
  254. String ls_SerialNum
  255. Select CusCommID
  256. Into :ll_sendcuscommid
  257. From LJFIEB_CusComm
  258. Where CusType = 0 Using tr_eb_sqlca;
  259. If tr_eb_sqlca.SQLCode <> 0 Then
  260. MessageBox('Error','查询本公司企业编号失败,'+tr_eb_sqlca.SQLErrText)
  261. Return
  262. End If
  263. Select Top 1 getdate() Into :server_dt From u_user ;
  264. If sqlca.SQLCode <> 0 Then
  265. MessageBox('error',"查询操作失败,日期 ")
  266. Return
  267. End If
  268. If ll_postid = 0 Then
  269. arg_s_post.postid = ll_newid
  270. Else
  271. arg_s_post.postid = ll_postid
  272. End If
  273. arg_s_post.sdate = ld_sdate
  274. arg_s_post.edate = ld_edate
  275. arg_s_post.dscrp = ls_dscrp
  276. arg_s_post.opemp = publ_operator
  277. arg_s_post.opdate = server_dt
  278. For ll_i = 1 To dw_mx.RowCount()
  279. ls_commcode = dw_mx.Object.commcode[ll_i]
  280. ls_commsccode = dw_mx.Object.commsccode[ll_i]
  281. ls_commname = dw_mx.Object.commname[ll_i]
  282. Select CusCommID
  283. Into :ll_receivecuscommid
  284. From LJFIEB_CusComm
  285. Where cuscode = :ls_commcode Using tr_eb_sqlca;
  286. If tr_eb_sqlca.SQLCode <> 0 Then
  287. ll_receivecuscommid = 0
  288. End If
  289. If ll_receivecuscommid = 0 Then
  290. arg_msg_err = arg_msg_err + '第'+String(ll_i)+'行,'+ls_commname+',找不到对应的企业编号,请检查' + '~r~n'
  291. Continue
  292. End If
  293. If uo_fieb.send_post(ll_sendcuscommid,'',ll_receivecuscommid,ls_commsccode,arg_s_post,arg_msg_tmp,True) = 0 Then
  294. arg_msg_err = arg_msg_err + '第'+String(ll_i)+'行,'+ls_commname+',推送公告失败,'+arg_msg_tmp + '~r~n'
  295. ll_fail++
  296. Continue
  297. End If
  298. ll_suc++
  299. Next
  300. //发送删除指令给修改删除的推送方
  301. If ins_postid > 0 Then
  302. ls_RelatedCode = String(ll_sendcuscommid) + '_' + String(ins_postid)
  303. For ll_i = 1 To dw_mx_ori.RowCount()
  304. For ll_j = 1 To dw_mx.RowCount()
  305. If dw_mx_ori.Object.commcode[ll_i] = dw_mx.Object.commcode[ll_j] And dw_mx_ori.Object.commsccode[ll_i] = dw_mx.Object.commsccode[ll_j] Then
  306. Goto _next
  307. End If
  308. Next
  309. ls_commcode = dw_mx_ori.Object.commcode[ll_i]
  310. ls_commsccode = dw_mx_ori.Object.commsccode[ll_i]
  311. ls_commname = dw_mx_ori.Object.commname[ll_i]
  312. Select TOP 1 NEWID() Into :ls_SerialNum
  313. From u_user Using sqlca;
  314. If sqlca.SQLCode <> 0 Then
  315. Rollback Using sqlca;
  316. MessageBox('Error', '第'+String(ll_i)+'行明细,生成序列号失败,'+sqlca.SQLErrText)
  317. Return
  318. End If
  319. Select CusCommID
  320. Into :ll_receivecuscommid
  321. From LJFIEB_CusComm
  322. Where cuscode = :ls_commcode Using tr_eb_sqlca;
  323. If tr_eb_sqlca.SQLCode <> 0 Then
  324. ll_receivecuscommid = 0
  325. End If
  326. If ll_receivecuscommid = 0 Then
  327. arg_msg_err = arg_msg_err + ls_commname+',找不到对应的企业编号,请检查' + '~r~n'
  328. Continue
  329. End If
  330. If uo_fieb.add_packet(ls_SerialNum,'',ll_sendcuscommid,'',ll_receivecuscommid,ls_commsccode,20,'','','','',ls_RelatedCode,0,arg_msg_tmp,True) = 0 Then
  331. arg_msg_err = arg_msg_err +ls_commname+',发送删除公告指令失败,'+arg_msg_tmp + '~r~n'
  332. ll_fail++
  333. Continue
  334. End If
  335. _next:
  336. Next
  337. End If
  338. MessageBox(publ_operator,'推送完成!成功:'+String(ll_suc)+',失败:'+String(ll_fail))
  339. If ll_fail > 0 Then
  340. OpenWithParm(w_message_err,arg_msg_err)
  341. Else
  342. Close(Parent)
  343. End If
  344. end event
  345. type dw_mx from u_dw_rbtnfilter within w_post_propel_edit_ljfieb
  346. integer x = 23
  347. integer y = 1004
  348. integer width = 2249
  349. integer height = 1148
  350. integer taborder = 20
  351. boolean bringtotop = true
  352. string dataobject = "dw_post_propel_mx_edit_ljfieb"
  353. boolean hscrollbar = true
  354. boolean vscrollbar = true
  355. end type
  356. event rowfocuschanged;call super::rowfocuschanged;IF currentrow > 0 THEN
  357. THIS.SelectRow(0,FALSE)
  358. THIS.SelectRow(currentrow,TRUE)
  359. END IF
  360. end event
  361. type cb_cus_ch from uo_imflatbutton within w_post_propel_edit_ljfieb
  362. integer x = 46
  363. integer y = 896
  364. integer taborder = 40
  365. boolean bringtotop = true
  366. string text = "选客户"
  367. string normalpicname = "mx1.BMP"
  368. integer picsize = 16
  369. end type
  370. event clicked;call super::clicked;Long uc_row,ls_j
  371. Long child_row,ll_receivecuscommid
  372. If Not IsValid(w_cust_comm_ch) Then
  373. s_edit_index_tran s_open //传递参数使用
  374. s_open.if_select_any = True
  375. s_open.b_string = ''
  376. This.Enabled = False
  377. OpenWithParm(w_cust_comm_ch,s_open)
  378. This.Enabled = True
  379. s_custom_arr s_inscust
  380. s_inscust = Message.PowerObjectParm //接受返回结构
  381. dw_mx.SetRedraw(False)
  382. For ls_j = 1 To UpperBound(s_inscust.cusid)
  383. If s_inscust.cusid[ls_j] > 0 Then //正常返回值则可以取以下值
  384. If dw_mx.Find("commcode ='" + s_inscust.commcode[ls_j]+"' and commsccode = '"+s_inscust.commsccode[ls_j]+"'", 1, dw_mx.RowCount()) > 0 Then Continue
  385. If dw_mx.GetRow() > 0 Then
  386. If dw_mx.Object.commname[dw_mx.GetRow()] <> '' Then
  387. child_row = dw_mx.InsertRow (0)
  388. Else
  389. child_row = dw_mx.GetRow()
  390. End If
  391. Else
  392. child_row = dw_mx.InsertRow (0)
  393. End If
  394. dw_mx.Object.Kind[child_row] = 0
  395. dw_mx.Object.commname[child_row] = s_inscust.Name[ls_j]
  396. dw_mx.Object.commcode[child_row] = s_inscust.commcode[ls_j]
  397. dw_mx.Object.commsccode[child_row] = s_inscust.commsccode[ls_j]
  398. End If
  399. Next
  400. dw_mx.SetRedraw(True)
  401. End If
  402. end event
  403. type cb_spt_ch from uo_imflatbutton within w_post_propel_edit_ljfieb
  404. integer x = 366
  405. integer y = 896
  406. integer width = 379
  407. integer taborder = 50
  408. boolean bringtotop = true
  409. string text = "选供应商"
  410. string normalpicname = "mx2.BMP"
  411. integer picsize = 16
  412. end type
  413. event clicked;call super::clicked;Long uc_row,ls_j
  414. Long child_row,ll_receivecuscommid
  415. If Not IsValid(w_spt_ecomm_ch) Then
  416. s_edit_index_tran s_open //传递参数使用
  417. s_open.if_select_any = True
  418. s_open.b_string = ''
  419. This.Enabled = False
  420. OpenWithParm(w_spt_ecomm_ch,s_open)
  421. This.Enabled = True
  422. s_custom_arr s_inscust
  423. s_inscust = Message.PowerObjectParm //接受返回结构
  424. dw_mx.SetRedraw(False)
  425. For ls_j = 1 To UpperBound(s_inscust.cusid)
  426. If s_inscust.cusid[ls_j] > 0 Then //正常返回值则可以取以下值
  427. If dw_mx.Find("commcode ='" + s_inscust.commcode[ls_j]+"' and commsccode = '"+s_inscust.commsccode[ls_j]+"'", 1, dw_mx.RowCount()) > 0 Then Continue
  428. If dw_mx.GetRow() > 0 Then
  429. If dw_mx.Object.commname[dw_mx.GetRow()] <> '' Then
  430. child_row = dw_mx.InsertRow (0)
  431. Else
  432. child_row = dw_mx.GetRow()
  433. End If
  434. Else
  435. child_row = dw_mx.InsertRow (0)
  436. End If
  437. dw_mx.Object.Kind[child_row] = 1
  438. dw_mx.Object.commname[child_row] = s_inscust.Name[ls_j]
  439. dw_mx.Object.commcode[child_row] = s_inscust.commcode[ls_j]
  440. dw_mx.Object.commsccode[child_row] = s_inscust.commsccode[ls_j]
  441. End If
  442. Next
  443. dw_mx.SetRedraw(True)
  444. End If
  445. end event
  446. type cb_delmx from uo_imflatbutton within w_post_propel_edit_ljfieb
  447. integer x = 782
  448. integer y = 896
  449. integer width = 379
  450. integer taborder = 50
  451. boolean bringtotop = true
  452. string text = "删除明细"
  453. string normalpicname = "DELETE.BMP"
  454. integer picsize = 16
  455. end type
  456. event clicked;call super::clicked;Long ll_row
  457. ll_row = dw_mx.GetRow()
  458. If ll_row <= 0 Then
  459. MessageBox('系统提示','请先选择要删除的行')
  460. Return
  461. End If
  462. If MessageBox('询问','是否确定要删除当前选中的推送对象?',question!,yesno!) = 2 Then Return
  463. dw_mx.DeleteRow (ll_row)
  464. If ll_row - 1 > 0 And ll_row - 1 <= dw_mx.RowCount() Then
  465. dw_mx.SelectRow(0,False)
  466. dw_mx.SelectRow(ll_row - 1,True)
  467. Else
  468. If dw_mx.RowCount() > 0 Then
  469. dw_mx.SelectRow(0,False)
  470. dw_mx.SelectRow(1,True)
  471. End If
  472. End If
  473. end event
  474. type dw_mx_ori from datawindow within w_post_propel_edit_ljfieb
  475. boolean visible = false
  476. integer x = 1280
  477. integer y = 936
  478. integer width = 686
  479. integer height = 400
  480. integer taborder = 60
  481. boolean bringtotop = true
  482. string title = "none"
  483. string dataobject = "dw_post_propel_mx_edit_ljfieb"
  484. boolean livescroll = true
  485. borderstyle borderstyle = stylelowered!
  486. end type