Esempio n. 1
0
        private void SavePari(Res response, int id, StructPari value)
        {
            SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;");

            Models.PariDAO       padao  = new Models.PariDAO(connection);
            Models.PariDetailDAO paddao = new Models.PariDetailDAO(connection);
            Models.ClientDAO     cldao  = new Models.ClientDAO(connection);

            Models.Pari       pari   = new Models.Pari(value.pari); pari.Id = padao.NextId();
            Models.PariDetail detail = new Models.PariDetail(value.detail); detail.Id = paddao.NextId(); detail.Pari = pari;
            Models.Client     client = cldao.SelectOne("WHERE id='" + pari.Client + "'");
            client.Solde -= detail.Montant;

            if (client != null && padao.Insert(pari.ToInsert()) > 0)
            {
                paddao.Insert(detail.ToInsert());
                cldao.Update(client);
                value.pari.id   = pari.Id;
                value.detail.id = detail.Id;
                response.data   = value;
                response.error  = false;
            }
            else
            {
                throw new Exception("Enregistrement du pari impossible !");
            }
        }
Esempio n. 2
0
        private void CheckLogin(Res response, Client model)
        {
            SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;");

            Models.ClientDAO cldao  = new Models.ClientDAO(connection);
            Models.Client    client = cldao.SelectOne("WHERE pseudo='" + model.pseudo + "' AND password='******'");
            if (client != null)
            {
                response.data  = client.Id;
                response.error = false;
            }
        }
Esempio n. 3
0
        private void Crediter(Res response, Client value)
        {
            SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;");

            Models.ClientDAO cldao  = new Models.ClientDAO(connection);
            Models.Client    client = cldao.SelectOne("WHERE id='" + value.id + "' AND password='******'");
            if (client != null)
            {
                client.Solde += value.solde;
                cldao.Update(client);
                response.error = false;
            }
            else
            {
                throw new Exception("Votre pseudo ou mots de passe est errone !");
            }
        }
Esempio n. 4
0
        private void DefinitivePlan(Plan value, SqlConnection connection)
        {
            this.VerifierPlan(value); value.AddInteret(connection);
            Models.PretDAO          prdao = new Models.PretDAO(connection);
            Models.ClientDAO        cldao = new Models.ClientDAO(connection);
            Models.RemboursementDAO rbdao = new Models.RemboursementDAO(connection);

            Models.Pret   pret   = new Models.Pret(value.pret);
            Models.Client client = cldao.SelectOne("WHERE id='" + value.pret.client.id + "'");
            client.Solde += pret.Montant;
            pret.Id       = prdao.NextId();
            pret.Client   = client;
            prdao.Insert(pret);
            cldao.Update(client);
            foreach (Remboursement r in value.remboursements)
            {
                Models.Remboursement rb = new Models.Remboursement(r); rb.Id = rbdao.NextId(); rb.Pret = pret;
                rbdao.Insert(rb);
            }
        }