Private Sub bt_pay_Click()
If (ed_datepay.Text = CDate(ed_datepay.Text)) And cb_whopay.Text <> "" And ed_money.Value <> "" And ed_money.Value <> 0 Then
Sheets("База").Activate
Sheets("База").Cells(1, 1).Select
all = Selection.CurrentRegion.Rows.Count
For i = 2 To all
If Sheets("База").Cells(i, 29) <> "Окончил" And (Sheets("База").Cells(i, 2) & " " & Sheets("База").Cells(i, 3) & " " & Sheets("База").Cells(i, 4)) = cb_whopay.Text Then Cells(i, 21) = Val(Cells(i, 21)) + ed_money.Value
Next i
y = MsgBox("Оплата внесена!", vbInformation + vbOKOnly, "Автошкола")
Else
x = MsgBox("Проверьте правильность введеных значений", vbCritical + vbOKOnly, "Автошкола")
End If
End Sub
Поле “Сумма платежа (руб.)”:
Private Sub ed_money_Change()
ed_money.Value = Val(ed_money.Value)
Активация формы:
Private Sub UserForm_Activate()
cb_whopay.Clear
ed_money.Value = ""
Dim x As Integer
x = 0
ed_datepay.Text = Date
If Sheets("База").Cells(i, 29) <> "Окончил" Then
cb_whopay.AddItem (Sheets("База").Cells(i, 2) & " " & Sheets("База").Cells(i, 3) & " " & Sheets("База").Cells(i, 4))
x = x + 1
If x = 0 Then
y = MsgBox("Текущая группа пуста!", vbCritical + vbOKOnly, "Автошкола")
PayForm.Hide
ClientForm.Show (0)
cb_whopay.ListIndex = 0
Завершение работы формы:
Private Sub UserForm_Terminate()
Процедура (обновление активности):
Sub endis()
level_1.Enabled = True
level_2.Enabled = True
level_3.Enabled = True
If cb_able.Value = True And cb_pdd.Value = True And cb_help.Value = True And Val(desc_howmuchdrive.Text) >= Sheets("Данные").Range("L4") And Val(desc_howmuchpay.Caption) >= Sheets("Данные").Range("L2") Then
level_1.Enabled = False
If cb_insidepdd.Value = True And cb_insidedrive.Value = True And cb_insidegorod.Value = True Then
level_2.Enabled = False
level_3.Enabled = False
Кнопка “Выйти”:
Private Sub bt_exit_Click()
WayForm.Hide
Кнопка “Сохранить”:
Private Sub bt_save_Click()
If ComboBox1.Text = (Sheets("База").Cells(i, 2) & " " & Sheets("База").Cells(i, 3) & " " & Sheets("База").Cells(i, 4)) And Sheets("База").Cells(i, 29) = "Обучаемый" Then
If cb_able.Value = True Then Sheets("База").Cells(i, 17) = "Да" Else Sheets("База").Cells(i, 17) = "Нет"
If cb_pdd.Value = True Then Sheets("База").Cells(i, 15) = "Да" Else Sheets("База").Cells(i, 15) = "Нет"
If cb_help.Value = True Then Sheets("База").Cells(i, 16) = "Да" Else Sheets("База").Cells(i, 16) = "Нет"
If cb_insidepdd.Value = True Then Sheets("База").Cells(i, 23) = "Да" Else Sheets("База").Cells(i, 23) = "Нет"
If cb_insidedrive.Value = True Then Sheets("База").Cells(i, 24) = "Да" Else Sheets("База").Cells(i, 24) = "Нет"
If cb_insidegorod.Value = True Then Sheets("База").Cells(i, 25) = "Да" Else Sheets("База").Cells(i, 25) = "Нет"
If cb_gaipdd.Value = True Then Sheets("База").Cells(i, 26) = "Да" Else Sheets("База").Cells(i, 26) = "Нет"
If cb_gaidrive.Value = True Then Sheets("База").Cells(i, 27) = "Да" Else Sheets("База").Cells(i, 27) = "Нет"
If cb_gaigorod.Value = True Then Sheets("База").Cells(i, 28) = "Да" Else Sheets("База").Cells(i, 28) = "Нет"
Sheets("База").Cells(i, 20) = desc_howmuchdrive.Text
Элементы типа Checkbox:
Private Sub cb_able_Click()
Call endis
Private Sub cb_help_Click()
Private Sub cb_insidedrive_Click()
Private Sub cb_insidegorod_Click()
Private Sub cb_insidepdd_Click()
Private Sub cb_pdd_Click()
Список “Клиент”:
Private Sub ComboBox1_Change()
cb_able.Value = False
cb_pdd.Value = False
cb_help.Value = False
cb_insidepdd.Value = False
cb_insidedrive.Value = False
cb_insidegorod.Value = False
cb_gaipdd.Value = False
cb_gaidrive.Value = False
cb_gaigorod.Value = False
If Sheets("База").Cells(i, 17) = "Да" Then cb_able.Value = True
If Sheets("База").Cells(i, 15) = "Да" Then cb_pdd.Value = True
If Sheets("База").Cells(i, 16) = "Да" Then cb_help.Value = True
If Sheets("База").Cells(i, 23) = "Да" Then cb_insidepdd.Value = True
If Sheets("База").Cells(i, 24) = "Да" Then cb_insidedrive.Value = True
If Sheets("База").Cells(i, 25) = "Да" Then cb_insidegorod.Value = True
If Sheets("База").Cells(i, 26) = "Да" Then cb_gaipdd.Value = True
If Sheets("База").Cells(i, 27) = "Да" Then cb_gaidrive.Value = True
If Sheets("База").Cells(i, 28) = "Да" Then cb_gaigorod.Value = True
desc_howmuchdrive.Text = Val(Cells(i, 20))
desc_howmuchpay.Caption = Val(Cells(i, 21))
Sheets("Данные").Activate
Поле “Откатано часов”:
Private Sub desc_howmuchdrive_Change()
desc_howmuchdrive.Text = Val(desc_howmuchdrive.Text)
Dim first, hod As Integer
hod = 0
first = 0
ComboBox1.Clear
If Sheets("База").Cells(i, 29) = "Обучаемый" Then
hod = hod + 1
If hod = 1 Then first = i
ComboBox1.AddItem (Sheets("База").Cells(i, 2) & " " & Sheets("База").Cells(i, 3) & " " & Sheets("База").Cells(i, 4))
If first <> 0 Then
i = first
desc_howmuchdrive.Text = Val(Sheets("База").Cells(i, 20))
desc_howmuchpay.Caption = Val(Sheets("База").Cells(i, 21))
ComboBox1.ListIndex = 0
Кнопка “ОК”:
Private Sub bt_ok_Click()
If ComboBox1.Text <> "" Then
If ComboBox1.Text = (Sheets("База").Cells(i, 2) & " " & Sheets("База").Cells(i, 3) & " " & Sheets("База").Cells(i, 4)) Then
Sheets("Клиент-Отчет").Range("B3") = ComboBox1.Text
Sheets("Клиент-Отчет").Range("B4") = Sheets("База").Cells(i, 5)
Sheets("Клиент-Отчет").Range("B5") = "№ " & Sheets("База").Cells(i, 8) & " " & Sheets("База").Cells(i, 9) & " выдан " & Sheets("База").Cells(i, 6) & ", " & Sheets("База").Cells(i, 7)
Sheets("Клиент-Отчет").Range("B6") = "ул. " & Sheets("База").Cells(i, 10) & ", " & "дом " & Sheets("База").Cells(i, 11) & ", кв. " & Sheets("База").Cells(i, 12)
If Sheets("База").Cells(i, 13) <> "" And Sheets("База").Cells(i, 14) <> "" Then
Sheets("Клиент-Отчет").Range("B7") = Sheets("База").Cells(i, 13) & " ; " & Sheets("База").Cells(i, 14)
Страницы: 1, 2, 3, 4, 5, 6