FrmOverallSearchStatistics.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmOverallSearchStatistics">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="进销货统计";
  9. GetSchema();
  10. txtCoNo.CValue=GetCurrentCompanyNo();
  11. txtCoName.CValue=GetCurrentCompanyShortName();
  12. ChangeMode("Search");
  13. ]]>
  14. </Load>
  15. <Closing>
  16. ;
  17. </Closing>
  18. <Closed>
  19. ;
  20. </Closed>
  21. </Events>
  22. <Mode>
  23. <Search>
  24. <Lable name="Search"/>
  25. </Search>
  26. </Mode>
  27. <Controls>
  28. <IKTextButton name="tbProduct1" DataSource="UI.StartNo_Product">
  29. <Events>
  30. <Click>
  31. <![CDATA[
  32. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct1.CValue);
  33. if( @temp == "" )
  34. return;
  35. tbProduct1.CValue = @temp;
  36. ]]>
  37. </Click>
  38. <TextBoxButtonTextChanged>
  39. tbProduct2.CValue = tbProduct1.CValue;
  40. </TextBoxButtonTextChanged>
  41. </Events>
  42. </IKTextButton>
  43. <IKTextButton name="tbProduct2" DataSource="UI.EndNo_Product" >
  44. <Events>
  45. <Click>
  46. <![CDATA[
  47. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct2.CValue);
  48. if( @temp == "" )
  49. return;
  50. tbProduct2.CValue = @temp;
  51. ]]>
  52. </Click>
  53. </Events>
  54. </IKTextButton>
  55. <IKButton name="btnView">
  56. <Events>
  57. <Click>
  58. @ClickType="View";
  59. <Lable name="Action"/>
  60. </Click>
  61. </Events>
  62. </IKButton>
  63. <IKButton name="btnExcel">
  64. <Events>
  65. <Click>
  66. @ClickType="Excel";
  67. <Lable name="Action"/>
  68. </Click>
  69. </Events>
  70. </IKButton>
  71. <IKButton name="btnWord">
  72. <Events>
  73. <Click>
  74. @ClickType="Word";
  75. <Lable name="Action"/>
  76. </Click>
  77. </Events>
  78. </IKButton>
  79. <IKButton name="btnPrint">
  80. <Events>
  81. <Click>
  82. @ClickType="PrintToPrinter";
  83. <Lable name="Action"/>
  84. </Click>
  85. </Events>
  86. </IKButton>
  87. </Controls>
  88. <ChildForms>
  89. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
  90. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  91. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  92. </ChildForm>
  93. </ChildForms>
  94. </Client>
  95. <Server>
  96. <Tables>
  97. <Table name="UI" Type="Parent">
  98. <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"/>
  99. </Table>
  100. </Tables>
  101. <Search>
  102. <SearchOverallSearchStatistics CmdType="Text" CmdText="
  103. IF Exists (Select * From tempdb.dbo.sysobjects Where id=Object_ID(N'tempdb.dbo.#TempP'))
  104. DROP TABLE #TempP
  105. IF Exists (Select * From tempdb.dbo.sysobjects Where id=Object_ID(N'tempdb.dbo.#TempS'))
  106. DROP TABLE #TempS
  107. Create Table #TempP
  108. (
  109. ID_Product uniqueidentifier,
  110. PDay varchar(10),
  111. Quantity_PurchaseInDepotBillProduct decimal(14,4),
  112. No int
  113. )
  114. Create Table #TempS
  115. (
  116. ID_Product uniqueidentifier,
  117. Mon varchar(7),
  118. Quantity_SaleOutDepotBillProduct decimal(14,4),
  119. InQuantity_ModifyDepotBillProduct decimal(14,4),
  120. OutQuantity_ModifyDepotBillProduct decimal(14,4),
  121. No int
  122. )
  123. Insert Into #TempP(ID_Product,PDay,Quantity_PurchaseInDepotBillProduct)
  124. Select ID_Product,PDay,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct
  125. From
  126. (
  127. Select Product.ID_Product,Convert(varchar(10),Date_PurchaseInDepotBill,120) As PDay,Quantity_PurchaseInDepotBillProduct
  128. From PurchaseInDepotBillProduct
  129. Left Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill
  130. Left Join Product On Product.ID_Product=PurchaseInDepotBillProduct.ID_Product
  131. Where ID_Assessor Is Not Null And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
  132. )a
  133. Group By ID_Product,PDay
  134. Order By ID_Product,PDay
  135. Insert Into #TempS(ID_Product,Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct)
  136. Select IsNull(smi.ID_Product,mo.ID_Product) As ID_Product,IsNull(smi.Mon,mo.Mon) As Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct
  137. From
  138. (
  139. Select IsNull(s.ID_Product,mi.ID_Product) As ID_Product,IsNull(s.Mon,mi.Mon) As Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct
  140. From
  141. (
  142. Select ID_Product,Sum(Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct,Mon
  143. From
  144. (
  145. Select Product.ID_Product,Quantity_SaleOutDepotBillProduct,Convert(varchar(10),Date_SaleOutDepotBill,120) As PDay,Convert(varchar(7),Date_SaleOutDepotBill,120) As Mon
  146. From SaleOutDepotBillProduct
  147. Left Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill
  148. Left Join Product On Product.ID_Product=SaleOutDepotBillProduct.ID_Product
  149. Where ID_Assessor Is Not Null And No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
  150. )a
  151. Group By ID_Product,Mon
  152. )s
  153. Full Outer Join
  154. (
  155. Select ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct,Mon
  156. From
  157. (
  158. Select Product.ID_Product,Quantity_ModifyDepotBillProduct,Convert(varchar(7),Date_ModifyDepotBill,120) As Mon
  159. From ModifyDepotBillProduct
  160. Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill
  161. Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill
  162. Left Join Product On Product.ID_Product=ModifyDepotBillProduct.ID_Product
  163. 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)
  164. )a
  165. Group By ID_Product,Mon
  166. )mi On mi.ID_Product=s.ID_Product And mi.Mon=s.Mon
  167. )smi
  168. Full Outer Join
  169. (
  170. Select ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct,Mon
  171. From
  172. (
  173. Select Product.ID_Product,Quantity_ModifyDepotBillProduct,Convert(varchar(7),Date_ModifyDepotBill,120) As Mon
  174. From ModifyDepotBillProduct
  175. Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill
  176. Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill
  177. Left Join Product On Product.ID_Product=ModifyDepotBillProduct.ID_Product
  178. 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)
  179. )a
  180. Group By ID_Product,Mon
  181. )mo On smi.ID_Product=mo.ID_Product And smi.Mon=mo.Mon
  182. Order By IsNull(smi.ID_Product,mo.ID_Product),IsNull(smi.Mon,mo.Mon)
  183. Declare @ID_Product uniqueidentifier
  184. Declare @PDay varchar(10)
  185. Declare @Mon nvarchar(7)
  186. Declare @VProduct uniqueidentifier
  187. Declare @Num int
  188. Set @VProduct=null
  189. Declare curP cursor For
  190. Select ID_Product,PDay From #TempP
  191. Open curP
  192. Fetch Next From curP Into @ID_Product,@PDay
  193. While @@Fetch_Status=0
  194. BEGIN
  195. IF @ID_Product=@VProduct
  196. Set @Num=@Num+1
  197. Else
  198. BEGIN
  199. SET @VProduct=@ID_Product
  200. Set @Num=1
  201. END
  202. Update #TempP Set No=@Num Where ID_Product=@ID_Product And PDay=@PDay
  203. Fetch Next From curP Into @ID_Product,@PDay
  204. END
  205. CLose curP
  206. Deallocate curP
  207. Set @VProduct=null
  208. Declare curS cursor For
  209. Select ID_Product,Mon From #TempS
  210. Open curS
  211. Fetch Next From curS Into @ID_Product,@Mon
  212. While @@Fetch_Status=0
  213. BEGIN
  214. IF @ID_Product=@VProduct
  215. Set @Num=@Num+1
  216. Else
  217. BEGIN
  218. SET @VProduct=@ID_Product
  219. Set @Num=1
  220. END
  221. Update #TempS Set No=@Num Where ID_Product=@ID_Product And Mon=@Mon
  222. Fetch Next From curS Into @ID_Product,@Mon
  223. END
  224. CLose curS
  225. Deallocate curS
  226. Select ps.ID_Product,No_Product,Name_Product,OpeningStockQty_ProductStocks,PDay,Quantity_PurchaseInDepotBillProduct,Mon,Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct,StockQty_ProductStocks
  227. From
  228. (
  229. Select Product.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks,Sum(StockQty_ProductStocks) As StockQty_ProductStocks
  230. From ProductStocks
  231. Left Join Product On Product.ID_Product=ProductStocks.ID_Product
  232. Where No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
  233. Group By Product.ID_Product
  234. )ps
  235. Left Join
  236. (
  237. Select IsNull(#TempP.ID_Product,#TempS.ID_Product) As ID_Product,PDay,Quantity_PurchaseInDepotBillProduct
  238. ,Mon, Quantity_SaleOutDepotBillProduct,InQuantity_ModifyDepotBillProduct,OutQuantity_ModifyDepotBillProduct
  239. From #TempP
  240. Full Outer Join #TempS On #TempP.ID_Product=#TempS.ID_Product And #TempP.No=#TempS.No
  241. )psmimo On ps.ID_Product=psmimo.ID_Product
  242. Left Join Product On Product.ID_Product=ps.ID_Product
  243. --Where No_Product Between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
  244. Order By No_Product
  245. ">
  246. <Params>
  247. <Param name="@StartNo_Product" type="Product.No_Product" Index="0" />
  248. <Param name="@EndNo_Product" type="Product.No_Product" Index="1" />
  249. </Params>
  250. <Tables>
  251. <Table name="OverallSearchStatistics"/>
  252. </Tables>
  253. </SearchOverallSearchStatistics>
  254. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
  255. <Tables>
  256. <Table name="AllProduct" />
  257. </Tables>
  258. </SearchAllProduct>
  259. </Search>
  260. </Server>
  261. <Lables>
  262. <Search>
  263. Empty();
  264. NewInstance();
  265. </Search>
  266. <Action>
  267. <![CDATA[
  268. UpdateForm(false,"");
  269. #UI.Name_Creator = GetCurrentUser();
  270. #UI.CreateDate = GetCurrentTime();
  271. @StartNo_Product=tbProduct1.CValue==""?DBNull():tbProduct1.CValue;
  272. @EndNo_Product=tbProduct2.CValue==""?DBNull():tbProduct2.CValue;
  273. Search("SearchOverallSearchStatistics",@StartNo_Product,@EndNo_Product);
  274. if(RowCount("#OverallSearchStatistics")==0)
  275. {
  276. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  277. }
  278. else
  279. {
  280. switch(@ClickType)
  281. {
  282. case "View":
  283. PrintReport("UIOverallSearchStatistics","UI","OverallSearchStatistics");
  284. break;
  285. default:
  286. ExportReport(@ClickType,"UIOverallSearchStatistics","UI","OverallSearchStatistics");
  287. break;
  288. }
  289. }
  290. ]]>
  291. </Action>
  292. </Lables>
  293. </Form>
  294. </Forms>