我有这个存储过程的问题,我无法创建RDLC报告,请帮助我。 感谢。
USE [ASSevenAzhitechs]
GO
/****** Object: StoredProcedure [dbo].[Sp_RepReceptionServicesParts] Script Date: 04/13/2016 11:16:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Sp_RepReceptionServicesParts]
(
@UserType as char(1),
@UserCode as varchar(5),
@DateFrom as varchar(10),
@DateTo as Varchar(10) ,
@DealerNo as varchar(5),
@DealerNoCombo as varchar(5),
@VehicleCode as varchar(5) ,
@ChassisNo as varchar(30),
@ReceptionCode as varchar(10),
@FactorNo as varchar(10),
@ServiceUserCode as varchar(30),
@PartNo as varchar(30) ,
@CostCenter as char(1) ,
@PartOrService as char(1),
@ReceptionType as char(1),
@VehicleType as char(1)
)
as
begin
declare @strParts as varchar(max)
declare @strServices as varchar(max)
declare @strFinal as varchar(max)
set @DateFrom = '''' + @DateFrom + ''''
set @DateTo = '''' + @DateTo + ''''
set @strParts = '
select ReceptionCode,RecDate,FactorNo,rp.DeliverDate FactorDate,VehicleFarsiName VehicleName, case when s.Imported = 1 then ''notok'' else ''ok'' end as VehicleType ,RecKilometer ReceptionKilometer, ''Parts'' as Type,
PartFarsiName as Name,''-'' as ServerName,PartNo as Code, Warranty=case HasWarranty when 1 then ''Yes'' when 0 then ''No'' end,
max(UnitPrice) UnitPrice,sum(Number) Qty,Sum(ExtraPrice) ExtraPrice,Sum(SpecialDiscount) Discount, Sum((UnitPrice*Number)+ExtraPrice - SpecialDiscount ) as Price ,ChassisNo,MotorNo,s.ActualDeliveryDate ''date start''
from V_RecParts rp
left join
V_LastSubscribers s
on rp.SubScriberCode = s.SubScriberCode
where RecDate between ' + @DateFrom + ' and ' + @DateTo + ' --DealerNoRMN --VehicleCodeRMN --ChassisNoRMN --ReceptionCodeRMN --FactorNoRMN
--PartNoRMN --CostCenterRMN --ReceptionTypeRMN --VehicleTypeRMN
group by ReceptionCode,RecDate,FactorNo,rp.DeliverDate,VehicleFarsiName,RecKilometer,HasWarranty,PartFarsiName,PartNo,ChassisNo,MotorNo,s.ActualDeliveryDate, s.imported '
set @strServices = '
select ReceptionCode,RecDate,FactorNo,rs.DeliverDate FactorDate,VehicleFarsiName VehicleName, case when s.Imported = 1 then ''notok'' else ''ok'' end as VehicleType,RecKilometer ReceptionKilometer, ''Services'' as Type,
FarsiName as Name,ServerName,ServiceUserCode as Code, Warranty=case HasWarranty when 1 then ''Yes'' when 0 then ''No'' end,
max(UnitPrice) UnitPrice,sum(Number) Qty,Sum(ExteraPrice) ExtraPrice,Sum(SpecialDiscount) Discount, Sum((UnitPrice*Number)+ExteraPrice - SpecialDiscount ) as Price ,ChassisNo,MotorNo,s.ActualDeliveryDate ''date start''
from V_RecServices rs
left join
V_LastSubscribers s
on rs.SubScriberCode = s.SubScriberCode
where RecDate between ' + @DateFrom + ' and ' + @DateTo + ' --DealerNoRMN --VehicleCodeRMN --ChassisNoRMN --ReceptionCodeRMN --FactorNoRMN
--ServiceUserCodeRMN --CostCenterRMN --ReceptionTypeRMN --VehicleTypeRMN
group by ReceptionCode,RecDate,FactorNo,rs.DeliverDate,VehicleFarsiName ,RecKilometer ,HasWarranty,FarsiName,ServerName,ServiceUserCode,ChassisNo,MotorNo,s.ActualDeliveryDate,s.imported '
if @PartOrService = 'P' -- output is just Parts
set @strFinal = @strParts
else
if @PartOrService = 'S' -- output is just Services
set @strFinal = @strServices
else
set @strFinal = '( '+ @strParts + ') union ( ' + @strServices + ' ) '
set @strFinal = @strFinal + ' order by ReceptionCode '
if @UserType <> 'A'
set @strFinal = replace(@strFinal ,'--DealerNoRMN', ' and ReceptionCode / 100000 = ' + @DealerNo )
else
if @DealerNoCombo <> -1
set @strFinal = replace(@strFinal ,'--DealerNoRMN', ' and ReceptionCode / 100000 = ' + @DealerNoCombo )
else
set @strFinal = replace(@strFinal ,'--DealerNoRMN', '' )
if len(@vehicleCode) > 0
set @strFinal = replace(@strFinal ,'--VehicleCodeRMN', ' and VehicleCode = ' + @vehicleCode )
else
set @strFinal = replace(@strFinal ,'--VehicleCodeRMN', '' )
if len(@ChassisNo) > 0
set @strFinal = replace(@strFinal ,'--ChassisNoRMN', ' and ChassisNo like ''%' + @ChassisNo + '%''' )
else
set @strFinal = replace(@strFinal ,'--ChassisNoRMN', '' )
if len(@ReceptionCode) > 0
set @strFinal = replace(@strFinal ,'--ReceptionCodeRMN', ' and ReceptionCode = ' + @ReceptionCode )
else
set @strFinal = replace(@strFinal ,'--ReceptionCodeRMN', '' )
if len(@FactorNo) > 0
set @strFinal = replace(@strFinal ,'--FactorNoRMN', ' and FactorNo = ' + @FactorNo )
else
set @strFinal = replace(@strFinal ,'--FactorNoRMN', '' )
if len(@PartNo) > 0
set @strFinal = replace(@strFinal ,'--PartNoRMN', ' and PartNo like ''%' + @PartNo + '%''' )
else
set @strFinal = replace(@strFinal ,'--PartNoRMN', '' )
if len(@ServiceUserCode) > 0
set @strFinal = replace(@strFinal ,'--ServiceUserCodeRMN', ' and ServiceUserCode like ''%' + @ServiceUserCode + '%''' )
else
set @strFinal = replace(@strFinal ,'--ServiceUserCodeRMN', '' )
if @CostCenter = 'G' -- output is just guaranty
set @strFinal = replace(@strFinal ,'--CostCenterRMN', ' and HasWarranty = 1' )
else
if @CostCenter = 'C' -- output is just Customer
set @strFinal = replace(@strFinal ,'--CostCenterRMN', ' and HasWarranty = 0' )
else -- 'B' output is Customer and guaranty
set @strFinal = replace(@strFinal ,'--CostCenterRMN', '' )
if @ReceptionType = 'C' -- output is just Closed Reception
set @strFinal = replace(@strFinal ,'--ReceptionTypeRMN', ' and QCFlag = 1 and FactorNo is not Null' )
else
if @ReceptionType = 'O' -- output is just Open Reception
set @strFinal = replace(@strFinal ,'--ReceptionTypeRMN', ' and (QCFlag = 0 or FactorNo is Null)' )
else
set @strFinal = replace(@strFinal ,'--ReceptionTypeRMN', '' )
if @VehicleType = 'F'
set @strFinal = replace(@strFinal ,'--VehicleTypeRMN', ' and s.Imported = 0 ' ) -- Imported = 0 --> Factory
else
if @VehicleType = 'N'
set @strFinal = replace(@strFinal ,'--VehicleTypeRMN', ' and s.Imported = 1 ' ) -- Imported = 1 --> Not Factory
else
set @strFinal = replace(@strFinal ,'--VehicleTypeRMN', '' )
--print @strFinal
exec (@strFinal)
结束
答案 0 :(得分:0)
我可以通过以下代码向datagridview显示数据:
public DataTable MySelect(字符串UserType,字符串UserCode,字符串DateFrom,字符串DateTo, string DealerNo,string DealerNoCombo,string VehicleCode,string ChassisNo,string ReceptionCode, string FactorNo,string ServiceUserCode,string PartNo,string CostCenter,string PartOrService, string ReceptionType,string VehicleType,string HasWarranty) {
if (openConnection() == true)
{
Cmd = new SqlCommand("Sp_MyFullShowing", Con2);
//Cmd.CommandText = "Sp_MyFullShowing";
Cmd.Parameters.AddWithValue("@UserType", UserType);
Cmd.Parameters.AddWithValue("@UserCode", UserCode);
Cmd.Parameters.AddWithValue("@DateFrom", DateFrom);
Cmd.Parameters.AddWithValue("@DateTo", DateTo);
Cmd.Parameters.AddWithValue("@DealerNo", DealerNo);
Cmd.Parameters.AddWithValue("@DealerNoCombo", DealerNoCombo);
Cmd.Parameters.AddWithValue("@VehicleCode", VehicleCode);
Cmd.Parameters.AddWithValue("@ChassisNo", ChassisNo);
Cmd.Parameters.AddWithValue("@ReceptionCode", ReceptionCode);
Cmd.Parameters.AddWithValue("@FactorNo", FactorNo);
Cmd.Parameters.AddWithValue("@ServiceUserCode", ServiceUserCode);
Cmd.Parameters.AddWithValue("@PartNo", PartNo);
Cmd.Parameters.AddWithValue("@CostCenter", CostCenter);
Cmd.Parameters.AddWithValue("@PartOrService", PartOrService);
Cmd.Parameters.AddWithValue("@ReceptionType", ReceptionType);
Cmd.Parameters.AddWithValue("@VehicleType", VehicleType);
Cmd.Parameters.AddWithValue("@HasWarranty", HasWarranty);
Cmd.CommandType = CommandType.StoredProcedure;
DT = new DataTable();
Adapter = new SqlDataAdapter(Cmd);
Adapter.Fill(DT);
closeConnection();
}
return DT;
}
并在按钮中单击此代码:
dt = sql.MySelect(&#34;&#34;,&#34;&#34;,lbl1.Text,lbl2.Text,&#34;&#34;,&#34;&# 34;,&#34;&#34;,&#34;&#34;,txtPaziresh.Text,&#34;&#34;,&#34;&#34;,&#34;&#34 ;,&#34;&#34;,&#34;&#34;,&#34;&#34;,&#34;&#34;,cmbGarant.Text); elDataGridView3.DataSource = dt.DefaultView;
但我无法从中创建rdlc报告。 任何人都无法helppppppp ????