/// <summary> /// Creer l'animal passé en params /// Et le retourne avec son GUID /// </summary> /// <param name="animal"></param> public static BO.Animaux Create(BO.Animaux animal) { try { BO.Clients cli = DAL.Clients.Get(animal.CodeClient); SqlConnection cnx = DAL.SqlConnexion.OpenConnexion(); Guid temp = cnx.ExecuteScalar <Guid>("EXEC ajout_animal @nomclient, @prenomclient, @nomani, @sexe, @couleur, @espece, @race, @archive", new { nomclient = cli.NomClient, prenomclient = cli.PrenomClient, nomani = animal.NomAnimal, sexe = animal.Sexe, couleur = animal.Couleur, espece = animal.Espece, race = animal.Race, archive = false }); animal.CodeAnimal = temp; SqlConnexion.CloseConnexion(cnx); return(animal); } catch (Exception e) { throw e; } }
/// <summary> /// Construction d'un dossier médical avec un animal en param /// Déactive la recherche et la navigation /// </summary> /// <param name="animal"></param> public SubFormDossierMedical(BO.Animaux animal) { InitializeComponent(); currentAnimal = animal; GenerateMedicalFolder(); SetStatutNavigation(false); this.textBoxSearch.Enabled = false; this.comboBoxSearchType.Enabled = false; I18N(); }
/// <summary> /// Archive l'animal séléctionner /// </summary> /// <param name="animal"></param> /// <returns></returns> public static bool Archive(BO.Animaux animal) { try { SqlConnection cnx = DAL.SqlConnexion.OpenConnexion(); var query = @"UPDATE Animaux SET Archive=1 WHERE CodeAnimal = @codeAnimal"; int rowNb = cnx.Execute(query, new { codeAnimal = animal.CodeAnimal }); SqlConnexion.CloseConnexion(cnx); return(rowNb > 0); } catch (Exception e) { throw e; } }
/// <summary> /// Charge l'animal a l'index spécifié /// </summary> private void LoadAnimal() { // La liste est vide if (index == -1) { this.richTextBoxAnimal.Rtf = SubFormDossierMedical.defaultRtfText; this.richTextBoxAnimal.Enabled = false; } // La liste n'est pas vide else if (index < animauxList.Count) { currentAnimal = animauxList[index]; GenerateMedicalFolder(); this.Text = String.Format(GUI.Lang.SUBFORM_DOSSIER_MEDICAL_TITLE, currentAnimal.NomAnimal); } }
/// <summary> /// Retourne l'animal dont on a passer le guid en param /// </summary> /// <param name="item"></param> /// <returns></returns> private static BO.Animaux Get(Guid item) { try { SqlConnection cnx = DAL.SqlConnexion.OpenConnexion(); String query = @"SELECT * FROM Animaux WHERE CodeAnimal=@code;"; BO.Animaux results = cnx.Query <BO.Animaux>(query, new { code = item }).Single <BO.Animaux>(); SqlConnexion.CloseConnexion(cnx); return(results); } catch (Exception e) { throw e; } }
/// <summary> /// Met a jour l'animal passé en params /// </summary> /// <param name="animal"></param> public static bool Update(BO.Animaux animal) { try { SqlConnection cnx = DAL.SqlConnexion.OpenConnexion(); var query = @"UPDATE Animaux SET NomAnimal = @nomAnimal, Sexe = @sexe, Couleur = @couleur, Race = @race, Espece = @espece, CodeClient = @codeClient, Tatouage = @tatouage, Antecedents = @antecedents, Archive = @archive WHERE CodeAnimal = @codeAnimal"; int rowNb = cnx.Execute(query, new { codeAnimal = animal.CodeAnimal, codeClient = animal.CodeClient, nomAnimal = animal.NomAnimal, sexe = animal.Sexe, couleur = animal.Couleur, espece = animal.Espece, race = animal.Race, tatouage = animal.Tatouage, antecedents = animal.Antecedents, archive = false }); SqlConnexion.CloseConnexion(cnx); return(rowNb > 0); } catch (Exception e) { throw e; } }