FrmInventoryChange.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmInventoryChange">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="异动查询";
  9. GetSchema();
  10. Empty();
  11. ]]>
  12. </Load>
  13. </Events>
  14. <Mode>
  15. <Search>
  16. <Lable name="Search" />
  17. </Search>
  18. </Mode>
  19. <Controls>
  20. <IKTextButton name="ikTextButton1" DataSource="UI.StartNo_Product">
  21. <Events>
  22. <Click>
  23. @temp = ShowSearchBox("ProductSearch","INFOMATION",ikTextButton1.CValue);
  24. if( @temp == "" )
  25. return;
  26. ikTextButton1.CValue = @temp;
  27. </Click>
  28. <TextBoxButtonTextChanged>
  29. ikTextButton2.CValue = ikTextButton1.CValue;
  30. </TextBoxButtonTextChanged>
  31. </Events>
  32. </IKTextButton>
  33. <IKTextButton name="ikTextButton2" DataSource="UI.EndNo_Product">
  34. <Events>
  35. <Click>
  36. @temp = ShowSearchBox("ProductSearch","INFOMATION",ikTextButton2.CValue);
  37. if( @temp == "" )
  38. return;
  39. ikTextButton2.CValue = @temp;
  40. </Click>
  41. </Events>
  42. </IKTextButton>
  43. <IKComboBoxEx name="ikComboBoxEx1" DisplaySource="UI.StartModName_ModifyTypeSettings" ValueSource="UI.StartModName_ModifyTypeSettings" DataSource="Type" DisplayMember="result" ValueMember="result">
  44. <Events>
  45. <Reload>
  46. NewInstance();
  47. UpdateForm(false, "ikComboBoxEx1");
  48. Search("SearchType");
  49. UpdateForm(true, "ikComboBoxEx1");
  50. </Reload>
  51. </Events>
  52. </IKComboBoxEx>
  53. <IKComboBoxEx name="ikComboBoxEx2" DisplaySource="UI.EndModName_ModifyTypeSettings" ValueSource="UI.EndModName_ModifyTypeSettings" DataSource="Type" DisplayMember="result" ValueMember="result">
  54. <Events>
  55. <Reload>
  56. NewInstance();
  57. UpdateForm(false, "ikComboBoxEx2");
  58. Search("SearchType");
  59. UpdateForm(true, "ikComboBoxEx2");
  60. </Reload>
  61. </Events>
  62. </IKComboBoxEx>
  63. <IKDateTimePicker name="ikDateTimePicker1" DataSource="UI.StartDate"/>
  64. <IKDateTimePicker name="ikDateTimePicker2" DataSource="UI.EndDate"/>
  65. <IKExtendGrid name="dgProduct" DataSource="Total" TableStyleIndex="0">
  66. <DataColumn Index="0" DataSource="Total.ModName_ModifyTypeSettings"/>
  67. <DataColumn Index="1" DataSource="Total.Comment_ModifyDepotBill"/>
  68. <DataColumn Index="2" DataSource="Total.No_Product"/>
  69. <DataColumn Index="3" DataSource="Total.Name_Product"/>
  70. <DataColumn Index="4" DataSource="Total.SUM_Quantity_ModifyDepotBillProduct"/>
  71. <DataColumn Index="5" DataSource="Total.SUM_Quantity"/>
  72. <DataColumn Index="6" DataSource="Total.SUM_NoQuantity"/>
  73. <DataColumn Index="7" DataSource="Total.Date_ModifyDepotBill"/>
  74. <DataColumn Index="8" DataSource="Total.No_ModifyDepotBill"/>
  75. <DataColumn Index="9" DataSource="Total.Name_Location"/>
  76. <Events>
  77. <ClickPreview>
  78. PrintReport(dgProduct.CurrentView);
  79. </ClickPreview>
  80. <ClickRefresh>
  81. Empty();
  82. NewInstance();
  83. @StartProductNo =DBNull();
  84. @EndProductNo =DBNull();
  85. @StartModifyTypeSettings =DBNull();
  86. @EndModifyTypeSettings =DBNull();
  87. @StartDate =DBNull();
  88. @EndDate =DBNull();
  89. if(!Equals(ikTextButton1.CValue,""))
  90. @StartProductNo= ikTextButton1.CValue;
  91. if(!Equals(ikTextButton2.CValue,""))
  92. @EndProductNo= ikTextButton2.CValue;
  93. if(!Equals(ikComboBoxEx1.Text,""))
  94. @StartModifyTypeSettings= ikComboBoxEx1.Text;
  95. if(!Equals(ikComboBoxEx2.Text,""))
  96. @EndModifyTypeSettings= ikComboBoxEx2.Text;
  97. if(ikDateTimePicker1.Checked)
  98. @StartDate= ikDateTimePicker1.Value;
  99. if(ikDateTimePicker2.Checked)
  100. @EndDate= ikDateTimePicker2.Value;
  101. Search("SearchReceivales",@StartProductNo,@EndProductNo,@StartModifyTypeSettings,@EndModifyTypeSettings,
  102. @StartDate,@EndDate);
  103. if(Equals(@StartProductNo,DBNull()))
  104. @StartProductNo = "";
  105. if(Equals(@EndProductNo,DBNull()))
  106. @EndProductNo = "";
  107. if(Equals(@EndModifyTypeSettings,DBNull()))
  108. @EndModifyTypeSettings = "";
  109. if(Equals(@StartModifyTypeSettings,DBNull()))
  110. @StartModifyTypeSettings = "";
  111. #UI.StartNo_Product = @StartProductNo;
  112. #UI.EndNo_Product = @EndProductNo;
  113. #UI.StartModName_ModifyTypeSettings = @StartModifyTypeSettings;
  114. #UI.EndModName_ModifyTypeSettings = @EndModifyTypeSettings;
  115. #UI.StartDate = @StartDate;
  116. #UI.EndDate =@EndDate;
  117. </ClickRefresh>
  118. <ClickFilter>
  119. ;
  120. </ClickFilter>
  121. <ClickNOFilter>
  122. ;
  123. </ClickNOFilter>
  124. </Events>
  125. </IKExtendGrid>
  126. <IKButton name="ikButton1">
  127. <Events>
  128. <Click>
  129. Empty();
  130. NewInstance();
  131. @StartProductNo = DBNull();
  132. @EndProductNo = DBNull();
  133. @StartModifyTypeSettings = DBNull();
  134. @EndModifyTypeSettings = DBNull();
  135. @StartDate =DBNull();
  136. @EndDate =DBNull();
  137. if(!Equals(ikTextButton1.CValue,""))
  138. @StartProductNo= ikTextButton1.CValue;
  139. if(!Equals(ikTextButton2.CValue,""))
  140. @EndProductNo= ikTextButton2.CValue;
  141. if(!Equals(ikComboBoxEx1.Text,""))
  142. @StartModifyTypeSettings= ikComboBoxEx1.Text;
  143. if(!Equals(ikComboBoxEx2.Text,""))
  144. @EndModifyTypeSettings= ikComboBoxEx2.Text;
  145. if(ikDateTimePicker1.Checked)
  146. @StartDate= ikDateTimePicker1.Value;
  147. if(ikDateTimePicker2.Checked)
  148. @EndDate= ikDateTimePicker2.Value;
  149. Search("SearchReceivales",@StartProductNo,@EndProductNo,@StartModifyTypeSettings,@EndModifyTypeSettings,
  150. @StartDate,@EndDate);
  151. if(Equals(@StartProductNo,DBNull()))
  152. @StartProductNo = "";
  153. if(Equals(@EndProductNo,DBNull()))
  154. @EndProductNo = "";
  155. if(Equals(@EndModifyTypeSettings,DBNull()))
  156. @EndModifyTypeSettings = "";
  157. if(Equals(@StartModifyTypeSettings,DBNull()))
  158. @StartModifyTypeSettings = "";
  159. #UI.StartNo_Product = @StartProductNo;
  160. #UI.EndNo_Product = @EndProductNo;
  161. #UI.StartModName_ModifyTypeSettings = @StartModifyTypeSettings;
  162. #UI.EndModName_ModifyTypeSettings = @EndModifyTypeSettings;
  163. #UI.StartDate = @StartDate;
  164. #UI.EndDate =@EndDate;
  165. </Click>
  166. </Events>
  167. </IKButton>
  168. <IKButton name="btnEmpty">
  169. <Events>
  170. <Click>
  171. Empty();
  172. ikTextButton1.CValue="";
  173. ikTextButton2.CValue="";
  174. ikComboBoxEx1.SelectedName="";
  175. ikComboBoxEx2.SelectedName="";
  176. ikDateTimePicker1.Checked=False;
  177. ikDateTimePicker2.Checked=False;
  178. </Click>
  179. </Events>
  180. </IKButton>
  181. </Controls>
  182. <ChildForms>
  183. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
  184. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  185. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  186. </ChildForm>
  187. </ChildForms>
  188. </Client>
  189. <Server>
  190. <Tables>
  191. <Table name="Total" Type="Child">
  192. <GetSchema CmdType="Text" CmdText="SELECT TOP 0 ModName_ModifyTypeSettings,Comment_ModifyDepotBill,No_Product,Name_Product,CONVERT(DECIMAL(14,2),0) AS SUM_Quantity_ModifyDepotBillProduct,CONVERT(DECIMAL(14,2),0) AS SUM_Quantity,CONVERT(DECIMAL(14,2),0) AS SUM_NoQuantity,Date_ModifyDepotBill,No_ModifyDepotBill,Name_Location FROM ModifyDepotBill
  193. LEFT JOIN ModifyDepotBillProduct ON ModifyDepotBillProduct.ID_ModifyDepotBill = ModifyDepotBill.ID_ModifyDepotBill
  194. LEFT JOIN Product ON Product.ID_Product = ModifyDepotBillProduct.ID_Product
  195. LEFT JOIN Location ON Location.ID_Location = ModifyDepotBillProduct.ID_Location
  196. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = ModifyDepotBill.Style_ModifyDepotBill"/>
  197. </Table>
  198. <Table name="UI" Type="Parent">
  199. <GetSchema CmdType="Text" CmdText="SELECT TOP 0 CONVERT(NVARCHAR(64),'') AS StartNo_Product,CONVERT(NVARCHAR(64),'') AS EndNo_Product,CONVERT(NVARCHAR(64),'') AS StartModName_ModifyTypeSettings,CONVERT(NVARCHAR(64),'') AS EndModName_ModifyTypeSettings,
  200. CONVERT(DATETIME,0) AS StartDate,CONVERT(DATETIME,0) AS EndDate "/>
  201. </Table>
  202. </Tables>
  203. <Search>
  204. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
  205. <Tables>
  206. <Table name="AllProduct" />
  207. </Tables>
  208. </SearchAllProduct>
  209. <SearchType CmdType="Text" CmdText="select ModName_ModifyTypeSettings as result from ModifyTypeSettings
  210. UNION SELECT ''">
  211. <Tables>
  212. <Table name="Type" />
  213. </Tables>
  214. </SearchType>
  215. <SearchReceivales CmdType="Text" CmdText="
  216. DECLARE @No_ProductEND nvarchar(64)
  217. declare @ModName_ModifyTypeSettingsEND nvarchar(64)
  218. set @No_ProductEND =(SELECT top 1 No_Product FROM Product order by No_Product desc)
  219. set @ModName_ModifyTypeSettingsEND = (select top 1 ModName_ModifyTypeSettings from ModifyTypeSettings order by ModName_ModifyTypeSettings desc)
  220. IF Object_ID(N' tempdb..#TEMP') IS Not NULL
  221. DROP TABLE #TEMP
  222. CREATE TABLE #TEMP
  223. (
  224. ID_ModifyDepotBilltemp UNIQUEIDENTIFIER,
  225. ID_Producttemp UNIQUEIDENTIFIER,
  226. ID_Locationtemp UNIQUEIDENTIFIER,
  227. Quantity_ModifyDepotBilltemp DECIMAL(14,2),
  228. Quantity_temp DECIMAL(14,2),
  229. NoQuantity_temp DECIMAL(14,2),
  230. )
  231. DECLARE @ID_Product UNIQUEIDENTIFIER
  232. DECLARE @ID_Location UNIQUEIDENTIFIER
  233. DECLARE @ID_ModifyDepotBill UNIQUEIDENTIFIER
  234. DECLARE @Quantity_ModifyDepotBill DECIMAL(14,2)
  235. set @Quantity_ModifyDepotBill = 0
  236. DECLARE @Quantity DECIMAL(14,2)
  237. DECLARE @NoQuantity DECIMAL(14,2)
  238. set @NoQuantity = 0
  239. DECLARE @ModName_ModifyTypeSettings NVARCHAR(64)
  240. DECLARE @STR NVARCHAR(400)
  241. DECLARE CUR CURSOR FOR SELECT ModName_ModifyTypeSettings,Product.ID_Product,Location.ID_Location,ModifyDepotBill.ID_ModifyDepotBill,SUM_Quantity_ModifyDepotBillProduct,0,0 FROM (SELECT ID_Product,ID_Location,ID_ModifyDepotBill,SUM(Quantity_ModifyDepotBillProduct) AS SUM_Quantity_ModifyDepotBillProduct FROM ModifyDepotBillProduct GROUP BY ID_Product,ID_Location,ID_ModifyDepotBill) L
  242. LEFT JOIN ModifyDepotBill ON ModifyDepotBill.ID_ModifyDepotBill = L.ID_ModifyDepotBill
  243. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = ModifyDepotBill.Style_ModifyDepotBill
  244. LEFT JOIN Product ON Product.ID_Product= L.ID_Product
  245. LEFT JOIN Location ON Location.ID_Location = L.ID_Location
  246. WHERE ModifyDepotBill.ID_Assessor IS NOT NULL AND No_Product &gt;= isnull(@StartProductNo,'') AND No_Product &lt;= isnull(@EndProductNo,@No_ProductEND) and ModName_ModifyTypeSettings &gt;= isnull(@StartModifyTypeSettings,'') and ModName_ModifyTypeSettings &lt;= isnull(@EndModifyTypeSettings,@ModName_ModifyTypeSettingsEND)
  247. and ModifyDepotBill.Date_ModifyDepotBill &gt;= DateAdd(day,DateDiff(day,0,convert(nvarchar(64),isnull(@StartDate,''))),0) and ModifyDepotBill.Date_ModifyDepotBill &lt;= DateAdd(day,DateDiff(day,0,isnull(@EndDate,getdate())+1),0)
  248. OPEN CUR
  249. FETCH NEXT FROM CUR INTO @ModName_ModifyTypeSettings,@ID_Product,@ID_Location,@ID_ModifyDepotBill,@Quantity_ModifyDepotBill,@Quantity,@NoQuantity
  250. WHILE @@FETCH_STATUS = 0
  251. BEGIN
  252. IF(@ModName_ModifyTypeSettings = '借入' OR @ModName_ModifyTypeSettings = '借出')
  253. BEGIN
  254. IF(@ModName_ModifyTypeSettings = '借入')
  255. BEGIN
  256. IF EXISTS (SELECT * FROM ModifyDepotBill X
  257. LEFT JOIN ModifyDepotBill Y ON X.No_ModifyDepotBill = Y.Source_ModifyDepotBill
  258. LEFT JOIN ModifyDepotBillProduct B ON B.ID_ModifyDepotBill = Y.ID_ModifyDepotBill
  259. LEFT JOIN Product ON Product.ID_Product = B.ID_Product
  260. LEFT JOIN ModifyTypeSettings D ON D.ID_ModifyTypeSettings = Y.Style_ModifyDepotBill
  261. WHERE X.ID_Assessor IS NOT NULL AND Y.ID_Assessor IS NOT NULL AND D.ModName_ModifyTypeSettings = '借入归还' AND B.ID_Product = @ID_Product AND X.ID_ModifyDepotBill = @ID_ModifyDepotBill)
  262. BEGIN
  263. SELECT @Quantity=B.SUM_Quantity FROM ModifyDepotBill X
  264. LEFT JOIN ModifyDepotBill Y ON X.No_ModifyDepotBill = Y.Source_ModifyDepotBill
  265. LEFT JOIN ModifyDepotBillProduct ON ModifyDepotBillProduct.ID_ModifyDepotBill = Y.ID_ModifyDepotBill
  266. LEFT JOIN (SELECT ID_Product,SUM(Quantity_ModifyDepotBillProduct) AS SUM_Quantity FROM ModifyDepotBillProduct
  267. LEFT JOIN ModifyDepotBill YY ON YY.ID_ModifyDepotBill = ModifyDepotBillProduct.ID_ModifyDepotBill
  268. LEFT JOIN ModifyDepotBill XX ON XX.No_ModifyDepotBill = YY.Source_ModifyDepotBill
  269. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = YY.Style_ModifyDepotBill
  270. WHERE YY.ID_Assessor IS NOT NULL AND ModName_ModifyTypeSettings = '借入归还' AND XX.ID_ModifyDepotBill = @ID_ModifyDepotBill
  271. GROUP BY ID_Product) B ON B.ID_Product = ModifyDepotBillProduct.ID_Product
  272. WHERE X.ID_Assessor IS NOT NULL AND Y.ID_Assessor IS NOT NULL AND B.ID_Product = @ID_Product AND X.ID_ModifyDepotBill = @ID_ModifyDepotBill
  273. END
  274. END
  275. IF(@ModName_ModifyTypeSettings = '借出')
  276. BEGIN
  277. IF EXISTS (SELECT * FROM ModifyDepotBill X
  278. LEFT JOIN ModifyDepotBill Y ON X.No_ModifyDepotBill = Y.Source_ModifyDepotBill
  279. LEFT JOIN ModifyDepotBillProduct B ON B.ID_ModifyDepotBill = Y.ID_ModifyDepotBill
  280. LEFT JOIN Product ON Product.ID_Product = B.ID_Product
  281. LEFT JOIN ModifyTypeSettings D ON D.ID_ModifyTypeSettings = Y.Style_ModifyDepotBill
  282. WHERE X.ID_Assessor IS NOT NULL AND Y.ID_Assessor IS NOT NULL AND D.ModName_ModifyTypeSettings = '借出归还' AND B.ID_Product = @ID_Product AND X.ID_ModifyDepotBill = @ID_ModifyDepotBill)
  283. BEGIN
  284. SELECT @Quantity=B.SUM_Quantity FROM ModifyDepotBill X
  285. LEFT JOIN ModifyDepotBill Y ON X.No_ModifyDepotBill = Y.Source_ModifyDepotBill
  286. LEFT JOIN ModifyDepotBillProduct ON ModifyDepotBillProduct.ID_ModifyDepotBill = Y.ID_ModifyDepotBill
  287. LEFT JOIN (SELECT ID_Product,SUM(Quantity_ModifyDepotBillProduct) AS SUM_Quantity FROM ModifyDepotBillProduct
  288. LEFT JOIN ModifyDepotBill YY ON YY.ID_ModifyDepotBill = ModifyDepotBillProduct.ID_ModifyDepotBill
  289. LEFT JOIN ModifyDepotBill XX ON XX.No_ModifyDepotBill = YY.Source_ModifyDepotBill
  290. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = YY.Style_ModifyDepotBill
  291. WHERE YY.ID_Assessor IS NOT NULL AND ModName_ModifyTypeSettings = '借出归还' AND XX.ID_ModifyDepotBill = @ID_ModifyDepotBill
  292. GROUP BY ID_Product) B ON B.ID_Product = ModifyDepotBillProduct.ID_Product
  293. WHERE X.ID_Assessor IS NOT NULL AND Y.ID_Assessor IS NOT NULL AND B.ID_Product = @ID_Product AND X.ID_ModifyDepotBill = @ID_ModifyDepotBill
  294. END
  295. END
  296. SET @NoQuantity = @Quantity_ModifyDepotBill - @Quantity
  297. END
  298. SET @STR = N'INSERT INTO #TEMP VALUES(@TID_ModifyDepotBilltemp,@TID_Producttemp,@TID_Locationtemp,@TQuantity_ModifyDepotBilltemp,@TQuantity_temp,@TNoQuantity_temp)'
  299. EXECUTE sp_executesql @STR,N'@TID_ModifyDepotBilltemp UNIQUEIDENTIFIER,@TID_Producttemp UNIQUEIDENTIFIER,@TID_Locationtemp UNIQUEIDENTIFIER,@TQuantity_ModifyDepotBilltemp DECIMAL(14,2),@TQuantity_temp DECIMAL(14,2),@TNoQuantity_temp DECIMAL(14,2)',@ID_ModifyDepotBill,@ID_Product,@ID_Location,@Quantity_ModifyDepotBill,@Quantity,@NoQuantity
  300. FETCH NEXT FROM CUR INTO @ModName_ModifyTypeSettings,@ID_Product,@ID_Location,@ID_ModifyDepotBill,@Quantity_ModifyDepotBill,@Quantity,@NoQuantity
  301. END
  302. CLOSE CUR
  303. DEALLOCATE CUR
  304. SELECT ModName_ModifyTypeSettings,Comment_ModifyDepotBill,No_Product,Name_Product,Quantity_ModifyDepotBilltemp as SUM_Quantity_ModifyDepotBillProduct,Quantity_temp as SUM_Quantity,NoQuantity_temp as SUM_NoQuantity,DATEADD(day, 0, convert(nvarchar(10),Date_ModifyDepotBill,20)) as Date_ModifyDepotBill,No_ModifyDepotBill,Name_Location FROM #TEMP
  305. LEFT JOIN ModifyDepotBill ON #TEMP.ID_ModifyDepotBilltemp = ModifyDepotBill.ID_ModifyDepotBill
  306. LEFT JOIN Product ON Product.ID_Product = #TEMP.ID_Producttemp
  307. LEFT JOIN Location ON Location.ID_Location = #TEMP.ID_Locationtemp
  308. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = ModifyDepotBill.Style_ModifyDepotBill
  309. DROP TABLE #TEMP
  310. ">
  311. <Params>
  312. <Param name="@StartProductNo" type="Product.No_Product" Index="0" />
  313. <Param name="@EndProductNo" type="Product.No_Product" Index="1" />
  314. <Param name="@StartModifyTypeSettings" type="ModifyTypeSettings.ModName_ModifyTypeSettings" Index="2" />
  315. <Param name="@EndModifyTypeSettings" type="ModifyTypeSettings.ModName_ModifyTypeSettings" Index="3" />
  316. <Param name="@StartDate" type="SaleBill.AssessDate_SaleBill" Index="4" />
  317. <Param name="@EndDate" type="SaleBill.AssessDate_SaleBill" Index="5" />
  318. </Params>
  319. <Tables>
  320. <Table name="Total"/>
  321. </Tables>
  322. </SearchReceivales>
  323. </Search>
  324. </Server>
  325. <Lables>
  326. <Search>
  327. </Search>
  328. </Lables>
  329. </Form>
  330. </Forms>