Example #1
0
        public int add(Facture f)
        {
            int res = 0;

            try
            {
                SqlConnection cnx    = Connexion.GetConnection();
                CommandeDAO   cmddao = new CommandeDAO();

                SqlCommand sqlCmd = new SqlCommand("insert into Facture ( totalTTC,totalHT,totalTVA) values (@ttc,@ht,@tva)", cnx);

                sqlCmd.Parameters.AddWithValue("ttc", f.totalTTC);
                sqlCmd.Parameters.AddWithValue("ht", f.totalHT);
                sqlCmd.Parameters.AddWithValue("tva", f.totalTVA);

                res = sqlCmd.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Connexion.closeConnection();
            }
            return(res);
        }
Example #2
0
        public int add(Crediteur c)
        {
            int     res = 0;
            decimal sum;

            try
            {
                SqlConnection cnx    = Connexion.GetConnection();
                CommandeDAO   cmddao = new CommandeDAO();
                Commande      cmd    = cmddao.getById(c.Idcmd);
                sum = cmd.prixtotal;
                SqlCommand sqlCmd = new SqlCommand("insert into Client_Crediteurs ( nomprenom, cin,totalCmdTTC , tel,idCommande) values (@nomprenom,@cin,@prix,@tel,@idcmd)", cnx);
                //  sqlCmd.Parameters.AddWithValue("idc", c.IdCrediteur);
                sqlCmd.Parameters.AddWithValue("nomprenom", c.nomprenom);
                sqlCmd.Parameters.AddWithValue("cin", c.cin);
                sqlCmd.Parameters.AddWithValue("prix", c.MontantCredit);
                sqlCmd.Parameters.AddWithValue("tel", c.tel);
                sqlCmd.Parameters.AddWithValue("idcmd", c.Idcmd);
                res = sqlCmd.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Connexion.closeConnection();
            }
            return(res);
        }