我使用下面的存储过程来生成水晶报告。我的报告主要基于两个可能的值,Arcade或Franchise来过滤数据。
我将数据过滤为Arcade = 1,Franchise = 2且Both = 0.OnletType参数获取这些int值。
当我过滤一个特定值时它给了我街机和特许经营值。
ALTER PROCEDURE [dbo].[PrintReceiptCancellationWorkflow]
@EntryType int,
@OutletType int,
@RequestedUser varchar(50),
@FromDate DateTime2,
@ToDate DateTime2,
@OutletCode varchar(10),
@CancelledUser varchar(20),
@Status int
AS
BEGIN
SELECT
Outlets.OutletDesc AS 'Branch',
Receipt.CancelUser AS 'RequestedBy',
Receipt.RecDate AS 'ReqDateTime',
--ReceiptCancellationStatus.ApprovedStatus AS 'Status',
ReceiptCancellationStatus.StatusDesc As Status,
WorkflowRequestQueue.CposReference AS 'WCRNo',
Receipt.ReceiptNo AS 'ReceiptNo',
Receipt.PaymentMode AS 'PaymentMode',
Receipt.AppliedAmount AS 'Amount',
WorkflowRequestQueue.AppRejUser AS 'CompletedBy',
WorkflowRequestQueue.AppRejDateTime AS 'CompletedDateTime',
EntryTypes.EntryType AS 'PaymentCategory',
WorkflowRequestQueue.AppRejComment AS 'Comment',
OutletCategories.CatDesc As 'OutletType'
FROM Receipt
INNER JOIN
Outlets ON Receipt.OutletCode = Outlets.OutletCode
LEFT OUTER JOIN
EntryTypes ON Receipt.EntryTypeId = EntryTypes.Id
LEFT OUTER JOIN
WorkflowRequestQueue ON Receipt.CposReference = WorkflowRequestQueue.CposReference
LEFT OUTER JOIN
OutletCategories ON Outlets.OutletType = OutletCategories.CatCode
LEFT OUTER JOIN
ReceiptCancellationStatus ON WorkflowRequestQueue.ApprovedStatus = ReceiptCancellationStatus.Id
WHERE (Outlets.OutletType = @OutletType OR Outlets.OutletType = 0) OR
(Receipt.EntryTypeId = @EntryType OR Receipt.EntryTypeId = 0) OR
Receipt.CancelUser = @RequestedUser OR
(( CONVERT(DATE,WorkflowRequestQueue.AppRejDateTime) >= @FromDate) AND ( CONVERT(DATE,WorkflowRequestQueue.AppRejDateTime) <= @ToDate)) OR
Outlets.OutletCode = @OutletCode OR
WorkflowRequestQueue.ApprovedPerson = @CancelledUser OR
(WorkflowRequestQueue.ApprovedStatus = @Status OR WorkflowRequestQueue.ApprovedStatus = 0)
END
出口类型下拉值,
$scope.VendorDropdown = [
{ "text": "Select", "value": "0" },
{ "text": "Arcade", "value": "1" },
{ "text": "Franchise", "value": "2" },
];
报告生成代码,
object paymentCategory = Convert.ToInt32(Request.Form["PaymentCategory"]);
object vendor = Convert.ToInt32(Request.Form["Vendor"]);
object requestedUser = Convert.ToString(Request.Form["RequestedUser"]);
object cancelledUser = Convert.ToString(Request.Form["CancelledUser"]);
object Fromdate = Convert.ToDateTime(Request.Form["dateFrom"]);
object Todate = Convert.ToDateTime(Request.Form["dateTo"]);
object status = Convert.ToInt32(Request.Form["Status"]);
object outlet = Convert.ToString(Request.Form["Outlet"]);
if (isExcel)
{
myReport.Load(Server.MapPath("~/CPOSReport/MIS/CancellationReports/ReceiptCancellationWorkFlow.rpt"));
}
else {
myReport.Load(Server.MapPath("~/CPOSReport/MIS/CancellationReports/ReceiptCancellationWorkFlow.rpt"));
}
myReport.SetParameterValue("@EntryType", paymentCategory);
myReport.SetParameterValue("@OutletType",vendor );
myReport.SetParameterValue("@RequestedUser", requestedUser);
myReport.SetParameterValue("@CancelledUser", cancelledUser);
myReport.SetParameterValue("@FromDate", Fromdate);
myReport.SetParameterValue("@ToDate", Todate);
myReport.SetParameterValue("@Status", status);
myReport.SetParameterValue("@OutletCode", outlet);
答案 0 :(得分:1)
您所有的条件都是“或”。这意味着如果其中一个满意,则将包括该行。
您可能应该尝试使用不同的条件并且一起使用这个WHERE:
WHERE (Outlets.OutletType = @OutletType OR Outlets.OutletType = 0) AND
(Receipt.EntryTypeId = @EntryType OR Receipt.EntryTypeId = 0) AND
Receipt.CancelUser = @RequestedUser AND
(
( CONVERT(DATE,WorkflowRequestQueue.AppRejDateTime) >= @FromDate) AND
( CONVERT(DATE,WorkflowRequestQueue.AppRejDateTime) <= @ToDate)
) AND
Outlets.OutletCode = @OutletCode AND
WorkflowRequestQueue.ApprovedPerson = @CancelledUser AND
(WorkflowRequestQueue.ApprovedStatus = @Status OR WorkflowRequestQueue.ApprovedStatus = 0)