示例#1
0
        //Methode pour get tous les factures suivants le client

        public List <FactureModel> GetListeFacture(string codeClient)
        {
            using (SqlConnection Conn = new SqlConnection(ClassVariableGlobal.SetConnexion()))

                try
                {
                    Conn.Open();
                    List <FactureModel> _listeFacture = new List <FactureModel>();

                    if (Conn.State != System.Data.ConnectionState.Open)
                    {
                        Conn.Open();
                    }

                    string s = "SELECT  * FROM tFacturation where CodeClient=@codeClient";

                    //SELECT * FROM tClasse
                    SqlCommand objCommand = new SqlCommand(s, Conn);

                    objCommand.Parameters.AddWithValue("@codeClient", codeClient);

                    SqlDataReader _Reader = objCommand.ExecuteReader();

                    while (_Reader.Read())
                    {
                        FactureModel objCust = new FactureModel();

                        objCust.IdFacture         = Convert.ToInt32(_Reader["IdFacture"]);
                        objCust.RefFacture        = _Reader["RefFacture"].ToString();
                        objCust.MontantFacture    = Convert.ToDouble(_Reader["Quantite"]);
                        objCust.QuantiteFacture   = Convert.ToDouble(_Reader["Montant"]);
                        objCust.CodeClientFacture = _Reader["CodeClient"].ToString();
                        objCust.DateFacture       = Convert.ToDateTime(_Reader["DateFacture"]);
                        objCust.MontantRistourne  = Convert.ToDouble(_Reader["MontantRistourne"]);


                        _listeFacture.Add(objCust);
                    }

                    return(_listeFacture);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    if (Conn != null)
                    {
                        if (Conn.State == ConnectionState.Open)
                        {
                            Conn.Close();
                            Conn.Dispose();
                        }
                    }
                }
        }
示例#2
0
        // Methode pour enregistrer une facture

        public int InsertFacture(FactureModel facture)
        {
            using (SqlConnection connection = new SqlConnection(ClassVariableGlobal.SetConnexion()))
            {
                connection.Open();

                string query = "INSERT INTO tFacturation" +
                               "(RefFacture, Quantite, Montant, CodeClient," +
                               "DateFacture, MontantRistourne)VALUES(@RefFacture, @Quantite, @Montant, " +
                               " @CodeClient, @DateFacture, @MontantRistourne)";

                SqlCommand commande = new SqlCommand(query, connection);

                commande.Parameters.AddWithValue("@RefFacture", facture.RefFacture);
                commande.Parameters.AddWithValue("@Quantite", facture.QuantiteFacture);
                commande.Parameters.AddWithValue("@Montant", facture.MontantFacture);
                commande.Parameters.AddWithValue("@CodeClient", facture.CodeClientFacture);
                commande.Parameters.AddWithValue("@DateFacture", facture.DateFacture);
                commande.Parameters.AddWithValue("@MontantRistourne", facture.MontantRistourne);

                return(commande.ExecuteNonQuery());
            }
        }
示例#3
0
        // Somme des points facture par periode par client

        public List <FactureModel> GetSommePointsFactureTouParperiode(string codeClient, DateTime date1, DateTime date2)
        {
            using (SqlConnection Conn = new SqlConnection(ClassVariableGlobal.SetConnexion()))

                try
                {
                    Conn.Open();
                    List <FactureModel> _listeFacture = new List <FactureModel>();

                    if (Conn.State != System.Data.ConnectionState.Open)
                    {
                        Conn.Open();
                    }

                    string s = "SommeDePointFacturePourUnePeriode";

                    //SELECT * FROM tClasse
                    SqlCommand objCommand = new SqlCommand(s, Conn);
                    objCommand.CommandType = CommandType.StoredProcedure;
                    objCommand.Parameters.AddWithValue("@CodeClient", codeClient);
                    objCommand.Parameters.AddWithValue("@Date1", date1);
                    objCommand.Parameters.AddWithValue("@Date2", date2);
                    SqlDataReader _Reader = objCommand.ExecuteReader();

                    while (_Reader.Read())
                    {
                        FactureModel objCust = new FactureModel();

                        // objCust.IdFacture = Convert.ToInt32(_Reader["IdFacture"]);
                        objCust.RefFacture = _Reader["RefFacture"].ToString();
                        try { objCust.MontantFacture = Convert.ToDouble(_Reader["Quantite"]); } catch { objCust.MontantFacture = 0; }


                        objCust.QuantiteFacture   = Convert.ToDouble(_Reader["Montant"]);
                        objCust.CodeClientFacture = _Reader["CodeClient"].ToString();
                        try { objCust.DateFacture = Convert.ToDateTime(_Reader["DateFacture"]); } catch { objCust.DateFacture = DateTime.Now; }

                        objCust.MontantRistourne = Convert.ToDouble(_Reader["MontantRistourne"]);


                        _listeFacture.Add(objCust);
                    }

                    return(_listeFacture);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    if (Conn != null)
                    {
                        if (Conn.State == ConnectionState.Open)
                        {
                            Conn.Close();
                            Conn.Dispose();
                        }
                    }
                }
        }