I am working on Asp.net MVC5(Entity Framework) in which :
1: I have one master table (FeeMaster)

2: all fields have default value 0.
3: another table (Basic Details),SELECT TOP (1000) [Id]
,[Name_Department]
,[Father_OrgName]
,[City]
,[Street]
,[Locality]
,[Pincode]
,[PlotNo]
,[District]
,[Tehsil]
,[Village]
,[Ward]
,[KhasraNo]
,[KhewetNo]
,[KhataNo]
,[CompoundWall]
,[LandDevelopment]
,[MeasureGround]
,[MeasureBase]
,[MeasureTotal]
,[NoOfFloor]
,[Floor1]
,[Area1]
,[Floor2]
,[Area2]
,[Floor3]
,[Area3]
,[Floor4]
,[Area4]
,[Floor5]
,[Area5]
FROM [dbname].[dbo].[BasicDetails]
in which if i enter MeasureBase = 700 then its multiply by RateBase i.e. 10 Rs/Sqt similarly if i enter MeasureGround = 700 then its multiply by Rate ground i.e 15 Rs/Sqt, and if i enter Number of floor = 2 then it multiply by RateFloor i.e 20 rs/sqt , as with compundwall = 300 then it multiply by CompundWall i.e 10 Rs/rft and Landscapping 200 then it multiply by 25 Rs/sft, after all the calculation(multiplication and addition) it give value in Measure Total.
How can i use master table and all the calculation
Sachin SinghPosted Dec 23, 2022, 7:18 AM
You need to do calculation on onchange event of textboxes
Sachin SinghPosted Dec 23, 2022, 9:41 AM
@Garima
for MeasureTotal
you need to sum all textbox values (except one pair obviously all other will be zero, so it won't affect the calculation)
Sachin SinghPosted Dec 23, 2022, 7:54 AM
@Garima, as per your design it is even easier
same for other controls.
Garima BansalPosted Dec 23, 2022, 7:33 AM
Sachin Singh
i have two database table one is BasicDetails and other is Feemaster is a master table, so i create this in controller
Then in View, i created hidden fileds for mastertable
Garima BansalPosted Dec 23, 2022, 7:02 AM
Vishal Joshi
this scenario doesnt work
Vishal JoshiPosted Dec 21, 2022, 12:38 PM
ViewBag is fine.
Now you need to get data for BasicDetails same as FeeMaster. Please reref below sample code for the same.
Another way you can set BasicDetails data in ViewBag Or Strongly type mode and in UI/FronEnd side write multiplication logic to calculate total cost.
Thank you
Garima BansalPosted Dec 21, 2022, 11:30 AM
i use viewbag to deal with master table, in actionmethod
public ActionResult Index(FormCollection fomr)
{
ViewBag.RateBase = "";
ViewBag.RateGround = "";
ViewBag.RateFloor = "";
ViewBag.CompoundWall = "";
ViewBag.LandScapping = "";
FeeMaster mastertable = (db.FeeMasters.Where(x => x.Id == 1)).SingleOrDefault();
if (mastertable != null)
{
ViewBag.RateBase = mastertable.RateBase;
ViewBag.RateGround = mastertable.RateGround;
ViewBag.RateFloor = mastertable.RateFloor;
ViewBag.CompoundWall = mastertable.CompoundWall;
ViewBag.LandScapping = mastertable.LandScapping;
}
to get the value.
but next scenrio is :
if i enter MeasureBase = 700 then its multiply by RateBase i.e. 10 Rs/Sqt similarly if i enter MeasureGround = 700 then its multiply by Rate ground i.e 15 Rs/Sqt, and if i enter Number of floor = 2 then it multiply by RateFloor i.e 20 rs/sqt , as with compundwall = 300 then it multiply by CompundWall i.e 10 Rs/rft and Landscapping 200 then it multiply by 25 Rs/sft, after all the calculation(multiplication and addition) it give value in Measure Total.
Vishal JoshiPosted Dec 21, 2022, 9:12 AM
Hello,
There can be several wasy to achive this secnario. but, i would suggesst to create Model Structure. Please check below sample code.
Thank You