コード例 #1
0
        public Boolean InsertMvt(clsmvt mvt)
        {
            try
            {
                InitializeConnection();
                string q = "insert into mouvement(ref_art,libeleMvt,typeMvt,nbrpieces,prix_gros,prix_u,totalpaie,typepaie,ref_client,ref_agent,voirBoss) values(@ref_art,@libeleMvt,@typeMvt,@nbrpieces,@prix_gros,@prix_u,@totalpaie,@typepaie,@ref_client,@ref_agent,@voirBoss)";
                cmd = new MySqlCommand(q, con);
                cmd.Parameters.Add(new MySqlParameter("@ref_art", mvt.Ref_art));
                cmd.Parameters.Add(new MySqlParameter("@libeleMvt", mvt.Lblmvt));
                cmd.Parameters.Add(new MySqlParameter("@typeMvt", mvt.Typemvt));
                cmd.Parameters.Add(new MySqlParameter("@nbrpieces", mvt.Nbpieces));
                cmd.Parameters.Add(new MySqlParameter("@prix_gros", mvt.Prix_gro));
                cmd.Parameters.Add(new MySqlParameter("@prix_u", mvt.Prix_U));
                cmd.Parameters.Add(new MySqlParameter("@totalpaie", mvt.Totalpaie));
                cmd.Parameters.Add(new MySqlParameter("@typepaie", mvt.Typepaie));
                cmd.Parameters.Add(new MySqlParameter("@ref_client", mvt.Ref_cl));
                cmd.Parameters.Add(new MySqlParameter("@ref_agent", mvt.Ref_agent));
                cmd.Parameters.Add(new MySqlParameter("@voirBoss", mvt.VoirBoss));

                DialogResult result = MessageBox.Show("Voulez-vous vraiment passer cette vente ?", "VENTE", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    if (cmd.ExecuteNonQuery() == 1)
                    {
                        clsArticle ar = new clsArticle();
                        ar.CodeArt = mvt.Ref_art;
                        //MessageBox.Show("" + ar.CodeArt);
                        updateStock(ar, mvt.Nbpieces);

                        if (mvt.Typepaie == "Credit")
                        {
                            clsCredit cr = new clsCredit();
                            cr.Ref_cl  = mvt.Ref_cl;
                            cr.Ref_Art = mvt.Ref_art;
                            cr.Qte     = mvt.Nbpieces;
                            cr.Montant = mvt.Totalpaie;

                            insertCredit(cr);
                        }

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }

            return(false);
        }
コード例 #2
0
        public void insertCredit(clsCredit cre)
        {
            try
            {
                InitializeConnection();
                string q = "insert into credit(ref_client,ref_art,qte,montant) values(@ref_client,@ref_art,@qte,@montant)";
                cmd = new MySqlCommand(q, con);
                cmd.Parameters.Add(new MySqlParameter("@ref_client", cre.Ref_cl));
                cmd.Parameters.Add(new MySqlParameter("@ref_art", cre.Ref_Art));
                cmd.Parameters.Add(new MySqlParameter("@qte", cre.Qte));
                cmd.Parameters.Add(new MySqlParameter("@montant", cre.Montant));

                if (cmd.ExecuteNonQuery() == 1)
                {
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }