Bonjour, j'ai deux tables : tables homologation(numHomologation(FK), ...), TypeHomologuer(#codeMarque, type, #numHomologation) (codeMarque+type FK

dans une fenetre d'ajout d'un nouveau type homologué, je dois enregister l'homlogation puis apres le type mais si l'homologation ne passe pas le type aussi ne dois pas passer, c'est normal parce que numHomologation existe dans la deuxieme table, mais j'ai obtenu les resultat souhaité, veuillez m'aider !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
string typeHomologue = typeHomo.isTypeHomologuation(txtNvType.Text, m);
 
            if (typeHomologue == "OK")
                lblResult.Visible = true;
            else
            {
 
 
                try { 
                        int r = Homologues.AddBObjectAndBDataHomologation(Convert.ToString(txtHomologation.Text), DateTime.Now.Date,
                    Convert.ToInt32(txtPTC.Text), Convert.ToInt32(txtPAV.Text), Convert.ToInt32(txtCylindree.Text), 
                    Convert.ToInt32(txtNbrCylindre.Text), Convert.ToInt32(txtPF.Text)); 
                    if (r == 1)
                        {
                            int r2 = typeHomo.AddBObjectAndBDataTypeHomologue(txtNvType.Text, m, txtHomologation.Text);
 
                            if (r2 != 1)
                                Homologues.DeleteBObjectAndBDataHomologation(txtHomologation.Text);
                        }
                        else
                        {
                            lblResult.Visible = true;
 
                        }
                }
                catch (Exception ex) {
                    MessageBox.Show("Redondance ! "+ex.Message + txtNvType, "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
 
            }
Merci