Exemplo n.º 1
0
 /// <summary>
 /// Mode ajout de la fenètre
 /// </summary>
 public DialogAnimal(BO.Clients client = null)
 {
     InitializeComponent();
     UpdateContent();
     CreateMode(client);
     I18N(); ///!\ DOIT TOUJOURS ETRE APPELER EN DERNIER /!\
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creation d'un client
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static BO.Clients Create(BO.Clients client)
        {
            try
            {
                SqlConnection cnx  = DAL.SqlConnexion.OpenConnexion();
                Guid          temp = cnx.ExecuteScalar <Guid>("EXEC ajout_client @nom, @prenom, @add, @add2, @cp, @ville, @tel, @ass, @mail, @arch",
                                                              new
                {
                    nom    = client.NomClient,
                    prenom = client.PrenomClient,
                    add    = client.Adresse1,
                    add2   = client.Adresse2,
                    cp     = client.CodePostal,
                    ville  = client.Ville,
                    tel    = client.NumTel,
                    ass    = client.Assurance,
                    mail   = client.Email,
                    arch   = 0
                });
                client.CodeClient = temp;
                SqlConnexion.CloseConnexion(cnx);

                return(client);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retourne tout les animaux par client, archivé ou non
        /// </summary>
        /// <param name="client"></param>
        /// <param name="archived"></param>
        /// <returns></returns>
        public static List <BO.Animaux> GetAllByClient(BO.Clients client, bool archived)
        {
            if (client.CodeClient == null)
            {
                throw new Exception(Lang.ANIMAUX_CANT_GET_BY_CLIENT_WITHOUT_GUID);
            }

            return(DAL.Animaux.GetAllByClient(client, archived));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Déactive/Active un client
 /// </summary>
 /// <param name="client"></param>
 /// <returns></returns>
 public static bool Archive(BO.Clients client, bool archived)
 {
     try
     {
         SqlConnection cnx   = DAL.SqlConnexion.OpenConnexion();
         var           query = @"UPDATE Clients SET Archive=@archive WHERE CodeClient = @codeClient";
         int           rowNb = cnx.Execute(query, new { codeClient = client.CodeClient, archive = (archived) ? 1 : 0 });
         SqlConnexion.CloseConnexion(cnx);
         return(rowNb > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 5
0
        private void buttonAddAnimal_Click(object sender, EventArgs e)
        {
            BO.Clients client = (BO.Clients) this.comboBoxClient.SelectedItem;

            if (client != null)
            {
                GUI.Dialog.DialogAnimal dialog = new DialogAnimal(client);
                dialog.ShowDialog();
                dialog.Disposed += UpdateContentEvent;
            }
            else
            {
                MessageBox.Show(GUI.Lang.SUBFORM_PRENDRERDV_ERROR_NOCLIENT,
                                GUI.Lang.FORM_DEFAULT_ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Archive tout les animaux du clients passé en params
        /// </summary>
        /// <param name="client"></param>
        public static void DeleteAllByClient(BO.Clients client)
        {
            if (client.CodeClient == null)
            {
                throw new Exception(Lang.ANIMAUX_CANT_DELETE_ANI_CUST_WITHOUT_GUID);
            }

            List <BO.Animaux> animaux = DAL.Animaux.GetAllByClient(client);

            foreach (BO.Animaux animal in animaux)
            {
                if (DAL.Consultations.GetNonPayed(animal) > 0)
                {
                    throw new Exception(String.Format(Lang.ANIMAUX_CANT_ARCHIVE_CONSULT_NOT_PAID, client.getFullName()));
                }
            }
            DAL.Animaux.ArchiveAllByClient(client);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Archive le client passé en paramètre
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static void Delete(BO.Clients client)
        {
            //Vérification du guid
            if (client.CodeClient == null)
            {
                throw new Exception(Lang.CLIENTS_CANT_DELETE_WITHOUT_GUID);
            }

            //Vérification client
            //Toutes les factures doivent être payé pour archiver le client
            Int32 factureImpayee = BLL.FacturesMgr.Impayees(client);

            if (factureImpayee > 0)
            {
                throw new Exception(String.Format(Lang.CLIENTS_CANT_DELETE_HAVE_NOT_PAID_FACTURE, factureImpayee));
            }

            BLL.AnimauxMgr.DeleteAllByClient(client);
            DAL.Clients.Archive(client, true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Retourne le client liée au Guid
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BO.Clients Get(Guid?id)
        {
            if (id == null)
            {
                return(null);
            }

            try
            {
                var           query   = @"SELECT * FROM  Clients c WHERE CodeClient = @code";
                SqlConnection cnx     = DAL.SqlConnexion.OpenConnexion();
                BO.Clients    results = cnx.Query <BO.Clients>(query, new { code = id }).ToList <BO.Clients>().First();
                SqlConnexion.CloseConnexion(cnx);

                return(results);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Permet de passer en mode création
        /// </summary>
        private void CreateMode(BO.Clients client = null)
        {
            animalEdited = null;

            if (client != null)
            {
                clientEdited = clientsList.Find(x => x.CodeClient == client.CodeClient);

                if (clientEdited == null)
                {
                    this.Close();
                    MessageBox.Show(GUI.Lang.DIALOG_ANIMAL_CLIENT_ERROR,
                                    GUI.Lang.FORM_DEFAULT_ERROR_TITLE,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                this.comboBoxCustomer.SelectedItem = clientEdited;
                mode = DialogAnimalMode.CLIENT;
                this.comboBoxCustomer.Enabled = false;
            }

            this.buttonMedicalFolder.Enabled = false; //Mode création pas de bouton de liaison
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creer le client passé en paramètre
 /// </summary>
 /// <param name="client"></param>
 /// <returns></returns>
 public static BO.Clients Create(BO.Clients client)
 {
     return(DAL.Clients.Create(client));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Retourne le nombre de facture non payée du client
 /// </summary>
 /// <param name="client"></param>
 /// <returns></returns>
 public static Int32 Impayees(BO.Clients client)
 {
     return(DAL.Factures.CountFactureByClient(client) - DAL.Factures.CountFactureEtatByClient(client, (short)BLL.FacturesEtat.PAYEE));
 }
Exemplo n.º 12
0
 private void comboBoxClient_SelectedIndexChanged(object sender, EventArgs e)
 {
     BO.Clients client = (BO.Clients) this.comboBoxClient.SelectedItem;
     this.comboBoxAnimal.DataSource = BLL.AnimauxMgr.GetAllByClient(client, false);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Retourne l'ensemble des factures d'un client
 /// </summary>
 /// <param name="client"></param>
 /// <returns></returns>
 public static List <BO.Factures> GetFactureByClient(BO.Clients client)
 {
     return(new List <BO.Factures>());
 }
Exemplo n.º 14
0
 /// <summary>
 /// Retourne le nombre de facture d'un client avec cet état
 /// </summary>
 /// <param name="client"></param>
 /// <param name="etat"></param>
 /// <returns></returns>
 public static Int32 CountFactureEtatByClient(BO.Clients client, int etat)
 {
     return(0);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Retourne le nombre de facture d'un client
 /// </summary>
 /// <param name="client"></param>
 /// <returns></returns>
 public static Int32 CountFactureByClient(BO.Clients client)
 {
     return(0);
 }