如何在C#windows窗体应用程序中计算并计算“购买”数量的总价? [英] How can I compute and put the total price on quantity of 'purchase' in C# windows form application?

查看:530
本文介绍了如何在C#windows窗体应用程序中计算并计算“购买”数量的总价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为学校项目制作销售点,我如何计算每件商品的数量价格:$ 17数量3,我需要帮助请

见图片:



https://imageshack.com/a/img922/7637/5cNJZh.png



我有什么尝试过:



i尝试了谷歌搜索和Youtube,但没有一个能给我所需的代码

Im Making a Point of sale for a School Project, how can i total the price of quantity per item ex:$17 quantity 3, i need help pls
See Image:

https://imageshack.com/a/img922/7637/5cNJZh.png

What I have tried:

i have tried google searches and Youtube but none of them can give me the needed code

推荐答案

17数量3,我需要帮助请

见图片:



https://imageshack.com/a/ img922 / 7637 / 5cNJZh.png



我的尝试:


$ b $我试过谷歌搜索和Youtube,但没有一个能给我所需的代码
17 quantity 3, i need help pls
See Image:

https://imageshack.com/a/img922/7637/5cNJZh.png

What I have tried:

i have tried google searches and Youtube but none of them can give me the needed code


这是功课,所以我们不会给你任何代码 - 这毕竟是你的工作,而不是我们的工作!



说实话,如果我们想要的话,我们无法给你代码 - 我们不知道你的现有代码是如何工作的,而且远远不够太远了任何变量供我们猜测。



首先看看你的代码:你需要处理一个事件(如果是基于Windows的C#,基于Web的Javascript)数量发生变化时发生的情况。这可能是一个TextChanged事件,但确切的细节将根据您使用的控件类型以及它运行的环境而有所不同。



然后你需要将每个数量转换为数字 - 在C#中可能是int.TryParse方法 - 并对价格做同样的事情。然后你可以简单地通过将它们相乘,并将所有结果加在一起来生成总数。



试一试:这不是很复杂,它只需要一点思考!
This is homework, so we'll give you no code - that is after all you job, not ours!

And to be honest, we couldn't give you code if we wanted to - we have no idea about how your existing code works, and there are far, far too many variables for us to guess.

So start by looking at your code: you need to handle an event (in C# if windows based, in Javascript in web based) that occurs when the quantity changes. That may be a TextChanged event, but the exact detail will be different depending on what kind of control you used, and what environment it runs under.

Then you need to convert each quantity to a number - in C# that's probably the int.TryParse method - and do the same with the prices. You can then generate the total simply by multiplying one by the other, and adding all the results together.

Give it a try: this isn't really complicated, it just takes a little thinking about!


这篇关于如何在C#windows窗体应用程序中计算并计算“购买”数量的总价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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