Click here to Skip to main content
15,884,537 members
Home / Discussions / C#
   

C#

 
GeneralRe: Abuse Standard File Property/Attribute Pin
Kevin Marois22-Mar-20 13:04
professionalKevin Marois22-Mar-20 13:04 
Questionupdate problem Pin
ago248619-Mar-20 23:31
ago248619-Mar-20 23:31 
AnswerRe: update problem Pin
OriginalGriff20-Mar-20 0:03
mveOriginalGriff20-Mar-20 0:03 
GeneralRe: update problem Pin
ago248620-Mar-20 0:08
ago248620-Mar-20 0:08 
GeneralRe: update problem Pin
ago248620-Mar-20 2:52
ago248620-Mar-20 2:52 
GeneralRe: update problem Pin
OriginalGriff20-Mar-20 3:00
mveOriginalGriff20-Mar-20 3:00 
GeneralRe: update problem Pin
ago248620-Mar-20 3:10
ago248620-Mar-20 3:10 
Questionproblem to make a second recording Pin
ago248618-Mar-20 23:58
ago248618-Mar-20 23:58 
the goal is to add and save later I can do it once when I want to do it for a second time I have an error: unable to find table 0, I must close the form and open it again so that I can do another one ... how to solve this problem without closing my form before?


  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 (OleDbCommand cmd = sql_con.CreateCommand())
                            {
                                cmd.CommandText = "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)";
                                cmd.Parameters.AddWithValue("@ref_det", TxtRefProduit.Text);
                                cmd.Parameters.AddWithValue("@qute_det", TxtQteCmd.Text);
                                cmd.Parameters.AddWithValue("@Designation", TxtDesignation.Text);
                                cmd.Parameters.AddWithValue("@Prix_unitaire_HT", TxtPrixUnitaire.Text);
                                cmd.Parameters.AddWithValue("@Prix_total_HT", total);

                                cmd.ExecuteNonQuery();
                                DS.Reset();
                                DB.Fill(DS);
                                DT = DS.Tables[0]; (Problem is here):confused::confused:
                                dataGridView1.DataSource = DT;
                                cmd.Dispose();
                                sql_con.Close();
                             
                            }
                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        
Designation, Prix_unitaire_HT, Prix_total_HT) VALUES (@ref_det, @qute_det, @Designation, @Prix_unitaire_HT, @Prix_total_HT)";
                       
                

                        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
                            vider();
                            
                          
                            
                        }
                       
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            sql_con.Close();
                        }
                        finally
                        {
                            sql_con.Close();
                        }

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

            }

        }

AnswerRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 0:06
mveOriginalGriff19-Mar-20 0:06 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 0:29
ago248619-Mar-20 0:29 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 0:35
mveOriginalGriff19-Mar-20 0:35 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 0:48
ago248619-Mar-20 0:48 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 0:52
mveOriginalGriff19-Mar-20 0:52 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 0:59
ago248619-Mar-20 0:59 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 2:06
ago248619-Mar-20 2:06 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 2:26
mveOriginalGriff19-Mar-20 2:26 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:04
ago248619-Mar-20 3:04 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 3:22
mveOriginalGriff19-Mar-20 3:22 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:27
ago248619-Mar-20 3:27 
QuestionRe: problem to make a second recording Pin
ZurdoDev19-Mar-20 3:51
professionalZurdoDev19-Mar-20 3:51 
QuestionHow to solve 100 Doors Kata using TDD in C# Pin
User-862169518-Mar-20 5:30
User-862169518-Mar-20 5:30 
AnswerRe: How to solve 100 Doors Kata using TDD in C# Pin
Bohdan Stupak19-Mar-20 5:12
professionalBohdan Stupak19-Mar-20 5:12 
Questionproblem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 3:13
ago248618-Mar-20 3:13 
AnswerRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 3:50
mveOriginalGriff18-Mar-20 3:50 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 4:11
ago248618-Mar-20 4:11 

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.