АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция

Module1

Читайте также:
  1. Создание макроса.

Module Module1

Public ID As String

Public Повреждение As String

Public Наименование As String

Public Наличие As String

Public Фамилия As String

Public Имя As String

Public Отчество As String

Public Клиенты As String

Public ФИО As String

Public Ошибка As String

Public Услуга As String

Public Материал As String

Public Цвет As String

Public Стоимость As String

Public Изделие As String

End Module

Form1

Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Private lvwColumnSorter As Class1

Dim DataBaseFileName As String = Application.StartupPath & "\db.mdb"

Dim Connector As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFileName)

Sub Выдать()

Dim Дата As String = Format(Now, "d MMMM yyyy")

'ID = ListView1.SelectedItems.Item(0).Text

'Наименование = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

'Повреждение = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

'Материал = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

'Цвет = ListView1.SelectedItems.Item(0).SubItems.Item(4).Text

'Стоимость = ListView1.SelectedItems.Item(0).SubItems.Item(5).Text

'Услуга = ListView1.SelectedItems.Item(0).SubItems.Item(6).Text

'Наличие = "Нет"

Try

Dim Command As New OleDbCommand("UPDATE Изделия SET [Наименование]='" & Наименование & "', [Повреждение]='" & Повреждение & "', [Материал]='" & Материал & "', [Цвет]='" & Цвет & "', [Стоимость]='" & Стоимость & "', [Услуга]='" & Услуга & "', [Наличие]='" & Наличие & "' WHERE ([ID] Like '" & ListView1.SelectedItems.Item(0).Text & "')", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

ListView1.SelectedItems.Item(0).Text = Наименование

ListView1.SelectedItems.Item(0).SubItems.Item(1).Text = Повреждение

ListView1.SelectedItems.Item(0).SubItems.Item(2).Text = Материал

ListView1.SelectedItems.Item(0).SubItems.Item(3).Text = Цвет

ListView1.SelectedItems.Item(0).SubItems.Item(4).Text = Стоимость

ListView1.SelectedItems.Item(0).SubItems.Item(5).Text = Услуга

ListView1.SelectedItems.Item(0).SubItems.Item(6).Text = Наличие

Dim Command1 As New OleDbCommand("Insert Into [Журнал] ([ФИО], [История], [Дата]) values ('" & Клиенты & "', '" & Изделие & "', '" & Дата & "')", Connector)

Connector.Open()

Command1.ExecuteNonQuery()

Connector.Close()

ListView1.Items.Add("ID")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("ФИО")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("История")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("Дата")

Dim Command2 As New OleDbCommand("Insert Into [Журнал выдач] ([ФИО], [История], [IDGurnal]) values ('" & Клиенты & "', '" & Изделие & "', '" & ID & "')", Connector)

Connector.Open()

Command2.ExecuteNonQuery()

Connector.Close()

ListView1.Items.Add("ID")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("ФИО")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("История")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("IDGurnal")

Form1_Load(Me, New EventArgs)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

MessageBox.Show("Изделия: " & Chr(13) & Chr(10) & Изделие & Chr(13) & Chr(10) & "Для:" & Chr(13) & Chr(10) & Клиенты & Chr(13) & Chr(10) & "Успешно выданно!!!", "Операция успешна завершина", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub

 

Sub Editor_zap()

Try

Dim Command As New OleDbCommand("UPDATE Изделия SET [Наименование]='" & Наименование & "', [Повреждение]='" & Повреждение & "', [Материал]='" & Материал & "', [Цвет]='" & Цвет & "', [Стоимость]='" & Стоимость & "', [Услуга]='" & Услуга & "', [Наличие]='" & Наличие & "' WHERE ([ID] Like '" & ListView1.SelectedItems.Item(0).Text & "')", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

ListView1.SelectedItems.Item(0).Text = Наименование

ListView1.SelectedItems.Item(0).SubItems.Item(1).Text = Повреждение

ListView1.SelectedItems.Item(0).SubItems.Item(2).Text = Материал

ListView1.SelectedItems.Item(0).SubItems.Item(3).Text = Цвет

ListView1.SelectedItems.Item(0).SubItems.Item(4).Text = Стоимость

ListView1.SelectedItems.Item(0).SubItems.Item(5).Text = Услуга

ListView1.SelectedItems.Item(0).SubItems.Item(6).Text = Наличие

Form1_Load(Me, New EventArgs)

End Sub

Sub Dobavlenie_zap()

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

Try

Dim Command As New OleDbCommand("INSERT INTO Изделия (Наименование, Повреждение, Материал, Цвет, Стоимость, Услуга, Наличие) values ('" & Наименование & "', '" & Повреждение & "', '" & Материал & "', '" & Цвет & "', '" & Стоимость & "', '" & Услуга & "', '" & Наличие & "')", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Form1_Load(Me, New EventArgs)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

ListView1.Columns.Clear()

ListView1.Columns.Add("ID")

ListView1.Columns.Add("Наименование")

ListView1.Columns.Add("Повреждение")

ListView1.Columns.Add("Материал")

ListView1.Columns.Add("Цвет")

ListView1.Columns.Add("Стоимость")

ListView1.Columns.Add("Услуга")

ListView1.Columns.Add("Наличие")

ListView1.Items.Clear()

Try

Dim DataReader As OleDbDataReader

Dim Command As New OleDbCommand("Select * From Изделия", Connector)

Dim kartinka As Integer

kartinka = 2

Connector.Open()

DataReader = Command.ExecuteReader

While DataReader.Read() = True

If DataReader.GetValue(6) = "Химчистка" Then kartinka = 0

If DataReader.GetValue(6) = "Крашение" Then kartinka = 1

If DataReader.GetValue(6) = "Реставрация" Then kartinka = 2

ListView1.Items.Add(DataReader.GetValue(0), kartinka)

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(4))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(5))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(6))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(7))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

 

