FrmInventorySearch.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmInventorySearch">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="库存异动查询";
  9. GetSchema();
  10. Search("SearchLocation");
  11. SuspendLayout();
  12. for(@i=0;@i<RowCount("#Location");@i=@i+1)
  13. {
  14. SetPosition("#Location", @i);
  15. cbLocation.Items.Add(#Location.Name_Location);
  16. }
  17. ResumeLayout();
  18. Search("SearchType");
  19. Search("SearchLowLocation");
  20. Empty();
  21. EndDate.Value=GetCurrentTime();
  22. StartDate.Value=GetCurrentTime();
  23. cbLocation.Text = GetCurrentDepot();
  24. ]]>
  25. </Load>
  26. <Closing>
  27. ;<!--TODO-->
  28. </Closing>
  29. <Closed>
  30. ;<!--TODO-->
  31. </Closed>
  32. </Events>
  33. <Mode>
  34. <Search>
  35. <Lable name="Search" />
  36. </Search>
  37. </Mode>
  38. <Controls>
  39. <!--<IKCheckedListBox name="CLB_Location" DataSource="Location" DisplayMember="Name_location" ValueMember="ID_Location">
  40. <Events>
  41. <ItemCheck>
  42. if(CLB_Location.SelectedIndex == 0)
  43. CLB_Location.SelectAllItems();
  44. </ItemCheck>
  45. </Events>
  46. </IKCheckedListBox>-->
  47. <IKComboBox name ="cbLocation" DataSource="Location" DisplayMember="Name_Location" >
  48. </IKComboBox>
  49. <IKTextButton name="tbLocationNo1" DataSource="LowLocation.No_Location">
  50. <Events>
  51. <Click>
  52. <![CDATA[
  53. if (tbLocationNo1.ReadOnly == false)
  54. {
  55. @temp = ShowSearchBox("LocationSearch","INFOMATION",tbLocationNo1.CValue,cbLocation.SelectedItem);
  56. if( @temp == "" )
  57. return;
  58. tbLocationNo1.CValue = @temp;
  59. }
  60. ]]>
  61. </Click>
  62. </Events>
  63. </IKTextButton>
  64. <IKTextButton name="tbLocationNo2" DataSource="LowLocation.No_Location">
  65. <Events>
  66. <Click>
  67. <![CDATA[
  68. if (tbLocationNo2.ReadOnly == false)
  69. {
  70. @temp = ShowSearchBox("LocationSearch","INFOMATION",tbLocationNo2.CValue,cbLocation.SelectedItem);
  71. if( @temp == "" )
  72. return;
  73. tbLocationNo2.CValue = @temp;
  74. }
  75. ]]>
  76. </Click>
  77. </Events>
  78. </IKTextButton>
  79. <IKComboBoxEx name="cbType1" DataSource="Type" DisplayMember="Name_TypeDef" />
  80. <IKComboBoxEx name="cbType2" DataSource="Type" DisplayMember="Name_TypeDef" />
  81. <IKExtendGrid name="dgProduct" DataSource="Total" TableStyleIndex="0">
  82. <DataColumn Index="0" DataSource="Total.No_Product"/>
  83. <DataColumn Index="1" DataSource="Total.Name_Product"/>
  84. <DataColumn Index="2" DataSource="Total.Type_Product"/>
  85. <DataColumn Index="3" DataSource="Total.No_Location"/>
  86. <DataColumn Index="4" DataSource="Total.OpeningStockQty_ProductStocks"/>
  87. <DataColumn Index="5" DataSource="Total.Quantity_SaleOutDepotBillProduct"/>
  88. <DataColumn Index="6" DataSource="Total.OutQuantity_ModifyDepotBillProduct"/>
  89. <DataColumn Index="7" DataSource="Total.Quantity_PurchaseInDepotBillProduct"/>
  90. <DataColumn Index="8" DataSource="Total.InQuantity_ModifyDepotBillProduct"/>
  91. <DataColumn Index="9" DataSource="Total.InQuantity_StocktakingBillProduct"/>
  92. <DataColumn Index="10" DataSource="Total.OutQuantity_StocktakingBillProduct"/>
  93. <DataColumn Index="11" DataSource="Total.StockQty_ProductStocks"/>
  94. <Events>
  95. <ClickPreview>
  96. PrintReport(dgProduct.CurrentView);
  97. </ClickPreview>
  98. <ClickRefresh>
  99. Empty();
  100. <Lable name="btnActionClick"/>
  101. </ClickRefresh>
  102. <ClickFilter>
  103. txtSum.CValue=SumOfCol("#Total.Quantity_RealSale",dgProduct.FilterCondition,true);
  104. </ClickFilter>
  105. <ClickNOFilter>
  106. txtSum.CValue=SumOfCol("#Total.Quantity_RealSale",dgProduct.FilterCondition,true);
  107. </ClickNOFilter>
  108. </Events>
  109. </IKExtendGrid>
  110. <IKButton name="btnAction">
  111. <Events>
  112. <Click>
  113. <Lable name="btnActionClick"/>
  114. </Click>
  115. </Events>
  116. </IKButton>
  117. <IKButton name="btnEmpty">
  118. <Events>
  119. <Click>
  120. Empty();
  121. </Click>
  122. </Events>
  123. </IKButton>
  124. </Controls>
  125. <ChildForms>
  126. <ChildForm name="LocationSearch" DataSource="Location" SearchFunction="SearchAllLocation" SearchFunctionByNo="" MappingName="库位" >
  127. <DataColumn Index="0" MappingName="#Location.No_Location" HeaderText="库位编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#LowLocation.No_Location"/>
  128. <DataColumn Index="1" MappingName="#Location.Name_Location" HeaderText="库位名称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  129. </ChildForm>
  130. </ChildForms>
  131. </Client>
  132. <Server>
  133. <Tables>
  134. <Table name="Total" Type="Parent">
  135. <GetSchema CmdType="Text" CmdText="
  136. Select Top 0 Product.No_Product,Product.Name_Product,Product.Type_Product,Product.Cost_Product,ProductStocks.OpeningAvailableQty_ProductStocks,OpeningStockQty_ProductStocks,ProductStocks.AvailableQty_ProductStocks,StockQty_ProductStocks,SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct,
  137. a.Quantity_ModifyDepotBillProduct As OutQuantity_ModifyDepotBillProduct,b.Quantity_ModifyDepotBillProduct As InQuantity_ModifyDepotBillProduct,PurchaseInDepotBillProduct.Quantity_PurchaseInDepotBillProduct,
  138. c.Quantity_StocktakingBillProduct As OutQuantity_StocktakingBillProduct,d.Quantity_StocktakingBillProduct As InQuantity_StocktakingBillProduct,No_Location
  139. From Product
  140. Left Join ProductStocks On ProductStocks.ID_Product=Product.ID_Product
  141. Left Join SaleOutDepotBillProduct On SaleOutDepotBillProduct.ID_Product=Product.ID_Product
  142. Left Join SaleRtnBillProduct On SaleRtnBillProduct.ID_Product=Product.ID_Product
  143. Left Join ModifyDepotBillProduct a On a.ID_Product=Product.ID_Product
  144. Left Join ModifyDepotBillProduct b On b.ID_Product=Product.ID_Product
  145. Left Join PurchaseInDepotBillProduct On PurchaseInDepotBillProduct.ID_Product=Product.ID_Product
  146. Left Join StocktakingBillProduct c ON c.ID_Product=Product.ID_Product
  147. Left Join StocktakingBillProduct d On d.ID_Product=Product.ID_Product
  148. Left Join Location On Location.ID_Location = ProductStocks.ID_Location
  149. "/>
  150. </Table>
  151. </Tables>
  152. <Search>
  153. <SearchLocation CmdType="Text" CmdText="Select Name_Location,No_Location from Location where Level_Location = 0
  154. Union Select '全部' As Name_Location, '00' As No_Location">
  155. <Tables>
  156. <Table name="Location"/>
  157. </Tables>
  158. </SearchLocation>
  159. <SearchType CmdType="Text" CmdText=" SELECT Name_TypeDef From TypeDef Where Type_TypeDef=8 Order By Name_TypeDef ">
  160. <Tables>
  161. <Table name="Type"/>
  162. </Tables>
  163. </SearchType>
  164. <SearchAllLocation CmdType="Text" CmdText="Select No_Location,Name_Location
  165. From Location Where ID_Warehouse IN(
  166. Select ID_Location
  167. From Location
  168. ">
  169. <Tables>
  170. <Table name="AllLocation" />
  171. </Tables>
  172. </SearchAllLocation>
  173. <SearchLowLocation CmdType="" CmdText="Select No_Location From Location Where Level_Location = 1">
  174. <Tables>
  175. <Table name="LowLocation"/>
  176. </Tables>
  177. </SearchLowLocation>
  178. </Search>
  179. </Server>
  180. <Lables>
  181. <Search>
  182. </Search>
  183. <btnActionClick>
  184. @LocationAll = " la.No_Location In (Select No_Location From Location Where Level_Location = 0)" ;
  185. if(cbLocation.SelectedItem == "全部")
  186. {
  187. @Location = "x.Level_Location = 1";
  188. }
  189. else
  190. {
  191. @Location = " x.Level_Location = 1 And x.No_Location BETWEEN ISNULL(@StartNo_Location,x.No_Location) AND ISNULL(@EndNo_Location,x.No_Location) And s.Name_Location = '" + cbLocation.SelectedItem + "'";
  192. }
  193. @dateCondition=" between "+" DATEADD(day,0,DATEDIFF(day,0,"+"'"+TypeConvert("String",StartDate.Value)+"'"+")) and "+" DATEADD(day,0,(DATEDIFF(day,0,"+"'"+TypeConvert("String",EndDate.Value)+"'"+")+1))";
  194. @bisNow=" &lt;= DATEADD(day,0,(DATEDIFF(day,0,'"+TypeConvert("String",EndDate.Value)+"')+1))";
  195. @sqlCmd=" Declare @StartNo_Location Nvarchar(64) Set @StartNo_Location = Null"
  196. +" Declare @EndNo_Location Nvarchar(64) Set @EndNo_Location = Null";
  197. if(tbLocationNo1.CValue != "")
  198. {
  199. @sqlCmd = @sqlCmd + " Set @StartNo_Location ='" +tbLocationNo1.CValue+"'";
  200. }
  201. if(tbLocationNo2.CValue != "")
  202. {
  203. @sqlCmd = @sqlCmd + " Set @EndNo_Location ='" +tbLocationNo2.CValue+"'";
  204. }
  205. @sqlCmd =@sqlCmd +" Select No_Location,Product.No_Product,Product.Name_Product,Product.Type_Product,Product.Cost_Product,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)+IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)-IsNull(h.Quantity_PurchaseInDepotBillProduct,0)-IsNull(e.InQuantity_ModifyDepotBillProduct,0)) As OpeningStockQty_ProductStocks ,(IsNull(b.OpeningStockQty_ProductStocks,0)-IsNull(d1.Quantity_SaleOutDepotBillProduct,0)-IsNull(f1.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h1.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e1.InQuantity_ModifyDepotBillProduct,0)) As StockQty_ProductStocks,"
  206. +" IsNull(d.Quantity_SaleOutDepotBillProduct,0) As Quantity_SaleOutDepotBillProduct,IsNull(e.InQuantity_ModifyDepotBillProduct,0) As InQuantity_ModifyDepotBillProduct,IsNull(f.OutQuantity_ModifyDepotBillProduct,0) As OutQuantity_ModifyDepotBillProduct,"
  207. +" IsNull(h.Quantity_PurchaseInDepotBillProduct,0) As Quantity_PurchaseInDepotBillProduct,IsNull(i.InQuantity_StocktakingBillProduct,0) As InQuantity_StocktakingBillProduct,IsNull(j.OutQuantity_StocktakingBillProduct,0) As OutQuantity_StocktakingBillProduct"
  208. +" From "
  209. +" ( "
  210. +" Select ID_Product,ID_Location From ProductStocks"
  211. +" )a"
  212. +" Left Join Product On Product.ID_Product = a.ID_Product"
  213. +" Join"
  214. +" ("
  215. +" Select ID_Location,ProductStocks.ID_Product,Sum(OpeningStockQty_ProductStocks) As OpeningStockQty_ProductStocks"
  216. +" From ProductStocks"
  217. +" Where ID_Location IN("
  218. +" Select x.ID_Location From Location x"
  219. +" Left Join Location s On x.ID_Warehouse = s.ID_Location Where "
  220. + @Location
  221. +" )"
  222. +" Group By ID_Product,ID_Location"
  223. +" )b On a.ID_Product=b.ID_Product And a.ID_Location = b.ID_Location"
  224. +" Left Join"
  225. +" ("
  226. +" Select lb.ID_Location,SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
  227. +" From SaleOutDepotBillProduct"
  228. +" Left Join Location lb On lb.ID_Location = SaleOutDepotBillProduct.ID_Location"
  229. +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
  230. +" Join Location la On la.ID_Location=SaleOutDepotBill.ID_Location"
  231. +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@dateCondition+ " And "+@LocationAll
  232. +" Group By SaleOutDepotBillProduct.ID_Product,lb.ID_Location"
  233. +" )d On a.ID_Product=d.ID_Product And a.ID_Location = d.ID_Location"
  234. +" Left Join"
  235. +" ("
  236. +" Select lb.ID_Location,ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
  237. +" From ModifyDepotBillProduct"
  238. +" Left Join Location lb On lb.ID_Location = ModifyDepotBillProduct.ID_Location"
  239. +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
  240. +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
  241. +" Join Location la On la.ID_Location=ModifyDepotBill.ID_Location"
  242. +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@dateCondition+ " And "+@LocationAll
  243. +" Group By ModifyDepotBillProduct.ID_Product,lb.ID_Location"
  244. +" )e On a.ID_Product=e.ID_Product And a.ID_Location = e.ID_Location"
  245. +" Left Join"
  246. +" ("
  247. +" Select lb.ID_Location,ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
  248. +" From ModifyDepotBillProduct"
  249. +" Left Join Location lb On lb.ID_Location = ModifyDepotBillProduct.ID_Location"
  250. +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
  251. +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
  252. +" Join Location la On la.ID_Location=ModifyDepotBill.ID_Location"
  253. +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@dateCondition+ " And "+@LocationAll
  254. +" Group By ModifyDepotBillProduct.ID_Product,lb.ID_Location"
  255. +" )f On a.ID_Product=f.ID_Product And a.ID_Location = f.ID_Location"
  256. +" Left Join"
  257. +" ("
  258. +" Select lb.ID_Location,PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
  259. +" From PurchaseInDepotBillProduct"
  260. +" Left Join Location lb On lb.ID_Location = PurchaseInDepotBillProduct.ID_Location"
  261. +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
  262. +" Join Location la On la.ID_Location=PurchaseInDepotBill.ID_Location"
  263. +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@dateCondition+ " And "+@LocationAll
  264. +" Group By PurchaseInDepotBillProduct.ID_Product,lb.ID_Location"
  265. +" )h On a.ID_Product=h.ID_Product And a.ID_Location = h.ID_Location"
  266. +" Left Join"
  267. +" ("
  268. +" Select lb.ID_Location,StocktakingBillProduct.ID_Product,Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As InQuantity_StocktakingBillProduct"
  269. +" From StocktakingBillProduct"
  270. +" Left Join Location lb On lb.ID_Location = StocktakingBillProduct.ID_Location"
  271. +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
  272. +" Join Location la On la.ID_Location=StocktakingBill.ID_Location"
  273. +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) &gt; 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@LocationAll
  274. +" Group By StocktakingBillProduct.ID_Product,lb.ID_Location"
  275. +" )i On a.ID_Product=i.ID_Product And a.ID_Location = i.ID_Location"
  276. +" Left Join"
  277. +" ("
  278. +" Select lb.ID_Location,StocktakingBillProduct.ID_Product,-Sum(StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) As OutQuantity_StocktakingBillProduct"
  279. +" From StocktakingBillProduct"
  280. +" Left Join Location lb On lb.ID_Location = StocktakingBillProduct.ID_Location"
  281. +" Join StocktakingBill On StocktakingBill.ID_StocktakingBill=StocktakingBillProduct.ID_StocktakingBill"
  282. +" Join Location la On la.ID_Location=StocktakingBill.ID_Location"
  283. +" Where StocktakingBill.ID_Assessor Is Not Null And (StocktakingBillProduct.Quantity_StocktakingBillProduct-StocktakingBillProduct.StockQty_StocktakingBillProduct) &lt; 0 And StocktakingBill.Date_StocktakingBill "+@dateCondition+ " And "+@LocationAll
  284. +" Group By StocktakingBillProduct.ID_Product,lb.ID_Location"
  285. +" )j On a.ID_Product=j.ID_Product And a.ID_Location = i.ID_Location"
  286. +" Left Join"
  287. +" ("
  288. +" Select lb.ID_Location,SaleOutDepotBillProduct.ID_Product,Sum(SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct) As Quantity_SaleOutDepotBillProduct"
  289. +" From SaleOutDepotBillProduct"
  290. +" Left Join Location lb On lb.ID_Location = SaleOutDepotBillProduct.ID_Location"
  291. +" Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill"
  292. +" Join Location la On la.ID_Location=SaleOutDepotBill.ID_Location"
  293. +" Where SaleOutDepotBill.ID_Assessor Is Not Null And SaleOutDepotBill.Date_SaleOutDepotBill "+@bisNow+ " And "+@LocationAll
  294. +" Group By SaleOutDepotBillProduct.ID_Product,lb.ID_Location"
  295. +" )d1 On a.ID_Product=d1.ID_Product And a.ID_Location = d1.ID_Location"
  296. +" Left Join"
  297. +" ("
  298. +" Select lb.ID_Location,ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As InQuantity_ModifyDepotBillProduct"
  299. +" From ModifyDepotBillProduct"
  300. +" Left Join Location lb On lb.ID_Location = ModifyDepotBillProduct.ID_Location"
  301. +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
  302. +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
  303. +" Join Location la On la.ID_Location=ModifyDepotBill.ID_Location"
  304. +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=1 And Date_ModifyDepotBill "+@bisNow+ " And "+@LocationAll
  305. +" Group By ModifyDepotBillProduct.ID_Product,lb.ID_Location"
  306. +" )e1 On a.ID_Product=e1.ID_Product And a.ID_Location = e1.ID_Location"
  307. +" Left Join"
  308. +" ("
  309. +" Select lb.ID_Location,ModifyDepotBillProduct.ID_Product,Sum(Quantity_ModifyDepotBillProduct) As OutQuantity_ModifyDepotBillProduct"
  310. +" From ModifyDepotBillProduct"
  311. +" Left Join Location lb On lb.ID_Location = ModifyDepotBillProduct.ID_Location"
  312. +" Join ModifyDepotBill On ModifyDepotBillProduct.ID_ModifyDepotBill=ModifyDepotBill.ID_ModifyDepotBill"
  313. +" Join ModifyTypeSettings On ModifyTypeSettings.ID_ModifyTypeSettings=ModifyDepotBill.Style_ModifyDepotBill"
  314. +" Join Location la On la.ID_Location=ModifyDepotBill.ID_Location"
  315. +" Where ModifyDepotBill.ID_Assessor Is Not Null And ModifyTypeSettings.Type_ModifyTypeSettings=0 And Date_ModifyDepotBill "+@bisNow+ " And "+@LocationAll
  316. +" Group By ModifyDepotBillProduct.ID_Product,lb.ID_Location"
  317. +" )f1 On a.ID_Product=f1.ID_Product And a.ID_Location = f1.ID_Location"
  318. +" Left Join"
  319. +" ("
  320. +" Select lb.ID_Location,PurchaseInDepotBillProduct.ID_Product,Sum(Quantity_PurchaseInDepotBillProduct) As Quantity_PurchaseInDepotBillProduct"
  321. +" From PurchaseInDepotBillProduct"
  322. +" Left Join Location lb On lb.ID_Location = PurchaseInDepotBillProduct.ID_Location"
  323. +" Join PurchaseInDepotBill On PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill"
  324. +" Join Location la On la.ID_Location=PurchaseInDepotBill.ID_Location"
  325. +" Where PurchaseInDepotBill.ID_Assessor Is Not Null And PurchaseInDepotBill.Date_PurchaseInDepotBill "+@bisNow+ " And "+@LocationAll
  326. +" Group By PurchaseInDepotBillProduct.ID_Product,lb.ID_Location"
  327. +" )h1 On a.ID_Product=h1.ID_Product And a.ID_Location = h1.ID_Location"
  328. +" Left Join Location On Location.ID_Location = a.ID_Location";
  329. @where=true;
  330. if(cbType1.Text!="")
  331. {
  332. if(@where==true)
  333. {
  334. @sqlCmd=@sqlCmd+" Where Type_Product &gt;=" +"'"+cbType1.Text+"'";
  335. @where=false;
  336. }
  337. else
  338. {
  339. @sqlCmd=@sqlCmd+" And Type_Product &gt;=" +"'"+cbType1.Text+"'";
  340. }
  341. }
  342. if(cbType2.Text!="")
  343. {
  344. if(@where==true)
  345. {
  346. @sqlCmd=@sqlCmd+" Where Type_Product &lt;="+"'"+cbType2.Text+"'";
  347. @where=false;
  348. }
  349. else
  350. {
  351. @sqlCmd=@sqlCmd+" And Type_Product &lt;="+"'"+cbType2.Text+"'";
  352. }
  353. }
  354. if(ckSuspend.Checked)
  355. {
  356. if(@where==true)
  357. {
  358. @sqlCmd=@sqlCmd+" Where (IsNull(IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0),0)) &gt; 0 ";
  359. @where=false;
  360. }
  361. else
  362. {
  363. @sqlCmd=@sqlCmd+" And (IsNull(d.Quantity_SaleOutDepotBillProduct,0)+IsNull(f.OutQuantity_ModifyDepotBillProduct,0)+IsNull(h.Quantity_PurchaseInDepotBillProduct,0)+IsNull(e.InQuantity_ModifyDepotBillProduct,0)+IsNull(i.InQuantity_StocktakingBillProduct,0)+IsNull(j.OutQuantity_StocktakingBillProduct,0),0)) &gt; 0 ";
  364. }
  365. }
  366. @sqlCmd=@sqlCmd+" Order By Product.No_Product ";
  367. MessageBox(@sqlCmd,@Title);
  368. SearchEx(@sqlCmd,"Total");
  369. </btnActionClick>
  370. </Lables>
  371. </Form>
  372. </Forms>