根据数据库值禁用按钮 [英] Disable a button based on database value

查看:87
本文介绍了根据数据库值禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有40个按钮,用于我的Windows应用程序项目中的座位选择。



任何人都可以选择其中一个按钮来选择公交车上的座位。



如果任何乘客在相同的出发日期,同一时间,相同的离开地点和去处之前选择座位按钮,这些座位按钮将被禁用。



我尝试了什么:



尝试多次后我无法解决这个问题。

所以请帮我解决这个问题。

I have 40 button which is for seat selection on my Windows Application project.

Anyone can pick up one of these button for select a seat in a bus.

These seat button will be disable if any passenger select the seat button before on same Departing date,same time, same Leaving place and going place.

What I have tried:

I can't solve this problem after trying many times.
So please help me to solve this problem.

推荐答案

你可以用很多方法来解决这个问题。

您可以将所有按钮存储在一个数组中,然后将已采取的索引存储在数据库中。当您回读它们时,将Button.Enabled属性设置为false。

您可以将座位号设置为按钮的文本,然后存储它。 (如果您的座位标识是行号,列号:7C,3D等等,这会有所帮助。)

您可以在Button.Tag属性中找到座位号信息,并在检索到时查找信息。

或者,如果你是绝望的,你可以使用按钮名称属性并循环。



这真的取决于你和你喜欢做什么。



我?我可能不会使用按钮,因为它们中有40个需要管理!相反,我可能会使用公交车座位布局的图像,并通过点击的X和Y位置检测座位。然后我将其转换为座位索引,然后存储。但这样做的工作要多一些 - 即使它最终看起来好多了!
There are a whole load of ways you could do this.
You could store all the buttons in an array, then store the "taken" indexes in the DB. When you read them back, set the Button.Enabled property to false.
You could set the Seat Number as the Text of the button, and store that. (This helps if your seat identification is row number, column letter: 7C, 3D and so forth).
You could the seat number info in the Button.Tag property and look for that when you retrieve your info.
Or if you were desperate, you could use the Button Name property and loop for that.

It really depends on you and how you like to do things.

Me? I probably wouldn't use Buttons, as 40 of them is a lot to manage! Instead, I'd probably use an image of the seat layout for the bus and detect the seat by the X and Y location clicked on. I'd then convert that to a seat index, and store that. But that's a bit more work - even if it looks a lot better in the end!


这篇关于根据数据库值禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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