如何在mvc索引页面中将年薪转换为月薪? [英] how to convert annual salary to monthly salary in mvc index page ?

查看:56
本文介绍了如何在mvc索引页面中将年薪转换为月薪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我有一个创建视图,员工将插入他们的名字和年度薪水?我需要的是在索引视图中显示他们的员工姓名及其月薪?任何人都可以给我一个示例代码示例



例如:



emp名称是shiva和年薪在创建视图中输入360000



我需要在索引视图中显示为shiva和30000(月薪)

hi friends,
I have a create view in which employees will insert their names and annual salarys ? what i need is to show their employee names and their monthly salarys in index view ? Can anyone give me a sample code examples

for eg :

emp name is shiva and annual salary is 360000 is entered in create view

and i need to show in index view as shiva and 30000(monthly salary)

推荐答案

您可以在 Model 中为 MonthlySalary 创建新的 readonly 属性,如下所示,并且可以在 View中访问此属性通过模型。此 readonly 属性根据 AnnualSalary 属性的值自动计算月薪



You can create new readonly property in Model for MonthlySalary as shown below and can access this property in View through Model. This readonly property calculates Monthly Salary automatically depending upon the value of AnnualSalary property.

Public decimal MonthlySalary
{
    get {
      return AnnualSalary/12;
    }
}





我希望这会对你有所帮助:)



I hope this will help you :)


这篇关于如何在mvc索引页面中将年薪转换为月薪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