Click here to Skip to main content
15,885,164 members
Home / Discussions / C#
   

C#

 
GeneralRe: Add a listview cell Pin
ago248627-Jul-20 2:31
ago248627-Jul-20 2:31 
GeneralRe: Add a listview cell Pin
OriginalGriff27-Jul-20 2:59
mveOriginalGriff27-Jul-20 2:59 
GeneralRe: Add a listview cell Pin
ago248627-Jul-20 3:18
ago248627-Jul-20 3:18 
GeneralRe: Add a listview cell Pin
OriginalGriff27-Jul-20 3:37
mveOriginalGriff27-Jul-20 3:37 
GeneralRe: Add a listview cell Pin
ago248627-Jul-20 4:08
ago248627-Jul-20 4:08 
GeneralRe: Add a listview cell Pin
OriginalGriff27-Jul-20 4:38
mveOriginalGriff27-Jul-20 4:38 
GeneralRe: Add a listview cell Pin
ago248627-Jul-20 4:45
ago248627-Jul-20 4:45 
GeneralRe: Add a listview cell Pin
ago248627-Jul-20 4:53
ago248627-Jul-20 4:53 
C#
private void Ajouter (String refProd, String quantite, String design, String prixU, String prixTtc)
       {

           String[] row = { refProd, quantite, design, prixU, prixTtc };
           ListViewItem item = new ListViewItem(row);

           listView1.Items.Add(item);
       }


C#
private void BtnAjouter_Click(object sender, EventArgs e)
        {
            double total;
            decimal total_achat;
           
         
            if (Lbl_Affich_Designation.Text == "" || Lbl_Affich_PrixUnitaire.Text == "" || TxtQteCmd.Text == "" || Lbl_affich_TxtQteStock.Text == "" || CmbRef_Produit.Text == "")
            {
                MessageBox.Show("Rassurez vous que tous les champs ont bien été rempli.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
               
                if (CmbRef_Produit.Text != "")
                {
                   
                    double a = 0;
                    double b = 0;
                    double c;
                    int nbprod;
             
                    double.TryParse(TxtQteCmd.Text.Trim(), out a);
                    double.TryParse(Lbl_affich_TxtQteStock.Text.Trim(), out b);
                    double.TryParse(Lbl_Affich_PrixUnitaire.Text.Trim(), out c);

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

                        try
                        {
            
                            

                            using (OleDbCommand cmd = d.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", CmbRef_Produit.Text);
                                cmd.Parameters.AddWithValue("@qute_det", TxtQteCmd.Text);
                                cmd.Parameters.AddWithValue("@Designation", Lbl_Affich_Designation.Text);
                                cmd.Parameters.AddWithValue("@Prix_unitaire_HT", Lbl_Affich_PrixUnitaire.Text);
                                cmd.Parameters.AddWithValue("@Prix_total_HT", total);
                              
                                d.sql_con.Open();

                                cmd.ExecuteNonQuery();
            
                                dataGridView1.DataSource = d.DT;
                                Ajouter(CmbRef_Produit.Text, TxtQteCmd.Text, Lbl_Affich_Designation.Text, Lbl_Affich_PrixUnitaire.Text, total.ToString()); //I had to put the display of my listview here and not after the for loop
                                cmd.Dispose();
                                d.sql_con.Close();
                            }

                            
                           
                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                       
                        try
                        {

                           LoadDB();

                        
                            for (int i = 0; i < listView1.Items.Count; i++) 
                            {
                                total_achat += Convert.ToDecimal(listView1.Items[i].SubItems[4].Text);
                                nbprod++;
                                LblNbProd.Text = nbprod.ToString();

                            }



                            Lbl_Affich_TotalCmd.Text = total_achat.ToString();
                            //Ajouter(CmbRef_Produit.Text, TxtQteCmd.Text, Lbl_Affich_Designation.Text, Lbl_Affich_PrixUnitaire.Text, total.ToString());
                            Vider();
                            TxtQteCmd.Text = "1";
                         
                           
                            
                        }
                       
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            d.sql_con.Close();
                        }

                    }
                    else
                    {
                        MessageBox.Show("Veuillez verifier le stock du produit!!!", "Problème avec le stock", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Caractères non autorisés", "Problème de saisie", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

        }

Questionsaving a Word Doc from address bar in .net/C# Pin
Pita3225-Jul-20 5:50
Pita3225-Jul-20 5:50 
AnswerRe: saving a Word Doc from address bar in .net/C# Pin
Gerry Schmitz25-Jul-20 7:19
mveGerry Schmitz25-Jul-20 7:19 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
DerekT-P25-Jul-20 9:22
professionalDerekT-P25-Jul-20 9:22 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
Gerry Schmitz25-Jul-20 9:58
mveGerry Schmitz25-Jul-20 9:58 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
DerekT-P25-Jul-20 11:38
professionalDerekT-P25-Jul-20 11:38 
AnswerRe: saving a Word Doc from address bar in .net/C# Pin
Richard MacCutchan25-Jul-20 21:59
mveRichard MacCutchan25-Jul-20 21:59 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
Pita3226-Jul-20 6:37
Pita3226-Jul-20 6:37 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
Richard MacCutchan26-Jul-20 6:46
mveRichard MacCutchan26-Jul-20 6:46 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
Richard Deeming26-Jul-20 23:50
mveRichard Deeming26-Jul-20 23:50 
GeneralRe: saving a Word Doc from address bar in .net/C# Pin
Richard MacCutchan27-Jul-20 0:03
mveRichard MacCutchan27-Jul-20 0:03 
AnswerRe: saving a Word Doc from address bar in .net/C# Pin
Richard Deeming26-Jul-20 23:51
mveRichard Deeming26-Jul-20 23:51 
QuestionGet List Of SQL Foreign Keys Using C# Pin
Kevin Marois24-Jul-20 6:46
professionalKevin Marois24-Jul-20 6:46 
AnswerRe: Get List Of SQL Foreign Keys Using C# Pin
Richard Deeming24-Jul-20 7:29
mveRichard Deeming24-Jul-20 7:29 
GeneralRe: Get List Of SQL Foreign Keys Using C# Pin
Kevin Marois24-Jul-20 7:42
professionalKevin Marois24-Jul-20 7:42 
GeneralRe: Get List Of SQL Foreign Keys Using C# Pin
Dave Kreskowiak24-Jul-20 7:49
mveDave Kreskowiak24-Jul-20 7:49 
GeneralRe: Get List Of SQL Foreign Keys Using C# Pin
Kevin Marois24-Jul-20 7:53
professionalKevin Marois24-Jul-20 7:53 
GeneralRe: Get List Of SQL Foreign Keys Using C# Pin
Kevin Marois24-Jul-20 7:53
professionalKevin Marois24-Jul-20 7:53 

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.