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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
|
Imports System.IO
Imports System.Data.OleDb
Imports System.Text.RegularExpressions
Imports System.Diagnostics
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Friend Class FrmEntry
Dim Main As New FrmMain
Public ShowBind As String
Public FormState As ModGlobal.Form_State
Private Sub FrmEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If FormState = Form_State.Add_RecordState Then
KeyPreview = True
Call ContextMnu()
Call CapsLock()
Call regimentItem()
Me.BSave.Text = "Sauvegarde:"
Me.Text = "Ajouter Enregistrement:"
Call ImageSyntax()
Try
With OleCn
If .State <> ConnectionState.Open Then
.ConnectionString = StrConnection()
.Open()
'Initialized Command...
With OleDa
.SelectCommand = New OleDbCommand()
.SelectCommand.CommandText = "SELECT * FROM [registre]"
.SelectCommand.Connection = OleCn
End With
'Insert Command...
With OleDa
.InsertCommand = New OleDbCommand()
.InsertCommand.CommandText = "INSERT INTO [registre] ([ID_Membre] , [Nom] , [prenom] , [Grade] , [regiment] , [entreele] , [contingent] , " & _
"[sortiele] , [Mail] , [profession] , [Ville] , [CodePostal] , [Photos_membre] , [observation]) VALUES (@ID_Membre , @Nom , @Prenom , @Grade , @regiment , @entreele , @contingent , " & _
"@sortiele , @mail , @profession , @ville , @CodePostal , @photos_membre , @observation)"
.InsertCommand.Connection = OleCn
.InsertCommand.Parameters.Add("@ID_Membre", OleDbType.VarWChar, 50, "ID_Membre")
.InsertCommand.Parameters.Add("@Nom", OleDbType.VarWChar, 50, "Nom")
.InsertCommand.Parameters.Add("@Prenom", OleDbType.VarWChar, 50, "Prenom")
.InsertCommand.Parameters.Add("@Grade", OleDbType.VarWChar, 50, "Grade")
.InsertCommand.Parameters.Add("@regiment", OleDbType.VarWChar, 50, "regiment")
.InsertCommand.Parameters.Add("@entreele", OleDbType.VarWChar, 50, "entreele")
.InsertCommand.Parameters.Add("@contingent", OleDbType.VarWChar, 50, "contingent")
.InsertCommand.Parameters.Add("@sortiele", OleDbType.VarWChar, 50, "sortiele")
.InsertCommand.Parameters.Add("@mail", OleDbType.VarWChar, 50, "mail")
.InsertCommand.Parameters.Add("@profession", OleDbType.VarWChar, 50, "profession")
.InsertCommand.Parameters.Add("@ville", OleDbType.VarWChar, 50, "ville")
.InsertCommand.Parameters.Add("@CodePostal", OleDbType.VarWChar, 50, "codepostal")
.InsertCommand.Parameters.Add("@photos_membre", OleDbType.Binary, 0, "photos_membre")
.InsertCommand.Parameters.Add("@observation", OleDbType.VarWChar, 50, "observation")
End With
With OleDa
.UpdateCommand = New OleDbCommand()
.UpdateCommand.CommandText = "UPDATE [registre] SET [Nom] = @Nom , [prenom] = @Prenom , [Grade] = @Grade , [regiment] = @regiment , " & _
"[entreele] = @entreele , [contingent] = @contingent , [sortiele] = @sortiele , [Mail] = @mail , [profession] = @profession , [Ville] = @ville , [CodePostal] = @CodePostal , [Photos_membre] = @photos_membre , [observation] = @observation WHERE ([ID_Membre] = @ID_Membre_Syntax)"
.UpdateCommand.Connection = OleCn
.UpdateCommand.Parameters.Add("@Nom", OleDbType.VarWChar, 50, "Nom")
.UpdateCommand.Parameters.Add("@Prenom", OleDbType.VarWChar, 50, "Prenom")
.UpdateCommand.Parameters.Add("@Grade", OleDbType.VarWChar, 50, "Grade")
.UpdateCommand.Parameters.Add("@regiment", OleDbType.VarWChar, 50, "regiment")
.UpdateCommand.Parameters.Add("@entreele", OleDbType.VarWChar, 50, "entreele")
.UpdateCommand.Parameters.Add("@contingent", OleDbType.VarWChar, 50, "contingent")
.UpdateCommand.Parameters.Add("@sortiele", OleDbType.VarWChar, 50, "sortiele")
.UpdateCommand.Parameters.Add("@mail", OleDbType.VarWChar, 50, "mail")
.UpdateCommand.Parameters.Add("@profession", OleDbType.VarWChar, 50, "profession")
.UpdateCommand.Parameters.Add("@ville", OleDbType.VarWChar, 50, "ville")
.UpdateCommand.Parameters.Add("@CodePostal", OleDbType.VarWChar, 50, "codepostal")
.UpdateCommand.Parameters.Add("@photos_membre", OleDbType.Binary, 0, "photos_membre")
.UpdateCommand.Parameters.Add("@observation", OleDbType.VarWChar, 50, "observation")
.UpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ID_Membre_Syntax", System.Data.OleDb.OleDbType.VarWChar, 50, _
System.Data.ParameterDirection.Input, False, _
CType(0, Byte), CType(0, Byte), "ID_Membre", _
DataRowVersion.Default, True))
End With
End If
End With
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
Finally
OleCn.Close()
End Try
Exit Sub
End If
If FormState = Form_State.Edit_RecordState Then
KeyPreview = True
Call ContextMnu()
Call CapsLock()
Call regimentItem()
Me.BSave.Text = "Mise à Jours:"
Me.Text = "Edition Enregistrement:"
Try
With OleCn
If .State <> ConnectionState.Open Then
.ConnectionString = StrConnection()
.Open()
With OleDa
.SelectCommand = New OleDbCommand()
.SelectCommand.CommandText = "SELECT * FROM [registre] WHERE (ID_membre = @ID_Membre)"
.SelectCommand.Parameters.Add("@ID_Membre", OleDbType.VarChar, 50, "ID_Membre").Value = ShowBind.ToString()
.SelectCommand.Connection = OleCn
End With
With OleDa
.UpdateCommand = New OleDbCommand()
.UpdateCommand.CommandText = "UPDATE [registre] SET [ID_Membre] = @ID_Membre , [Nom] = @Nom , [prenom] = @Prenom , [Grade] = @Grade , [regiment] = @regiment , " & _
"[entreele] = @entreele , [contingent] = @contingent , [sortiele] = @sortiele , [Mail] = @mail , [profession] = @profession , [Ville] = @ville , [CodePostal] = @CodePostal , [Photos_membre] = @photos_membre , [observation] = @observation WHERE ([ID_Membre] = @ID_Membre_Syntax)"
.UpdateCommand.Connection = OleCn
.UpdateCommand.Parameters.Add("@ID_Membre", OleDbType.VarWChar, 50, "ID_Membre")
.UpdateCommand.Parameters.Add("@Nom", OleDbType.VarWChar, 50, "Nom")
.UpdateCommand.Parameters.Add("@Prenom", OleDbType.VarWChar, 50, "Prenom")
.UpdateCommand.Parameters.Add("@Grade", OleDbType.VarWChar, 50, "Grade")
.UpdateCommand.Parameters.Add("@regiment", OleDbType.VarWChar, 50, "regiment")
.UpdateCommand.Parameters.Add("@entreele", OleDbType.VarWChar, 50, "entreele")
.UpdateCommand.Parameters.Add("@contingent", OleDbType.VarWChar, 50, "contingent")
.UpdateCommand.Parameters.Add("@sortiele", OleDbType.VarWChar, 50, "sortiele")
.UpdateCommand.Parameters.Add("@mail", OleDbType.VarWChar, 50, "mail")
.UpdateCommand.Parameters.Add("@profession", OleDbType.VarWChar, 50, "profession")
.UpdateCommand.Parameters.Add("@ville", OleDbType.VarWChar, 50, "ville")
.UpdateCommand.Parameters.Add("@CodePostal", OleDbType.VarWChar, 50, "codepostal")
.UpdateCommand.Parameters.Add("@photos_membre", OleDbType.Binary, 0, "photos_membre")
.UpdateCommand.Parameters.Add("@observation", OleDbType.VarWChar, 50, "observation")
.UpdateCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ID_Membre_Syntax", System.Data.OleDb.OleDbType.VarWChar, 50, _
System.Data.ParameterDirection.Input, False, _
CType(0, Byte), CType(0, Byte), "ID_Membre", _
DataRowVersion.Original, True))
End With
DtaSet2.Clear()
OleDa.Fill(DtaSet2, "registre")
Me.Identification.DataBindings.Add(New Binding("Text", DtaSet2, "registre.ID_membre", True))
Me.TxtNom.DataBindings.Add(New Binding("Text", DtaSet2, "registre.Nom", True))
Me.TxtPrenom.DataBindings.Add(New Binding("Text", DtaSet2, "registre.Prenom", True))
Me.TxtGrade.DataBindings.Add(New Binding("Text", DtaSet2, "registre.Grade", True))
Me.CBRegiment.DataBindings.Add(New Binding("Text", DtaSet2, "registre.regiment", True))
Me.DTEntrele.DataBindings.Add(New Binding("Text", DtaSet2, "registre.entreele", True))
Me.DTSortiele.DataBindings.Add(New Binding("Text", DtaSet2, "registre.sortiele", True))
Me.TxtContingent.DataBindings.Add(New Binding("Text", DtaSet2, "registre.contingent", True))
Me.TxtEmail.DataBindings.Add(New Binding("Text", DtaSet2, "registre.mail", True))
Me.TxtProfession.DataBindings.Add(New Binding("Text", DtaSet2, "registre.profession", True))
Me.TxtVille.DataBindings.Add(New Binding("Text", DtaSet2, "registre.ville", True))
Me.TxtCP.DataBindings.Add(New Binding("Text", DtaSet2, "registre.codepostal", True))
Me.TxtObservation.DataBindings.Add(New Binding("Text", DtaSet2, "registre.observation", True))
Main = FrmMain
Me.PicStudent.Image = FrmMain.PictureBox1.Image
End If
End With
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Erreur...")
Finally
OleCn.Close()
End Try
Exit Sub
End If
End Sub
'Private Function RequiredEntry() As Boolean
' If Identification.Text = "" Or TxtNom.Text = "" Or TxtPrenom.Text = "" Or _
' TxtGrade.Text = "" Or TxtContingent.Text = "" Or TxtEmail.Text = "" Or TxtProfession.Text = "" Or _
' TxtVille.Text = "" Or TxtCP.Text = "" = True Then
' MsgBox("Il manque Des informations ....", MsgBoxStyle.Critical, "Attention...")
' Return True
' Exit Function
' End If
'End Function
Private Sub BSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSave.Click
Main = FrmMain
If FormState = Form_State.Add_RecordState Then
' If RequiredEntry() = True Then
' Return
' End If
Try
Dim DtaRow As DataRow
Dim MemStream As New MemoryStream
Dim DataPic_Insert As Byte()
DtaRow = DtaSet.Tables("registre").NewRow
With DtaRow
.Item("ID_Membre") = IIf(Identification.Text = "", System.DBNull.Value, Identification.Text)
.Item("Nom") = IIf(TxtNom.Text = "", System.DBNull.Value, TxtNom.Text)
.Item("Prenom") = IIf(TxtPrenom.Text = "", System.DBNull.Value, TxtPrenom.Text)
.Item("Grade") = IIf(TxtGrade.Text = "", System.DBNull.Value, TxtGrade.Text)
.Item("regiment") = IIf(CBRegiment.Text = "", System.DBNull.Value, CBRegiment.Text)
.Item("entreele") = IIf(DTEntrele.Text = "", System.DBNull.Value, DTEntrele.Text)
.Item("contingent") = IIf(TxtContingent.Text = "", System.DBNull.Value, TxtContingent.Text)
.Item("sortiele") = IIf(DTSortiele.Text = "", System.DBNull.Value, DTSortiele.Text)
.Item("mail") = IIf(TxtEmail.Text = "", System.DBNull.Value, TxtEmail.Text)
.Item("profession") = IIf(TxtProfession.Text = "", System.DBNull.Value, TxtProfession.Text)
.Item("ville") = IIf(TxtVille.Text = "", System.DBNull.Value, TxtVille.Text)
.Item("codepostal") = IIf(TxtCP.Text = "", System.DBNull.Value, TxtCP.Text)
.Item("observation") = IIf(TxtObservation.Text = "", System.DBNull.Value, TxtObservation.Text)
Me.PicStudent.Image.Save(MemStream, Imaging.ImageFormat.Jpeg)
DataPic_Insert = MemStream.GetBuffer()
MemStream.Read(DataPic_Insert, 0, MemStream.Length)
.Item("photos_membre") = DataPic_Insert
End With
DtaSet.Tables("registre").Rows.Add(DtaRow)
OleDa.Update(DtaSet, "registre")
DtaSet.AcceptChanges()
With Main
.BindingContext.Item(DtaSet, "registre").Position = Main.BindingContext.Item(DtaSet, "registre").Count - 1
Call .Navigation()
End With
MsgBox("Enregistrement Avec Succés...", MsgBoxStyle.Information, "Enregistrement Reussi...")
If MsgBox("Ajouter un Nouveau Membre?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation...") = MsgBoxResult.Yes Then
Me.FormState = Form_State.Add_RecordState
Call ResetEntry()
Identification.Focus()
Exit Sub
End If
Me.Close()
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Exclamation, "Désolé, impossible de sauvegarder...")
Identification.Focus()
Identification.SelectAll()
DtaSet.RejectChanges()
End Try
Exit Sub
End If
If FormState = Form_State.Edit_RecordState Then
' If RequiredEntry() = True Then
' Return
'End If
Try
Dim MemStream As New MemoryStream
Dim DataPic_Update As Byte()
With DtaSet2
.Tables("registre").Rows(0).Item("ID_Membre") = IIf(Identification.Text = "", System.DBNull.Value, Identification.Text)
.Tables("registre").Rows(0).Item("Nom") = IIf(TxtNom.Text = "", System.DBNull.Value, TxtNom.Text)
.Tables("registre").Rows(0).Item("Prenom") = IIf(TxtPrenom.Text = "", System.DBNull.Value, TxtPrenom.Text)
.Tables("registre").Rows(0).Item("Grade") = IIf(TxtGrade.Text = "", System.DBNull.Value, TxtGrade.Text)
.Tables("registre").Rows(0).Item("regiment") = IIf(CBRegiment.Text = "", System.DBNull.Value, CBRegiment.Text)
.Tables("registre").Rows(0).Item("entreele") = IIf(DTEntrele.Text = "", System.DBNull.Value, DTEntrele.Text)
.Tables("registre").Rows(0).Item("contingent") = IIf(TxtContingent.Text = "", System.DBNull.Value, TxtContingent.Text)
.Tables("registre").Rows(0).Item("sortiele") = IIf(DTSortiele.Text = "", System.DBNull.Value, DTSortiele.Text)
.Tables("registre").Rows(0).Item("mail") = IIf(TxtEmail.Text = "", System.DBNull.Value, TxtEmail.Text)
.Tables("registre").Rows(0).Item("profession") = IIf(TxtProfession.Text = "", System.DBNull.Value, TxtProfession.Text)
.Tables("registre").Rows(0).Item("ville") = IIf(TxtVille.Text = "", System.DBNull.Value, TxtVille.Text)
.Tables("registre").Rows(0).Item("codepostal") = IIf(TxtCP.Text = "", System.DBNull.Value, TxtCP.Text)
.Tables("registre").Rows(0).Item("observation") = IIf(TxtObservation.Text = "", System.DBNull.Value, TxtObservation.Text)
Me.PicStudent.Image.Save(MemStream, Imaging.ImageFormat.Jpeg)
DataPic_Update = MemStream.GetBuffer()
MemStream.Read(DataPic_Update, 0, MemStream.Length)
.Tables("registre").Rows(0).Item("photos_membre") = DataPic_Update
End With
BindingContext(DtaSet2, "registre").EndCurrentEdit()
If DtaSet2.HasChanges() Then
OleDa.Update(DtaSet2, "registre")
DtaSet2.AcceptChanges()
End If
With Main
With .DgV
.SelectedRows(0).Cells(0).Value = Me.Identification.Text
.SelectedRows(0).Cells(1).Value = Me.TxtNom.Text
.SelectedRows(0).Cells(2).Value = Me.TxtPrenom.Text
.SelectedRows(0).Cells(3).Value = Me.TxtGrade.Text
.SelectedRows(0).Cells(4).Value = Me.CBRegiment.Text
.SelectedRows(0).Cells(5).Value = Me.TxtContingent.Text
.SelectedRows(0).Cells(6).Value = Me.DTEntrele.Text
.SelectedRows(0).Cells(7).Value = Me.DTSortiele.Text
.SelectedRows(0).Cells(8).Value = Me.TxtEmail.Text
.SelectedRows(0).Cells(9).Value = Me.TxtProfession.Text
.SelectedRows(0).Cells(10).Value = Me.TxtVille.Text
.SelectedRows(0).Cells(11).Value = Me.TxtCP.Text
.SelectedRows(0).Cells(12).Value = Me.TxtObservation.Text
End With
.PictureBox1.Image = Me.PicStudent.Image
End With
MsgBox("Mise à jours réussie...", MsgBoxStyle.Information, "Enregistrement Mis à jours...")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Désolé, impossible de mettre à jours ...")
Me.Identification.Text = Main.DgV.SelectedRows(0).Cells(0).Value
End Try
Exit Sub
End If
End Sub
Private Sub BBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBrowse.Click
Dim OpenFile As New OpenFileDialog()
Try
With OpenFile
.FileName = ""
.Title = "Photo:"
.Filter = "Image files: (*.jpg)|*.jpg|(*.jpeg)|*.jpeg|(*.png)|*.png|(*.Gif)|*.Gif|(*.bmp)|*.bmp| All Files (*.*)|*.*"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Me.PicStudent.Image = System.Drawing.Image.FromFile(.FileName)
Else
End If
End With
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
End Try
End Sub
Private Sub BStartCamera_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BStartCamera.Click
FrmCamera.ShowDialog()
End Sub
Private Sub BRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BRemove.Click
Call ImageSyntax()
End Sub
Private Sub ImageSyntax()
Me.PicStudent.Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\ImageSyntax\NoImage.JPG")
End Sub
Private Sub regimentItem()
With CBRegiment
.Items.Clear()
.Items.Add("46 éme Régiment dinfanterie")
.Items.Add("11 ème Régiment de Chasseurs")
.Items.Add("110 ème Compagnie de Genie")
.Items.Add("357 ème Hopital des Armées Louis Pasteur")
.Items.Add("501 ème EMSH Etablissement Mixte des Subsistances et Habillement")
.Items.Add("DTCB (Direction des Transports et de la Circulation")
.Items.Add("GS - Groupement de Service")
.Items.Add("DTMVF -Direction des Transports Militaires par Voie Ferrée")
.Items.Add("ESCADRON de SECURITE puis CEG - Compagnie délèves Gendarmes")
.Items.Add("QG (Quartier Général")
.Items.Add("11 ème Compagnie de Transmissions")
.Items.Add("BPM 600")
.Items.Add("BA 165")
.Items.Add("728 ème Compagnie de Transmissions")
.Items.Add("GMSH 300")
.Items.Add("Famille de militaires ayant vecu à Berlin")
End With
End Sub
Private Sub CapsLock()
Me.Identification.CharacterCasing = CharacterCasing.Upper
Me.TxtNom.CharacterCasing = CharacterCasing.Upper
Me.TxtPrenom.CharacterCasing = CharacterCasing.Upper
Me.TxtGrade.CharacterCasing = CharacterCasing.Upper
Me.TxtContingent.CharacterCasing = CharacterCasing.Upper
Me.TxtEmail.CharacterCasing = CharacterCasing.Upper
Me.TxtProfession.CharacterCasing = CharacterCasing.Upper
Me.TxtVille.CharacterCasing = CharacterCasing.Upper
Me.TxtCP.CharacterCasing = CharacterCasing.Upper
Me.TxtObservation.CharacterCasing = CharacterCasing.Upper
End Sub
Private Sub ResetEntry()
Call ImageSyntax()
Me.Identification.Text = ""
Me.TxtNom.Text = ""
Me.TxtPrenom.Text = ""
Me.TxtGrade.Text = ""
Call regimentItem()
Me.TxtContingent.Text = ""
Me.DTEntrele.ResetText()
Me.DTSortiele.ResetText()
Me.TxtEmail.Text = ""
Me.TxtProfession.Text = ""
Me.TxtVille.Text = ""
Me.TxtCP.Text = ""
Me.TxtObservation.Text = ""
End Sub
Private Sub ContextMnu()
Dim Context As New ContextMenuStrip()
Me.Identification.ContextMenuStrip = Context
Me.TxtNom.ContextMenuStrip = Context
Me.TxtPrenom.ContextMenuStrip = Context
Me.TxtGrade.ContextMenuStrip = Context
Me.TxtContingent.ContextMenuStrip = Context
Me.DTEntrele.ContextMenuStrip = Context
Me.DTSortiele.ContextMenuStrip = Context
Me.TxtEmail.ContextMenuStrip = Context
Me.TxtProfession.ContextMenuStrip = Context
Me.TxtVille.ContextMenuStrip = Context
Me.TxtCP.ContextMenuStrip = Context
Me.TxtObservation.ContextMenuStrip = Context
End Sub
Private Sub FrmEntry_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
e.SuppressKeyPress = e.Control
End Sub
Private Sub FrmEntry_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Dispose()
End Sub
Private Sub BCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BCancel.Click
Me.Close()
End Sub
Private Sub Identification_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Identification.KeyPress
Dim NotAllowedSpace As String = " "
Dim NotAllowed As String = "`~!@#$%^&*()-_=+[{[};:'\| <,>.?/"
'Allowed numbers and letters only...
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
If e.KeyChar <> ControlChars.Back Then
If NotAllowedSpace.IndexOf(e.KeyChar) = False Then
e.Handled = True
Exit Sub
End If
End If
End Sub
Private Sub TxtNom_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtNom.KeyPress
Dim NotAllowed As String = "1234567890~`@#$%^&*()_-+={[}]:;'.><?/|\"
'Allowed Letters only
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtPrenom_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPrenom.KeyPress
Dim NotAllowed As String = "1234567890~`@#$%^&*()_+={[}]:;'.><?/|\"
'Allowed Letters only
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtGrade_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtGrade.KeyPress
Dim NotAllowed As String = "~`@$%^&*+={[}]:;'><?/|\"
'Allowed letters and numbers
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtContingent_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtContingent.KeyPress
Dim NotAllowed As String = "~`@$%^&*+={[}]():;'><?|\"
'Allowed letters and numbers
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
'Private Sub TxtEmail_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtEmail.KeyPress
' Dim NotAllowed As String = "~`$%^&*+={[}]():;'><?/|\"
' 'Allowed letters and numbers
' If e.KeyChar <> ControlChars.Back = True Then
' If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
' e.Handled = True
' End If
' End If
'End Sub
Private Sub TxtEmail_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TxtEmail.Validating
Dim email As String = TxtEmail.Text
If EmailAddressCheck(email) = False Then
Dim result As DialogResult _
= MessageBox.Show("Adresse Email Invalide." & _
" Voulez Vous en entrer une nouvelle?", " Email Addresse Invalide", _
MessageBoxButtons.YesNo, MessageBoxIcon.Error)
If result = Windows.Forms.DialogResult.Yes Then
e.Cancel = True
End If
End If
End Sub
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]" & _
"*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
End Function
Private Sub TxtProfession_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtProfession.KeyPress
Dim NotAllowed As String = "~`@$%^&*_+={[}]:;'()>-<?/|\"
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtVille_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtVille.KeyPress
Dim NotAllowed As String = "~`@$%^&*+={[}]():;'><?/|\"
'Allowed letters and numbers
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtCP_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCP.KeyPress
Dim NotAllowed As String = "~`@$%^&*+={[}]():;'><?/|\"
'Allowed letters and numbers
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
Private Sub TxtObservation_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtObservation.KeyPress
Dim NotAllowed As String = "~`@$%^&*+={[}]():;'><?/|\"
'Allowed(letters And numbers)
If e.KeyChar <> ControlChars.Back = True Then
If NotAllowed.IndexOf(e.KeyChar) = -1 = False Then
e.Handled = True
End If
End If
End Sub
End Class |
Partager