diff --git a/MauiAppStock/Data/Database.cs b/MauiAppStock/Data/Database.cs index 844953c..4985fb6 100644 --- a/MauiAppStock/Data/Database.cs +++ b/MauiAppStock/Data/Database.cs @@ -20,6 +20,7 @@ namespace MauiAppStock.Data await db.CreateTableAsync(); await db.CreateTableAsync(); await db.CreateTableAsync(); // Table de liaison + await db.CreateTableAsync(); // Table des mouvements de stock } } @@ -139,5 +140,34 @@ namespace MauiAppStock.Data .Where(ap => ap.AppareilId == appareilId && ap.PieceId == pieceId) .FirstOrDefaultAsync(); } + + // CRUD pour MouvementStock + public static Task AddMouvementStockAsync(MouvementStock mouvement) + { + return db.InsertAsync(mouvement); + } + + public static Task> GetMouvementsStockAsync() + { + return db.Table().OrderByDescending(m => m.DateMouvement).ToListAsync(); + } + + public static async Task> GetMouvementsStockForPieceAsync(int pieceId) + { + return await db.Table() + .Where(m => m.PieceId == pieceId) + .OrderByDescending(m => m.DateMouvement) + .ToListAsync(); + } + + public static Task UpdateMouvementStockAsync(MouvementStock mouvement) + { + return db.UpdateAsync(mouvement); + } + + public static Task DeleteMouvementStockAsync(MouvementStock mouvement) + { + return db.DeleteAsync(mouvement); + } } } diff --git a/MauiAppStock/Models/Appareil.cs b/MauiAppStock/Models/Appareil.cs index e1bca2e..01e244e 100644 --- a/MauiAppStock/Models/Appareil.cs +++ b/MauiAppStock/Models/Appareil.cs @@ -9,5 +9,12 @@ namespace MauiAppStock.Models public string Nom { get; set; } public string Description { get; set; } // Vous pouvez ajouter d'autres propriétés (stock, historique, etc.) + + public override string ToString() + { + return $"{Nom}"; + } } + + } \ No newline at end of file diff --git a/MauiAppStock/Models/MouvementStock.cs b/MauiAppStock/Models/MouvementStock.cs new file mode 100644 index 0000000..86baf17 --- /dev/null +++ b/MauiAppStock/Models/MouvementStock.cs @@ -0,0 +1,32 @@ +using SQLite; + +namespace MauiAppStock.Models +{ + public class MouvementStock + { + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + + public int PieceId { get; set; } + + public DateTime DateMouvement { get; set; } + + public TypeMouvement Type { get; set; } + + public int Quantite { get; set; } // Number of parts moved + + public string? Commentaire { get; set; } + + [Ignore] + public string NomPiece { get; set; } + + [Ignore] + public bool HasComment => !string.IsNullOrWhiteSpace(Commentaire); + } + + public enum TypeMouvement + { + EntreeStock, // Parts entering stock (purchase) + SortieReparation // Parts used for repair + } +} \ No newline at end of file diff --git a/MauiAppStock/Models/Piece.cs b/MauiAppStock/Models/Piece.cs index 3de67ac..81cdee9 100644 --- a/MauiAppStock/Models/Piece.cs +++ b/MauiAppStock/Models/Piece.cs @@ -6,13 +6,17 @@ namespace MauiAppStock.Models { [PrimaryKey, AutoIncrement] public int Id { get; set; } - public string Nom { get; set; } - public string Description { get; set; } + public string? Nom { get; set; } + public string? Description { get; set; } public double Prix { get; set; } public int Stock { get; set; } - public string Fournisseur { get; set; } + public string? Fournisseur { get; set; } + + // public int Appareil { get; set; } [Ignore] public bool EstRecommandee { get; set; } + + public string DetailView { get { return " ID : " + Id + @" - " + Description; } } } } \ No newline at end of file diff --git a/MauiAppStock/Views/AddPiecePage.xaml b/MauiAppStock/Views/AddPiecePage.xaml index 56f0f12..014b745 100644 --- a/MauiAppStock/Views/AddPiecePage.xaml +++ b/MauiAppStock/Views/AddPiecePage.xaml @@ -8,6 +8,9 @@ +