Bonjour,
je suis entrain de m'entrainer au développement avec ASP .NET MVC avec le développement d'une application qui permet d'enregistrer les commandes fournisseurs seulement.
Pour ce faire, j'ai créer 3 tables: Fournisseur, Produit, Commande, Ligne_Commande et voici le schéma de ces tables:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 CREATE TABLE [dbo].[Fournisseur]( [Fournisseur_id] [int] IDENTITY(1,1) NOT NULL, [Fournisseur_ref] [nvarchar](20) NOT NULL, [Fournisseur_raison] [nvarchar](50) NULL, [Fournisseur_adresse] [nvarchar](50) NULL, CONSTRAINT [PK_Fournisseur] PRIMARY KEY CLUSTERED ( [Fournisseur_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [Fournisseur_reference] UNIQUE NONCLUSTERED ( [Fournisseur_ref] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 CREATE TABLE [dbo].[Produit]( [Produit_id] [bigint] IDENTITY(1,1) NOT NULL, [Produit_ref] [nvarchar](20) NOT NULL, [Produit_LIbelle] [nvarchar](max) NOT NULL, [Produit_description] [ntext] NOT NULL, [Produit_codeBare] [nvarchar](10) NULL, [Produit_photo] [image] NULL, [Produit_stockMini] [int] NULL, CONSTRAINT [PK_Produit] PRIMARY KEY CLUSTERED ( [Produit_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 CREATE TABLE [dbo].[COMMANDE]( [ID_CDE] [bigint] IDENTITY(1,1) NOT NULL, [Reference] [nvarchar](50) NOT NULL, [DateCDE] [date] NOT NULL, [RefFournisseur] [int] NOT NULL, CONSTRAINT [PK_ENTREE] PRIMARY KEY CLUSTERED ( [IDCDE] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Notons que dans la table Ligne_Commande, les champs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 CREATE TABLE [dbo].[Ligne_Commande]( [IDLigne] [bigint] IDENTITY(1,1) NOT NULL, [IDCDE] [bigint] NOT NULL, [RefProduit] [bigint] NOT NULL, [Designation] [nvarchar](max) NOT NULL, [Qte] [bigint] NOT NULL, [PA] [numeric](10, 2) NOT NULL, CONSTRAINT [PK_Ligne] PRIMARY KEY CLUSTERED ( [IDLigne] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
- IDCDE référence le champ ID_CDE de la table commande
- RefProduit référence le champ Produit_id de la table Produit
- Designation référence le champ Libelle de la table Produit
- RefFournisseur référence le champ Fournisseur_ref de la table Fournisseur
Voila, j'arrive à enregistrer avec le MVC en créant des vues les tables Produit, Fournisseur mais j'arrive pas à combiner mes tables Commande, Ligne_Commande sur des vues (create, edit, delete, list). Voir image ci-joint pour le modèle souhaité pour l'enregistrement.
Partager