123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmSaleInvoiceStatistics">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="销售开票统计";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- Empty();
- NewInstance();
- #UI.StartDate_SaleBill = GetCurrentTime();
- #UI.EndDate_SaleBill = GetCurrentTime();
- ]]>
- </Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search"/>
- </Search>
- </Mode>
- <Controls>
- <IKDateTimePicker name="dtStart" DataSource="UI.StartDate_SaleBill">
- <Events>
- <CheckedChanged>
- dtEnd.Checked = dtStart.Checked;
- </CheckedChanged>
- <ValueChanged>
- dtEnd.CValue = dtStart.CValue;
- </ValueChanged>
- </Events>
- </IKDateTimePicker>
- <IKDateTimePicker name="dtEnd" DataSource="UI.EndDate_SaleBill"/>
- <IKTextButton name="tbSaleBillNo1" DataSource="UI.StartNo_SaleBill">
- <Events>
- <Click>
- @temp=ShowSearchBox("BillSearch","HAVEDEPOT", "tbSaleBillNo1",tbSaleBillNo1.CValue);
- if(@temp=="")
- return;
- tbSaleBillNo1.CValue=@temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbSaleBillNo2.CValue = tbSaleBillNo1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbSaleBillNo2" DataSource="UI.EndNo_SaleBill" >
- <Events>
- <Click>
- @temp=ShowSearchBox("BillSearch","HAVEDEPOT", "tbSaleBillNo2",tbSaleBillNo2.CValue);
- if(@temp=="")
- return;
- tbSaleBillNo2.CValue=@temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbCustomerNo1" DataSource="UI.StartNo_Customer">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo1.CValue);
- if( @temp == "" )
- return;
- tbCustomerNo1.CValue = @temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbCustomerNo2.CValue = tbCustomerNo1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbCustomerNo2" DataSource="UI.EndNo_Customer">
- <Events>
- <Click>
- @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo2.CValue);
- if( @temp == "" )
- return;
- tbCustomerNo2.CValue = @temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProductNo1" DataSource="UI.StartNo_Product">
- <Events>
- <Click>
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNo1.CValue);
- if( @temp == "" )
- return;
- tbProductNo1.CValue = @temp;
- </Click>
- <TextBoxButtonTextChanged>
- tbProductNo2.CValue = tbProductNo1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProductNo2" DataSource="UI.EndNo_Product">
- <Events>
- <Click>
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNo2.CValue);
- if( @temp == "" )
- return;
- tbProductNo2.CValue = @temp;
- </Click>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbInvoiceNo1" DataSource="UI.StartNo_Invoice">
- <Events>
- <Click>
- ShowSearchBox("SaleInvoiceBillSearch","NODEPOT", "tbInvoiceNo1",tbInvoiceNo1.CValue);
- </Click>
- <TextBoxButtonTextChanged>
- tbInvoiceNo2.CValue = tbInvoiceNo1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbInvoiceNo2" DataSource="UI.EndNo_Invoice">
- <Events>
- <Click>
- ShowSearchBox("SaleInvoiceBillSearch","NODEPOT", "tbInvoiceNo2",tbInvoiceNo2.CValue);
- </Click>
- </Events>
- </IKTextButton>
- <IKButton name="btnView">
- <Events>
- <Click>
- UpdateForm(false,"");
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @StartNo_SaleBill = DBNull();
- @EndNo_SaleBill = DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @StartNo_Product = DBNull();
- @EndNo_Product =DBNull();
- @StartNo_Invoice = DBNull();
- @EndNo_Invoice = DBNull();
- @IsRtn = 0;
- #UI.IsRtn = "N";
-
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #UI.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #UI.EndDate_SaleBill=DBNull();
- if(tbSaleBillNo1.CValue != "")
- @StartNo_SaleBill = tbSaleBillNo1.CValue;
- if(tbSaleBillNo2.CValue != "")
- @EndNo_SaleBill = tbSaleBillNo2.CValue;
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if(tbProductNo1.CValue != "")
- @StartNo_Product = tbProduct1.CValue;
- if(tbProductNo2.CValue != "")
- @EndNo_Product = tbProduct2.CValue;
- if(tbInvoiceNo1.CValue != "")
- @StartNo_Invoice = tbInvoice1.CValue;
- if(tbInvoiceNo2.CValue != "")
- @EndNo_Invoice = tbInvoice2.CValue;
- if(ikRtnCheck.Checked)
- {
- @IsRtn = 1;
- #UI.IsRtn = "Y";
- }
- else
- {
- @IsRtn = 0;
- #UI.IsRtn = "N";
- }
-
- Search("SearchSaleInvoiceStatistics",@StartDate_SaleBill,@EndDate_SaleBill,@StartNo_SaleBill,@EndNo_SaleBill,@StartNo_Customer,@EndNo_Customer,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"),@IsRtn,@StartNo_Product,@EndNo_Product,@StartNo_Invoice,@EndNo_Invoice);
- if(RowCount("#FrmSaleInvoiceStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("UIFrmSaleInvoiceStatistics","UI","FrmSaleInvoiceStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnExcel">
- <Events>
- <Click>
-
- UpdateForm(false,"");
-
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @StartNo_SaleBill = DBNull();
- @EndNo_SaleBill = DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @IsRtn = 0;
- #UI.IsRtn = "N";
-
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #UI.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #UI.EndDate_SaleBill=DBNull();
- if(tbSaleBillNo1.CValue != "")
- @StartNo_SaleBill = tbSaleBillNo1.CValue;
- if(tbSaleBillNo2.CValue != "")
- @EndNo_SaleBill = tbSaleBillNo2.CValue;
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if(tbProductNo1.CValue != "")
- @StartNo_Product = tbProduct1.CValue;
- if(tbProductNo2.CValue != "")
- @EndNo_Product = tbProduct2.CValue;
- if(tbInvoiceNo1.CValue != "")
- @StartNo_Invoice = tbInvoice1.CValue;
- if(tbInvoiceNo2.CValue != "")
- @EndNo_Invoice = tbInvoice2.CValue;
- if(ikRtnCheck.Checked)
- {
- @IsRtn = 1;
- #UI.IsRtn = "Y";
- }
- else
- {
- @IsRtn = 0;
- #UI.IsRtn = "N";
- }
-
-
- Search("SearchSaleInvoiceStatistics",@StartDate_SaleBill,@EndDate_SaleBill,@StartNo_SaleBill,@EndNo_SaleBill,@StartNo_Customer,@EndNo_Customer,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"),@IsRtn,@StartNo_Product,@EndNo_Product,@StartNo_Invoice,@EndNo_Invoice);
- if(RowCount("#FrmSaleInvoiceStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("Excel","UIFrmSaleInvoiceStatistics","UI","FrmSaleInvoiceStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- UpdateForm(false,"");
-
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @StartNo_SaleBill = DBNull();
- @EndNo_SaleBill = DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @IsRtn = 0;
- #UI.IsRtn = "N";
-
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #UI.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #UI.EndDate_SaleBill=DBNull();
- if(tbSaleBillNo1.CValue != "")
- @StartNo_SaleBill = tbSaleBillNo1.CValue;
- if(tbSaleBillNo2.CValue != "")
- @EndNo_SaleBill = tbSaleBillNo2.CValue;
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if(tbProductNo1.CValue != "")
- @StartNo_Product = tbProduct1.CValue;
- if(tbProductNo2.CValue != "")
- @EndNo_Product = tbProduct2.CValue;
- if(tbInvoiceNo1.CValue != "")
- @StartNo_Invoice = tbInvoice1.CValue;
- if(tbInvoiceNo2.CValue != "")
- @EndNo_Invoice = tbInvoice2.CValue;
- if(ikRtnCheck.Checked)
- {
- @IsRtn = 1;
- #UI.IsRtn = "Y";
- }
- else
- {
- @IsRtn = 0;
- #UI.IsRtn = "N";
- }
-
-
- Search("SearchSaleInvoiceStatistics",@StartDate_SaleBill,@EndDate_SaleBill,@StartNo_SaleBill,@EndNo_SaleBill,@StartNo_Customer,@EndNo_Customer,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"),@IsRtn,@StartNo_Product,@EndNo_Product,@StartNo_Invoice,@EndNo_Invoice);
- if(RowCount("#FrmSaleInvoiceStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("Word","UIFrmSaleInvoiceStatistics","UI","FrmSaleInvoiceStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- UpdateForm(false,"");
-
- @StartDate_SaleBill=DBNull();
- @EndDate_SaleBill=DBNull();
- @StartNo_SaleBill = DBNull();
- @EndNo_SaleBill = DBNull();
- @StartNo_Customer = DBNull();
- @EndNo_Customer = DBNull();
- @IsRtn = 0;
- #UI.IsRtn = "N";
-
- if(dtStart.Checked)
- @StartDate_SaleBill=dtStart.Value;
- else
- #UI.StartDate_SaleBill=DBNull();
- if(dtEnd.Checked)
- @EndDate_SaleBill=dtEnd.Value;
- else
- #UI.EndDate_SaleBill=DBNull();
- if(tbSaleBillNo1.CValue != "")
- @StartNo_SaleBill = tbSaleBillNo1.CValue;
- if(tbSaleBillNo2.CValue != "")
- @EndNo_SaleBill = tbSaleBillNo2.CValue;
- if(tbCustomerNo1.CValue != "")
- @StartNo_Customer = tbCustomerNo1.CValue;
- if(tbCustomerNo2.CValue != "")
- @EndNo_Customer = tbCustomerNo2.CValue;
- if(tbProductNo1.CValue != "")
- @StartNo_Product = tbProduct1.CValue;
- if(tbProductNo2.CValue != "")
- @EndNo_Product = tbProduct2.CValue;
- if(tbInvoiceNo1.CValue != "")
- @StartNo_Invoice = tbInvoice1.CValue;
- if(tbInvoiceNo2.CValue != "")
- @EndNo_Invoice = tbInvoice2.CValue;
- if(ikRtnCheck.Checked)
- {
- @IsRtn = 1;
- #UI.IsRtn = "Y";
- }
- else
- {
- @IsRtn = 0;
- #UI.IsRtn = "N";
- }
-
-
- Search("SearchSaleInvoiceStatistics",@StartDate_SaleBill,@EndDate_SaleBill,@StartNo_SaleBill,@EndNo_SaleBill,@StartNo_Customer,@EndNo_Customer,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"),@IsRtn,@StartNo_Product,@EndNo_Product,@StartNo_Invoice,@EndNo_Invoice);
- if(RowCount("#FrmSaleInvoiceStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- PrintReport("PrintToPrinter","UIFrmSaleInvoiceStatistics","UI","FrmSaleInvoiceStatistics");
- }
- </Click>
- </Events>
- </IKButton>
- </Controls>
- <ChildForms>
- <ChildForm name="BillSearch" DataSource="SaleBill" SearchFunction="SearchAllBill" SearchFunctionCondition="SearchBillCondition" SearchFunctionByNo="SearchSaleBillWithNo">
- <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" HeaderText="销售单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="1" MappingName="#SaleBill.Date_SaleBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="2" MappingName="#SaleBill.No_Customer" HeaderText="客户编号" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="3" MappingName="#SaleBill.ShortName_Customer" HeaderText="客户名称" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="4" MappingName="#SaleBill.Name_Principal" HeaderText="业务负责" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="5" MappingName="#SaleBill.TaxCurrency_SaleBill" HeaderText="税别" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="5" MappingName="#SaleBill.Name_Linkman" HeaderText="联系人" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="6" MappingName="#SaleBill.Tel_SaleBill" HeaderText="电话" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="7" MappingName="#SaleBill.Fax_SaleBill" HeaderText="传真" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- </ChildForm>
- <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo="" MappingName="客户">
- <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
- </ChildForm>
- <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
- <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
- </ChildForm>
- <ChildForm name="SaleInvoiceBillSearch" DataSource="SaleInvoice" SearchFunction="SearchAllSaleInvoiceBill" SearchFunctionByNo="" MappingName="发票">
- <DataColumn Index="0" MappingName="#SaleInvoice.No_Invoice" HeaderText="发票号码" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
- <DataColumn Index="1" MappingName="#SaleInvoice.No_SaleInvoice" HeaderText="销项发票单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
- </ChildForm>
- </ChildForms>
- <FormatString>
- <Format name="SearchCustomerCondition">
- if(GetRight("客户基本资料","全权查看"))
- {
- FormatString("");
- }
- else
- {
- FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
- }
- </Format>
- <Format name="SearchBillCondition">
- if(GetRight("客户基本资料","全权查看"))
- {
- FormatString("");
- }
- else
- {
- FormatString(" Disable_SaleBill=0 and Customer.ID_Creator='{0}' ",GetLoginUserID());
- }
- </Format>
- </FormatString>
- </Client>
- <Server>
- <Tables>
- <Table name="UI" Type="Parent">
- <GetSchema CmdType="Text" CmdText="
- SELECT TOP 0 convert(datetime,0) As StartDate_SaleBill
- ,convert(datetime,0) As EndDate_SaleBill
- ,convert(nvarchar(64),'') As StartNo_SaleBill
- ,convert(nvarchar(64),'') As EndNo_SaleBill
- ,convert(nvarchar(64),'') As StartNo_Customer
- ,convert(nvarchar(64),'') As EndNo_Customer
- ,convert(nvarchar(64),'') As IsRtn
- ,convert(nvarchar(64),'') As StartNo_Product
- ,convert(nvarchar(64),'') As EndNo_Product
- ,convert(nvarchar(64),'') As StartNo_Invoice
- ,convert(nvarchar(64),'') As EndNo_Invoice
- "/>
- </Table>
- </Tables>
- <Search>
- <SearchAllBill CmdType="Text" CmdText=" SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer,
- Customer.Type_Customer, Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
- a.Name_User AS Name_Creator, b.Name_User AS Name_Assessor, c.Name_User AS LastModUserName,
- Location.No_Location, Location.Name_Location, CONVERT(decimal(18,6), 0) AS NumSum, CONVERT(decimal(18,6), 0) AS MoneySum,
- CONVERT(decimal(18,6), 0) AS TaxSum, Employee.No_Employee AS No_Principal, Employee.Name_Employee AS Name_Principal
- FROM SaleBill
- LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
- LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
- LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
- LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
- LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
- LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
- ">
- <Tables>
- <Table name="AllBill" />
- </Tables>
- </SearchAllBill>
- <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer FROM Customer ">
- <Tables>
- <Table name="AllCustomer" />
- </Tables>
- </SearchAllCustomer>
- <SearchAllProduct CmdType="Text" CmdText="Select No_Product, Name_Product From Product">
- <Tables>
- <Table name="AllProduct" />
- </Tables>
- </SearchAllProduct>
- <SearchAllSaleInvoiceBill CmdType="Text" CmdText="Select * From SaleInvoice">
- <Tables>
- <Table name="AllSaleInvoiceBill" />
- </Tables>
- </SearchAllSaleInvoiceBill>
- <SearchSaleInvoiceStatistics CmdType="Text" CmdText="declare @sqlCmd nvarchar(4000)
- set @sqlCmd=N' Select SaleBillDetail.No_Customer'
- +N' , SaleBillDetail.ShortName_Customer As Name_Customer'
- +N' , No_SaleBill'
- +N' , Date_SaleBill As CreateDate_SaleBill'
- +N' , No_Product'
- +N' , Name_Product'
- +N' , No_SaleInvoice'
- +N' , No_Invoice'
- +N' , IsNull(SaleInvoiceDetail.Quantity_SaleInvoiceProduct,0) As Quantity_SaleInvoiceProduct'
- +N' , IsNull(SaleInvoiceDetail.Money_SaleInvoiceProduct,0) As Money_SaleInvoiceProduct'
- if (@IsRtn = 1)
- begin
- set @sqlCmd=@sqlCmd+N' , (IsNull(SaleBillDetail.Quantity_SaleBillProduct,0) - IsNull(SaleRtnDetail.Quantity_SaleRtnBillProduct,0)) As Quantity_SaleBillProduct'
- +N' , (IsNull(SaleBillDetail.Momey_SaleBillProduct,0) - IsNull(SaleRtnDetail.Money_SaleRtnBillProduct,0)) As Momey_SaleBillProduct'
- end
- else
- begin
- set @sqlCmd=@sqlCmd+N' , IsNull(SaleBillDetail.Quantity_SaleBillProduct,0) As Quantity_SaleBillProduct'
- +N' , IsNull(SaleBillDetail.Momey_SaleBillProduct,0) As Momey_SaleBillProduct'
- end
- set @sqlCmd=@sqlCmd+N' From'
- +N' ('
- +N' Select No_SaleBill'
- +N' , ID_Product'
- +N' , No_SaleBillProduct'
- +N' , SaleDetail.Quantity_SaleBillProduct'
-
- +N' , SaleDetail.Momey_SaleBillProduct * (case TaxCurrency_SaleBill WHEN '+nchar(39)+'外加'+nchar(39)+ N' Then 1.17 else 1 end) AS Momey_SaleBillProduct'
- +N' , No_Customer'
- +N' , ShortName_Customer'
- +N' , Date_SaleBill'
- +N' From'
- +N' ('
- +N' Select ID_SaleBill'
- +N' , ID_Product'
- +N' , No_SaleBillProduct'
- +N' , Sum(Quantity_SaleBillProduct) As Quantity_SaleBillProduct'
- +N' , Sum(UnitPrice_SaleBillProduct * Quantity_SaleBillProduct) As Momey_SaleBillProduct'
- +N' From SaleBillProduct'
- +N' Group By ID_SaleBill, ID_Product ,No_SaleBillProduct'
- +N' ) SaleDetail '
- +N' Left Join SaleBill On SaleBill.ID_SaleBill = SaleDetail.ID_SaleBill'
- +N' Left Join Customer On Customer.ID_Customer = SaleBill.ID_Customer'
- +N' Where SaleBill.ID_Assessor Is Not Null '
- +N' ) SaleBillDetail'
-
-
- +N' Left Join'
- +N' ('
- +N' Select SaleInvoiceProduct.ID_SaleInvoice'
- +N' , No_FromBill'
- +N' , ID_Product'
- +N' , No_FromBillProduct'
- +N' , Sum(Quantity_SaleInvoiceProduct) As Quantity_SaleInvoiceProduct'
- +N' , Sum(Amount_SaleInvoiceProduct) * (case IncludeTax_SaleInvoice WHEN 0 Then 1.17 else 1 end) As Money_SaleInvoiceProduct'
- +N' From SaleInvoiceProduct'
- +N' Left Join SaleInvoice On SaleInvoice.ID_SaleInvoice = SaleInvoiceProduct.ID_SaleInvoice'
- +N' Where SaleInvoice.ID_Assessor Is Not Null'
- +N' And Type_FromBill = 21'
- +N' Group By SaleInvoiceProduct.ID_SaleInvoice, No_FromBill, ID_Product, IncludeTax_SaleInvoice, No_FromBillProduct'
- +N' ) SaleInvoiceDetail On SaleInvoiceDetail.No_FromBill = SaleBillDetail.No_SaleBill'
- +N' And SaleInvoiceDetail.ID_Product = SaleBillDetail.ID_Product'
- +N' And SaleInvoiceDetail.No_FromBillProduct = SaleBillDetail.No_SaleBillProduct'
- +N' Left Join SaleInvoice On SaleInvoice.ID_SaleInvoice = SaleInvoiceDetail.ID_SaleInvoice '
- +N' Left Join Product On Product.ID_Product = SaleBillDetail.ID_Product'
- if (@IsRtn = 1)
- begin
- set @sqlCmd=@sqlCmd+N' Left Join'
- +N' ('
- +N' Select No_FromBill'
- +N' , No_FromBillProduct'
-
- +N' , Sum(Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct'
- +N' , Sum((Quantity_SaleRtnBillProduct * UnitPrice_SaleRtnBillProduct)) * (case TaxCurrency_SaleRtnBill WHEN '+nchar(39)+'外加'+nchar(39)+ N' Then 1.17 else 1 end) As Money_SaleRtnBillProduct'
- +N' From SaleRtnBillProduct'
- +N' Left Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill'
- +N' Where SaleRtnBill.ID_Assessor Is Not Null'
- +N' Group By No_FromBill,No_FromBillProduct,TaxCurrency_SaleRtnBill'
- +N' ) SaleRtnDetail On SaleRtnDetail.No_FromBill = SaleBillDetail.No_SaleBill'
-
- +N' And SaleRtnDetail.No_FromBillProduct = SaleBillDetail.No_SaleBillProduct'
- end
- set @sqlCmd=@sqlCmd+N' Where No_SaleBill Is Not Null'
- if(@StartDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N',Date_SaleBill) >=0 '
- if(@EndDate_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N',Date_SaleBill) <=0 '
- if(@StartNo_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_SaleBill >= '+nchar(39)+@StartNo_SaleBill+nchar(39)
- if(@EndNo_SaleBill Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_SaleBill <= '+nchar(39)+@EndNo_SaleBill+nchar(39)
- if(@StartNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer >= '+nchar(39)+@StartNo_Customer+nchar(39)
- if(@EndNo_Customer Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Customer <= '+nchar(39)+@EndNo_Customer+nchar(39)
- if(@StartNo_Product Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product >= '+nchar(39)+@StartNo_Product+nchar(39)
- if(@EndNo_Product Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Product <= '+nchar(39)+@EndNo_Product+nchar(39)
- if(@StartNo_Invoice Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Invoice >= '+nchar(39)+@StartNo_Invoice+nchar(39)
- if(@EndNo_Invoice Is Not Null)
- set @sqlCmd=@sqlCmd+N' And No_Invoice <= '+nchar(39)+@EndNo_Invoice+nchar(39)
- if(@Right Is Not Null)
- set @sqlCmd=@sqlCmd+N' And Customer.ID_Creator= '+nchar(39)+Convert(nvarchar(64),@Right)+nchar(39)
- if(@Special=0)
- set @sqlCmd=@sqlCmd+N' And Special_SaleBill=0 '
- set @sqlCmd=@sqlCmd+N' Order By No_Customer,Date_SaleBill'
- EXECUTE sp_executesql @sqlCmd">
- <Params>
- <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
- <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
- <Param name="@StartNo_SaleBill" type="SaleBill.No_SaleBill" Index="2" />
- <Param name="@EndNo_SaleBill" type="SaleBill.No_SaleBill" Index="3" />
- <Param name="@StartNo_Customer" type="Customer.No_Customer" Index="4" />
- <Param name="@EndNo_Customer" type="Customer.No_Customer" Index="5" />
- <Param name="@Right" type="SaleBill.ID_Customer" Index="6" />
- <Param name="@Special" type="SaleBill.Special_SaleBill" Index="7" />
- <Param name="@IsRtn" type="SaleInvoice.Type_SaleInvoice" Index="8" />
- <Param name="@StartNo_Product" type="Product.No_Product" Index="9" />
- <Param name="@EndNo_Product" type="Product.No_Product" Index="10" />
- <Param name="@StartNo_Invoice" type="Invoice.No_Invoice" Index="11" />
- <Param name="@EndNo_Invoice" type="Invoice.No_Invoice" Index="12" />
- </Params>
- <Tables>
- <Table name="FrmSaleInvoiceStatistics"/>
- </Tables>
- </SearchSaleInvoiceStatistics>
- </Search>
- </Server>
- </Form>
- </Forms>
|