Private Sub БольшиеИконкиToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles БольшиеИконкиToolStripMenuItem.Click

ListView1.View = View.LargeIcon

End Sub

 

Private Sub ДеталиToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ДеталиToolStripMenuItem.Click

ListView1.View = View.Details

End Sub

 

Private Sub МаленькиеИконкиToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles МаленькиеИконкиToolStripMenuItem.Click

ListView1.View = View.SmallIcon

End Sub

 

Private Sub СписокToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles СписокToolStripMenuItem.Click

ListView1.View = View.List

End Sub

 

Private Sub НазваниеToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles НазваниеToolStripMenuItem.Click

ListView1.View = View.Tile

End Sub

 

Private Sub БольшиеИконкиToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles БольшиеИконкиToolStripMenuItem1.Click

ListView1.View = View.LargeIcon

End Sub

 

Private Sub ДеталиToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ДеталиToolStripMenuItem1.Click

ListView1.View = View.Details

End Sub

 

Private Sub МаленькиеИконкиToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles МаленькиеИконкиToolStripMenuItem1.Click

ListView1.View = View.SmallIcon

End Sub

 

Private Sub СписокToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles СписокToolStripMenuItem1.Click

ListView1.View = View.List

End Sub

 

Private Sub НазваниеToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles НазваниеToolStripMenuItem1.Click

ListView1.View = View.Tile

End Sub

 

 

Private Sub УдалитьToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles УдалитьToolStripMenuItem1.Click

УдалитьToolStripMenuItem_Click(Me, New EventArgs)

End Sub

 

Private Sub УдалитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles УдалитьToolStripMenuItem.Click

