-
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:10k
源码类别:

企业管理

开发平台:

Visual Basic

  1. Attribute VB_Name = "XtsyModule"
  2. '系统私有模块用来放置一些子系统独有的过程与函数
  3. Dim Tsxx As String                                      '系统提示信息
  4. Public str_Code As String                               '存储列内容参数
  5. Public str_SQLAutoid As String                          '计划合并生成字符串
  6. Public Int_PlanQueryType As Integer                     '计划执行情况查询类型
  7. Public Sub Drxtztcs()                                   '读入系统帐套参数
  8.    
  9.     Dim Ztcsbrec As New ADODB.Recordset
  10.     Dim RecTemp As New ADODB.Recordset
  11.     Dim Sqlstr As String
  12.     '读入本位币
  13.         Sqlstr = "Select ForeignCurrCode,ForeignCurrName from Gy_ForeignCurrency where StandardFlag=1"
  14.         Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  15.         XtSCurrCode = Trim(RecTemp.Fields("ForeignCurrCode"))
  16.         XtSCurrName = Trim(RecTemp.Fields("ForeignCurrName"))
  17.     With Ztcsbrec
  18.         '金额总位数
  19.         .Open "Select * From Gy_AccInformation Where SystemCode='cwzz'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  20.         .MoveFirst
  21.         .Find "itemcode='cwjezws'"
  22.         If Not Ztcsbrec.EOF Then
  23.             Xtjezws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  24.         End If
  25.         
  26.         '数量总位数
  27.         .MoveFirst
  28.         .Find "itemcode='cwslzws'"
  29.         If Not Ztcsbrec.EOF Then
  30.             Xtslzws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  31.         End If
  32.    
  33.         '单价总位数
  34.         .MoveFirst
  35.         .Find "itemcode='cwdjzws'"
  36.         If Not Ztcsbrec.EOF Then
  37.             Xtdjzws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  38.         End If
  39.         
  40.         '金额小数位数
  41.         .MoveFirst
  42.         .Find "itemcode='cwjexsws'"
  43.         If Not Ztcsbrec.EOF Then
  44.             Xtjexsws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  45.         End If
  46.    
  47.         '数量小数位数
  48.         .MoveFirst
  49.         .Find "itemcode='cwslxsws'"
  50.         If Not Ztcsbrec.EOF Then
  51.             Xtslxsws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  52.         End If
  53.         
  54.         '单价小数位数
  55.         .MoveFirst
  56.         .Find "itemcode='cwdjxsws'"
  57.         If Not Ztcsbrec.EOF Then
  58.             Xtdjxsws = S2N(Trim(Ztcsbrec.Fields("itemvalue")))
  59.         End If
  60.         .Close
  61.     End With
  62.   
  63. End Sub
  64. Function RoundToFormat(var_Value, var_Byte) As String
  65.     Dim i As Long
  66.     Dim str_ByteFormat As String
  67.   
  68.     If var_Byte = 0 Then
  69.         str_ByteFormat = ""
  70.     Else
  71.         str_ByteFormat = "."
  72.         For i = 1 To var_Byte
  73.             str_ByteFormat = str_ByteFormat & "0"
  74.         Next i
  75.     End If
  76.     RoundToFormat = Format(var_Value, "##############################" & str_ByteFormat)
  77.   
  78. End Function
  79. Public Function CheckBillDate(LrText As TextBox, KjYear As Integer, Period As Integer) As Boolean
  80. '函数功能:判断用户输入的制单日期是否已经结帐,CheckBillDate为True时,表示已经结帐
  81.     Dim RecTemp As New ADODB.Recordset
  82.     Dim Sqlstr As String
  83.     Dim Tsxx As String
  84.     
  85.     Sqlstr = "Select * FROM  Gy_Kjrlb Where Qsrq<='" & LrText & "' and zzrq>='" & LrText & "' and kjyear=" & Mid(LrText, 1, 4)
  86.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  87.     
  88.     With RecTemp
  89.         If Not .EOF Then
  90.             If .Fields("cgjzbz") Then
  91.                CheckBillDate = True
  92.                Tsxx = "所选会计期间已经结帐,不能再填制单据!"
  93.                Call Xtxxts(Tsxx, 0, 1)
  94.                LrText.SetFocus
  95.                Exit Function
  96.             Else
  97.                CheckBillDate = False
  98.                KjYear = S2N(.Fields("kjyear"))
  99.                Period = S2N(.Fields("Period"))
  100.             End If
  101.         Else
  102.             CheckBillDate = True
  103.             Tsxx = "所选年度不正确!"
  104.             Call Xtxxts(Tsxx, 0, 1)
  105.             LrText.SetFocus
  106.             Exit Function
  107.         End If
  108.     End With
  109.     
  110.     RecTemp.Close
  111.     Set RecTemp = Nothing
  112. End Function
  113. Public Function CG_StartAccountCheck(Optional Cancel As Boolean = False) As Boolean  '采购期初结账判断
  114.     Dim rst_Temp As New ADODB.Recordset
  115.     Dim rst_Sqltemp As String
  116.     Dim Tsxx As String
  117.     str_sqlTemp = "SELECT ItemValue From Gy_AccInformation" & _
  118.         " WHERE ltrim(rtrim(SystemCode)) ='Cg' and ltrim(rtrim(ItemCode))='Cg_StartAccount'"
  119.     Set rst_Temp = Cw_DataEnvi.DataConnect.Execute(str_sqlTemp)
  120.     If rst_Temp.RecordCount <> 0 Then
  121.         rst_Temp.MoveFirst
  122.         If Trim("" & rst_Temp.Fields("ItemValue")) = "1" Then
  123.             If Cancel = False Then
  124.                 Tsxx = "期初发票已经结帐!"
  125.                 Call Xtxxts(Tsxx, 0, 4)
  126.                 CG_StartAccountCheck = False
  127.                 Exit Function
  128.             End If
  129.         Else
  130.             If Cancel = True Then
  131.                 Tsxx = "期初尚未结帐,不能取消期初结帐!"
  132.                 Call Xtxxts(Tsxx, 0, 4)
  133.                 CG_StartAccountCheck = False
  134.                 Exit Function
  135.             End If
  136.         End If
  137.     Else
  138.         Tsxx = "公用信息表中未有发票结帐标识!"
  139.         Call Xtxxts(Tsxx, 0, 4)
  140.         CG_StartAccountCheck = False
  141.         Exit Function
  142.     End If
  143.     CG_StartAccountCheck = True
  144. End Function
  145. Public Function Cg_startCheck(Optional ChalkitupMan As Boolean = False) As Boolean
  146.     Dim rst_Temp As New ADODB.Recordset
  147.     If ChalkitupMan = False Then
  148.         Set rst_Temp = Cw_DataEnvi.DataConnect.Execute("SELECT COUNT(*) AS NUMber From Cg_InvoiceMain WHERE (PeriodStarFlag = 1) AND (LTRIM(RTRIM(ISNULL(Checker, ''))) = '') ")
  149.         If rst_Temp.Fields(0).Value <> 0 Then
  150.             Tsxx = "期初发票未全部审核,不能结账!"
  151.             Call Xtxxts(Tsxx, 0, 4)
  152.             Cg_startCheck = False
  153.             Exit Function
  154.         End If
  155.         rst_Temp.Close
  156.         Set rst_Temp = Nothing
  157.         Cg_startCheck = True
  158.    Else
  159.         Set rst_Temp = Cw_DataEnvi.DataConnect.Execute(" SELECT CgJzbz FROM Gy_kjrlb where BeginFlag=1")
  160.         If rst_Temp.RecordCount <> 0 Then
  161.             If rst_Temp.Fields(0) Then
  162.                 Tsxx = "已进行了月末结账,不能取消期初结帐!"
  163.                 Call Xtxxts(Tsxx, 0, 4)
  164.                 Cg_startCheck = False
  165.                 Exit Function
  166.             End If
  167.         End If
  168.         rst_Temp.Close
  169.         Set rst_Temp = Nothing
  170.         Cg_startCheck = True
  171.   End If
  172. End Function
  173. Public Function Bln_IsStartChalk() As Boolean                         '判断系统是否已经期初结帐
  174.     Dim Rec_IsStartChalk As New ADODB.Recordset
  175.     Bln_IsStartChalk = True
  176.     Set Rec_IsStartChalk = Cw_DataEnvi.DataConnect.Execute("Select * from Gy_AccInformation Where " & _
  177.                             " ltrim(rtrim(SystemCode))='Cg' and ltrim(rtrim(ItemCode))='Cg_StartAccount' and ltrim(rtrim(ItemValue))='1'")
  178.     If Rec_IsStartChalk.EOF Then
  179.         
  180.         Bln_IsStartChalk = False
  181.         Exit Function
  182.     End If
  183. End Function
  184. Public Function Fun_GetInputCode(ParaItem As String) As String                                                      '读取应收应付系统基本科目
  185.     'ParaItem 是系统传递来的项目参数
  186.     
  187.     Dim RecTemp As New ADODB.Recordset
  188.     
  189.     Sqlstr = "SELECT Ccode From Rp_InputCode Where ItemCode='" & ParaItem & "'"
  190.             
  191.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  192.     
  193.     If Not RecTemp.EOF Then
  194.         Fun_GetInputCode = Trim(RecTemp.Fields("Ccode") & "")
  195.     Else
  196.         Fun_GetInputCode = ""
  197.     End If
  198. End Function
  199. Public Function Fun_InputCodeSupplier(ParaSup As String, Optional ArPr As Integer) As String                        '读取供应商对应应付、预付科目
  200.     
  201.     'ParaCus 供应商编码或供应商名称   ArPr:0-默认应付科目 1-预付科目
  202.     
  203.     Dim RecTemp As New ADODB.Recordset      '临时使用动态集
  204.     Dim Sqlstr As String                    '连接字符串
  205.     
  206.     Fun_InputCodeSupplier = ""
  207.     
  208.     Sqlstr = "SELECT ApAccCode,PpAccCode FROM Gy_Supplier Where SupplierCode='" & ParaSup & "' OR SupplierName='" & ParaSup & "'"
  209.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  210.     
  211.     If Not RecTemp.EOF Then
  212.         Select Case ArPr
  213.             Case 0
  214.                 If Trim(RecTemp.Fields("ApAccCode") & "") <> "" Then
  215.                     Fun_InputCodeSupplier = Trim(RecTemp.Fields("ApAccCode") & "")
  216.                 Else
  217.                     Fun_InputCodeSupplier = Fun_GetInputCode("AP_ApAccCode")
  218.                 End If
  219.             Case 1
  220.                 If Trim(RecTemp.Fields("PpAccCode") & "") <> "" Then
  221.                     Fun_InputCodeSupplier = Trim(RecTemp.Fields("PpAccCode") & "")
  222.                 Else
  223.                     Fun_InputCodeSupplier = Fun_GetInputCode("AP_PpAccCode")
  224.                 End If
  225.         End Select
  226.     End If
  227.     
  228. End Function
  229. Public Function Fun_InputCodePurTax(MaterialCode As String, Optional PurTax As Integer) As String           '读取存货对应采购和采购税金科目
  230.     
  231.     'MaterialCode 存货编码  PurTax:0-默认采购科目 1-采购税金科目
  232.     
  233.     Dim RecTemp As New ADODB.Recordset      '临时使用动态集
  234.     Dim Sqlstr As String                    '连接字符串
  235.     
  236.     Fun_InputCodePurTax = ""
  237.     
  238.     Sqlstr = "SELECT PurAccCode,PurTaxAccCode FROM Gy_Material Where MNumber='" & MaterialCode & "' OR Mname='" & MaterialCode & "'"
  239.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  240.     
  241.     If Not RecTemp.EOF Then
  242.         Select Case PurTax
  243.             Case 0
  244.                 If Trim(RecTemp.Fields("PurAccCode") & "") <> "" Then
  245.                     Fun_InputCodePurTax = Trim(RecTemp.Fields("PurAccCode") & "")
  246.                 Else
  247.                     Fun_InputCodePurTax = Fun_GetInputCode("AP_PurAccCode")
  248.                 End If
  249.             Case 1
  250.                 If Trim(RecTemp.Fields("PurTaxAccCode") & "") <> "" Then
  251.                     Fun_InputCodePurTax = Trim(RecTemp.Fields("PurTaxAccCode") & "")
  252.                 Else
  253.                     Fun_InputCodePurTax = Fun_GetInputCode("AP_PurTaxAccCode")
  254.                 End If
  255.         End Select
  256.     End If
  257.     
  258. End Function