在Asp.net中计算比率 [英] To Calculate Ratio in Asp.net

查看:75
本文介绍了在Asp.net中计算比率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想以3:2的形式计算比率并将其标志值存储在数据库中.我有2个文本框,我们输入比率即3:2.

现在如何计算(Tot_share/3)* 2,并且如果结果包含十进制值,则标记值应为"Y",否则为"N".

在此示例中,我们有(Tot_share/3)* 2 =(300/3)* 2 = 100 * 2 = 200,因为它不包含小数,其标志值为N(即,否),并且这些值应存储在当我单击提交按钮时,数据库表.

例如:

Tot_share结果FlagValue
300200 N

任何帮助将不胜感激..

解决方案

您的问题是?

首先,根据您的操作,将其标记为ASP.NET无关紧要.步骤:
1.输入-比率
2.接受输入-总份额
3.应用简单的数学并根据比率获得份额A和份额B
4.使用简单的"if"和%"模量运算符查看它是整数还是小数
5.基于值的标志
6.连接到DB
7.将标志值传递给DB进行存储.

试试吧!

如果您遇到困难并需要帮助,请分享您的尝试并针对您的问题进行具体说明.当然可以帮助您.



很好,但是我该如何为上面的代码编写存储过程.


hi
I wanna calculate ratio in 3:2 form and to store its flag value and result ina database.and i have 2 textboxes wherein we enter ratio i.e.,3:2.

Now how to calculate (Tot_share/3)*2 and also if the result contain decimal value then flag value should be ''Y'' Otherwise ''N''.

Here in the example we have (Tot_share/3)*2=(300/3)*2=100*2=200 since it doesnt contain decimal its flag value is N(i.e., No) and these values should be stored in a database table when i click the submit button.

For ex:

Tot_share Result FlagValue
300 200 N

Any help would be appreciated..

解决方案

And your issue is?

First of all, based on what you have to do, tagging it as ASP.NET is irrelevant. Steps to do:
1. Take input - ratio
2. Take input - total share
3. Apply simple maths and get the share A & share B based on ratio
4. Using a simple ''if'' and a ''%'' modulus operator see if it is a whole number or decimal
5. Flag based on value
6. Connect to DB
7. Pass the flag value to DB for storage.

Try!

If you get stuck and need help, share what you tried and be specific with your issue. Surely one will help you out.


hi
Its fine but how can i write stored procedure for the above..


这篇关于在Asp.net中计算比率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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