Dim МВох As DialogResult = MessageBox.Show("Вы действительно хотите без возвратно удалить изделие из базы данных?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)

If МВох = DialogResult.No Then Exit Sub

If МВох = DialogResult.Yes Then

Try

Dim Command As New OleDbCommand("DELETE * FROM Изделия WHERE (((Изделия.ID)=" & ListView1.SelectedItems.Item(0).Text & "));", Connector)

'DELETE(Изделия.ID, Изделия.Наименование, Изделия.Повреждение, Изделия.Материал, Изделия.Цвет, Изделия.Стоимость, Изделия.Услуга, Изделия.Наличие) FROM Изделия WHERE (((Изделия.ID)=" & ListView1.SelectedItems.Item(0).Text & "));

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

ListView1.SelectedItems.Item(0).Remove()

Form1_Load(Me, New EventArgs)

Catch ex As Exception

MessageBox.Show("Выделите изделие, прежде чем удалить его из бызы данных!!!", "Ошибка!!!")

End Try

 

End If

End Sub

 

Private Sub ДобавитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ДобавитьToolStripMenuItem.Click

Form2.Text = "Добавление записи"

Form2.Show()

End Sub

 

Private Sub ДобавитьToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ДобавитьToolStripMenuItem1.Click

ДобавитьToolStripMenuItem_Click(Me, New EventArgs)

End Sub

 

Private Sub ПолучателиToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ПолучателиToolStripMenuItem.Click

Form3.Text = "Клиенты"

Form3.Show()

End Sub

 

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

Form1_Load(Me, New EventArgs)

Timer1.Enabled = False

End Sub

 

Private Sub ВыдатьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВыдатьToolStripMenuItem.Click

Try

If ListView1.SelectedItems.Item(0).SubItems.Item(7).Text = "Да" Then

ID = ListView1.SelectedItems.Item(0).Text

Наименование = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

Повреждение = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

Материал = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Цвет = ListView1.SelectedItems.Item(0).SubItems.Item(4).Text

Стоимость = ListView1.SelectedItems.Item(0).SubItems.Item(5).Text

Услуга = ListView1.SelectedItems.Item(0).SubItems.Item(6).Text

Наличие = "Нет"

Изделие = Наименование & " - " & Повреждение & " - " & Материал & " - " & Цвет & " - " & Стоимость & " - " & Услуга

Form3.Show()

Form3.Text = "Выбирите клиента..."

Else

MessageBox.Show("Данное изделие уже было успешно выдан ранее..." & Chr(13) & Chr(10) & "Смотрите журнал выдач...", "Не возможно выполнить операцию....", MessageBoxButtons.OK, MessageBoxIcon.Error)

End If

Catch ex As Exception

MessageBox.Show("Выделите изделие, прежде чем его выдать клиенту!!!", "Ошибка!!!")

End Try

End Sub

 

Private Sub ВыдатьToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ВыдатьToolStripMenuItem1.Click

ВыдатьToolStripMenuItem_Click(Me, New EventArgs)

End Sub

 

Private Sub ЖурналToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ЖурналToolStripMenuItem.Click

Form5.Text = "Архив выдач..."

Form5.Show()

End Sub

 

Private Sub ОтчетПоВыданнойТехникиToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОтчетПоВыданнойТехникиToolStripMenuItem.Click

Form6.Text = "Текущий отчет..."

Form6.Show()

End Sub

 

Private Sub ЖурналВыдачиДаннойУстройстваToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ЖурналВыдачиДаннойУстройстваToolStripMenuItem.Click

ID = ListView1.SelectedItems.Item(0).Text

Наименование = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

Повреждение = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

Материал = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Цвет = ListView1.SelectedItems.Item(0).SubItems.Item(4).Text

Стоимость = ListView1.SelectedItems.Item(0).SubItems.Item(5).Text

Услуга = ListView1.SelectedItems.Item(0).SubItems.Item(6).Text

Изделие = Наименование & " - " & Повреждение & " - " & Материал & " - " & Цвет & " - " & Стоимость & " - " & Услуга

Form5.Text = "Отчет по: " & Изделие

Form5.Show()

End Sub

 

Private Sub ТToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ТToolStripMenuItem.Click

ID = ListView1.SelectedItems.Item(0).Text

Наименование = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

Повреждение = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

Материал = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Цвет = ListView1.SelectedItems.Item(0).SubItems.Item(4).Text

Стоимость = ListView1.SelectedItems.Item(0).SubItems.Item(5).Text

Услуга = ListView1.SelectedItems.Item(0).SubItems.Item(6).Text

Изделие = Наименование & " - " & Повреждение & " - " & Материал & " - " & Цвет & " - " & Стоимость & " - " & Услуга

Form6.Text = "Отчет текущий по: " & Изделие

Form6.Show()

End Sub

 

Private Sub ВыходToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВыходToolStripMenuItem.Click

End

End Sub

 

Private Sub ОбновитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОбновитьToolStripMenuItem.Click

Timer1.Enabled = True

End Sub

 

Private Sub ОбновитьToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ОбновитьToolStripMenuItem1.Click

ОбновитьToolStripMenuItem_Click(Me, New EventArgs)

End Sub

 

Private Sub ОПрограммеToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОПрограммеToolStripMenuItem.Click

Form7.Show()

Form7.Text = "О программе"

End Sub

 

Private Sub ОАвтореToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОАвтореToolStripMenuItem.Click

Form8.Show()

Form8.Text = "Об авторе"

End Sub

Private Sub ПерезагрузкаToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ПерезагрузкаToolStripMenuItem.Click

Application.Restart()

End Sub

 

Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick

Try

ID = ListView1.SelectedItems.Item(0).Text

Наименование = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

Повреждение = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

Материал = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Цвет = ListView1.SelectedItems.Item(0).SubItems.Item(4).Text

Стоимость = ListView1.SelectedItems.Item(0).SubItems.Item(5).Text

Услуга = ListView1.SelectedItems.Item(0).SubItems.Item(6).Text

Наличие = ListView1.SelectedItems.Item(0).SubItems.Item(7).Text

Form2.Text = "Редактирование записи"

Form2.Show()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

 

Private Sub ListView1_MouseUp(sender As Object, e As MouseEventArgs) Handles ListView1.MouseUp

Dim ItemIndex As Integer

If e.Button = Windows.Forms.MouseButtons.Right Then

ItemIndex = ListView1.SelectedIndices.Count

If ItemIndex = 1 Then

ContextMenuStrip1.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip1.Height)

