2
Hello,
Handel Duplicate value in calculation
As per the question, there are duplicate prices in add/update record. It's fine to have same value for each block because when you check for a single block you need the same value.
But, you can check in foreach loop if it's a duplicate or the same value you should take FirstOrDefault() or not add again if it's already added to the total price calculation.
Make the input field read-only
you can check if a value has already been added in a database or if it's not null or zero then you should set read-only
Thanks
Vishal Joshi
Accepted 1
To achieve this in a .NET application, you can utilize data structures like dictionaries or hashsets to store unique values for each block. Additionally, you can implement a mechanism to enforce read-only access to the compounding wall value across blocks.
using System;
using System.Collections.Generic;
public class Application
{
private Dictionary<string, decimal> blockPrices = new Dictionary<string, decimal>();
private decimal compoundingWallPrice;
public void SetBlockPrice(string blockName, decimal price)
{
if (!blockPrices.ContainsKey(blockName))
{
blockPrices[blockName] = price;
}
}
public decimal GetBlockPrice(string blockName)
{
return blockPrices.ContainsKey(blockName) ? blockPrices[blockName] : 0;
}
public decimal CompoundingWallPrice
{
get { return compoundingWallPrice; }
private set { compoundingWallPrice = value; }
}
}