1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| Public Class Catalogue
Dim i As Integer
' \\\\\\\\\\\ technique de mouver la form //////////////
#Region "Global Variables"
Dim point As New System.Drawing.Point
Dim x, y As Integer
#End Region
#Region "GUI"
Private Sub Catalogue_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
If e.Button = MouseButtons.Left Then
point = Control.MousePosition
point.X = point.X - (x)
point.Y = point.Y - (y)
Me.Location = point
End If
End Sub
Private Sub Catalogue_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
x = Control.MousePosition.X - Me.Location.X
y = Control.MousePosition.Y - Me.Location.Y
End Sub
#End Region
Private Sub Catalogue_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.MdiParent = Menu1
remplir_dgv_cat()
remplir_cbo_famille()
End Sub
'Sub sup_P(ByVal Code_pdt As String)
' Code_pdt = dgv_cat.SelectedRows.Count
' Dim rsql As String = "delete from Catalogue where code_pdt='" & Code_pdt & "'"
' cmd = New SqlCommand(rsql, cn)
' With cmd.Parameters
' .AddWithValue("@Code_pdt ", Code_pdt)
' End With
' Try
' cmd.ExecuteNonQuery()
' Catch ex As Exception
' MessageBox.Show(ex.Message)
' Finally
' cmd.Dispose()
' MsgBox("votre suppression a été réalisée avec succès")
' End Try
'End Sub
Sub remplir_dgv_cat()
Dim Rsql As String = "Select*From Catalogue "
cmd = New SqlCommand(Rsql, cn)
dr = cmd.ExecuteReader
dgv_cat.Rows.Clear()
While dr.Read
dgv_cat.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5), dr(6), dr(7), dr(8), dr(9))
End While
cmd.Dispose()
dr.Close()
End Sub
' \\\\\\\\\\ chargement cbo famille /////////////
Sub remplir_cbo_famille()
Dim Rsql As String = "Select*From famille order by famille asc"
cmd = New SqlCommand(Rsql, cn)
dr = cmd.ExecuteReader
Famille.Items.Clear()
While dr.Read
Famille.Items.Add(dr(0))
End While
cmd.Dispose()
dr.Close()
End Sub
' \\\\\\\\\\ procédure ajout/////////////
Sub ajouter_produit(ByVal Code_pdt As String, ByVal Code_barre As String, ByVal Libelle As String, ByVal CUMP As Decimal, ByVal Prix_Public As Decimal, ByVal Prix_revendeur As Decimal, ByVal Qte_stock As Double, ByVal Qte_dispo As Double, ByVal Qte_Critique As Double, ByVal famille As String)
Dim rsql As String = ""
'rsql = "Select Code_pdt from Catalogue where code_pdt='" & Code_pdt & "'"
'cmd = New SqlCommand(rsql, cn)
'dr = cmd.ExecuteReader
'If dr.Read Then
' MessageBox.Show("Ce Produit il existe déjà")
' Exit Sub
'End If
'cmd.Dispose()
'dr.Close()
rsql = " Insert into Catalogue(Code_pdt,Code_barre,Libelle,CUMP,Prix_Public,Prix_revendeur,Qte_stock,Qte_dispo,Qte_Critique,famille) values(@Code_pdt,@Code_barre,@Libelle,@CUMP,@Prix_Public,@Prix_revendeur,@Qte_stock,@Qte_dispo,@Qte_Critique,@famille)"
cmd = New SqlCommand(rsql, cn)
With cmd.Parameters
.AddWithValue("@Code_pdt", Code_pdt)
.AddWithValue("@Code_barre", Code_barre)
.AddWithValue("@Libelle", Libelle)
.AddWithValue("@CUMP", CUMP)
.AddWithValue("@Prix_Public", Prix_Public)
.AddWithValue("@Prix_revendeur", Prix_revendeur)
.AddWithValue("@Qte_stock", Qte_stock)
.AddWithValue("@Qte_dispo", Qte_dispo)
.AddWithValue("@Qte_Critique", Qte_Critique)
.AddWithValue("@famille", famille)
End With
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cmd.Dispose()
End Try
End Sub
' \\\\\\\\\\\\\\\\\\\\button enregistrer////////////
Private Sub bt_enrg_Click(sender As Object, e As EventArgs) Handles bt_enrg.Click
'Try
For i As Short = 0 To dgv_cat.Rows.Count - 2
With dgv_cat
ajouter_produit(.Item(i, 0).Value, .Item(i, 1).Value, .Item(i, 2).Value, .Item(i, 3).Value, .Item(i, 4).Value, .Item(i, 5).Value, .Item(i, 6).Value, .Item(i, 7).Value, .Item(i, 8).Value, .Item(i, 9).Value)
End With
Next
'Catch ex As Exception
' MessageBox.Show(ex.Message)
'Finally
'End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub bt_sup_p_Click(sender As Object, e As EventArgs) Handles bt_sup_p.Click
'sup_P(Column1.Selected.ToString)
End Sub
End Class |
Partager