4 . Разработка базы данных
Option Explicit
Private Sub CommandButton1_Click()
Me.Hide
StartRegister
End Sub
Private Sub CommandButton2_Click()
Me.Hide
StartRedact
End Sub
Private Sub CommandButton3_Click()
Me.Hide
ViewBD
End Sub
Private Sub CommandButton4_Click()
Quit
End Sub
Private Sub CommandButton5_Click()
SaveBd
End Sub
Private Sub CommandButton6_Click()
Dim cancl As Integer
cancl = MsgBox("Вы действительно хотите выйти из программы?", vbQuestion + vbYesNo, "Выход")
If cancl = vbYes Then
' Worksheets("Сеть").Cells(1, 1).Value = 0
Me.Hide
' Worksheets("Старт").CommandButton1.Visible = True
End If
End Sub
Private Sub CommandButton7_Click()
MsgBox "Малышев Максим"
End Sub
Private Sub UserForm_Initialize()
With CommandButton1
.Default = True
.ControlTipText = "Занести нового Клиента"
End With
CommandButton2.ControlTipText = "Изменить данные клиента"
CommandButton3.ControlTipText = "Посмотреть базу данных"
With CommandButton4
.Cancel = True
.ControlTipText = "Выход без сохранения"
End With
CommandButton6.ControlTipText = "Сохранить данные"
Label2.Caption = Format(Date, "dd.mm.yyyy")
End Sub
Option Explicit
Dim i, j As Integer
Dim СouRow As Integer
Dim ComT1, ComT2, ComT3 As String
Private Sub ComboBox1_DropButtonClick()
FindFIO
End Sub
Private Sub ComboBox2_DropButtonClick()
FindFIO
End Sub
Private Sub ComboBox3_DropButtonClick()
FindFIO
End Sub
Private Sub CommandButton1_Click()
FindClient
End Sub
Private Sub CommandButton2_Click()
Me.Hide
If FoundRow <> 0 Then frmData.Show Else frmStart.Show
End Sub
Private Sub CommandButton3_Click()
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
End Sub
Private Sub UserForm_Activate()
Dim Ran As Object
Set Ran = Worksheets("Сп.клиентов").Cells(1, 1).CurrentRegion
CommandButton3_Click
СouRow = Ran.Rows.Count
ComT1 = "werge2edf"
FindFIO
End Sub
Private Sub UserForm_Initialize()
With CommandButton1
.Default = True
.ControlTipText = "Начать поиск клиентов"
End With
With CommandButton2
.Cancel = True
.ControlTipText = "Отменить поиск"
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = 1
End Sub
Private Sub FindFIO()
Dim per1, per2, per3 As String
If ComboBox1.Text = ComT1 And ComboBox2.Text = ComT2 And ComboBox3.Text = ComT3 Then Exit Sub
ComT1 = ComboBox1.Text
ComT2 = ComboBox2.Text
ComT3 = ComboBox3.Text
ComboBox1.Clear
ComboBox2.Clear
ComboBox3.Clear
With Worksheets("Сп.клиентов")
For i = 2 To СouRow
per1 = ComT1
per2 = ComT2
per3 = ComT3
If per1 = "" Then per1 = .Cells(i, 1).Value
If per2 = "" Then per2 = .Cells(i, 2).Value
If per3 = "" Then per3 = .Cells(i, 3).Value
If (per1 = .Cells(i, 1).Value) And (per2 = .Cells(i, 2).Value) And (per3 = .Cells(i, 3).Value) Then
If ComT1 = "" Then Call FindDuble(ComboBox1, ComboBox1.ListCount, per1)
If ComT2 = "" Then Call FindDuble(ComboBox2, ComboBox2.ListCount, per2)
If ComT3 = "" Then Call FindDuble(ComboBox3, ComboBox3.ListCount, per3)
End If
Next
End With
ComboBox1.Text = ComT1
ComboBox2.Text = ComT2
ComboBox3.Text = ComT3
End Sub
Private Sub FindDuble(CombX As ComboBox, Coun As Integer, ByVal Sdan As String)
For j = 0 To Coun - 1
If Sdan = CombX.List(j) Then Exit Sub
Next
CombX.AddItem Sdan
End Sub
Option Explicit
Private Sub CheckBox3_Click()
End Sub
Private Sub ComboBox1_Change()
End Sub
' Действия при нажатии на кнопку 1(Запомнить):
Private Sub CommandButton1_Click()
If TextBox1.Text = "" Or TextBox2.Text = "" _
Or TextBox3.Text = "" Or ComboBox1.Text = "" Then
MsgBox "Не введены данные в одно или несколько обязательных полей:" _
& vbCrLf & "Фамилия, Имя, Отчество."
Exit Sub
End If
If NewTur = True Then
AddClient
'Очистить форму "Регистрация клиентов"
ClearForm
Else
ReplaceClient
End If
End Sub
Private Sub CommandButton2_Click()
Me.Hide
frmFind.Show
End Sub
Private Sub CommandButton3_Click()
Me.Hide
frmFind.Show
End Sub
Private Sub CommandButton4_Click()
DeleteClient
End Sub
'Процедура обработки события нажатия кнопки "Сделать выходную форму"
Private Sub CommandButton5_Click()
'объявление переменных
Dim Dataf(1 To 12) As Variant 'хранение данных о выбранном клиенте
Dim i As Integer 'индекс
'Считываем фамилию
Dataf(1) = TextBox1.Text
'Считываем имя
Dataf(2) = TextBox2.Text
'Считываем отчество
Dataf(3) = TextBox3.Text
'Считываем номер телефона
Dataf(6) = TextBox5.Text
'Считываем вид услуги
Dataf(12) = ComboBox1.Text
'Считываем, уплачено или нет
If CheckBox1.Value = True Then
Dataf(7) = "Оплачено"
Else
Dataf(7) = "НЕ ОПЛАЧЕНО"
End If
'Записать на лист - "Данные" данные о клиенте
With Worksheets("Данные")
For i = 1 To 12
.Cells(i + 1, 2).Value = Dataf(i)
Next i
End With
Me.Hide 'скрыть эту форму
Worksheets("Данные").Activate 'Открыть форму "Данные"
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub Label8_Click()
End Sub
Private Sub TextBox5_Change()
End Sub
Private Sub UserForm_Activate()
If NewTur = False Then EditClient
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = 1
End Sub
