如何在现有数量上进行销售并拒绝数量(如果不可用)(SQL和VB) [英] How do I make a sell on an existing quantity and reject quantity if it is not available (SQL and VB)

查看:70
本文介绍了如何在现有数量上进行销售并拒绝数量(如果不可用)(SQL和VB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个程序,如果数量可用,则从数据库中减去所请求的数量,如果数量耗尽则拒绝。我遇到的问题是,尽管系统从数据库中减去,但即使在负数量上,它仍然接受卖出。

我将非常感谢任何帮助我解决这个问题的帮助谜题。



我尝试过的事情:



I am making a program that subtracts the requested quantity from the database if the quantity is available and reject if the quantity is depleted. The problem I have is that as much as the system is subtracting from the database it is still accepting the sell even on negative quantity.
I will really appreciate any help that will be rendered to me in resolving this puzzle.

What I have tried:

Try
If txtquantity.text = Nothing then
Dim ct as string = "select stockavailable from stocks where barcode='" and stockavailable <=0"
ConnDB()
Cmd = New MysqlCommand(SQL, conn)
Dr=cmd.execute reader()

If Dr.read = true then
If e.keycode = keys.enter then
E.suppresskeypress= true
Addtolist()
Total cost+= total price
Lbltotalcost.text = Format(totalcost, "0.00")

Txtquantity. Clear()
Txtsearch.focus()
End if
End if
Else
Reset()
End if
Catch ex as exception
Messagebox.show(" requested quantity is not available!!! ", " input error" messageboxbuttons. OK, messageboxicon.error)
Finally
Cmd.dispose()
Conn.close()
End try

推荐答案

这里有很多问题,以你的代码赢了开头编译,SQL不喜欢它,如果它,它继续SQL注入, If 条件永远不会为True所以代码将不会被执行,多用户访问问题,并完全忽略从数据库返回的内容,...



停止你正在做的事情,并考虑你想要实现的目标ve:你无法测试代码,如果它不能编译,所以你不能看到该代码的任何结果,你从先前版本的编译得到结果。



当您解决明显的问题并获得干净的编译时,您可以使用调试器开始向您展示您遇到的其他问题。但此刻,看起来它在啤酒上过了一夜之后就被抛在了一起......
There are a lot of problems here, start with "your code won't compile", SQL wouldn't like it if it did, moving on to SQL Injection, an If condition that will never be True so the code won't be executed, multiuser access problems, and totally ignoring what is returned from the DB, ...

Stop what you are doing, and think about what you are trying to achieve: you can't test your code if it won't compile, so you don't get to see any results from that code, you get results from the previous version that did compile.

When you fix the obvious problems and get a clean compilation, then you can use the debugger to start showing you what other problems you have. But at the moment, that looks like it was thrown together after a night on the beer ...


Quote:

我遇到的问题是,尽管系统从数据库中减去,但即使在负数量上,它仍然接受卖出。

The problem I have is that as much as the system is subtracting from the database it is still accepting the sell even on negative quantity.



不,问题在于代码不做任何事情,因为它不正确vb。


No, the problem is that this code don't do anything because it is not correct vb.

Dim ct as string = "select stockavailable from stocks where barcode='" and stockavailable <=0"



在vb中,报价是成对的,这里有3个引号。

同一行也忘了告诉你想要哪个条形码

stockavailable < = 0 表示您只想要负 stockavailable 的记录。


In vb, quotes are going by pairs, here you have 3 quotes.
The same line also forget to tell which barcode you want.
stockavailable <=0 means that you want only records with negative stockavailable.


我的第一个代码是这样的:



如果txtquantity。 Text = Nothing then

Else

如果e.keycode = keys.Enter则

E.suppresskeypress = true

Addtolist()

总费用+ =总价格



Lbltotalcost.text =格式(totalcost,0.00)

Txtquantity。清除()

Txtsearch.Focus()

结束如果

结束如果

结束sub。



'此代码运行良好,当然减去广告正常的股票。只有系统无法检测到数量不再可用。那时我问了这个问题。请不要尖叫我......只要你能尽力帮助。比一百万。
The first code I had was this:

If txtquantity. Text = Nothing then
Else
If e.keycode = keys.Enter then
E.suppresskeypress = true
Addtolist()
Total cost+= totalprice

Lbltotalcost.text = format(totalcost, "0.00")
Txtquantity. Clear()
Txtsearch.Focus()
End if
End if
End sub.

'This code was working very well and of course subtracting stock ad normal. Only that the system could not detect that quantities are no longer available. That when I asked that question. Please don't scream at me...just help where you can. Thanx a million.


这篇关于如何在现有数量上进行销售并拒绝数量(如果不可用)(SQL和VB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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