Вы находитесь на странице: 1из 32

James Gad Sibomana

Reg.Number:5648/06
Exam of Vb.net Using WindowsApplication&cs
3rd Year
ISM Departement

Code Of Procedures in Sql

For Computer table

ALTER PROCEDURE add1(


@ComputerId nvarchar(20),
@Name nvarchar(12),
@processor nvarchar(10),
@EntrenceDate smallDatetime,
@functionalty nvarchar(10),
@Details nvarchar(16),
@Status nvarchar(10),
@Network nvarchar(10),
@Location nvarchar(20))
AS
BEGIN
insert into Computer
values(@Computerid,@Name,@Processor,@Entrencedate,@Functionalty,@Details,@Status,@Network,
@Location);

ALTER PROCEDURE dele1(


@del nvarchar(20))
AS
BEGIN
delete from Computer where ComputerId=@del;
END
ALTER PROCEDURE update1(
@ComputerId nvarchar(20),
@Name nvarchar(12),
@processor nvarchar(10),
@EntrenceDate Datetime,
@functionalty nvarchar(10),
@Details nvarchar(16),
@Status nvarchar(10),
@Network nvarchar(10),
@Location nvarchar(20))
AS
BEGIN
UPDATE Computer set
Name=@Name,Processor=@Processor,EntrenceDate=@EntrenceDate,Functionalty=@functionalty,Details=@Detai
ls,status=@status,Network=@Network,Location=@Location where ComputerId=@ComputerId;
END

 For Screen Table

ALTER PROCEDURE add2(


@ScreenId nvarchar(20),
@ComputerId nvarchar(20),
@Name nvarchar(16),
@EntrenceDate smalldatetime,
@Functiionalty nvarchar(10),
@Details nvarchar(16),
@Location nvarchar(20))

AS
BEGIN
insert into Screen values(@ScreenId,@ComputerId,@Name,@EntrenceDate,@Functiionalty,@Details,
@Location)
END

ALTER PROCEDURE delet2(


@dell nvarchar(20))
AS
BEGIN
delete from Screen where ScreenId=@dell;
END

 For Accessory Table

create PROCEDURE add3(


@MaterielCode nvarchar(20),
@ComputerId nvarchar(20),
@Name nvarchar(20),
@EntrenceDate smalldatetime,
@Functionalty nvarchar(10),
@Details nvarchar(10),
@Location nvarchar(10))
AS
BEGIN
insert into Accessory values
(@MaterielCode,@ComputerId,@Name,@EntrenceDate,@Functionalty,@Details,@Location)
END

ALTER PROCEDURE dele3(


@aa nvarchar(20))
AS
BEGIN
delete From Accessory where MaterielCode=@aa
END

ALTER PROCEDURE [dbo].[upacc](


@MaterielCode nvarchar(20),
@ComputerId nvarchar(20),
@Name nvarchar(20),
@EntrenceDate smalldatetime,
@Functionalty nvarchar(10),
@Details nvarchar(10),
@Location nvarchar(10))
as
begin
update Accessory set ComputerId=@ComputerId,Name=@Name,EntrenceDate=@EntrenceDate,Functionalty=
@Functionalty,Details=@Details,Location=@Location where MaterielCode=@MaterielCode
END

For Printer table


ALTER PROCEDURE add4(
@PrinterId nvarchar(20),
@ComputerId nvarchar(20),
@Name nvarchar(16),
@EntrenceDate smalldatetime,
@Functionalty nvarchar(10),
@Detals nvarchar(16),
@Location nvarchar(20))
AS
BEGIN
insert into Printer values(@PrinterId,@ComputerId,@Name,@EntrenceDate,@Functionalty,@Detals,
@Location )
END

ALTER PROCEDURE dele4(


@dell nvarchar(20))
AS
BEGIN
delete from Printer where PrinterId=@dell
END

ALTER PROCEDURE update4(


@PrinterId nvarchar(20),
@ComputerId nvarchar(20),
@Name nvarchar(16),
@EntrenceDate smalldatetime,
@Functionalty nvarchar(10),
@Detals nvarchar(16),
@Location nvarchar(20))
AS
BEGIN
Update printer set
PrinterId=@PrinterId,ComputerId=@ComputerId,Name=@Name,EntrenceDate=@EntrenceDate,Functionalty=@F
unctionalty,Details=@Detals,Location=@Location where PrinterId =@PrinterId;
END

