예제 #1
0
        // METHODS :

        private int ExecuteUpdate(SqlCommand cmd, PariDetail model)
        {
            cmd.CommandText = "UPDATE PariDetail SET montant=@val1 WHERE id=@val2";
            cmd.Parameters.AddWithValue("@val1", model.Montant);
            cmd.Parameters.AddWithValue("@val2", model.Id);

            return(cmd.ExecuteNonQuery());
        }
예제 #2
0
파일: Jonction.cs 프로젝트: GimmyR/footage
 public Jonction(String id, PariDetail pari, PariDetail contrePari, float montant, int regle)
 {
     this.Id         = id;
     this.Pari       = pari;
     this.ContrePari = contrePari;
     this.Montant    = montant;
     this.Regle      = regle;
 }
예제 #3
0
        public int Update(PariDetail model)
        {
            int result = -1;

            connexion.Open(); using (SqlCommand cmd = connexion.CreateCommand()) {
                result = this.ExecuteUpdate(cmd, model);
            } connexion.Close();

            return(result);
        }
예제 #4
0
 private void ReglerQte(Jonction jonct, Pari pari, Json.Stat stat, PariDetail pd1, PariDetail pd2)
 {
     if (stat.equipe1 > (stat.equipe2 + pd1.Compensation))
     {
         int ecart = stat.equipe1 - (stat.equipe2 + pd1.Compensation);
         if (ecart > pd1.Ecart)
         {
             int   ecart2  = ecart / (int)pd1.Ecart;
             float montant = ecart2 * pd1.MontantEcart;
             if (montant > jonct.Montant)
             {
                 montant = jonct.Montant;
             }
             Client cl1 = pd1.Pari.Client, cl2 = pd2.Pari.Client;
             cl1.Solde += (jonct.Montant + montant);
             cl2.Solde += (jonct.Montant - montant);
             new ClientDAO(connection).Update(cl1);
             new ClientDAO(connection).Update(cl2);
         }
         else
         {
             Client client = pd1.Pari.Client;
             client.Solde += jonct.Montant;
             new ClientDAO(connection).Update(client);
         }
     }
     else if (stat.equipe1 < (stat.equipe2 + pd1.Compensation))
     {
         int ecart = (stat.equipe2 + pd1.Compensation) - stat.equipe1;
         if (ecart > pd2.Ecart)
         {
             int   ecart2  = ecart / (int)pd2.Ecart;
             float montant = ecart2 * pd2.MontantEcart;
             if (montant > jonct.Montant)
             {
                 montant = jonct.Montant;
             }
             Client cl1 = pd1.Pari.Client, cl2 = pd2.Pari.Client;
             cl1.Solde += (jonct.Montant - montant);
             cl2.Solde += (jonct.Montant + montant);
             new ClientDAO(connection).Update(cl1);
             new ClientDAO(connection).Update(cl2);
         }
         else
         {
             Client client = pd2.Pari.Client;
             client.Solde += jonct.Montant;
             new ClientDAO(connection).Update(client);
         }
     }
     else
     {
         this.Egalite(jonct, pari, pd1, pd2);
     }
 }
예제 #5
0
        public PariDetail SelectOne(String condition)
        {
            PariDetail result = null;

            if (connexion.State == ConnectionState.Open)
            {
                connexion = new SqlConnection(connexion.ConnectionString + "Password=itu");
            }
            connexion.Open();
            using (SqlCommand cmd = connexion.CreateCommand()) {
                result = this.ExecuteSelectOne(cmd, condition);
            } connexion.Close();

            return(result);
        }
예제 #6
0
        private void Regler(Jonction jonction)
        {
            PariDetail pd1 = jonction.Pari, pd2 = jonction.ContrePari;
            Pari       pari   = pd1.Pari;
            Partie     partie = pari.Partie.Partie;
            Action     action = pari.Action;

            Json.Stat stat = new OtherDAO(connection).SelectOneStat(partie.Id, action.Id, pd1.Equipe.Id, pd2.Equipe.Id);
            if (pari.TypePari == 0)
            {
                this.ReglerTotal(jonction, pari, stat, pd1, pd2);
            }
            else
            {
                this.ReglerQte(jonction, pari, stat, pd1, pd2);
            }
        }
예제 #7
0
        private PariDetail ExecuteSelectOne(SqlCommand cmd, String condition)
        {
            PariDetail result = null;

            string cond = "";

            if (condition != null)
            {
                cond = " " + condition;
            }
            cmd.CommandText = "SELECT * FROM PariDetail" + cond;
            using (SqlDataReader reader = cmd.ExecuteReader()) {
                if (reader.Read())
                {
                    result = this.Map(reader);
                }
            } return(result);
        }
예제 #8
0
 private void ReglerTotal(Jonction jonct, Pari pari, Json.Stat stat, PariDetail pd1, PariDetail pd2)
 {
     if (stat.equipe1 > (stat.equipe2 + pd1.Compensation))
     {
         Client client = pd1.Pari.Client;
         client.Solde += (jonct.Montant * 2);
         new ClientDAO(connection).Update(client);
     }
     else if (stat.equipe1 < (stat.equipe2 + pd1.Compensation))
     {
         Client client = pd2.Pari.Client;
         client.Solde += (jonct.Montant * 2);
         new ClientDAO(connection).Update(client);
     }
     else
     {
         this.Egalite(jonct, pari, pd1, pd2);
     }
 }
예제 #9
0
        private void Egalite(Jonction jonct, Pari pari, PariDetail pd1, PariDetail pd2)
        {
            Client    cl1 = pd1.Pari.Client, cl2 = pd2.Pari.Client;
            ClientDAO cldao = new ClientDAO(connection);

            if (pari.RegleEgalite == 0)
            {
                cl1.Solde += jonct.Montant; cl2.Solde += jonct.Montant;
                cldao.Update(cl1); cldao.Update(cl2);
            }
            else if (pari.RegleEgalite == 1)
            {
                cl1.Solde += (jonct.Montant * 2);
                cldao.Update(cl1);
            }
            else
            {
                cl2.Solde += (jonct.Montant * 2);
                cldao.Update(cl2);
            }
        }
예제 #10
0
        // METHODS :

        public bool Equals(PariDetail detail)
        {
            return(this.id == detail.Id);
        }