FrmProductInventory.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Forms>
  3. <Form Name="FrmProductInventory">
  4. <Client>
  5. <Events>
  6. <Load><![CDATA[
  7. @Title="产品库存查询";
  8. GetSchema();
  9. ChangeMode("Search");
  10. RecordHistoryRead("FrmProductInventory");
  11. Search("SearchCessOut");
  12. @cessout = #System.CessOut_SystemSetting;
  13. ]]></Load>
  14. <Closing>
  15. RecordHistoryWrite("FrmProductInventory","dtStart","dtEnd","ckNearly","tbNearly"
  16. ,"ckPriceQuery","ckIndent","ckSaleBill","ckSaleRtn","ckPQuery","ckpurchase","ckInventory","ckSaleOut","ckPurchIn");
  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">
  29. <Events>
  30. <Click>
  31. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct1.CValue);
  32. if( @temp == "" )
  33. return;
  34. tbProduct1.CValue = @temp;
  35. </Click>
  36. <Enter>
  37. tbProduct2.CValue = tbProduct1.CValue;
  38. </Enter>
  39. <TextBoxButtonTextChanged>
  40. </TextBoxButtonTextChanged>
  41. </Events>
  42. </IKTextButton>
  43. <IKTextButton name="tbProduct2">
  44. <Events>
  45. <Click>
  46. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProduct2.CValue);
  47. if( @temp == "" )
  48. return;
  49. tbProduct2.CValue = @temp;
  50. </Click>
  51. </Events>
  52. </IKTextButton>
  53. <IKTextButton name="tbPName1">
  54. <Events>
  55. <Click>
  56. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbPName1.CValue);
  57. if( @temp == "" )
  58. return;
  59. tbPName1.CValue = @temp;
  60. </Click>
  61. <TextBoxButtonTextChanged>
  62. </TextBoxButtonTextChanged>
  63. </Events>
  64. </IKTextButton>
  65. <IKTextButton name="tbPName2">
  66. <Events>
  67. <Click>
  68. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbPName2.CValue);
  69. if( @temp == "" )
  70. return;
  71. tbPName2.CValue = @temp;
  72. </Click>
  73. </Events>
  74. </IKTextButton>
  75. <IKComboBoxEx name="cbType1" DataSource="Type" DisplayMember="Type_Product" >
  76. <Events>
  77. <Reload>
  78. UpdateForm(false, "cbType1");
  79. Search("SearchType");
  80. UpdateForm(true, "cbType1");
  81. </Reload>
  82. <TextChanged>
  83. cbType2.Text = cbType1.Text;
  84. </TextChanged>
  85. </Events>
  86. </IKComboBoxEx>
  87. <IKComboBoxEx name="cbType2" DataSource="Type" DisplayMember="Type_Product" >
  88. <Events>
  89. <Reload>
  90. UpdateForm(false, "cbType2");
  91. Search("SearchType");
  92. UpdateForm(true, "cbType2");
  93. </Reload>
  94. </Events>
  95. </IKComboBoxEx>
  96. <IKButton name="btnSearch">
  97. <Events>
  98. <Click>
  99. Empty();
  100. @StartNo_Product=DBNull();
  101. @EndNo_Product=DBNull();
  102. @StartType_Product=DBNull();
  103. @EndType_Product=DBNull();
  104. if(tbProduct1.CValue!="")
  105. @StartNo_Product=tbProduct1.CValue;
  106. if(tbProduct2.CValue!="")
  107. @EndNo_Product=tbProduct2.CValue;
  108. if(cbType1.Text!="")
  109. @StartType_Product=cbType1.Text;
  110. if(cbType2.Text!="")
  111. @EndType_Product=cbType2.Text;
  112. @StartName_Product=tbPName1.CValue==""?DBNull():tbPName1.CValue;
  113. @EndName_Product=tbPName2.CValue==""?DBNull():tbPName2.CValue;
  114. Search("SearchProductInventory",@StartNo_Product,@EndNo_Product,@StartType_Product,@EndType_Product,@StartName_Product,@EndName_Product);
  115. if(RowCount("#FrmProductInventory") == 0)
  116. MessageBox("不存在符合查询条件的记录!");
  117. </Click>
  118. </Events>
  119. </IKButton>
  120. <IKButton name="btnEmpty">
  121. <Events>
  122. <Click>
  123. ChangeMode("Search");
  124. tbProduct1.CValue="";
  125. tbProduct2.CValue="";
  126. cbType1.Text="";
  127. cbType2.Text="";
  128. tbPName1.CValue="";
  129. tbPName2.CValue="";
  130. </Click>
  131. </Events>
  132. </IKButton>
  133. <IKDataGridEx name="dgHistory" DataSource="ExchangeHistory" TableStyleIndex="0">
  134. <DataColumn Index="0" DataSource="ExchangeHistory.Date" />
  135. <DataColumn Index="1" DataSource="ExchangeHistory.Name_Bill" />
  136. <DataColumn Index="2" DataSource="ExchangeHistory.No_Bill" />
  137. <DataColumn Index="3" DataSource="ExchangeHistory.No_CustomerOrSupprier" />
  138. <DataColumn Index="4" DataSource="ExchangeHistory.shortname" />
  139. <DataColumn Index="5" DataSource="ExchangeHistory.num" />
  140. <DataColumn Index="6" DataSource="ExchangeHistory.price" />
  141. <DataColumn Index="7" DataSource="ExchangeHistory.TaxCurrency" />
  142. <DataColumn Index="8" DataSource="ExchangeHistory.Comment" />
  143. <Events>
  144. <RowHeaderDoubleClick>
  145. DgDoubleClick(#ExchangeHistory.Name_Bill,#ExchangeHistory.No_Bill);
  146. </RowHeaderDoubleClick>
  147. </Events>
  148. </IKDataGridEx>
  149. <IKButton name="btSearch">
  150. <Events>
  151. <Click>
  152. <![CDATA[
  153. Empty("#ExchangeHistory");
  154. @cktn = 0;
  155. if(RowCount("#FrmProductInventory")==0)
  156. {
  157. return;
  158. }
  159. @CurrentRowNo=dgProduct.GetCurrentSpecifyValue("No_Product");
  160. ikLabel6.Text = @CurrentRowNo;
  161. ikLabel10.Text = GetCurrentUser();
  162. @Right=TypeConvert("String",GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID());
  163. @RightIndentBill=GetFieldRight("订货单","特价单","查看");
  164. @RightSaleBill=GetFieldRight("销货单","特价单","查看");
  165. @StartTime = DBNull();
  166. @EndTime = DBNull();
  167. if(dtStart.Checked==true)
  168. @StartTime = dtStart.CValue;
  169. if(dtEnd.Checked==true)
  170. @EndTime = dtEnd.CValue;
  171. if(ckNearly.Checked==true)
  172. {
  173. @tbNearly=tbNearly.CValue;
  174. }
  175. if(ckPriceQuery.Checked == true)
  176. {
  177. @cktn = 1;
  178. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  179. {
  180. MergeTable("#searchAllBill","#ExchangeHistory");
  181. }
  182. }
  183. if(ckIndent.Checked == true)
  184. {
  185. @cktn = 2;
  186. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  187. {
  188. MergeTable("#searchAllBill","#ExchangeHistory");
  189. }
  190. }
  191. if(ckSaleBill.Checked == true)
  192. {
  193. @cktn = 3;
  194. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  195. {
  196. MergeTable("#searchAllBill","#ExchangeHistory");
  197. }
  198. }
  199. if(ckSaleRtn.Checked==true)
  200. {
  201. @cktn = 4;
  202. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  203. {
  204. MergeTable("#searchAllBill","#ExchangeHistory");
  205. }
  206. }
  207. if(ckSaleOut.Checked==true)
  208. {
  209. @cktn = 5;
  210. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  211. {
  212. MergeTable("#searchAllBill","#ExchangeHistory");
  213. }
  214. }
  215. if(ckPQuery.Checked==true)
  216. {
  217. @cktn = 6;
  218. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  219. {
  220. MergeTable("#searchAllBill","#ExchangeHistory");
  221. }
  222. }
  223. if(ckpurchase.Checked==true)
  224. {
  225. @cktn = 7;
  226. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  227. {
  228. MergeTable("#searchAllBill","#ExchangeHistory");
  229. }
  230. }
  231. if(ckInventory.Checked==true)
  232. {
  233. @cktn = 8;
  234. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  235. {
  236. MergeTable("#searchAllBill","#ExchangeHistory");
  237. }
  238. }
  239. if(ckPurchIn.Checked==true)
  240. {
  241. @cktn = 9;
  242. if(Search("searchAllBill",ikLabel6.Text,GetCurrentUser(),@cktn,@StartTime,@EndTime))
  243. {
  244. MergeTable("#searchAllBill","#ExchangeHistory");
  245. }
  246. }
  247. if(RowCount("#ExchangeHistory") == 0)
  248. MessageBox("不存在符合查询条件的记录!");
  249. ]]></Click>
  250. </Events>
  251. </IKButton>
  252. <IKExtendGrid name="dgProduct" DataSource="FrmProductInventory" TableStyleIndex="0">
  253. <DataColumn Index="0" DataSource="FrmProductInventory.No_Product"/>
  254. <DataColumn Index="1" DataSource="FrmProductInventory.Name_Product"/>
  255. <DataColumn Index="2" DataSource="FrmProductInventory.AvailableQty_ProductStocks"/>
  256. <DataColumn Index="3" DataSource="FrmProductInventory.StockQty_ProductStocks"/>
  257. <DataColumn Index="4" DataSource="FrmProductInventory.OnShipQty_Product"/>
  258. <DataColumn Index="5" DataSource="FrmProductInventory.Quantity_NoSaleOutDepot"/>
  259. <DataColumn Index="6" DataSource="FrmProductInventory.Quantity_NoSaleRtnInDepot"/>
  260. <DataColumn Index="7" DataSource="FrmProductInventory.Quantity_NoPurchaseInDepot"/>
  261. <DataColumn Index="8" DataSource="FrmProductInventory.Price_Product"/>
  262. <Events>
  263. <ClickPreview>
  264. PrintReport(dgProduct.CurrentView, "UIFrmProductInventory","FrmProductInventory");
  265. </ClickPreview>
  266. <ClickFilter>
  267. ;
  268. </ClickFilter>
  269. <ClickNOFilter>
  270. ;
  271. </ClickNOFilter>
  272. <ClickRefresh>
  273. Empty();
  274. @StartNo_Product=DBNull();
  275. @EndNo_Product=DBNull();
  276. @StartType_Product=DBNull();
  277. @EndType_Product=DBNull();
  278. if(tbProduct1.CValue!="")
  279. @StartNo_Product=tbProduct1.CValue;
  280. if(tbProduct2.CValue!="")
  281. @EndNo_Product=tbProduct2.CValue;
  282. if(cbType1.Text!="")
  283. @StartType_Product=cbType1.Text;
  284. if(cbType2.Text!="")
  285. @EndType_Product=cbType2.Text;
  286. @StartName_Product=tbPName1.CValue==""?DBNull():tbPName1.CValue;
  287. @EndName_Product=tbPName2.CValue==""?DBNull():tbPName2.CValue;
  288. Search("SearchProductInventory",@StartNo_Product,@EndNo_Product,@StartType_Product,@EndType_Product,@StartName_Product,@EndName_Product);
  289. </ClickRefresh>
  290. </Events>
  291. </IKExtendGrid>
  292. </Controls>
  293. <ChildForms>
  294. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
  295. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  296. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品名称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  297. <DataColumn Index="2" MappingName="#Product.suspension" HeaderText="暂停使用" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  298. <DataColumn Index="3" MappingName="#Product.Price_Product" HeaderText="标准售价" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  299. <DataColumn Index="4" MappingName="#Product.Unit_Product" HeaderText="基本单位" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  300. <DataColumn Index="5" MappingName="#Product.Type_Product" HeaderText="产品大类" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  301. <DataColumn Index="6" MappingName="#Product.Property_Product" HeaderText="产品性质" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  302. </ChildForm>
  303. </ChildForms>
  304. </Client>
  305. <Server>
  306. <Tables>
  307. <Table name="FrmProductInventory" Type="Child">
  308. <GetSchema CmdType="Text" CmdText="
  309. SELECT TOP 0 convert(nvarchar(64),'') As No_Product,convert(nvarchar(64),'') As Name_Product, convert(decimal(14,4),0) As OnShipQty_Product, convert(decimal(14,4),0) As AvailableQty_ProductStocks,convert(decimal(14,4),0) As StockQty_ProductStocks,
  310. convert(decimal(14,4),0) As Quantity_NoSaleOutDepot,convert(decimal(14,4),0) As Quantity_NoSaleRtnInDepot,convert(decimal(14,4),0) As Quantity_NoPurchaseInDepot,convert(decimal(18,6),0) As Price_Product
  311. "/>
  312. </Table>
  313. <Table name="ExchangeHistory" Type="Other">
  314. <GetSchema CmdType="Text" CmdText=" SELECT Top 0 Date_SaleBill as Date,convert(nvarchar(64),'') as Name_Bill,
  315. convert(nvarchar(64),'') as No_Bill,convert(nvarchar(64),'') as No_CustomerOrSupprier,convert(nvarchar(64),'')as shortname,
  316. convert(decimal,0.00) as num,convert(decimal,0.00)as price,convert(nvarchar(64),'') as TaxCurrency,convert(nvarchar(200),'')as Comment
  317. FROM SaleBill" />
  318. </Table>
  319. </Tables>
  320. <Search>
  321. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product,suspension = Case isnull(SuspendDate_Product,0) when 0 then '否' else '是' end,convert(decimal(14,2),Price_Product) as Price_Product,Unit_Product,Type_Product,Product.Property_Product FROM Product">
  322. <Tables>
  323. <Table name="AllProduct" />
  324. </Tables>
  325. </SearchAllProduct>
  326. <SearchType CmdType="Text" CmdText=" SELECT Name_TypeDef as Type_Product FROM TypeDef WHERE (Type_TypeDef = 8) ORDER BY Name_TypeDef">
  327. <Tables>
  328. <Table name="Type"/>
  329. </Tables>
  330. </SearchType>
  331. <SearchProductInventory CmdType="Text" CmdText="
  332. SELECT G.*, ISNULL(H.OnShipQty_Product, 0) AS OnShipQty_Product FROM
  333. (
  334. Select Product.ID_Product, Product.No_Product,Name_Product,Price_Product,IsNull(A.AvailableQty_ProductStocks,0) As AvailableQty_ProductStocks,IsNull(B.StockQty_ProductStocks,0) As StockQty_ProductStocks,IsNull(C.Quantity_NoSaleOutDepot,0) As Quantity_NoSaleOutDepot,IsNull(D.Quantity_NoSaleRtnInDepot,0) As Quantity_NoSaleRtnInDepot,IsNull(E.Quantity_NoPurchaseInDepot,0) As Quantity_NoPurchaseInDepot
  335. From Product
  336. Left Join
  337. (
  338. Select ID_Product,Sum(AvailableQty_ProductStocks) As AvailableQty_ProductStocks
  339. From ProductStocks
  340. Join Location On Location.ID_Location=ProductStocks.ID_Location
  341. Where Level_Location=0
  342. Group BY ID_Product
  343. )A On A.ID_Product=Product.ID_Product
  344. Left Join
  345. (
  346. Select ID_Product,Sum(StockQty_ProductStocks) As StockQty_ProductStocks
  347. From ProductStocks
  348. Join Location On Location.ID_Location=ProductStocks.ID_Location
  349. Where Level_Location=1
  350. Group BY ID_Product
  351. )B On B.ID_Product=Product.ID_Product
  352. Left Join
  353. (
  354. Select SaleBillProduct.ID_Product,Sum(Quantity_Sale-Quantity_OutDepot) As Quantity_NoSaleOutDepot
  355. From SaleSourceBillProduct
  356. Join SaleBillProduct On SaleSourceBillProduct.ID_SaleSourceBillProduct=SaleBillProduct.ID_SaleBillProduct
  357. Where (Quantity_Sale-Quantity_OutDepot)&gt;0
  358. Group By SaleBillProduct.ID_Product
  359. )C On C.ID_Product=Product.ID_Product
  360. Left Join
  361. (
  362. Select SaleBillProduct.ID_Product,Sum(Quantity_SaleRtn-Quantity_InDepot) As Quantity_NoSaleRtnInDepot
  363. From SaleSourceBillProduct
  364. Join SaleBillProduct On SaleSourceBillProduct.ID_SaleSourceBillProduct=SaleBillProduct.ID_SaleBillProduct
  365. Where (Quantity_SaleRtn-Quantity_InDepot)&gt;0
  366. Group By SaleBillProduct.ID_Product
  367. )D On D.ID_Product=Product.ID_Product
  368. Left Join
  369. (
  370. Select po.ID_Product,Sum(ps.Quantity_Order-ps.Quantity_InDepot-ps.Quantity_EndCase) As Quantity_NoPurchaseInDepot
  371. From PurchaseSourceBillProduct ps
  372. Join PurchaseOrderBillProduct po On po.ID_PurchaseOrderBillProduct=ps.ID_PurchaseSourceBillProduct
  373. Where (ps.Quantity_Order-ps.Quantity_InDepot-ps.Quantity_EndCase)&gt;0
  374. Group BY po.ID_Product
  375. )E On E.ID_Product=Product.ID_Product
  376. Where No_Product between IsNull(@StartNo_Product,No_Product) And IsNull(@EndNo_Product,No_Product)
  377. And Name_Product between IsNull(@StartName_Product,Name_Product) And IsNull(@EndName_Product,Name_Product)
  378. And Type_Product between IsNull(@StartType_Product,Type_Product) And IsNull(@EndType_Product,Type_Product)
  379. And (A.AvailableQty_ProductStocks Is Not Null Or B.StockQty_ProductStocks Is Not Null Or C.Quantity_NoSaleOutDepot Is Not Null Or D.Quantity_NoSaleRtnInDepot Is Not Null Or E.Quantity_NoPurchaseInDepot Is Not Null)
  380. --Order By Product.Type_Product, Product.Name_Product
  381. )G
  382. left join
  383. (
  384. select ID_Product, SUM(ISNULL(Quantity_OnShipProduct, 0)) AS OnShipQty_Product from OnShipProduct
  385. GROUP BY ID_Product
  386. ) H ON G.ID_Product = H.ID_Product
  387. ">
  388. <Params>
  389. <Param name="@StartNo_Product" type="Product.No_Product" Index="0" />
  390. <Param name="@EndNo_Product" type="Product.No_Product" Index="1" />
  391. <Param name="@StartType_Product" type="Product.Type_Product" Index="2" />
  392. <Param name="@EndType_Product" type="Product.Type_Product" Index="3" />
  393. <Param name="@StartName_Product" type="Product.Name_Product" Index="4" />
  394. <Param name="@EndName_Product" type="Product.Name_Product" Index="5" />
  395. </Params>
  396. <Tables>
  397. <Table name="FrmProductInventory" />
  398. </Tables>
  399. </SearchProductInventory>
  400. <SearchCessOut CmdType="Text" CmdText=" SELECT SystemSetting.CessOut_SystemSetting FROM SystemSetting">
  401. <Tables>
  402. <Table name="System" />
  403. </Tables>
  404. </SearchCessOut>
  405. <searchAllBill CmdType="Text" CmdText=" Declare @ID_Product Uniqueidentifier
  406. Select @ID_Product = ID_Product From Product Where No_Product =@No_Product
  407. SELECT * FROM
  408. (SELECT Top 0 convert(datetime,'') as Date,convert(nvarchar(64),'') as Name_Bill,
  409. convert(nvarchar(64),'') as No_Bill,convert(nvarchar(64),'') as No_CustomerOrSupprier,convert(nvarchar(64),'')as shortname,
  410. convert(decimal,0.00) as num,convert(decimal,0.00)as price,convert(nvarchar(200),'')as Comment,SaleBill.ID_Assessor as ID_Assessor,convert(nvarchar(64),'') as No_Product,convert(nvarchar(64),'') as TaxCurrency
  411. FROM SaleBill
  412. Union all
  413. select PriceQueryBill.Date_PriceQueryBill as Date
  414. ,convert(nvarchar(64),'报价单') as Name_Bill
  415. ,PriceQueryBill.No_PriceQueryBill as No_Bill
  416. ,Customer.No_Customer as No_CustomerOrSupprier
  417. ,Customer.ShortName_Customer as shortname
  418. ,PriceQueryBillProduct.Quantity_PriceQueryBillProduct as num,
  419. PriceQueryBillProduct.UnitPrice_PriceQueryBillProduct as price,
  420. PriceQueryBillProduct.Comment_PriceQueryBillProduct as Comment,
  421. PriceQueryBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product
  422. ,PriceQueryBill.TaxCurrency_PriceQueryBill as TaxCurrency
  423. From PriceQueryBill
  424. join PriceQueryBillProduct on PriceQueryBill.ID_PriceQueryBill = PriceQueryBillProduct.ID_PriceQueryBill
  425. left join Customer on Customer.ID_Customer=PriceQueryBill.ID_Customer
  426. left join Product on PriceQueryBillProduct.ID_Product = Product.ID_Product
  427. where Customer.ID_Creator IS NOT NULL
  428. AND Customer.No_Customer in ( Select No_Customer From Customer Where ID_RegionalLeader in(Select ID_RegionalLeader From Principal Left join Employee on Employee.ID_Employee = Principal.ID_Employee Where Name_Employee = @Name_Employee))
  429. and PriceQueryBill.ID_Assessor is not null
  430. And @cktn =1
  431. union all
  432. select IndentBill.Date_IndentBill as Date,convert(nvarchar(64),'订货单') as Name_Bill,IndentBill.No_IndentBill as No_Bill,
  433. Customer.No_Customer as No_CustomerOrSupprier,Customer.ShortName_Customer as shortname,
  434. IndentBillProduct.Quantity_IndentBillProduct as num,
  435. IndentBillProduct.UnitPrice_IndentBillProduct as price,
  436. IndentBillProduct.Comment_IndentBillProduct as Comment,
  437. IndentBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,IndentBill.TaxCurrency_IndentBill as TaxCurrency
  438. from IndentBill
  439. join IndentBillProduct on IndentBill.ID_IndentBill=IndentBillProduct.ID_IndentBill
  440. left join Customer on Customer.ID_Customer=IndentBill.ID_Customer
  441. left join Product on IndentBillProduct.ID_Product = Product.ID_Product
  442. where Customer.ID_Creator is not null
  443. and IndentBill.ID_Assessor is not null
  444. AND Customer.No_Customer in ( Select No_Customer From Customer Where ID_RegionalLeader in(Select ID_RegionalLeader From Principal Left join Employee on Employee.ID_Employee = Principal.ID_Employee Where Name_Employee = @Name_Employee))
  445. And @cktn =2
  446. Union all
  447. select SaleBill.Date_SaleBill as Date,convert(nvarchar(64),'销货单') as Name_Bill,SaleBill.No_SaleBill as No_Bill,
  448. Customer.No_Customer as No_CustomerOrSupprier,Customer.ShortName_Customer as shortname,
  449. SaleBillProduct.Quantity_SaleBillProduct as num,
  450. SaleBillProduct.UnitPrice_SaleBillProduct as price,
  451. SaleBillProduct.Comment_SaleBillProduct as Comment,
  452. SaleBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,SaleBill.TaxCurrency_SaleBill as TaxCurrency
  453. from SaleBill
  454. join SaleBillProduct on SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  455. left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  456. left join Product on SaleBillProduct.ID_Product = Product.ID_Product
  457. where Customer.ID_Creator is not null
  458. AND Customer.No_Customer in ( Select No_Customer From Customer Where ID_RegionalLeader in(Select ID_RegionalLeader From Principal Left join Employee on Employee.ID_Employee = Principal.ID_Employee Where Name_Employee = @Name_Employee))
  459. And SaleBill.ID_Assessor is not null
  460. And @cktn =3
  461. Union all
  462. select SaleRtnBill.Date_SaleRtnBill as Date,convert(nvarchar(64),'销售退货单') as Name_Bill,SaleRtnBill.No_SaleRtnBill as No_Bill,
  463. Customer.No_Customer as No_CustomerOrSupprier,Customer.ShortName_Customer as shortname,
  464. SaleRtnBillProduct.Quantity_SaleRtnBillProduct as num,
  465. SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct as price,
  466. SaleRtnBillProduct.Comment_SaleRtnBillProduct as Comment,
  467. SaleRtnBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,SaleRtnBill.TaxCurrency_SaleRtnBill as TaxCurrency
  468. from SaleRtnBill
  469. join SaleRtnBillProduct on SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  470. left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  471. left join Product on SaleRtnBillProduct.ID_Product = Product.ID_Product
  472. where Customer.ID_Creator is not null
  473. AND Customer.No_Customer in ( Select No_Customer From Customer Where ID_RegionalLeader in(Select ID_RegionalLeader From Principal Left join Employee on Employee.ID_Employee = Principal.ID_Employee Where Name_Employee = @Name_Employee))
  474. and SaleRtnBill.ID_Assessor is not null
  475. And @cktn =4
  476. Union all
  477. select SaleOutDepotBill.Date_SaleOutDepotBill as Date,convert(nvarchar(64),'销货出库单') as Name_Bill,SaleOutDepotBill.No_SaleOutDepotBill as No_Bill,
  478. Customer.No_Customer as No_CustomerOrSupprier,Customer.ShortName_Customer as shortname,
  479. SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct as num,
  480. isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0.00) as price,
  481. SaleOutDepotBillProduct.Comment_SaleOutDepotBillProduct as Comment,
  482. SaleOutDepotBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,'' as TaxCurrency
  483. from SaleOutDepotBill
  484. join SaleOutDepotBillProduct on SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill And SaleOutDepotBillProduct.ID_Product = @ID_Product
  485. left join Customer on Customer.ID_Customer=SaleOutDepotBill.ID_Customer
  486. left join Product on SaleOutDepotBillProduct.ID_Product = Product.ID_Product And SaleOutDepotBillProduct.ID_Product = @ID_Product
  487. left join SaleBillProduct on SaleBillProduct.ID_Product = @ID_Product And SaleOutDepotBillProduct.Type_FromBill=21
  488. and SaleOutDepotBillProduct.No_FromBill=(select SaleBill.No_SaleBill from SaleBill where SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill)
  489. and SaleOutDepotBillProduct.No_FromBillProduct=SaleBillProduct.No_SaleBillProduct
  490. where Customer.No_Customer in ( Select No_Customer From Customer Where ID_RegionalLeader in(Select ID_RegionalLeader From Principal Left join Employee on Employee.ID_Employee = Principal.ID_Employee Where Name_Employee = @Name_Employee))
  491. and SaleOutDepotBill.ID_Assessor is not null
  492. And @cktn =5
  493. Union all
  494. select PurchaseQueryBill.Date_PurchaseQueryBill as Date,convert(nvarchar(64),'询价单') as Name_Bill,PurchaseQueryBill.No_PurchaseQueryBill as No_Bill,
  495. Supplier.No_Supplier as No_CustomerOrSupprier,Supplier.ShortName_Supplier as shortname,
  496. PurchaseQueryBillProduct.Quantity_PurchaseQueryBillProduct as num,
  497. PurchaseQueryBillProduct.UnitPrice_PurchaseQueryBillProduct as price,
  498. PurchaseQueryBillProduct.Comment_PurchaseQueryBillProduct as Comment,
  499. PurchaseQueryBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,PurchaseQueryBill.TaxCurrency_PurchaseQueryBill as TaxCurrency
  500. from PurchaseQueryBill
  501. join PurchaseQueryBillProduct on PurchaseQueryBill.ID_PurchaseQueryBill=PurchaseQueryBillProduct.ID_PurchaseQueryBill
  502. left join Supplier on Supplier.ID_Supplier=PurchaseQueryBill.ID_Supplier
  503. left join Product on PurchaseQueryBillProduct.ID_Product = Product.ID_Product
  504. Where PurchaseQueryBill.ID_Assessor is not null
  505. And @cktn =6
  506. Union all
  507. select PurchaseOrderBill.Date_PurchaseOrderBill as Date,convert(nvarchar(64),'采购订单') as Name_Bill,PurchaseOrderBill.No_PurchaseOrderBill as No_Bill,
  508. Supplier.No_Supplier as No_CustomerOrSupprier,Supplier.ShortName_Supplier as shortname,
  509. PurchaseOrderBillProduct.Quantity_PurchaseOrderBillProduct as num,
  510. PurchaseOrderBillProduct.UnitPrice_PurchaseOrderBillProduct as price,
  511. PurchaseOrderBillProduct.Comment_PurchaseOrderBillProduct as Comment,
  512. PurchaseOrderBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,PurchaseOrderBill.TaxCurrency_PurchaseOrderBill as TaxCurrency
  513. from PurchaseOrderBill
  514. join PurchaseOrderBillProduct on PurchaseOrderBill.ID_PurchaseOrderBill=PurchaseOrderBillProduct.ID_PurchaseOrderBill
  515. left join Supplier on Supplier.ID_Supplier=PurchaseOrderBill.ID_Supplier
  516. left join Product on PurchaseOrderBillProduct.ID_Product = Product.ID_Product
  517. Where PurchaseOrderBill.ID_Assessor is not null
  518. And @cktn =7
  519. Union all
  520. select ModifyDepotBill.Date_ModifyDepotBill as Date,convert(nvarchar(64),('库存异动作业'+'('+ModName_ModifyTypeSettings+')')) as Name_Bill,ModifyDepotBill.No_ModifyDepotBill as No_Bill,'' as No_CustomerOrSupprier,
  521. shortname= case when ModName_ModifyTypeSettings='销退入库' or ModName_ModifyTypeSettings='借出' or ModName_ModifyTypeSettings='借出归还' or ModName_ModifyTypeSettings='借入' or ModName_ModifyTypeSettings='借入归还' then ModifyDepotBill.Comment_ModifyDepotBill else '' end,
  522. ModifyDepotBillProduct.Quantity_ModifyDepotBillProduct as num,0 as price,ModifyDepotBillProduct.Comment_ModifyDepotBillProduct as Comment,
  523. ModifyDepotBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,'' as TaxCurrency
  524. from ModifyDepotBill
  525. join ModifyDepotBillProduct on ModifyDepotBill.ID_ModifyDepotBill=ModifyDepotBillProduct.ID_ModifyDepotBill
  526. left join Product on ModifyDepotBillProduct.ID_Product = Product.ID_Product
  527. LEFT JOIN ModifyTypeSettings ON ModifyTypeSettings.ID_ModifyTypeSettings = ModifyDepotBill.Style_ModifyDepotBill
  528. Where ModifyDepotBill.ID_Assessor is not null
  529. And @cktn =8
  530. Union all
  531. select PurchaseInDepotBill.Date_PurchaseInDepotBill as Date,convert(nvarchar(64),'采购入库单') as Name_Bill,PurchaseInDepotBill.No_PurchaseInDepotBill as No_Bill,
  532. Supplier.No_Supplier as No_CustomerOrSupprier,Supplier.ShortName_Supplier as shortname,
  533. PurchaseInDepotBillProduct.Quantity_PurchaseInDepotBillProduct as num,
  534. isnull(PurchaseOrderBillProduct.UnitPrice_PurchaseOrderBillProduct,0.00) as price,
  535. PurchaseInDepotBillProduct.Comment_PurchaseInDepotBillProduct as Comment,
  536. PurchaseInDepotBill.ID_Assessor as ID_Assessor,Product.No_Product as No_Product,'' as TaxCurrency
  537. from PurchaseInDepotBill
  538. join PurchaseInDepotBillProduct on PurchaseInDepotBill.ID_PurchaseInDepotBill=PurchaseInDepotBillProduct.ID_PurchaseInDepotBill
  539. left join Supplier on Supplier.ID_Supplier=PurchaseInDepotBill.ID_Supplier
  540. left join Product on PurchaseInDepotBillProduct.ID_Product = Product.ID_Product
  541. left join PurchaseOrderBillProduct on PurchaseInDepotBillProduct.Type_FromBill=41
  542. and PurchaseInDepotBillProduct.No_FromBill=(select PurchaseOrderBill.No_PurchaseOrderBill from PurchaseOrderBill where PurchaseOrderBill.ID_PurchaseOrderBill=PurchaseOrderBillProduct.ID_PurchaseOrderBill)
  543. and PurchaseInDepotBillProduct.No_FromBillProduct=PurchaseOrderBillProduct.No_PurchaseOrderBillProduct
  544. Where PurchaseInDepotBill.ID_Assessor is not null
  545. And @cktn =9
  546. )A
  547. where A.No_Product = @No_Product
  548. AND A.Date Between isnull(DateAdd(day,DateDiff(day,0,@StartTime),0),A.Date)
  549. AND Isnull(DateAdd(day,DateDiff(day,0,@EndTime),1),A.Date)
  550. Order By Date desc
  551. ">
  552. <Params>
  553. <Param name="@No_Product" type="Customer.No_Customer" />
  554. <Param name="@Name_Employee" type="Employee.Name_Employee" />
  555. <Param name="@cktn" type="Customer.DunDate_Customer" />
  556. <Param name="@StartTime" type="PurchaseInDepotBill.Date_PurchaseInDepotBill" />
  557. <Param name="@EndTime" type="PurchaseInDepotBill.Date_PurchaseInDepotBill" />
  558. </Params>
  559. <Tables>
  560. <Table name="searchAllBill" />
  561. </Tables>
  562. </searchAllBill>
  563. </Search>
  564. </Server>
  565. <Lables>
  566. <Search>
  567. Empty();
  568. Empty("#ExchangeHistory");
  569. NewInstance();
  570. </Search>
  571. </Lables>
  572. </Form>
  573. </Forms>