Else

ContextMenuStrip2.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip1.Height)

End If

End If

End Sub

Private Sub ListView1_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles ListView1.ColumnClick

If (e.Column = lvwColumnSorter.SortColumn) Then

If (lvwColumnSorter.Order = SortOrder.Ascending) Then

lvwColumnSorter.Order = SortOrder.Descending

Else

lvwColumnSorter.Order = SortOrder.Ascending

End If

Else

lvwColumnSorter.SortColumn = e.Column

lvwColumnSorter.Order = SortOrder.Ascending

End If

Me.ListView1.Sort()

End Sub

End Class

Form2

Public Class Form2

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Close()

End Sub

 

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

If Me.Text = "Редактирование записи" Then

TextBox1.Text = Наименование

TextBox2.Text = Повреждение

ComboBox3.Text = Материал

TextBox4.Text = Цвет

TextBox5.Text = Стоимость

ComboBox1.Text = Услуга

ComboBox2.Text = Наличие

End If

End Sub

 

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

If Me.Text = "Добавление записи" Then

If TextBox1.Text = "" Or TextBox2.Text = "" Or ComboBox1.Text = "" Or ComboBox2.Text = "" Or ComboBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then

MessageBox.Show("Не все строки заполненны!!!")

Else

Наименование = TextBox1.Text

Повреждение = TextBox2.Text

Материал = ComboBox3.Text

Цвет = TextBox4.Text

Стоимость = TextBox5.Text

Услуга = ComboBox1.Text

Наличие = ComboBox2.Text

Form1.Dobavlenie_zap()

Me.Close()

End If

Else

Наименование = TextBox1.Text

Повреждение = TextBox2.Text

Материал = ComboBox3.Text

Цвет = TextBox4.Text

Стоимость = TextBox5.Text

Услуга = ComboBox1.Text

Наличие = ComboBox2.Text

Form1.Editor_zap()

Me.Close()

End If

End Sub

End Class

Form3

Imports System.Data

Imports System.Data.OleDb

 

Public Class Form3

Private lvwColumnSorter As Class1

Dim DataBaseFileName As String = Application.StartupPath & "\db.mdb"

Dim Connector As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFileName)

 

Sub Dobavlenie_zap()

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

Try

Dim Command As New OleDbCommand("Insert Into Клиенты ([Фамилия], [Имя], [Отчество]) values ('" & Фамилия & "', '" & Имя & "', '" & Отчество & "')", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

ListView1.Items.Add("Фамилия")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("Имя")

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("Отчество")

Form3_Load(Me, New EventArgs)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

Sub Editor_zap()

Try

Dim Command As New OleDbCommand("UPDATE Клиенты SET [Фамилия]='" & Фамилия & "', [Имя]='" & Имя & "', [Отчество]='" & Отчество & "' WHERE ([ID] Like '" & ListView1.SelectedItems.Item(0).Text & "')", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

ListView1.SelectedItems.Item(0).Text = Фамилия

ListView1.SelectedItems.Item(0).SubItems.Item(1).Text = Имя

ListView1.SelectedItems.Item(0).SubItems.Item(2).Text = Отчество

Form3_Load(Me, New EventArgs)

End Sub

 

Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

ListView1.Columns.Clear()

ListView1.Columns.Add("ID")

ListView1.Columns.Add("Фамилия")

ListView1.Columns.Add("Имя")

ListView1.Columns.Add("Отчество")

ListView1.Items.Clear()

Try

Dim DataReader As OleDbDataReader

Dim Command As New OleDbCommand("Select * From Клиенты", Connector)

Connector.Open()

DataReader = Command.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0), 0)

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

 

