コード例 #1
0
        //
        // Fonction de création d'un client
        //
        public bool createClient(ClientEntity client)
        {
            using (var context = new MADERA_V1Entities())
            {
                MDR_Clients addCLient = new MDR_Clients();

                addCLient.Cli_Actif   = 1;
                addCLient.Cli_Adresse = client.Cli_Adresse;
                addCLient.Cli_Age     = client.Cli_Age;
                addCLient.Cli_CP      = client.Cli_CP;
                addCLient.Cli_Email   = client.Cli_Email;
                addCLient.Cli_Nom     = client.Cli_Nom;
                addCLient.Cli_Phone   = client.Cli_Phone;
                addCLient.Cli_Prenom  = client.Cli_Prenom;
                addCLient.Cli_Ville   = client.Cli_Ville;



                try
                {
                    context.MDR_Clients.Add(addCLient);
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
コード例 #2
0
        //
        // Fonction d'update d'un client
        //
        public bool updateClient(ClientEntity client)
        {
            using (var context = new MADERA_V1Entities())
            {
                MDR_Clients updatingClient = (from c in context.MDR_Clients
                                              where c.Cli_Index == client.Cli_Index
                                              select c).SingleOrDefault();

                updatingClient.Cli_Actif   = client.Cli_Actif;
                updatingClient.Cli_Adresse = client.Cli_Adresse;
                updatingClient.Cli_Age     = client.Cli_Age;
                updatingClient.Cli_CP      = client.Cli_CP;
                updatingClient.Cli_Email   = client.Cli_Email;
                updatingClient.Cli_Nom     = client.Cli_Nom;
                updatingClient.Cli_Phone   = client.Cli_Phone;
                updatingClient.Cli_Prenom  = client.Cli_Prenom;
                updatingClient.Cli_Ville   = client.Cli_Ville;

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
コード例 #3
0
        //
        // Fonction de suppression d'un client
        //
        public bool disabledClientById(int IdClient)
        {
            using (var context = new MADERA_V1Entities())
            {
                MDR_Clients updatingClient = (from c in context.MDR_Clients
                                              where c.Cli_Index == IdClient
                                              select c).SingleOrDefault();

                updatingClient.Cli_Actif = 0;

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }