123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <?xml version="1.0" encoding="utf-8" ?>
- <Forms>
- <Form Name="FrmOverallSearchStatistics">
- <Client>
- <Events>
- <Load>
- <![CDATA[
- @Title="进销货统计";
- GetSchema();
- txtCoNo.CValue=GetCurrentCompanyNo();
- txtCoName.CValue=GetCurrentCompanyShortName();
- ChangeMode("Search");
- ]]>
- </Load>
- <Closing>
- ;
- </Closing>
- <Closed>
- ;
- </Closed>
- </Events>
- <Mode>
- <Search>
- <Lable name="Search"/>
- </Search>
- </Mode>
- <Controls>
-
- <IKTextButton name="tbProduct1" DataSource="UI.StartNo_Product">
- <Events>
- <Click>
- <![CDATA[
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct1.CValue);
- if( @temp == "" )
- return;
- tbProduct1.CValue = @temp;
- ]]>
- </Click>
- <TextBoxButtonTextChanged>
- tbProduct2.CValue = tbProduct1.CValue;
- </TextBoxButtonTextChanged>
- </Events>
- </IKTextButton>
- <IKTextButton name="tbProduct2" DataSource="UI.EndNo_Product" >
- <Events>
- <Click>
- <![CDATA[
- @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct2.CValue);
- if( @temp == "" )
- return;
- tbProduct2.CValue = @temp;
- ]]>
- </Click>
- </Events>
- </IKTextButton>
-
- <IKButton name="btnView">
- <Events>
- <Click>
- @ClickType="View";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnExcel">
- <Events>
- <Click>
- @ClickType="Excel";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnWord">
- <Events>
- <Click>
- @ClickType="Word";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- <IKButton name="btnPrint">
- <Events>
- <Click>
- @ClickType="PrintToPrinter";
- <Lable name="Action"/>
- </Click>
- </Events>
- </IKButton>
- </Controls>
- <ChildForms>
- <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>
- </ChildForms>
- </Client>
- <Server>
- <Tables>
- <Table name="UI" Type="Parent">
- <GetSchema CmdType="Text" CmdText="SELECT TOP 0 Convert(nvarchar(64),'') As StartNo_Product,Convert(nvarchar(64),'') As EndNo_Product,convert(nvarchar(64),'') As Name_Creator,convert(datetime,0) As CreateDate"/>
- </Table>
- </Tables>
- <Search>
- <SearchOverallSearchStatistics CmdType="Text" CmdText="
- IF Exists (Select * From tempdb.dbo.sysobjects Where id=Object_ID(N'tempdb.dbo.#TempP'))
- DROP TABLE #TempP
- IF Exists (Select * From tempdb.dbo.sysobjects Where id=Object_ID(N'tempdb.dbo.#TempS'))
- DROP TABLE #TempS
- Create Table #TempP
- (
- ID_Product uniqueidentifier,
- PDay varchar(10),
- Quantity_PurchaseInDepotBillProduct decimal(14,4),
- No int
- )
- Create Table #TempS
- (
- ID_Product uniqueidentifier,
- Mon varchar(7),
- Quantity_SaleOutDepotBillProduct decimal(14,4),
- InQuantity_ModifyDepotBillProduct decimal(14,4),
- OutQuantity_ModifyDepotBillProduct decimal(14,4),
- No int
- )
- Insert Into #TempP(ID_Product,PDay,Quantity_PurchaseInDepotBillProduct)
- Select ID_Product,PDay,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct
- From
- (
- Select Product.ID_Product,Convert(varchar(10),Date_PurchaseInDepotBill,120) As PDay,Quantity_PurchaseInDepotBillProduct
- From PurchaseInDepotBillProduct
- Left Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill
- Left Join Product On Product.ID_Product=PurchaseInDepotBillProduct.ID_Product
- Where ID_Assessor Is Not Null And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- )a
- Group By ID_Product,PDay
- Order By ID_Product,PDay
- Insert Into #TempS(ID_Product,Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct)
- Select IsNull(smi.ID_Product,mo.ID_Product) As ID_Product,IsNull(smi.Mon,mo.Mon) As Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct
- From
- (
- Select IsNull(s.ID_Product,mi.ID_Product) As ID_Product,IsNull(s.Mon,mi.Mon) As Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct
- From
- (
- Select ID_Product,Sum(Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct,Mon
- From
- (
- Select Product.ID_Product,Quantity_SaleOutDepotBillProduct,Convert(varchar(10),Date_SaleOutDepotBill,120) As PDay,Convert(varchar(7),Date_SaleOutDepotBill,120) As Mon
- From SaleOutDepotBillProduct
- Left Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill
- Left Join Product On Product.ID_Product=SaleOutDepotBillProduct.ID_Product
- Where ID_Assessor Is Not Null And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- )a
- Group By ID_Product,Mon
-
- )s
- Full Outer Join
- (
- Select ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct,Mon
- From
- (
- Select Product.ID_Product,Quantity_ModifyDepotBillProduct,Convert(varchar(7),Date_ModifyDepotBill,120) As Mon
- From ModifyDepotBillProduct
- Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill
- Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill
- Left Join Product On Product.ID_Product=ModifyDepotBillProduct.ID_Product
- Where ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- )a
- Group By ID_Product,Mon
- )mi On mi.ID_Product=s.ID_Product And mi.Mon=s.Mon
- )smi
- Full Outer Join
- (
- Select ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct,Mon
- From
- (
- Select Product.ID_Product,Quantity_ModifyDepotBillProduct,Convert(varchar(7),Date_ModifyDepotBill,120) As Mon
- From ModifyDepotBillProduct
- Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill
- Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill
- Left Join Product On Product.ID_Product=ModifyDepotBillProduct.ID_Product
- Where ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- )a
- Group By ID_Product,Mon
- )mo On smi.ID_Product=mo.ID_Product And smi.Mon=mo.Mon
- Order By IsNull(smi.ID_Product,mo.ID_Product),IsNull(smi.Mon,mo.Mon)
- Declare @ID_Product uniqueidentifier
- Declare @PDay varchar(10)
- Declare @Mon nvarchar(7)
- Declare @VProduct uniqueidentifier
- Declare @Num int
-
- Set @VProduct=null
- Declare curP cursor For
- Select ID_Product,PDay From #TempP
- Open curP
- Fetch Next From curP Into @ID_Product,@PDay
- While @@Fetch_Status=0
- BEGIN
- IF @ID_Product=@VProduct
- Set @Num=@Num+1
- Else
- BEGIN
- SET @VProduct=@ID_Product
- Set @Num=1
- END
- Update #TempP Set No=@Num Where ID_Product=@ID_Product And PDay=@PDay
- Fetch Next From curP Into @ID_Product,@PDay
- END
- CLose curP
- Deallocate curP
- Set @VProduct=null
- Declare curS cursor For
- Select ID_Product,Mon From #TempS
- Open curS
- Fetch Next From curS Into @ID_Product,@Mon
- While @@Fetch_Status=0
- BEGIN
- IF @ID_Product=@VProduct
- Set @Num=@Num+1
- Else
- BEGIN
- SET @VProduct=@ID_Product
- Set @Num=1
- END
- Update #TempS Set No=@Num Where ID_Product=@ID_Product And Mon=@Mon
- Fetch Next From curS Into @ID_Product,@Mon
- END
- CLose curS
- Deallocate curS
-
- Select ps.ID_Product,No_Product,Name_Product,OpeningStockQty_ProductStocks,PDay,Quantity_PurchaseInDepotBillProduct,Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct,StockQty_ProductStocks
- From
- (
- Select Product.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks,Sum(StockQty_ProductStocks) As StockQty_ProductStocks
- From ProductStocks
- Left Join Product On Product.ID_Product=ProductStocks.ID_Product
- Where No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- Group By Product.ID_Product
- )ps
- Left Join
- (
- Select IsNull(#TempP.ID_Product,#TempS.ID_Product) As ID_Product,PDay,Quantity_PurchaseInDepotBillProduct
- ,Mon, Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct
- From #TempP
- Full Outer Join #TempS On #TempP.ID_Product=#TempS.ID_Product And #TempP.No=#TempS.No
- )psmimo On ps.ID_Product=psmimo.ID_Product
- Left Join Product On Product.ID_Product=ps.ID_Product
- --Where No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
- Order By No_Product
- ">
- <Params>
- <Param name="@StartNo_Product" type="Product.No_Product" Index="0" />
- <Param name="@EndNo_Product" type="Product.No_Product" Index="1" />
- </Params>
- <Tables>
- <Table name="OverallSearchStatistics"/>
- </Tables>
- </SearchOverallSearchStatistics>
- <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
- <Tables>
- <Table name="AllProduct" />
- </Tables>
- </SearchAllProduct>
- </Search>
- </Server>
- <Lables>
- <Search>
- Empty();
- NewInstance();
- </Search>
- <Action>
- <![CDATA[
- UpdateForm(false,"");
- #UI.Name_Creator = GetCurrentUser();
- #UI.CreateDate = GetCurrentTime();
-
- @StartNo_Product=tbProduct1.CValue==""?DBNull():tbProduct1.CValue;
- @EndNo_Product=tbProduct2.CValue==""?DBNull():tbProduct2.CValue;
- Search("SearchOverallSearchStatistics",@StartNo_Product,@EndNo_Product);
- if(RowCount("#OverallSearchStatistics")==0)
- {
- MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
- }
- else
- {
- switch(@ClickType)
- {
- case "View":
- PrintReport("UIOverallSearchStatistics","UI","OverallSearchStatistics");
- break;
- default:
- ExportReport(@ClickType,"UIOverallSearchStatistics","UI","OverallSearchStatistics");
- break;
- }
- }
- ]]>
- </Action>
- </Lables>
- </Form>
- </Forms>
|