Private Sub ВыходToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВыходToolStripMenuItem.Click

Close()

End Sub

 

Private Sub ListView1_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles ListView1.ColumnClick

If (e.Column = lvwColumnSorter.SortColumn) Then

If (lvwColumnSorter.Order = SortOrder.Ascending) Then

lvwColumnSorter.Order = SortOrder.Descending

Else

lvwColumnSorter.Order = SortOrder.Ascending

End If

Else

lvwColumnSorter.SortColumn = e.Column

lvwColumnSorter.Order = SortOrder.Ascending

End If

Me.ListView1.Sort()

End Sub

 

Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick

If Me.Text = "Клиенты" Then

Try

ID = ListView1.SelectedItems.Item(0).Text

Фамилия = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text

Имя = ListView1.SelectedItems.Item(0).SubItems.Item(2).Text

Отчество = ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Form4.Text = "Редактирование записи"

Form4.Show()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Else

Клиенты = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(2).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Form1.Выдать()

Close()

End If

End Sub

 

Private Sub ListView1_MouseUp(sender As Object, e As MouseEventArgs) Handles ListView1.MouseUp

Dim ItemIndex As Integer

If e.Button = Windows.Forms.MouseButtons.Right Then

ItemIndex = ListView1.SelectedIndices.Count

If ItemIndex = 1 Then

ContextMenuStrip2.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip2.Height)

Else

ContextMenuStrip1.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip1.Height)

End If

End If

End Sub

 

Private Sub ОбновитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОбновитьToolStripMenuItem.Click

Form3_Load(Me, New EventArgs)

End Sub

 

Private Sub ДобавитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ДобавитьToolStripMenuItem.Click

Form4.Text = "Добавление записи"

Form4.Show()

End Sub

 

Private Sub ЖурналToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ЖурналToolStripMenuItem.Click

ФИО = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(2).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Form5.Text = "Отчет по: " & ФИО

Form5.Show()

End Sub

 

Private Sub ТекущееСостояниеToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ТекущееСостояниеToolStripMenuItem.Click

ФИО = ListView1.SelectedItems.Item(0).SubItems.Item(1).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(2).Text & " " & ListView1.SelectedItems.Item(0).SubItems.Item(3).Text

Form6.Text = "Отчет текущий по: " & ФИО

Form6.Show()

End Sub

 

Private Sub УдалитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles УдалитьToolStripMenuItem.Click

