SHARE
TWEET

VFP

a guest Apr 3rd, 2018 195 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dwg_no_i = thisform.dwg_no_txt.text
  2. eqp_no_i = thisform.eqp_no_txt.text
  3. dwg_desc_i = alltrim(thisform.dwg_title_txt.text)
  4. if len(strtran(thisform.rev_no.text,' ','')) > 1
  5.     rev_no_i = left(thisform.rev_no.text,2)
  6. else
  7.     rev_no_i = thisform.rev_no.text
  8. endif
  9. store '' to sch_d_i,rece_d_i
  10. sch_d_i = strtran(thisform.sch_issue.text,'/','')
  11. rece_d_i = strtran(thisform.rece_date.text,'/','')
  12. dwg_id_i = 0
  13. rev_iss = ''
  14. sch_iss = ''
  15. if len(alltrim(eqp_no_old)) > 0
  16.     sql = "select * from fas.dbo.drawing_master where prj_no = '" + prj_no_i + "' and equip_no = '" + alltrim(eqp_no_old) + "' and ctci_no = '" + alltrim(dwg_no_old) + "'"
  17. else
  18.     sql = "select * from fas.dbo.drawing_master where prj_no = '" + prj_no_i + "' and equip_no = '" + alltrim(eqp_no_i) + "' and ctci_no = '" + alltrim(dwg_no_i) + "'"
  19. endif
  20. res = sqlexec(han3,sql,'curs1')
  21. if res > 0 and !empty(curs1.prj_no)
  22.     upd_sw = 1
  23.     sch_iss = curs1.sch_iss_d
  24.     rev_iss = curs1.rev_iss_d
  25.     dwg_id_i = curs1.dwg_id
  26.     select curs1
  27.     use
  28. else
  29.     upd_sw = 0
  30. endif
  31. sch_iss = strtran(sch_iss," ","")
  32. rev_iss = strtran(rev_iss," ","")
  33. if len(sch_iss) = 0 and len(sch_d_i) > 0
  34.     sch_iss = sch_d_i
  35. endif
  36. if len(rev_iss) = 0 and len(rece_d_i) > 0
  37.     rev_iss = rece_d_i
  38. endif
  39.  
  40. if upd_sw = 0
  41.     sql1 = "insert fas.dbo.drawing_master(prj_no,equip_no,ctci_no,dwg_desc,sch_iss_d,rev_iss_d) "
  42.     if left(rev_no_i,1) = '0'
  43.         sch_iss = sch_d_i
  44.         rev_iss = ''
  45.     else
  46.         sch_iss = ''
  47.         rev_iss = sch_d_i
  48.     endif
  49.     sql2 = "values('" + prj_no_i + "','" + eqp_no_i + "','" + dwg_no_i + "','" + dwg_desc_i + "','"
  50.     sql2 = sql2 + sch_iss + "','" + rev_iss + "')"
  51.     sql = sql1 + sql2
  52. else
  53.     sql1 = "update fas.dbo.drawing_master set equip_no = '" + eqp_no_i + "', dwg_desc = '"
  54.     sql2 = dwg_desc_i + "', sch_iss_d = '" + sch_iss + "', rev_iss_d = '" + rev_iss + "' where prj_no = '" + prj_no_i
  55.     if len(alltrim(eqp_no_old)) > 0
  56.         sql3 =  "' and equip_no = '" + alltrim(eqp_no_old) + "' and ctci_no = '" + dwg_no_old + "'"
  57.     else
  58.         sql3 =  "' and equip_no = '" + alltrim(eqp_no_i) + "' and ctci_no = '" + dwg_no_i + "'"
  59.     endif  
  60.     sql = sql1 + sql2 + sql3
  61. endif
  62.  
  63. res = sqlexec(han3,sql)
  64. if res < 0
  65.     =messagebox("Insert or Update Project Drawing Master table error : " + chr(13) + alltrim(message()) + chr(13) + sql,16)
  66. endif
  67. if len(alltrim(eqp_no_old)) > 0
  68.     sql = "select * from fas.dbo.drawing_master where prj_no = '" + prj_no_i + "' and equip_no = '" + alltrim(eqp_no_old) + "' and ctci_no = '" + alltrim(dwg_no_old) + "'"
  69. else
  70.     sql = "select * from fas.dbo.drawing_master where prj_no = '" + prj_no_i + "' and equip_no = '" + alltrim(eqp_no_i) + "' and ctci_no = '" + dwg_no_i + "'"
  71. endif
  72. res = sqlexec(han3,sql,'curs1')
  73. if res > 0 and !empty(curs1.prj_no)
  74.     dwg_id_i = curs1.dwg_id
  75.     select curs1
  76.     use
  77. endif
  78. rev_no_i =strtran(rev_no_i,' ','')
  79. if len(rev_no_i) > 0
  80.     sql = "select * from fas.dbo.xmitl_dtl where prj_no = '" + prj_no_i + "' and iss_rev = '" + rev_no_i + "' and dwg_id = " + str(dwg_id_i)
  81.     res = sqlexec(han3,sql,'curs2')
  82.     if res > 0 and !empty(curs2.prj_no)
  83.         upd_sw = 1
  84.     else
  85.         upd_sw = 0
  86.     endif
  87.     if upd_sw = 1
  88.         sql1 = "update fas.dbo.xmitl_dtl set iss_date_eg = '" + rece_d_i + "', equip_no = '" + eqp_no_i
  89.         sql2 = "' where prj_no = '" + prj_no_i + "' and iss_rev = '" + rev_no_i + "' and dwg_id = " + str(dwg_id_i)
  90.         sql = sql1 + sql2
  91.         res = sqlexec(han3,sql)
  92.         if res < 0
  93.             =messagebox("Update Project transmittal table error : " + chr(13) + alltrim(message()) + chr(13) + sql,16)
  94.         endif
  95.     else
  96.         sql1 = "insert fas.dbo.xmitl_dtl(prj_no,equip_no,ctci_no,iss_rev,iss_date_eg,dept_id,dwg_id) "
  97.         sql2 = "values('" + prj_no_i + "','" + eqp_no_i + "','" + dwg_no_i + "','" + rev_no_i
  98.         sql3 = "','" + rece_d_i + "','9100'," + str(dwg_id_i) + ")"
  99.         sql = sql1 + sql2 + sql3
  100.         res = sqlexec(han3,sql)
  101.         if res < 0
  102.             =messagebox("Insert Project transmittal table error : " + chr(13) + alltrim(message()) + chr(13) + sql,16)
  103.         endif
  104.     endif
  105. endif
  106.  
  107. rev_no_i = left((rev_no_i+space(2)),2)
  108. if len(sch_d_i) > 0
  109.     sch_d_i = left(sch_d_i,4) + '/' + substr(sch_d_i,5,2) + '/' + substr(sch_d_i,7,2)
  110. else
  111.     sch_d_i = ''
  112. endif
  113. if len(rece_d_i) > 0
  114.     m.rece_d = left(rece_d_i,4) + '/' + substr(rece_d_i,5,2) + '/' + substr(rece_d_i,7,2)
  115. else
  116.     m.rece_d = ''
  117. endif
  118. m.rev_no = rev_no_i
  119. if len(alltrim(m.rev_no)) > 0
  120.     store '' to rev0_d,rev1_d,rev2_d,rev3_d,rev4_d,rev5_d,rev6_d,rev7_d,rev8_d,rev9_d
  121.     store '' to rev10_d,rev11_d,rev12_d,rev13_d,rev14_d,rev15_d
  122.     if tit_idx = 0 then
  123.         r_f = 'rev0_d'
  124.         re_f = 'rec0_d'
  125.     else
  126.         if tit_idx <> 99 then
  127.             r_f = 'rev' + alltrim(str(tit_idx,2)) + '_d'
  128.             re_f = 'rec' + alltrim(str(tit_idx,2)) + '_d'
  129.         endif
  130.     endif
  131.     if tit_idx <> 99 then
  132.         &r_f = m.rece_d + '(' + left(rev_no_i,2) + ')'
  133.     endif
  134. endif
  135.  
  136. if ins_sw = 1
  137.     select dwg_grid
  138.     seek eqp_no_i + dwg_no_i
  139.     if !found()
  140.         insert into dwg_grid values(dwg_no_i,eqp_no_i,dwg_desc_i,sch_d_i,rev0_d,rev1_d,rev2_d,rev3_d,rev4_d,rev5_d,rev6_d,rev7_d,rev8_d,rev9_d,rev10_d,rev11_d,rev12_d,rev13_d,rev14_d,rev15_d)
  141.     endif
  142.     if tit_idx <> 99
  143.         replace &re_f   with &r_f
  144.     endif
  145. endif
  146. if edit_sw = 1
  147.     select dwg_grid
  148.     seek eqp_no_i + dwg_no_i
  149.     replace issue_d     with sch_d_i
  150.     replace eqp_no      with eqp_no_i
  151.     replace dwg_title   with dwg_desc_i
  152.     if tit_idx <> 99
  153.         replace &re_f       with m.rece_d + '(' + left(rev_no_i,2) + ')'
  154.     endif
  155. endif
  156.  
  157. thisform.grid1.refresh
  158. store 0 to ins_sw,edit_sw
  159. thisform.cmdInsert.enabled = .t.
  160. thisform.cmdEdit.enabled = .t.
  161. thisform.cmdDel.enabled = .t.
  162. thisform.cmdSave.enabled = .f.
  163. thisform.cmdCancel.enabled = .f.
  164. thisform.cmdExit.enabled = .t.
  165. thisform.dwg_no_txt.enabled = .f.
  166. thisform.eqp_no_txt.enabled = .f.
  167. thisform.dwg_title_txt.enabled = .f.
  168. thisform.sch_issue.enabled = .f.
  169. thisform.rev_no.enabled = .f.
  170. thisform.rece_date.enabled = .f.
  171. thisform.refresh
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top