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
| [ Private Sub CmdEnregistrer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdEnregistrer.Click
'si un champ n'est pas rempli fin de procédure
If Me.TxtNomCotisation.Text = "" Then
MessageBox.Show("Veuillez Confirmer ou Choisir" & ControlChars.NewLine & _
"le Nom de la Cotisation dans la Liste déroulante!!!", _
"Attention...", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.CboNomCotisation.Focus()
Exit Sub
End If
If Me.MTxtDateCotisation.Text = "" Then
MessageBox.Show("La Date de Cotisation est Obligatoire!!!", _
"Attention...", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.MTxtDateCotisation.Focus()
Exit Sub
End If
If Me.TxtTauxCotisation.Text = "" Then
MessageBox.Show("Le Taux de la Cotisation est Obligatoire!!!", _
"Attention...", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.TxtTauxCotisation.Focus()
Exit Sub
End If
If Me.TxtMtCotiser.Text = "" Then
MessageBox.Show("Entrez le Montant de la Cotisation de l'Adhérent!!!", _
"Attention...", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.TxtMtCotiser.Focus()
Exit Sub
End If
If Me.TxtMecano.Text = "" Then
MessageBox.Show("Le Mecano est Obligatoire!!!", _
"Attention...", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.TxtMecano.Focus()
Exit Sub
End If
'*****************************************************
REQ = "Select COTISER.* From COTISER Where Mecano='" & TxtMecano.Text & """ Where Annee='" & TxtAnnee.Text & " "
If TxtMecano.Text = DtTC.Rows(RowNb).Item("Mecano") And TxtAnnee.Text = DtTC.Rows(RowNb).Item("Annee") Then
MessageBox.Show("Une partie ou toute la Cotisation " & ControlChars.NewLine & "du " & TxtGrade.Text & " " & TxtNom.Text & " " & TxtPrenoms.Text & ControlChars.NewLine & "Mecano : " _
& TxtMecano.Text & ControlChars.NewLine & _
"est déjà Enregistrée dans" & ControlChars.NewLine & "la Base de Données !!!" & ControlChars.NewLine & "Veuillez procèder à une Mise à jour", _
"Doublon...", MessageBoxButtons.OK, MessageBoxIcon.Error)
'vider les textbox
Me.TxtGrade.Text = ""
Me.TxtNom.Text = ""
Me.TxtPrenoms.Text = ""
Me.TxtMatricule.Text = ""
Me.TxtMecano.Text = ""
Me.TxtCotisation.Text = ""
Me.TxtDroitAdhe.Text = ""
TxtGrade.Visible = False
TxtNom.Visible = False
TxtPrenoms.Visible = False
TxtMatricule.Visible = False
TxtMecano.Visible = False
TxtDroitAdhe.Visible = False
TxtCotisation.Visible = False
LblTlCotisation.Visible = False
EffacerGbCotisation()
TxtGrade1.Visible = True
TxtNom1.Visible = True
TxtPrenom1.Visible = True
TxtMatricule1.Visible = True
TxtMecano1.Visible = True
TxtDroitAdh1.Visible = True
DtSC.Clear()
DtAC.Fill(DtSC, "COTISER")
DtTC = DtSC.Tables("COTISER")
'***********************************************
DtS.Clear()
DtA.Fill(DtS, "ADHERENTS INNER JOIN COTISER")
DtT = DtS.Tables("ADHERENTS INNER JOIN COTISER")
'***********************************************
'mise à jour de la datagrid
DataGrid1.SetDataBinding(DtS, "ADHERENTS INNER JOIN COTISER")
Affichage()
CmdAjouter.Text = "Ajouter"
Exit Sub
Else
'***************************************************
Cotisation = CType(TxtCotisation.Text, Single)
Cotiser = CType(TxtMtCotiser.Text, Single)
Taux = CType(TxtTauxCotisation.Text, Single)
TxtTCotisation.Text = (Cotisation + Cotiser).ToString
TxtRestePayer.Text = (Taux - Cotiser).ToString
'crátion d'une nouvelle ligne avec les données des textbox
DtRC = DtSC.Tables("COTISER").NewRow
DtRC("Mecano") = Me.TxtMecano.Text
DtRC("DateCotisation") = Me.MTxtDateCotisation.Text
DtRC("NomCotisation") = Me.TxtNomCotisation.Text
DtRC("MontantCotisation") = Me.TxtTauxCotisation.Text
DtRC("MontantCotiser") = Me.TxtMtCotiser.Text
DtRC("RestePayer") = Me.TxtRestePayer.Text
DtRC("Annee") = Me.TxtAnnee.Text
'ajout de la ligne dans le DataSet
DtSC.Tables("COTISER").Rows.Add(DtRC)
'création et exécution du commandbuilder
'pour mettre à jour le DataAdapter
CmdBC = New OleDbCommandBuilder(DtAC)
'mise à jour des données du DataAdapter
'à partir du commandbuilder
DtAC.Update(DtSC, "COTISER")
MiseAJour()
MessageBox.Show("L'Enregistrement de la Cotisation du " & ControlChars.NewLine & _
TxtGrade.Text & " " & TxtNom.Text & " " & TxtPrenoms.Text & ControlChars.NewLine & _
"A été Effectué avec succès !", "Enregistrement...", MessageBoxButtons.OK, MessageBoxIcon.Information)
'vider les textbox
Me.TxtGrade.Text = ""
Me.TxtNom.Text = ""
Me.TxtPrenoms.Text = ""
Me.TxtMatricule.Text = ""
Me.TxtMecano.Text = ""
Me.TxtCotisation.Text = ""
Me.TxtDroitAdhe.Text = ""
TxtGrade.Visible = False
TxtNom.Visible = False
TxtPrenoms.Visible = False
TxtMatricule.Visible = False
TxtMecano.Visible = False
TxtDroitAdhe.Visible = False
TxtCotisation.Visible = False
LblTlCotisation.Visible = False
TxtGrade1.Visible = True
TxtNom1.Visible = True
TxtPrenom1.Visible = True
TxtMatricule1.Visible = True
TxtMecano1.Visible = True
TxtDroitAdh1.Visible = True
DtTA.Reset()
'on vide le dataset pour le recréer avec
'les nouvelles données
DtSC.Clear()
DtAC.Fill(DtSC, "COTISER")
DtTC = DtSC.Tables("COTISER")
'***********************************************
DtS.Clear()
DtA.Fill(DtS, "ADHERENTS INNER JOIN COTISER")
DtT = DtS.Tables("ADHERENTS INNER JOIN COTISER")
'***********************************************
'mise à jour de la datagrid
DataGrid1.SetDataBinding(DtS, "ADHERENTS INNER JOIN COTISER")
'aller au début du fichier
RowNum = 0
'affichage des données dans les texbox
Affichage()
'activation des boutons
CmdPremier.Enabled = True 'premier
CmdPrecedent.Enabled = True 'précédent
CmdSuivant.Enabled = True 'suivant
CmdDernier.Enabled = True 'dernier
CmdModifier.Enabled = True
CmdSupprimer.Enabled = True
'CmdFrmSituations.Visible = False
'CmdFrmUnites.Visible = False
'CmdSearch.Visible = True
'CmdSearch.Enabled = True
CmdAjouter.Enabled = True
CmdEnregistrer.Enabled = False 'valider
CmdAjouter.Text = "Ajouter"
'*************************************************************
End If
End Sub] |
Partager