Dim МВох As DialogResult = MessageBox.Show("Вы действительно хотите без возвратно удалить клиента из базы данных?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)

If МВох = DialogResult.No Then Exit Sub

If МВох = DialogResult.Yes Then

Try

Dim Command As New OleDbCommand("DELETE FROM Клиенты WHERE ID =" & ListView1.SelectedItems.Item(0).Text & "", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

ListView1.SelectedItems.Item(0).Remove()

Form3_Load(Me, New EventArgs)

End If

End Sub

End Class

Form4

Public Class Form4

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Close()

End Sub

 

Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load

If Me.Text = "Редактирование записи" Then

TextBox1.Text = Фамилия

TextBox2.Text = Имя

TextBox3.Text = Отчество

End If

End Sub

 

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

If Me.Text = "Добавление записи" Then

If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then

MessageBox.Show("Не все строки заполненны!!!")

Else

Фамилия = TextBox1.Text

Имя = TextBox2.Text

Отчество = TextBox3.Text

Form3.Dobavlenie_zap()

Me.Close()

End If

Else

Фамилия = TextBox1.Text

Имя = TextBox2.Text

Отчество = TextBox3.Text

Form3.Editor_zap()

Me.Close()

End If

End Sub

End Class

Form5

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.Office.Interop

 

Public Class Form5

Private lvwColumnSorter As Class1

Dim myXL As Excel.Application, myWB As Excel.Workbook, myWS As Excel.Worksheet

Dim DataBaseFileName As String = Application.StartupPath & "\db.mdb"

Dim Connector As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFileName)

 

Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim DataReader As OleDbDataReader

Dim Command As New OleDbCommand("Select * From Журнал", Connector)

Dim Command1 As New OleDbCommand("Select * From Журнал WHERE ФИО = '" & ФИО & "'", Connector)

Dim Command2 As New OleDbCommand("Select * From Журнал WHERE [История] = '" & Изделие & "'", Connector)

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

ListView1.Columns.Clear()

ListView1.Columns.Add("ID")

ListView1.Columns.Add("ФИО")

ListView1.Columns.Add("История")

ListView1.Columns.Add("Дата и время")

ListView1.Items.Clear()

If Me.Text = "Архив выдач..." Then

Try

Connector.Open()

DataReader = Command.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

If Me.Text = "Отчет по: " & ФИО Then

Try

Connector.Open()

DataReader = Command1.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

If Me.Text = "Отчет по: " & Изделие Then

Try

Connector.Open()

DataReader = Command2.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

 

Private Sub УдалитьИсториюToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles УдалитьИсториюToolStripMenuItem.Click

Dim МВох As DialogResult = MessageBox.Show("Вы действительно хотите очистить основной журнал?", "Внимание очистка журнала...", MessageBoxButtons.YesNo, MessageBoxIcon.Error)

If МВох = DialogResult.No Then Exit Sub

If МВох = DialogResult.Yes Then

Try

Dim Command As New OleDbCommand("DELETE * FROM Журнал", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Form5_Load(Me, New EventArgs)

End If

End Sub

 

Private Sub ListView1_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles ListView1.ColumnClick

If (e.Column = lvwColumnSorter.SortColumn) Then

If (lvwColumnSorter.Order = SortOrder.Ascending) Then

lvwColumnSorter.Order = SortOrder.Descending

Else

lvwColumnSorter.Order = SortOrder.Ascending

End If

Else

lvwColumnSorter.SortColumn = e.Column

lvwColumnSorter.Order = SortOrder.Ascending

End If

Me.ListView1.Sort()

End Sub

 

Private Sub ОбновитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОбновитьToolStripMenuItem.Click

Form5_Load(Me, New EventArgs)

End Sub

 

Private Sub ВыходToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВыходToolStripMenuItem.Click

Close()

End Sub

End Class

Form6

Imports System.Data

Imports System.Data.OleDb

Imports Microsoft.Office.Interop

 

Public Class Form6

Private lvwColumnSorter As Class1

Dim DataBaseFileName As String = Application.StartupPath & "\db.mdb"

Dim Connector As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFileName)

Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim DataReader As OleDbDataReader

Dim Command As New OleDbCommand("Select * From [Журнал выдач]", Connector)

Dim Command1 As New OleDbCommand("Select * From [Журнал выдач] WHERE (([Журнал выдач].ФИО) = '" & ФИО & "')", Connector)

Dim Command2 As New OleDbCommand("Select * From [Журнал выдач] WHERE [Журнал выдач].[История] = '" & Изделие & "'", Connector)

lvwColumnSorter = New Class1()

Me.ListView1.ListViewItemSorter = lvwColumnSorter

ListView1.Columns.Clear()

ListView1.Columns.Add("ID")

ListView1.Columns.Add("ФИО")

ListView1.Columns.Add("История")

ListView1.Columns.Add("IDGurnal")

ListView1.Items.Clear()

If Me.Text = "Текущий отчет..." Then

Try

Connector.Open()

DataReader = Command.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

If Me.Text = "Отчет текущий по: " & ФИО Then

Try

Connector.Open()

DataReader = Command1.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

If Me.Text = "Отчет текущий по: " & Изделие Then

Try

Connector.Open()

DataReader = Command2.ExecuteReader

While DataReader.Read() = True

ListView1.Items.Add(DataReader.GetValue(0))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(1))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(2))

ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(DataReader.GetValue(3))

End While

DataReader.Close()

Connector.Close()

Catch ex As Exception

Connector.Close()

MessageBox.Show(ex.Message)

End Try

End If

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)

For Each columnheader In Me.ListView1.Columns

columnheader.Width = -3

Next

End Sub

 

Private Sub ЭкспортWordToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ЭкспортWordToolStripMenuItem.Click

Dim Дата As String = Format(Now, "d MMMM yyyy")

Dim W = New Word.Application

W.Visible = True

W.Documents.Add()

W.Selection.TypeText("Текущий отчет на: " & Дата & Chr(13) & Chr(10))