Code With Vb.net

Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=gestion;Integrated
Security=SSPI")
Dim str As String
Dim sqlInsert As String = "add1'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'"
Dim sqldelete As String = "dele1'{0}'"
Dim sqlsearch As String = "select1 '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',’{8}’"
Dim sqlupdate As String = "update1'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',’{8}’"
Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Form1ToolStripMenuItem.Click
Form1.Visible = True
End Sub

Private Sub Form3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form3ToolStripMenuItem.Click
Form3.Visible = True
End Sub

Private Sub Form4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form4ToolStripMenuItem.Click
Form4.Visible = True
End Sub

Private Sub Form5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form5ToolStripMenuItem.Click
Form5.Visible = True
End Sub

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsave.Click
Try
str = String.Format(sqlInsert, ComboBox1.SelectedItem, textBox2.Text, textBox3.Text,
dateTimePicker1.Value, textBox5.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text)
Dim sql_com As New SqlCommand(Str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Your Data Has Saved ")
Clear_Txt()
Me.ComputerTableAdapter.Fill(Me.GestionDataSet.Computer)
sql_com = Nothing
Str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub ComputerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ComputerBindingNavigatorSaveItem.Click
Me.Validate()
Me.ComputerBindingSource.EndEdit()
Me.ComputerTableAdapter.Update(Me.gestionDataSet.computer)

End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
'TODO: This line of code loads data into the 'GestionDataSet.computer' table. You can move, or remove it, as
needed.
Me.ComputerTableAdapter.Fill(Me.gestionDataSet.computer)

End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btndelete.Click
Try
str = String.Format(sqldele1, ComboBox1.SelectedItem)
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Deleted ")
Clear_Txt()
Me.ComputerTableAdapter.Fill(Me.GestionDataSet.computer)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnclear.Click
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
TextBox7.ResetText()
TextBox8.ResetText()
txtsearch.ResetText()
End Sub

Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click


TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox7.Enabled = True
TextBox8.Enabled = True
End Sub

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsearch.Click
Dim query As String
Dim count As Integer = 0
query = "select* from computer where ComputerId='" + ComboBox1.SelectedItem + "'"
Dim cn As SqlConnection = New SqlConnection("data source=James;initial catalog=gestion;Integrated
security=true")
Dim cmd As SqlCommand = New SqlCommand(query, cn)
Dim rd As SqlDataReader
Try
cn.Open()
rd = cmd.ExecuteReader()
While (rd.Read)
txtsearch.Text = " "
count += 1
ComboBox1.Text = rd(0)
TextBox2.Text = rd(1)
Datetimepicker1.Text=rd(2)
TextBox3.Text = rd(3)
TextBox4.Text = rd(4)
TextBox5.Text = rd(5)
TextBox6.Text = rd(6)
TextBox7.Text = rd(7)
TextBox8.Text = rd(8)

TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("The Computer doesn't exist ")

End If

End Sub

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnupdate.Click
Try
str = String.Format(sqlupdate1, ComboBox1.SelectedItem, textBox2.Text, textBox3.Text,
dateTimePicker1.Value, textBox5.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text)
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("do you want to update your data ")
Me.ComputerTableAdapter.Fill(Me.GestionDataSet.computer)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Private Sub Label10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Label10.Click

End Sub
End Class

Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form3
Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=gestion;Integrated
Security=SSPI")
Dim str As String
Dim sqlInsert As String = "access'{0}','{1}','{2}','{3}','{4}','{5}','{6}'"
Dim sqldeletestr As String = "dele2'{0}'"
Dim sqlsearch As String = "searcha2 '{0}','{1}','{2}','{3}','{4}','{5}','{6}'"
Dim sqlupdatestr As String = "update2 '{0}','{1}','{2}','{3}','{4}','{5}','{6}'"

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
'TODO: This line of code loads data into the 'GestionDataSet.accessory' table. You can move, or remove it, as
needed.
Me.AccessoryTableAdapter.Fill(Me.GestionDataSet.accessory)

End Sub

Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form1ToolStripMenuItem.Click
Form1.Visible = True
End Sub

Private Sub Form2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form2ToolStripMenuItem.Click
Form2.Visible = True
End Sub

Private Sub Form4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form4ToolStripMenuItem.Click
Form4.Visible = True
End Sub

Private Sub Form5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form5ToolStripMenuItem.Click
Form5.Visible = True
End Sub

Private Sub AccessoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles AccessoryBindingNavigatorSaveItem.Click
Me.Validate()
Me.AccessoryBindingSource.EndEdit()
Me.AccessoryTableAdapter.Update(Me.GestionDataSet.accessory)

End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btnsave.Click
Try
str = String.Format(sqlInsertStr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, TextBox6.Text, CDate(TextBox7.Text))
Dim sql_com As New sqlcommand(Str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Your Data Has Saved ")
Clear_Txt()
'Me.AccessoryTableAdapter.Fill(Me.GestDataionSet.computer)
sql_com = Nothing
Str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btndelete.Click
Try
str = String.Format(sqlDeletestr, TextBox1.Text)
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Deleted ")
Clear_Txt()
Me.AccessoryTableAdapter.Fill(Me.GestionDataSet.accessory)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnclear.Click
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
TextBox7.ResetText()
txtsearch.ResetText()
End Sub

Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click


TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox7.Enabled = True

End Sub

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsearch.Click
Dim query As String
Dim count As Integer = 0
query = "select* from accessory where accessoryId='" + txtsearch.Text + "'"
Dim cn As SqlConnection = New SqlConnection("data source=James;initial catalog=Gestion;Integrated
security=true")
Dim cmd As SqlCommand = New SqlCommand(query, cn)
Dim rd As SqlDataReader
Try
cn.Open()
rd = cmd.ExecuteReader()
While (rd.Read)
txtsearch.Text = " "

count += 1

TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)
TextBox7.Text = rd(6)

TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False

End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")

End If
End Sub

Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

End Sub

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnupdate.Click
Try
str = String.Format(sqlupdatestr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, TextBox6.Text, CDate(TextBox7.Text))
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("do you want to update your data ")
Me.AccessoryTableAdapter.Fill(Me.VbexamenDataSet.accessory)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Form4


Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=Gestion;Integrated
Security=SSPI")
Dim str As String
Dim sqlInsertStr As String = "save3'{0}','{1}','{2}','{3}','{4}','{5}'"
Dim sqldeletestr As String = "dele3'{0}'"
Dim sqlsearch As String = "search3 '{0}','{1}','{2}','{3}','{4}','{5}'"
Dim sqlupdatestr As String = "update3 '{0}','{1}','{2}','{3}','{4}','{5}'"

Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form1ToolStripMenuItem.Click
Form1.Visible = True
End Sub

Private Sub Form2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form2ToolStripMenuItem.Click
Form2.Visible = True
End Sub

Private Sub Form3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form3ToolStripMenuItem.Click
Form3.Visible = True
End Sub

Private Sub Form5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form5ToolStripMenuItem.Click
Form5.Visible = True
End Sub

Private Sub PrinterBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles PrinterBindingNavigatorSaveItem.Click
Me.Validate()
Me.PrinterBindingSource.EndEdit()
Me.PrinterTableAdapter.Update(Me.GestionDataSet.printer)
End Sub

Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
'TODO: This line of code loads data into the 'GestionDataSet.printer' table. You can move, or remove it, as
needed.
Me.PrinterTableAdapter.Fill(Me.GestionDataSet.printer)

End Sub

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsave.Click
Try
str = String.Format(sqlInsertStr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, CDate(TextBox6.Text))
Dim sql_com As New SqlCommand(str, objConnection)
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Your Data Has Saved ")
Clear_Txt()
Me.PrinterTableAdapter.Fill(Me.GestionDataSet.printer)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btndelete.Click
Try
str = String.Format(sqldeletestr, TextBox1.Text)
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Deleted ")
Clear_Txt()
Me.PrinterTableAdapter.Fill(Me.GestionDataSet.printer)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnclear.Click
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
txtsearch.ResetText()
End Sub

Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click


TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True

End Sub

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsearch.Click
Dim query As String
Dim count As Integer = 0
query = "select* from printer where printerId='" + txtsearch.Text + "'"
Dim cn As SqlConnection = New SqlConnection("data source=James;initial catalog=Gestion;Integrated
security=true")
Dim cmd As SqlCommand = New SqlCommand(query, cn)
Dim rd As SqlDataReader
Try
cn.Open()
rd = cmd.ExecuteReader()
While (rd.Read)
txtsearch.Text = " "

count += 1

TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)

TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False

End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click
Try
str = String.Format(sqlupdatestr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, CDate(TextBox6.Text))
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("do you want to update your data ")
Me.PrinterTableAdapter.Fill(Me.GestionDataSet.printer)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

End Class

Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form5

Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=gestion;Integrated


Security=SSPI")
Dim str As String
Dim sqlInsertStr As String = "save4'{0}','{1}','{2}','{3}','{4}','{5}'"
Dim sqldeletestr As String = "dele4'{0}'"
Dim sqlsearch As String = "search4 '{0}','{1}','{2}','{3}','{4}','{5}'"
Dim sqlupdatestr As String = "update4'{0}','{1}','{2}','{3}','{4}','{5}'"

Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form1ToolStripMenuItem.Click
Form1.Visible = True
End Sub

Private Sub Form2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form2ToolStripMenuItem.Click
Form2.Visible = True
End Sub

Private Sub Form3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Form3ToolStripMenuItem.Click
Form3.Visible = True
End Sub
Private Sub Form4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Form4ToolStripMenuItem.Click
Form4.Visible = True
End Sub

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsave.Click
Try
Str = String.Format(sqlInsertStr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, CDate(TextBox6.Text))

Dim sql_com As New SqlCommand(Str, objConnection)


objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Your Data Has Saved ")
Me.ScreenTableAdapter.Fill(Me.GestionDataSet.screen)
sql_com = Nothing
Str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub ScreenBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ScreenBindingNavigatorSaveItem.Click
Me.Validate()
Me.ScreenBindingSource.EndEdit()
Me.ScreenTableAdapter.Update(Me.GestionDataSet.screen)

End Sub

Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
'TODO: This line of code loads data into the 'GestionDataSet.screen' table. You can move, or remove it, as
needed.
Me.ScreenTableAdapter.Fill(Me.GestionDataSet.screen)

End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btndelete.Click
Try
str = String.Format(sqldeletestr, TextBox1.Text)
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("Deleted ")
Clear_Txt()
Me.ScreenTableAdapter.Fill(Me.GestionDataSet.screen)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnclear.Click
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
txtsearch.ResetText()
End Sub

Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click


TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True

End Sub

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


btnsearch.Click
Dim query As String
Dim count As Integer = 0
query = "select* from screen where screenId'" + txtsearch.Text + "'"
Dim cn As SqlConnection = New SqlConnection("data source=James;initial catalog=Gestion;Integrated
security=true")
Dim cmd As SqlCommand = New SqlCommand(query, cn)
Dim rd As SqlDataReader
Try
cn.Open()
rd = cmd.ExecuteReader()
While (rd.Read)
txtsearch.Text = " "

count += 1

TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)

TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False

End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click
Try
str = String.Format(sqlupdatestr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, CDate(TextBox6.Text))
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("do you want to update your data ")
Me.ScreenTableAdapter.Fill(Me.GestionDataSet.screen)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class

Code with Cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string h = "Data source =.;Initial Catalog=gestion;Integrated Security=true";

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void form2ToolStripMenuItem_Click(object sender, EventArgs e)


{
Form2 frm = new Form2();
frm.ccon = new SqlConnection(h);
frm.Show();
}

private void form3ToolStripMenuItem_Click(object sender, EventArgs e)


{
Form3 frm = new Form3();
frm.ccon = new SqlConnection(h);
frm.Show();
}

private void form4ToolStripMenuItem_Click(object sender, EventArgs e)


{
Form4 frm = new Form4();
frm.ccon = new SqlConnection(h);
frm.Show();
}

private void reportToolStripMenuItem_Click(object sender, EventArgs e)


{
Repport2 frm = new Repport2();
frm.ccon = new SqlConnection(h);
frm.Show();

private void form5ToolStripMenuItem_Click(object sender, EventArgs e)


{
Form5 frm = new Form5();
frm.ccon = new SqlConnection(h);
frm.Show();
}

private void repportToolStripMenuItem_Click(object sender, EventArgs e)


{
Repport frm = new Repport();
frm.ccon = new SqlConnection(h);
frm.Show();
}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)


{

comboBox1.Enabled = true;
textBox2.Enabled = false;
textBox3.Enabled = false;
dateTimePicker1.Enabled = false;
textBox5.Enabled = false;
textBox6.Enabled = false;
textBox7.Enabled = false;
textBox8.Enabled = false;
textBox9.Enabled = false;
button1.Enabled = false;
button3.Enabled = false;
button5.Enabled = false;
//dataGridView1.Enabled = false;

con.Close();
con.Open();
string h = "select * from Computer";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Computer");
DataView dv = new DataView(ds.Tables["Computer"]);
dataGridView1.DataSource = dv;
}

private void button1_Click(object sender, EventArgs e)


{

private void button3_Click(object sender, EventArgs e)


{
}

private void button6_Click(object sender, EventArgs e)


{

private void groupBox1_Enter(object sender, EventArgs e)


{

private void button1_Click_1(object sender, EventArgs e)


{
string ajou = "exec add1 '" + comboBox1.SelectedItem + "','" + textBox2.Text + "','" + textBox3.Text + "','"
+ dateTimePicker1.Value + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" +
textBox8.Text + "','" + textBox9.Text + "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox1.Text = "";
textBox2.Text = "";
textBox3.Text="";
dateTimePicker1.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
con.Close();
Form2_Load(sender, e);

private void button2_Click(object sender, EventArgs e)


{
comboBox1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
dateTimePicker1.Enabled = true;
textBox5.Enabled = true;
textBox6.Enabled = true;
textBox7.Enabled = true;
textBox8.Enabled = true;
textBox9.Enabled = true;
button1.Enabled = true;
button3.Enabled = true;
button5.Enabled = true;

private void button3_Click_1(object sender, EventArgs e)


{
string ajou2 = "exec hello '" + comboBox1.SelectedItem + "'";
SqlCommand ajout = new SqlCommand(ajou2, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
con.Close();
Form2_Load(sender, e);

private void button6_Click_1(object sender, EventArgs e)


{

con.Close();
con.Open();
string c = "select * from Computer where ComputerId='"+comboBox1.SelectedItem+"'";
SqlDataAdapter da2 = new SqlDataAdapter(c,con);
DataSet ds =new DataSet();
da2.Fill(ds,"Computer");
DataView dv =new DataView(ds.Tables["Computer"]);
DataTable dt =ds.Tables["Computer"];
comboBox1.DataBindings.Add("text",dv,"ComputerId");
textBox2.DataBindings.Add("text",dv,"Name");
textBox3.DataBindings.Add("text",dv,"Processor");
dateTimePicker1.DataBindings.Add("text",dv,"EntrenceDate");
textBox5.DataBindings.Add("text",dv,"Functionalty");
textBox6.DataBindings.Add("text",dv,"Details");
textBox7.DataBindings.Add("text",dv,"Status");
textBox8.DataBindings.Add("text",dv,"Network");
textBox9.DataBindings.Add("text",dv,"Location");

private void button4_Click(object sender, EventArgs e)


{
//comboBox1.Enabled = false;
textBox2.Enabled = true;
textBox3.Enabled = true;
dateTimePicker1.Enabled = true;
textBox5.Enabled = true;
textBox6.Enabled = true;
textBox7.Enabled = true;
textBox8.Enabled = true;
textBox9.Enabled = true;
//button1.Enabled = true;
button3.Enabled = true;
button5.Enabled = true;
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)


{

private void button5_Click(object sender, EventArgs e)


{
string s = "exec kell'" + comboBox1.SelectedItem + "','" + textBox2.Text + "','" + textBox3.Text + "','" +
dateTimePicker1.Value + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text
+ "','" + textBox9.Text + "'";
SqlCommand cmd = new SqlCommand(s, con);
cmd.ExecuteNonQuery();
MessageBox.Show("successfull updated");
comboBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
dateTimePicker1.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";

con.Close();
Form2_Load(sender, e);

private void button7_Click(object sender, EventArgs e)


{
comboBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
dateTimePicker1.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
}

private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)


{

}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form3()
{

InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)


{
//comboBox1.Enabled = false;
comboBox2.Enabled = false;
textBox1.Enabled = false;
dateTimePicker1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
button2.Enabled = false;
button7.Enabled = false;
button3.Enabled=false;

comboBox2.SelectedValue= "";
con.Close();
con.Open();
string h = "select * from Screen";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Screen");
DataView dv = new DataView(ds.Tables["Screen"]);
dataGridView1.DataSource = dv;

string p1 = "select * from Computer";


SqlDataAdapter da1 = new SqlDataAdapter(p1, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "Computer");

DataView dv1 = new DataView(ds1.Tables["Computer"]);


comboBox2.DataSource = dv1;
comboBox2.ValueMember = "ComputerId";
comboBox2.DisplayMember = "ComputerId";
comboBox2.SelectedItem = "";
}

private void button1_Click(object sender, EventArgs e)


{
comboBox1.Enabled = true;
comboBox2.Enabled=true;
textBox1.Enabled = true;
dateTimePicker1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
button2.Enabled = true;
}

private void button2_Click(object sender, EventArgs e)


{

string ajou = "exec Sadd '" + comboBox1.SelectedItem + "','" + comboBox2.SelectedValue+ "','" +


textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text
+ "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox2.SelectedItem = "";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";

// b = false;
con.Close();
Form3_Load(sender, e);
}

private void groupBox1_Enter(object sender, EventArgs e)


{

private void button3_Click(object sender, EventArgs e)


{
string ajou2 = "exec sdell'" + comboBox1.SelectedItem + "'";
SqlCommand ajout = new SqlCommand(ajou2, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
// b = false;
con.Close();
Form3_Load(sender, e);

private void button6_Click(object sender, EventArgs e)


{
con.Close();
con.Open();
string c = "select * from Screen where ScreenId='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Screen");
DataView dv = new DataView(ds.Tables["Screen"]);
DataTable dt = ds.Tables["Screen"];
comboBox1.DataBindings.Add("text", dv, "ScreenId");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name1");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functiionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");

private void button7_Click(object sender, EventArgs e)


{

private void button4_Click(object sender, EventArgs e)


{
comboBox2.Enabled = true;
textBox1.Enabled = true;
dateTimePicker1.Enabled = true;
textBox2.Enabled = true;
textBox4.Enabled = true;
textBox3.Enabled = true;
button7.Enabled = true;
button3.Enabled = true;
}

private void button5_Click(object sender, EventArgs e)


{
comboBox1.Text = "";
comboBox2.Text = "";
dateTimePicker1.Text = "";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

private void label7_Click(object sender, EventArgs e)


{

}
private void label6_Click(object sender, EventArgs e)
{

private void label5_Click(object sender, EventArgs e)


{

private void label4_Click(object sender, EventArgs e)


{

private void label3_Click(object sender, EventArgs e)


{

private void label2_Click(object sender, EventArgs e)


{

private void label1_Click(object sender, EventArgs e)


{

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)


{

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)


{

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)


{

private void textBox4_TextChanged(object sender, EventArgs e)


{

private void textBox3_TextChanged(object sender, EventArgs e)


{

private void textBox2_TextChanged(object sender, EventArgs e)


{

private void textBox1_TextChanged(object sender, EventArgs e)


{

}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
public partial class Form4 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form4()
{
InitializeComponent();
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)


{

private void groupBox1_Enter(object sender, EventArgs e)


{

private void Form4_Load(object sender, EventArgs e)


{
comboBox1.Enabled = true;
comboBox2.Enabled = false;
textBox1.Enabled = false;
dateTimePicker1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
button1.Enabled =true ;
button2.Enabled = false;
button3.Enabled = false;
button6.Enabled = false;
con.Close();
con.Open();
string h = "select * from Printer";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Printer");
DataView dv = new DataView(ds.Tables["Printer"]);
dataGridView1.DataSource = dv;

string p1 = "select * from Computer";


SqlDataAdapter da1 = new SqlDataAdapter(p1, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "Computer");

DataView dv1 = new DataView(ds1.Tables["Computer"]);


comboBox2.DataSource = dv1;
comboBox2.ValueMember = "ComputerId";
comboBox2.DisplayMember = "ComputerId";
comboBox2.SelectedItem = "";
}

private void button2_Click(object sender, EventArgs e)


{
string ajou = "exec addp '" + comboBox1.SelectedItem + "','" + comboBox2.SelectedValue + "','" +
textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text
+ "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox1.Text = "";
comboBox2.Text = "";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";

// b = false;
con.Close();
Form4_Load(sender, e);
}

private void label6_Click(object sender, EventArgs e)


{

private void button3_Click(object sender, EventArgs e)


{
string ajou2 = "exec delp '" + comboBox1.SelectedItem + "'";
SqlCommand ajout = new SqlCommand(ajou2, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
// b = false;
con.Close();
Form4_Load(sender, e);

private void button5_Click(object sender, EventArgs e)


{

con.Close();
con.Open();
string c = "select * from Printer where PrinterId='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Printer");
DataView dv = new DataView(ds.Tables["Printer"]);
DataTable dt = ds.Tables["Printer"];
comboBox1.DataBindings.Add("text", dv, "PrinterId");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");

private void button6_Click(object sender, EventArgs e)


{
string ajou = "exec uppr '" + comboBox1.SelectedItem + "','" + comboBox2.SelectedValue + "','" +
textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text
+ "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox1.Text = "";
comboBox2.Text = "";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";

// b = false;
con.Close();
Form4_Load(sender, e);
}

private void button4_Click(object sender, EventArgs e)


{
comboBox1.Enabled = false;
comboBox2.Enabled = true;
textBox1.Enabled = true;
dateTimePicker1.Enabled =true;
textBox2.Enabled =true;
textBox3.Enabled =true ;
textBox4.Enabled = true;
//button1.Enabled =true;
button2.Enabled = false;
button3.Enabled = true;
button6.Enabled =true;
}

private void button1_Click(object sender, EventArgs e)


{
comboBox1.Enabled = true;
comboBox2.Enabled = true;
textBox1.Enabled = true;
dateTimePicker1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;

button2.Enabled = true;
//button3.Enabled = false;
// button6.Enabled = true;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
public partial class Form5 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}

public Form5()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
string ajou = "exec addac'" + comboBox1.SelectedItem + "','" + comboBox2.SelectedValue + "','" +
textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text
+ "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox1.Text = "";
comboBox2.Text = "";
textBox1.Text = "";
dateTimePicker1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
con.Close();
Form5_Load(sender, e);

private void Form5_Load(object sender, EventArgs e)


{
comboBox1.Enabled = true;
comboBox2.Text = "";
comboBox2.Enabled = false;
dateTimePicker1.Enabled = false;
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button5.Enabled = false;
con.Close();
con.Open();
string h = "select * from Accessory";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Accessory");
DataView dv = new DataView(ds.Tables["Accessory"]);
dataGridView1.DataSource = dv;

string p1 = "select * from Computer";


SqlDataAdapter da1 = new SqlDataAdapter(p1, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "Computer");

DataView dv1 = new DataView(ds1.Tables["Computer"]);


comboBox2.DataSource = dv1;
comboBox2.ValueMember = "ComputerId";
comboBox2.DisplayMember = "ComputerId";
comboBox2.SelectedItem = "";

private void button3_Click(object sender, EventArgs e)


{
string ajou2 = "exec delacc '" + comboBox1.SelectedItem + "'";
SqlCommand ajout = new SqlCommand(ajou2, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.Text = "";
comboBox2.Text = "";
con.Close();
Form5_Load(sender, e);

private void button7_Click(object sender, EventArgs e)


{

con.Close();
con.Open();
string c = "select * from Accessory where MaterielCode='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Accessory");
DataView dv = new DataView(ds.Tables["Accessory"]);
DataTable dt = ds.Tables["Accessory"];
comboBox1.DataBindings.Add("text", dv, "MaterielCode");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");

private void button1_Click(object sender, EventArgs e)


{
textBox1.Enabled = true;
comboBox1.Enabled = true;
comboBox2.Enabled = true;
dateTimePicker1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
button2.Enabled = true;
}

private void button4_Click(object sender, EventArgs e)


{
comboBox1.Enabled = false;
comboBox2.Enabled = true;
textBox1.Enabled = true;
dateTimePicker1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
button5.Enabled = true;
button3.Enabled = true;
}
private void button5_Click(object sender, EventArgs e)
{
string ajou = "exec upacc'" + comboBox1.SelectedItem + "','" + comboBox2.SelectedValue + "','" +
textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text
+ "'";
SqlCommand ajout = new SqlCommand(ajou, con);
ajout.ExecuteNonQuery();
MessageBox.Show("Operation terminated successful!");
comboBox1.SelectedItem = " ";
comboBox1.Text = "";
comboBox2.Text = "";
textBox1.Text = "";
dateTimePicker1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
con.Close();
Form5_Load(sender, e);

private void groupBox1_Enter(object sender, EventArgs e)


{

private void button6_Click(object sender, EventArgs e)


{
comboBox1.Text = "";
comboBox2.Text = "";
textBox1.Text = "";
dateTimePicker1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

}
}
}

Prepared By James Gad Sibomana

Оценить