Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: recording problem Pin
Luc Pattyn17-Mar-20 12:08
sitebuilderLuc Pattyn17-Mar-20 12:08 
GeneralRe: recording problem Pin
ago248617-Mar-20 22:04
ago248617-Mar-20 22:04 
GeneralRe: recording problem Pin
Luc Pattyn17-Mar-20 22:18
sitebuilderLuc Pattyn17-Mar-20 22:18 
GeneralRe: recording problem Pin
ago248617-Mar-20 23:20
ago248617-Mar-20 23:20 
AnswerRe: problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql Pin
Richard Deeming16-Mar-20 9:28
mveRichard Deeming16-Mar-20 9:28 
Generalproblem registering in the access database Pin
ago248617-Mar-20 0:58
ago248617-Mar-20 0:58 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:01
mveRichard Deeming17-Mar-20 1:01 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:08
ago248617-Mar-20 1:08 
ok thank you sir. But there is not much detail except that when I submit the button to add I receive the message microsoft jet engine.


private void BtnAjouter_Click(object sender, EventArgs e)
       {
           int total;
           decimal total_achat;
           //si les champs sont vides
           if (TxtDesignation.Text == "" || TxtPrixUnitaire.Text == "" || TxtQteCmd.Text == "" || TxtQteStock.Text == "" || TxtRefProduit.Text == "")
           {
               MessageBox.Show("Rassurez vous que tous les champs ont bien été rempli.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else
           {
               //Vérifier si la valeur saisie est numeric
               if (Int32.TryParse(TxtQteCmd.Text, out int value) && TxtRefProduit.Text != "")
               {
                   //Vérifier si la commande est inferieur ou egale au stock
                   int a = 0;
                   int b = 0;
                   int c;

                   //Convertire les textBox en int
                   int.TryParse(TxtQteCmd.Text.Trim(), out a);
                   int.TryParse(TxtQteStock.Text.Trim(), out b);
                   int.TryParse(TxtPrixUnitaire.Text.Trim(), out c);

                   if (a <= b)
                   {
                       total = a * c;
                       total_achat = 0;

                       try
                       {
                           //setConnection();
                          // sql_con.Open();
                          // using (sql_cmd = sql_con.CreateCommand())
                           {
                              string txtQuery = "INSERT INTO Detail_temp (ref_det, qute_det, Designation, Prix_unitaire_HT, Prix_total_HT) VALUES (@ref_det,@qute_det,@Designation,@Prix_unitaire_HT,@Prix_total_HT)";
                              sql_cmd.Parameters.AddWithValue("@ref_det", TxtRefProduit.Text);
                              sql_cmd.Parameters.AddWithValue("@qute_det", TxtQteCmd.Text);
                              sql_cmd.Parameters.AddWithValue("@Designation", TxtDesignation.Text);
                              sql_cmd.Parameters.AddWithValue("@Prix_unitaire_HT", TxtPrixUnitaire.Text);
                              sql_cmd.Parameters.AddWithValue("@Prix_total_HT", total);
                              sql_cmd = new OleDbCommand(txtQuery, sql_con);
                              sql_cmd.ExecuteNonQuery();
                               //ExecuteQuery(txtQuery);
                           }
                       }
                       catch(OleDbException ex)
                       {
                           MessageBox.Show(ex.Source);
                       }

                       //Création de la requête sql pour inserer des valeurs dans DB
                      //string txtQuery = "INSERT INTO Detail_temp (ref_det, qute_det, Designation, Prix_unitaire_HT, Prix_total_HT) VALUES ('"+ TxtRefProduit.Text+ "', '" + TxtQteCmd.Text + "', '" + TxtDesignation.Text + "', '" + TxtPrixUnitaire.Text + "', '" + total + "')";

                      //ExecuteQuery(txtQuery);

                       try
                       {

                           LoadDB();

                           //ADDITIONNER UNE COLONNE DU DATAGRIDVIEW
                           for (int i = 0; i < dataGridView1.Rows.Count; i++) //Car tu fais une infériorité stricte
                           {
                               total_achat += Convert.ToDecimal(dataGridView1.Rows[i].Cells[4].Value);

                           }
                           TxtTotalCmd.Text = total_achat.ToString();//convertir total_achat en string^pour pouvoir l'afficher dans le textbox
                           TxtDesignation.Text = "";
                           TxtQteCmd.Text = "";
                           TxtPrixUnitaire.Text = "";
                           TxtRefProduit.Text = "";
                           TxtQteCmd.Text = "";
                           //SupDetail_Temp();

                       }

                       catch (OleDbException ex)
                       {
                           MessageBox.Show(ex.Source);
                           sql_con.Close();
                       }
                       finally
                       {
                           sql_con.Close();
                       }

                   }
                   else
                   {
                       MessageBox.Show("Veuillez verifier le stock du produit!!!");
                   }
               }

           }

       }

GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:10
mveRichard Deeming17-Mar-20 1:10 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:17
ago248617-Mar-20 1:17 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 1:35
mveRichard Deeming17-Mar-20 1:35 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 2:00
ago248617-Mar-20 2:00 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:18
ago248617-Mar-20 1:18 
GeneralRe: problem registering in the access database Pin
Richard Deeming17-Mar-20 2:57
mveRichard Deeming17-Mar-20 2:57 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 3:14
ago248617-Mar-20 3:14 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 1:10
ago248617-Mar-20 1:10 
GeneralRe: problem registering in the access database Pin
Richard MacCutchan17-Mar-20 2:18
mveRichard MacCutchan17-Mar-20 2:18 
GeneralRe: problem registering in the access database Pin
ago248617-Mar-20 2:26
ago248617-Mar-20 2:26 
GeneralRe: problem registering in the access database Pin
Richard MacCutchan17-Mar-20 2:36
mveRichard MacCutchan17-Mar-20 2:36 
QuestionJava Api Callbacks crashes on dotnet framework version 4.5 and above Pin
isaketranjan16-Mar-20 0:06
isaketranjan16-Mar-20 0:06 
AnswerRe: Java Api Callbacks crashes on dotnet framework version 4.5 and above Pin
Gerry Schmitz16-Mar-20 5:05
mveGerry Schmitz16-Mar-20 5:05 
QuestionC# and ODATA CRUD communication with D365BC web service Pin
clemenslinders12-Mar-20 0:13
clemenslinders12-Mar-20 0:13 
SuggestionRe: C# and ODATA CRUD communication with D365BC web service Pin
Richard Deeming12-Mar-20 1:12
mveRichard Deeming12-Mar-20 1:12 
GeneralRe: C# and ODATA CRUD communication with D365BC web service Pin
clemenslinders12-Mar-20 3:48
clemenslinders12-Mar-20 3:48 
GeneralRe: C# and ODATA CRUD communication with D365BC web service Pin
Richard Deeming12-Mar-20 4:29
mveRichard Deeming12-Mar-20 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.