For i As Short = 0 To ListView1.Items.Count - 1

W.Selection.TypeText(ListView1.Items(i).SubItems.Item(0).Text & " " & ListView1.Items(i).SubItems.Item(1).Text & " " & ListView1.Items(i).SubItems.Item(2).Text & " " & ListView1.Items(i).SubItems.Item(3).Text & Chr(13) & Chr(10))

Next i

End Sub

 

Private Sub ЭкспортExcelToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ЭкспортExcelToolStripMenuItem.Click

Dim myXL As Excel.Application, myWB As Excel.Workbook, myWS As Excel.Worksheet

Dim i As Integer

Dim Y As Integer

Dim z As Integer

myXL = New Excel.Application

myWB = myXL.Workbooks.Add

myWS = myWB.Worksheets(1)

z = 2

myXL.Visible = True

For i = 1 To Me.ListView1.Items.Count

For Y = 1 To 2

myWS.Cells(1, Y) = ListView1.Columns(Y).Text

Next Y

myWS.Cells(z, 1) = ListView1.Items.Item(i - 1).SubItems.Item(1).Text

myWS.Cells(z, 2) = ListView1.Items.Item(i - 1).SubItems.Item(2).Text

z = z + 1

Next i

myWS.Columns(1).ColumnWidth = 50

myWS.Columns(2).ColumnWidth = 100

myXL = Nothing

myWB = Nothing

myWS = Nothing

End Sub

 

Private Sub ВыходToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВыходToolStripMenuItem.Click

Close()

End Sub

 

Private Sub ОбновитьToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ОбновитьToolStripMenuItem.Click

Form6_Load(Me, New EventArgs)

End Sub

 

Private Sub ListView1_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles ListView1.ColumnClick

If (e.Column = lvwColumnSorter.SortColumn) Then

If (lvwColumnSorter.Order = SortOrder.Ascending) Then

lvwColumnSorter.Order = SortOrder.Descending

Else

lvwColumnSorter.Order = SortOrder.Ascending

End If

Else

lvwColumnSorter.SortColumn = e.Column

lvwColumnSorter.Order = SortOrder.Ascending

End If

Me.ListView1.Sort()

End Sub

 

Private Sub ВНаличиеToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ВНаличиеToolStripMenuItem.Click

Try

Dim МВох As DialogResult = MessageBox.Show("Выполнить возврат", "Уведомление", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)

If МВох = DialogResult.No Then Exit Sub

If МВох = DialogResult.Yes Then

Dim Command As New OleDbCommand("DELETE FROM [Журнал выдач] WHERE ID =" & ListView1.SelectedItems.Item(0).Text & "", Connector)

Connector.Open()

Command.ExecuteNonQuery()

Connector.Close()

Dim Command1 As New OleDbCommand("UPDATE Изделия SET [Наличие]='Да' WHERE ([ID] Like '" & ListView1.SelectedItems.Item(0).SubItems.Item(3).Text & "')", Connector)

Connector.Open()

Command1.ExecuteNonQuery()

Connector.Close()

ListView1.SelectedItems.Item(0).Remove()

Form6_Load(Me, New EventArgs)

Form1.Timer1.Enabled = True

MessageBox.Show("Успешно выполнен возврат", "Операция успешна завершина", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

 

Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick

ВНаличиеToolStripMenuItem_Click(Me, New EventArgs)

End Sub

 

Private Sub ListView1_MouseUp(sender As Object, e As MouseEventArgs) Handles ListView1.MouseUp

Dim ItemIndex As Integer

If e.Button = Windows.Forms.MouseButtons.Right Then

ItemIndex = ListView1.SelectedIndices.Count

If ItemIndex = 1 Then

ContextMenuStrip2.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip2.Height)

Else

ContextMenuStrip1.Show(Me.Location.X + e.X, Me.Location.Y + e.Y + ContextMenuStrip1.Height)

End If

End If

End Sub

End Class

Form7

Public Class Form7

Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Label2.Text = "Версия 0.1 Alfa Корпорация Единорог 2015. Все права защищены."

End Sub

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Close()

End Sub

End Class

Form8

Public Class Form8

 

Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Label2.Text = "Версия 0.1 Alfa Корпорация Единорог 2015. Все права защищены."

End Sub

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Close()

End Sub

End Class


1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Поиск по сайту:



Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.197 сек.)