
Post your any code related problem to www.abctutorial.com
Follow the previous video and articles to complete the POS tutorials
Step-1
In our previous table structure we never use Product sales price and Produce Purchase price. Also a very important part we missed which is batch. Batch is very important because like example: we purchase few mobile phone in January by 100$ per piece but in next purchase when we went to market then price has been increase it to 120$ that mean when we sell then we will consider sells price based on 100$ then when this product will be sold-out then we will consider sells price based on 120$. That’s why we will make some change in our table and create new Batch table. Also we changed ProductQuantity table to ProductStock.
- Please create Batch table by executing below code.
CREATE TABLE [dbo].[Batch](
[BatchId] [int] IDENTITY(1,1) NOT NULL,
[BatchName] [nvarchar](50) NULL,
CONSTRAINT [PK_Batch] PRIMARY KEY CLUSTERED
(
[BatchId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
- Change ProductQuantity table name to ProductStock.
- Execute below code to add BatchId into ProductStock table and add new field PurchasePrice and SalesPrice.
CREATE TABLE [dbo].[ProductStock](
[ProductQtyId] [int] IDENTITY(1,1) NOT NULL,
[ProductId] [int] NULL,
[Quantity] [int] NULL,
[BatchId] [int] NULL,
[PurchasePrice] [decimal](18, 0) NULL,
[SalesPrice] [decimal](18, 0) NULL,
CONSTRAINT [PK_ProductQuantity] PRIMARY KEY CLUSTERED
(
[ProductQtyId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ProductStock] WITH CHECK ADD CONSTRAINT [FK_ProductQuantity_Product] FOREIGN KEY([ProductId])
REFERENCES [dbo].[Product] ([ProductId])
GO
ALTER TABLE [dbo].[ProductStock] CHECK CONSTRAINT [FK_ProductQuantity_Product]
GO
ALTER TABLE [dbo].[ProductStock] WITH CHECK ADD CONSTRAINT [FK_ProductStock_Batch] FOREIGN KEY([BatchId])
REFERENCES [dbo].[Batch] ([BatchId])
GO
ALTER TABLE [dbo].[ProductStock] CHECK CONSTRAINT [FK_ProductStock_Batch]
GO
Instead of Executing this code I recommend to see the video and follow video to complete this
- Now run the project.
- Then save, update, retrieve data.