在复选框方面需要您的帮助。这是我的代码:
CREATE PROCEDURE stad_list
@inp_location_code numeric (3,0) = -1
@inp_item_code_bgn numeric (5,0) = -1
@inp_item_code_end numeric (5,0) = -1
@inp_shipped numeric (2,0) = 0, --checkbox, if it is checked then returns the items in table which were shipped (value in table is 1)
@inp_check numeric (2,0) = 0, --checkbox, if it is checked then returns data which is still in process of checking for availability in warehouse (value in table is 0)
@inp_not_ship numeric(2,0) = 0 --checkbox, if it is checked then returns data which had not been shipped during some problems (valuein table is 2)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @SELECT as varchar (3000) = ''
DECLARE @WHERE as varchar (1000) = ''
IF (@inp_location_code != -1)
SET @WHERE = @WHERE + ' WHERE [dbo].item.location =' + CONVERT(varchar,@inp_location_code)
IF (@inp_item_code_bgn != -1)
SET @WHERE = @WHERE + ' AND [dbo].item.code>=' + CONVERT(varchar, @inp_item_code_bgn)
IF (@inp_item_code_end != -1)
SET @WHERE = @WHERE + ' AND [dbo].item.code<=' + CONVERT(varchar, @inp_item_code_end)
IF (@inp_shipped = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 1'
IF (@inp_check = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 0'
IF (@inp_not_ship = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 2'
SET @SELECT = @SELECT + '
SELECT
[dbo].item.name as ''NAME'',
[dbo].item.location as ''LOCATION'',
[dbo].item.code as ''CODE'',
[dbo].item.ship as ''STATUS''
FROM [dbo].item '
+ @WHERE
EXEC (@SELECT)
RETURN @@ROWCOUNT
END
当我只选中一个复选框时它工作正常,但在选中其中 2 个时无法获取任何数据。那么当我想选中两个复选框时该怎么办?有什么建议么?
这是我的桌子
Id Item_code Item_name Item_location Item_ship
1 14789 Juice Tokyo 0
2 14785 Boots Tokyo 2
3 98744 Hat Osaka 0
4 36987 Socks Kyoto 1
并且有三个复选框
已发货
检查
未发货
如果我检查发货,那么输出将是这样的:
Id Item_code Item_name Item_location Item_ship
4 36987 Socks Kyoto 1
但我想这样做。当我检查已发货和检查时,输出将是:
Id Item_code Item_name Item_location Item_ship
1 14789 Juice Tokyo 0
3 98744 Hat Osaka 0
4 36987 Socks Kyoto 1