Option Compare Database
Option Explicit
Private Sub exit_Click()
On Error GoTo err
DoCmd.Close acDataAccessPage, "naryad"
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub Form_Load()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
vers.Caption = version()
cop.Caption = copir()
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
cn.Open ConnectServer(BName())
year.Value = seti("year")
month.Value = seti("month")
logo.Caption = "ГѓГ«Г*ГўГ*Г*Гї Г±ГІГ°Г*Г*ГЁГ¶Г*"
For i = 1 To 8
g = "m" & i
If i = 1 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 1 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m1_Click()
On Error GoTo err
Dim i As Long
Dim a, b, g As String
logo.Caption = "ГѓГ«Г*ГўГ*Г*Гї Г±ГІГ°Г*Г*ГЁГ¶Г*"
For i = 1 To 8
g = "m" & i
If i = 1 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 1 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m2_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ГЌГ*ðÿäû"
For i = 1 To 8
g = "m" & i
If i = 2 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 2 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m3_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ГЉГ*ëüêóëÿöèè"
For i = 1 To 8
g = "m" & i
If i = 3 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 3 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m4_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ГЂГЉГ’Г»"
For i = 1 To 8
g = "m" & i
If i = 4 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 4 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m5_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ÑïðГ*âî÷Г*ГЁГЄГЁ"
For i = 1 To 8
g = "m" & i
If i = 5 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 5 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m6_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ГЋГІГ·ГҐГІГ»"
For i = 1 To 8
g = "m" & i
If i = 6 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 6 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m7_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "ГЌГ*ñòðîéêè"
For i = 1 To 8
g = "m" & i
If i = 7 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 7 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub m8_Click()
On Error GoTo err
Dim a, b, g As String
Dim i As Long
logo.Caption = "Àðõèâ"
For i = 1 To 8
g = "m" & i
If i = 8 Then
Form.Controls(g).ForeColor = 255
Form.Controls(g).FontBold = True
Else
Form.Controls(g).ForeColor = 0
Form.Controls(g).FontBold = False
End If
Next
a = "main_"
For i = 1 To 8
b = a & i
If i = 8 Then
Form.Controls(b).Visible = True
Else
Form.Controls(b).Visible = False
End If
Form.Controls(b).Left = 2250
Form.Controls(b).Width = 4950
Form.Controls(b).Height = 3200
Form.Controls(b).TOP = 1450
Next
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub
Private Sub upd_Click()
On Error GoTo err
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim a As Integer
Dim b As String
a = seti("year")
b = seti("month")
cn.Open ConnectServer(BName())
rs.Open ("SELECT Sum(tek) as sum FROM plobct WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!a1.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(izg) as sum FROM plobct WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aa1.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(tek+izg) as sum FROM plobct WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aaa1.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(kolv1*nv) as sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='True' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
rs.Close
rs.Open ("SELECT Sum(kolv1*normve) as sum FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND otl ='False' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!a2.Caption = Format(rs!sum, "0.00")
rs.Close
Else
rs1.Open ("SELECT Sum(kolv1*normve) as sum FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND otl ='False' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs1!sum) Then
Form!main_1!a2.Caption = Format(rs!sum, "0.00")
Else
Form!main_1!a2.Caption = Format(rs!sum + rs1!sum, "0.00")
End If
rs1.Close
rs.Close
End If
rs.Open ("SELECT Sum(kolv1*nv) as sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='False' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aa2.Caption = Format(rs!sum, "0.00")
rs.Close
Form!main_1!aaa2.Caption = Abs(Form!main_1!a2.Caption) + Abs(Form!main_1!aa2.Caption)
If IsNull(Form!main_1!a2.Caption) Then Form!main_1!aaa2.Caption = Form!main_1!aa2.Caption
If IsNull(Form!main_1!aa2.Caption) Then Form!main_1!aaa2.Caption = Form!main_1!a2.Caption
If IsNull(Form!main_1!a2.Caption) Or Form!main_1!a2.Caption = "" Or IsNull(Form!main_1!a1.Caption) Or Form!main_1!a1.Caption = "" Then
Form!main_1!a3.Caption = ""
Else
Form!main_1!a3.Caption = Format(Abs(Form!main_1!a2.Caption) / Abs(Form!main_1!a1.Caption), "0.00%")
End If
If IsNull(Form!main_1!aa2.Caption) Or Form!main_1!aa2.Caption = "" Or IsNull(Form!main_1!aa1.Caption) Or Form!main_1!aa1.Caption = "" Then
Form!main_1!aa3.Caption = ""
Else
Form!main_1!aa3.Caption = Format(Abs(Form!main_1!aa2.Caption) / Abs(Form!main_1!aa1.Caption), "0.00%")
End If
If IsNull(Form!main_1!aaa2.Caption) Or Form!main_1!aaa2.Caption = "" Or IsNull(Form!main_1!aaa1.Caption) Or Form!main_1!aaa1.Caption = "" Then
Form!main_1!aaa3.Caption = ""
Else
Form!main_1!aaa3.Caption = Format(Abs(Form!main_1!aaa2.Caption) / Abs(Form!main_1!aaa1.Caption), "0.00%")
End If
rs.Open ("SELECT Sum(sumt) as sum FROM plobct WHERE year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!a4.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(sumi) as sum FROM plobct WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aa4.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(sumt+sumi) as sum FROM plobct WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aaa4.Caption = Format(rs!sum, "0.00")
rs.Close
Dim g, d, z, n As String
Dim i As Long
g = Replace(seti_d("chch"), ",", ".")
g = seti_d("chch")
n = 0
rs.Open ("SELECT * FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ' AND otl ='False' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
For i = 1 To rs.RecordCount
d = Format((rs!normve * Abs(g)), "0.00")
If d = "" Or IsNull(d) Then z = 0
If d <> "" Then z = d * rs!kolv1
n = Abs(n) + z
rs.GetRows (1)
Next
If IsNull(n) Or n = 0 Or n = "" Then
Form!main_1!a5.Caption = Null
Else
Form!main_1!a5.Caption = Format(n, "0.00")
End If
rs.Close
rs.Open ("SELECT Sum(kolv1*stoim) as sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='False' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aa5.Caption = Format(rs!sum, "0.00")
rs.Close
If Form!main_1!a5.Caption = "" Then Form!main_1!aaa5.Caption = Form!main_1!aa5.Caption
If Form!main_1!aa5.Caption = "" Then Form!main_1!aaa5.Caption = Form!main_1!a5.Caption
If Form!main_1!aa5.Caption <> "" And Form!main_1!a5.Caption <> "" Then Form!main_1!aaa5.Caption = Abs(Form!main_1!a5.Caption) + Abs(Form!main_1!aa5.Caption)
If Form!main_1!a5.Caption = "" Then Form!main_1!a6.Caption = Form!main_1!a4.Caption
If Form!main_1!a4.Caption = "" Then Form!main_1!a6.Caption = Form!main_1!a5.Caption
If Form!main_1!a4.Caption <> "" And Form!main_1!a5.Caption <> "" Then Form!main_1!a6.Caption = Abs(Form!main_1!a5.Caption) - (Form!main_1!a4.Caption)
If Form!main_1!aa5.Caption = "" Then Form!main_1!aa6.Caption = Form!main_1!aa4.Caption
If Form!main_1!aa4.Caption = "" Then Form!main_1!aa6.Caption = Form!main_1!aa5.Caption
If Form!main_1!aa4.Caption <> "" And Form!main_1!aa5.Caption <> "" Then Form!main_1!aa6.Caption = Abs(Form!main_1!aa5.Caption) - Abs(Form!main_1!aa4.Caption)
If Form!main_1!aaa5.Caption = "" Then Form!main_1!aaa6.Caption = Form!main_1!aaa4.Caption
If Form!main_1!aaa4.Caption = "" Then Form!main_1!aaa6.Caption = Form!main_1!aaa5.Caption
If Form!main_1!aaa4.Caption <> "" And Form!main_1!aaa5.Caption <> "" Then Form!main_1!aaa6.Caption = Abs(Form!main_1!aaa5.Caption) - Abs(Form!main_1!aaa4.Caption)
rs.Open ("SELECT Sum(kolv1*cm) as sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='False' AND year =" & a & " AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_1!aa7.Caption = Format(rs!sum, "0.00")
rs.Close
'===================================== 2
rs.Open ("SELECT * FROM naryad WHERE otl ='False' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_2!it5.Caption = rs.RecordCount
rs.Close
rs.Open ("SELECT Sum(naryad.censum) AS sum FROM naryad WHERE otl ='False' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_2!it6.Caption = Format(rs!sum, "0.00")
End If
rs.Close
rs.Open ("SELECT Sum(naryad.normvi) AS sum FROM naryad WHERE otl ='False' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_2!it7.Caption = Format(rs!sum, "0.00")
End If
rs.Close
rs.Open ("SELECT * FROM naryad WHERE otl ='False' AND year ='" & a & "' AND month ='" & b & "' AND stat ='True'"), cn, adOpenKeyset, adLockPessimistic
Form!main_2!it8.Caption = rs.RecordCount
rs.Close
rs.Open ("SELECT * FROM naryad WHERE otl ='False' AND year ='" & a & "' AND month ='" & b & "' AND stat ='False'"), cn, adOpenKeyset, adLockPessimistic
Form!main_2!it9.Caption = rs.RecordCount
rs.Close
rs.Open ("SELECT * FROM naryad WHERE otl ='True' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_2!it10.Caption = rs.RecordCount
rs.Close
rs.Open ("SELECT Sum(naryad.censum) AS sum FROM naryad WHERE otl ='True' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_2!it11.Caption = Format(rs!sum, "0.00")
End If
rs.Close
rs.Open ("SELECT Sum(naryad.normvi) AS sum FROM naryad WHERE otl ='True' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_2!it12.Caption = Format(rs!sum, "0.00")
End If
rs.Close
'======================================= 3
rs.Open ("SELECT count(id) As cou FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND year ='" & a & "' AND month ='" & b & "'"), cn, adOpenKeyset, adLockPessimistic
Form!main_3!obr1.Caption = rs!cou
rs.Close
rs.Open ("SELECT count(idkalk) As cou FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND stat ='True' AND otl ='False' AND year ='" & a & "' AND month ='" & b & "' AND vidrab <>'ГІГҐГЄ. ðåìîГ*ГІ'"), cn, adOpenKeyset, adLockPessimistic
Form!main_3!obr2.Caption = rs!cou
rs.Close
rs.Open ("SELECT * FROM naryad WHERE idkalk IS null AND obct <>'Г–ГђГѓГ’ГЋ' AND stat ='True' AND otl ='False' AND year ='" & a & "' AND month ='" & b & "' AND vidrab <>'ГІГҐГЄ. ðåìîГ*ГІ'"), cn, adOpenKeyset, adLockPessimistic
Form!main_3!obr3.Caption = rs.RecordCount
rs.Close
'====================================== 4
rs.Open ("SELECT Count(id) As cou FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='False' AND kolv1 =0 AND otl_kolv <>0"), cn, adOpenKeyset, adLockPessimistic
Form!main_4!i1.Caption = rs!cou
rs.Close
rs.Open ("SELECT Count(id) As cou FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ' AND kolv1 =0 AND otl_kolv <>0"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!cou) Then
Else
Form!main_4!i1.Caption = Abs(Form!main_4!i1.Caption) + rs!cou
End If
rs.Close
rs.Open ("SELECT Sum(otl_kolv) As sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ' AND tekr_st ='False'"), cn, adOpenKeyset, adLockPessimistic
Form!main_4!i2.Caption = rs!sum
rs.Close
rs.Open ("SELECT Sum(otl_kolv) AS sum FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_4!i2.Caption = Abs(Form!main_4!i2.Caption) + rs!sum
End If
rs.Close
rs.Open ("SELECT Sum(nv*otl_kolv) As sum FROM kalk WHERE obct <>'Г–ГђГѓГ’ГЋ'"), cn, adOpenKeyset, adLockPessimistic
Form!main_4!i3.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(normve*otl_kolv) AS sum FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_4!i3.Caption = Format(Abs(Form!main_4!i3.Caption) + rs!sum, "0.00")
End If
rs.Close
rs.Open ("SELECT Sum(stoim*otl_kolv) As sum FROM kalk"), cn, adOpenKeyset, adLockPessimistic
Form!main_4!i4.Caption = Format(rs!sum, "0.00")
rs.Close
rs.Open ("SELECT Sum(cened*otl_kolv) AS sum FROM naryad WHERE obct <>'Г–ГђГѓГ’ГЋ' AND vidrab ='ГІГҐГЄ. ðåìîГ*ГІ'"), cn, adOpenKeyset, adLockPessimistic
If IsNull(rs!sum) Then
Else
Form!main_4!i4.Caption = Format(Abs(Form!main_4!i4.Caption) + rs!sum, "0.00")
End If
rs.Close
MsgBox "ГЋГЎГ*îâëåГ*Г®...", vbInformation, ""
Exit Sub
err:
Call errorb(err.Description, err.HelpContext, err.HelpFile, err.Number, err.Source, err.LastDllError)
End Sub