Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

ago2486

@ago2486
About
Posts
89
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • compulsorily pass through the login.html
    A ago2486

    hello friends I am developing a web application to connect to a mariaDb database. I have 04 tables (table 1, table 2, table 3, table 4)
    to have access to the first table I made a coinnection form but my problem is that if a person knows the link of table 2 he can display it. I want to force everyone to connect before having access to my web application... is this method possible?

    Web Development html database mysql help question

  • Add a listview cell
    A ago2486

    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);
        }
    

    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);
    
    C# question

  • Add a listview cell
    A ago2486

    sir sorry and thank you for seeing my error after a review of my code.
    I don't know how to explain it to you but I will illustrate it as a comment in my code.

    C# question

  • Add a listview cell
    A ago2486

    when I put the breakpoint on total buy + = Convert.ToDecimal (dataGridView1.Rows [i] .Cells [4] .Value); total_achat displays 0.

    C# question

  • Add a listview cell
    A ago2486

    thank you sir I followed your advice and I saw that the problem came from the fact that at the first addition my variables total_achat and i always remain 0. Frankly I do not know why?.

    private void BtnAjouter_Click(object sender, EventArgs e)
    {
    double total;
    decimal total_achat;

            //si les champs sont vides
            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
            {
                //Vérifier si la valeur saisie est numeric
                if (CmbRef\_Produit.Text != "")
                {
                    //Vérifier si la commande est inferieur ou egale au stock
                    double a = 0;
                    double b = 0;
                    double c;
                    int nbprod;
                    //Convertire les textBox en int
                    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;
                        //ADDITIONNER UNE COLONNE DU DATAGRIDVIEW
                       
    
                        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);
    
    C# question

  • Add a listview cell
    A ago2486

    ok thank you i'm getting started

    C# question

  • Add a listview cell
    A ago2486

    I want to add after adding, I had used the datagriedview which works well but for other reasons of redu I decided to use a listview but with this code it adds me that after the second addition, it is to say when I make a first addition, my textbox which receives the sum remains 0 and at the second addition it takes the value of the first and at the third it adds the first and the second, it does not add all the additions, and I do not that's not why. I need an explanation to review what is wrong in the code

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

                            }
    

    Lbl_Affich_TotalCmd.Text = total_achat.ToString();

    C# question

  • class to open its database
    A ago2486

    public class ConnectionDB
    {

        // Declaration des objets sql
        public OleDbConnection sql\_con;
        public OleDbCommand sql\_cmd;
        public OleDbDataAdapter DB;
        public DataSet DS = new DataSet();
        public DataTable DT = new DataTable();
        public OleDbDataReader DR;
        public string connetionString = null;
    
        // declaration de la methode connecter
        public void CONNECTER()
        {                           
                //connection à la base de donnée avec mot de passe
                connetionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Application.StartupPath + @"\\DB\_CaisseEnregistreuse.mdb;Persist Security Info=True;Jet OLEDB:Database Password=B@sta08091987";
                sql\_con = new OleDbConnection(connetionString);
        }
    
        // declaration de la methode deconnecter
        public void DECONNECTER()
        {
            
    
                if (sql\_con.State == ConnectionState.Open)
                {
    
                    sql\_con.Close();
                }
            
           
        }
    

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
    
    
    
        }
        ConnectionDB d = new ConnectionDB();
    

    private void LoadDB()
    {
    using (OleDbConnection sql_con = new OleDbConnection(d.connetionString))
    {
    sql_con.Open();
    using (OleDbCommand sql_cmd = d.sql_con.CreateCommand())
    {
    string CommandText = "SELECT * FROM Detail_temp";
    d.DB = new OleDbDataAdapter(CommandText, d.sql_con);
    d.DS.Reset();
    d.DB.Fill(d.DS);
    d.DT = d.DS.Tables[0];
    dataGridView1.DataSource = d.DT;
    d.DECONNECTER();
    }
    }
    }

    private void Form1_Load(object sender, EventArgs e)
    {

            try
            {
                
                LoadDB();
                d.sql\_con.Open();
                TxtQteCmd.Text = "1";
                Lbl\_Affich\_TotalCmd.Text = "0";
                LblAfficDate.Text = DateTime.Now.ToString(); 
    
                using (OleDbCommand cmbox = d.sql\_con.CreateCommand())
                {
                    cmbox.CommandText = "SELECT Code\_article FROM Catalogue";
    
    C# database security

  • class to open its database
    A ago2486

    thank you sir message well received. I haven't tried the configuration file side for the connection to the database yet, but I will study it and see if I can manage it.

    C# database security

  • class to open its database
    A ago2486

    I try and the error comes from me thank you very much mmister it works.

    C# database security

  • class to open its database
    A ago2486

    Thanks i will try it and you will get back

    C# database security

  • class to open its database
    A ago2486

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
    
        }
    

    ConnectionDB d = new ConnectionDB();

    using (OleDbCommand cmbox = d.sql\_con.CreateCommand())
                {
                    cmbox.CommandText = "SELECT Code\_article FROM Catalogue";
                    d.CONNECTER();// i have an error here
                    d.DR = cmbox.ExecuteReader();
    
                    try
                    {
                        while (d.DR.Read())
                        {
                            CmbRef\_Produit.Items.Add(d.DR\["Code\_article"\]).ToString();
                        }
    
                        //si le textbox est vide
                        if (string.IsNullOrWhiteSpace(CmbRef\_Produit.Text ))
                        {
                            // Message box
    
                            Lbl\_affich\_TxtQteStock.Text = "";
                            Lbl\_Affich\_Designation.Text = "";
                            Lbl\_Affich\_PrixUnitaire.Text = "";
                        }
    
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
    
                        d.DECONNECTER();
    
                    }
                }
    
            }
    

    }

    C# database security

  • class to open its database
    A ago2486

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
    
        }
    

    ConnectionDB d = new ConnectionDB();

    using (OleDbCommand cmbox = d.sql\_con.CreateCommand())
                {
                    cmbox.CommandText = "SELECT Code\_article FROM Catalogue";
                    d.CONNECTER.Open(); //\*\*\*\*i have an error here\*\*\*\*
                    d.DR = cmbox.ExecuteReader();
    
                    try
                    {
                        while (d.DR.Read())
                        {
                            CmbRef\_Produit.Items.Add(d.DR\["Code\_article"\]).ToString();
                        }
    
                        //si le textbox est vide
                        if (string.IsNullOrWhiteSpace(CmbRef\_Produit.Text ))
                        {
                            // Message box
    
                            Lbl\_affich\_TxtQteStock.Text = "";
                            Lbl\_Affich\_Designation.Text = "";
                            Lbl\_Affich\_PrixUnitaire.Text = "";
                        }
    
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
    
                        d.DECONNECTER.Close();
    
                    }
                }
    
            }
    

    }

    C# database security

  • class to open its database
    A ago2486

    public class ConnectionDB
    {

        // Declaration des objets sql
        public OleDbConnection sql\_con;
     
        // declaration de la methode connecter
        public void CONNECTER()
        {
            try
            {
                string connetionString = null;
                //connection à la base de donnée avec mot de passe
                connetionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Application.StartupPath + @"\\DB\_CaisseEnregistreuse.mdb;Persist Security Info=True;Jet OLEDB:Database Password=B@sta08091987";
                sql\_con = new OleDbConnection(connetionString);
                sql\_con.Open();
                
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur de connexion à la base donnée" + ex.ToString());
            }
    
            
        }
    
        // declaration de la methode deconnecter
        public void DECONNECTER()
        {
            try
            {
    
                if (sql\_con.State == ConnectionState.Open)
                {
    
                    sql\_con.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur de deconnexion à la base donnée" + ex.ToString());
            }
        }
    

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
    
        }
    

    ConnectionDB d = new ConnectionDB();

    using (OleDbCommand cmbox = d.sql\_con.CreateCommand())
                {
                    cmbox.CommandText = "SELECT Code\_article FROM Catalogue";
                    d.sql\_con.Open();
                    d.DR = cmbox.ExecuteReader();
    
                    try
                    {
                        while (d.DR.Read())
                        {
                            CmbRef\_Produit.Items.Add(d.DR\["Code\_article"\]).ToString();
                        }
    
                        //si le textbox est vide
                        if (string.IsNullOrWhiteSpace(CmbRef\_Produit.Text ))
                        {
                            // Message box
    
                            Lbl\_affich\_TxtQteStock.Text = "";
                            Lbl\_Affich\_Designation.Text = "";
                            Lbl\_Affich\_PrixUnitaire.Text = "";
                        }
    
                    }
                    catch (Exception ex)
    
    C# database security

  • update problem
    A ago2486

    Understood sir and thank you for your frankness. I will continue following your advice

    C# help database com announcement

  • update problem
    A ago2486

    Sir I am happy because I was able to find a solution, its not easy because I really did not know how to go about it to see what is wrong. but I was able to post my request in a texbox to see what was wrong. I do not know my code is clean but the update is done.
    How to find the code?

    using (OleDbCommand cmd4 = sql_con.CreateCommand())
    {

                                        //setConnection();
                                        OleDbCommand QteStock = sql\_con.CreateCommand();
                                        QteStock.CommandText = "SELECT Quantite FROM Catalogue";
                                        sql\_con.Open();
                                        int LastQteStock = Convert.ToInt32(QteStock.ExecuteScalar());
                                        sql\_con.Close();
                                        string query = "UPDATE Catalogue SET Quantite = (@quantite - @QteStc) WHERE Code\_article = (@code\_article)";
                                        cmd4.CommandText = query;
                                        MessageBox.Show(query);
                                        cmd4.Parameters.AddWithValue("@quantite", LastQteStock);
                                        cmd4.Parameters.AddWithValue("@QteStc", Qte\_prod);
                                        cmd4.Parameters.AddWithValue("@code\_article", ref\_prod);
                                        sql\_con.Open();
                                        cmd4.ExecuteNonQuery();
                                        sql\_con.Close();
    
                                    }
    
    C# help database com announcement

  • update problem
    A ago2486

    Understood sir and thank you for your promptness. i will keep looking

    C# help database com announcement

  • update problem
    A ago2486

    Quote:

    hello gentlemen and thank you to you who bring me your help. I am almost at the end of my program and I have an update problem. I don't see any change in my stock. I have no error when I validate but the quantity does not change in the access database

    for (int i = 0; i < dataGridView1.Rows.Count; i++) //Car tu fais une infériorité stricte
    {
    ref_prod = Convert.ToString(dataGridView1.Rows[i].Cells[0].Value);
    Qte_prod = Convert.ToInt64(dataGridView1.Rows[i].Cells[1].Value);

                                    using (OleDbCommand cmd3 = sql\_con.CreateCommand())
                                    {
                                        
                                        cmd3.CommandText = "INSERT INTO Detail\_commandes (com\_det, ref\_det, qute\_det) VALUES (@com\_det,@ref\_det,@qute\_det)";
                                        cmd3.Parameters.AddWithValue("@com\_det", TxtNunCmd.Text);
                                        cmd3.Parameters.AddWithValue("@ref\_det", ref\_prod);
                                        cmd3.Parameters.AddWithValue("@qute\_det", Qte\_prod);
                                        sql\_con.Open();
                                        cmd3.ExecuteNonQuery();
                                        sql\_con.Close();
    
                                    }
    
                                    using (OleDbCommand cmd4 = sql\_con.CreateCommand())
                                    {
                                        //setConnection();
                                        OleDbCommand QteStock = sql\_con.CreateCommand();
                                        QteStock.CommandText = "SELECT Quantite FROM Catalogue";
                                        sql\_con.Open();
                                        int LastQteStock = Convert.ToInt32(QteStock.ExecuteScalar());
                                        sql\_con.Close();
                                        cmd4.CommandText = "UPDATE Catalogue SET Quantite = @Quantite - @QteStc WHERE code\_article = (@code\_article)";
                                        cmd4.Parameters.AddWithValue("@Quantite", LastQteStock);
                                        cmd4.Parameters.AddWithValue("@QteStc", Qte\_prod);
                                        cmd4.Parameters.AddWithValue("@code\_article", TxtRefProduit.Text);
    
    C# help database com announcement

  • problem to make a second recording
    A ago2486

    yes sir and again thank you for your advice

    C# help database tutorial question

  • problem to make a second recording
    A ago2486

    yes sir i already did to change the datagridview

    private void LoadDB()
    {
    setConnection();
    sql_con.Open();
    sql_cmd = sql_con.CreateCommand();
    string CommandText = "SELECT * FROM Detail_temp";
    DB = new OleDbDataAdapter(CommandText, sql_con);
    DS.Reset();
    DB.Fill(DS);
    DT = DS.Tables[0];
    dataGridView1.DataSource = DT;
    sql_con.Close();
    }

    maybe I'm wrong? but I did it to see my recordings in the datagridview

    C# help database tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups