FrmProductSalesStatistics.xml 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmProductSalesStatistics">
  4. <Client>
  5. <Events>
  6. <Load><![CDATA[
  7. @Title="产品销售统计表";
  8. GetSchema();
  9. txtCoNo.CValue=GetCurrentCompanyNo();
  10. txtCoName.CValue=GetCurrentCompanyShortName();
  11. Empty();
  12. NewInstance();
  13. #Condition.StartDate_SaleBill=GetCurrentTime();
  14. #Condition.EndDate_SaleBill=GetCurrentTime();
  15. ]]></Load>
  16. <Closing>
  17. ;
  18. </Closing>
  19. <Closed>
  20. ;
  21. </Closed>
  22. </Events>
  23. <Mode>
  24. <Search>
  25. <Lable name="Search" />
  26. </Search>
  27. </Mode>
  28. <Controls>
  29. <IKDateTimePicker name="dtStart" DataSource="Condition.StartDate_SaleBill" >
  30. <Events>
  31. <CheckedChanged>
  32. dtEnd.Checked = dtStart.Checked;
  33. </CheckedChanged>
  34. <ValueChanged>
  35. dtEnd.CValue = dtStart.CValue;
  36. </ValueChanged>
  37. </Events>
  38. </IKDateTimePicker>
  39. <IKDateTimePicker name="dtEnd" DataSource="Condition.EndDate_SaleBill" />
  40. <IKTextButton name="tbCustomerNoFrom" DataSource="Condition.CustomerNoFrom">
  41. <Events>
  42. <Click>
  43. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNoFrom.CValue);
  44. if( @temp == "" )
  45. return;
  46. tbCustomerNoFrom.CValue = @temp;
  47. </Click>
  48. <TextBoxButtonTextChanged>
  49. tbCustomerNoTo.CValue = tbCustomerNoFrom.CValue;
  50. </TextBoxButtonTextChanged>
  51. </Events>
  52. </IKTextButton>
  53. <IKTextButton name="tbCustomerNoTo" DataSource="Condition.CustomerNoTo">
  54. <Events>
  55. <Click>
  56. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNoTo.CValue);
  57. if( @temp == "" )
  58. return;
  59. tbCustomerNoTo.CValue = @temp;
  60. </Click>
  61. </Events>
  62. </IKTextButton>
  63. <IKTextButton name="tbProductNoFrom" DataSource="Condition.ProductNoFrom">
  64. <Events>
  65. <Click>
  66. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNoFrom.CValue);
  67. if( @temp == "" )
  68. return;
  69. tbProductNoFrom.CValue = @temp;
  70. </Click>
  71. <TextBoxButtonTextChanged>
  72. tbProductNoTo.CValue = tbProductNoFrom.CValue;
  73. </TextBoxButtonTextChanged>
  74. </Events>
  75. </IKTextButton>
  76. <IKTextButton name="tbProductNoTo" DataSource="Condition.ProductNoTo">
  77. <Events>
  78. <Click>
  79. @temp = ShowSearchBox("ProductSearch","INFOMATION",tbProductNoTo.CValue);
  80. if( @temp == "" )
  81. return;
  82. tbProductNoTo.CValue = @temp;
  83. </Click>
  84. </Events>
  85. </IKTextButton>
  86. <IKComboBoxEx name="cbLevel_CustomerFrom" DisplaySource="Condition.Level_CustomerFrom" DataSource="CustomerLevel" DisplayMember="Level_Customer" >
  87. <Events>
  88. <Reload>
  89. UpdateForm(false, "cbLevel_CustomerFrom");
  90. Search("SearchCustomerLevel");
  91. UpdateForm(true, "cbLevel_CustomerFrom");
  92. </Reload>
  93. <TextChanged>
  94. cbLevel_CustomerTo.Text = cbLevel_CustomerFrom.Text;
  95. </TextChanged>
  96. </Events>
  97. </IKComboBoxEx>
  98. <IKComboBoxEx name="cbLevel_CustomerTo" DisplaySource="Condition.Level_CustomerTo" DataSource="CustomerLevel" DisplayMember="Level_Customer">
  99. <Events>
  100. <Reload>
  101. UpdateForm(false, "cbLevel_CustomerTo");
  102. Search("SearchCustomerLevel");
  103. UpdateForm(true, "cbLevel_CustomerTo");
  104. </Reload>
  105. </Events>
  106. </IKComboBoxEx>
  107. <IKComboBoxEx name="cbPrincipalFrom" DisplaySource="Condition.StartPrincipal" NoSource="Condition.StartNo_Principal" DataSource="Principal" DisplayMember="Name_Employee" NoMember="No_Employee">
  108. <Events>
  109. <Reload>
  110. UpdateForm(false, "cbPrincipalFrom");
  111. Search("SearchPrincipal");
  112. UpdateForm(true, "cbPrincipalFrom");
  113. </Reload>
  114. <TextChanged>
  115. cbPrincipalTo.SelectedName = cbPrincipalFrom.SelectedName;
  116. cbPrincipalTo.SelectedNo=cbPrincipalFrom.SelectedNo;
  117. </TextChanged>
  118. </Events>
  119. </IKComboBoxEx>
  120. <IKComboBoxEx name="cbPrincipalTo" DisplaySource="Condition.EndPrincipal" NoSource="Condition.EndNo_Principal" DataSource="Principal" DisplayMember="Name_Employee" NoMember="No_Employee">
  121. <Events>
  122. <Reload>
  123. UpdateForm(false, "cbPrincipalTo");
  124. Search("SearchPrincipal");
  125. UpdateForm(true, "cbPrincipalTo");
  126. </Reload>
  127. </Events>
  128. </IKComboBoxEx>
  129. <IKComboBoxEx name="cbTypeFrom" DisplaySource="Condition.TypeFrom" DataSource="Type" DisplayMember="Type_Product">
  130. <Events>
  131. <Reload>
  132. UpdateForm(false, "cbTypeFrom");
  133. Search("SearchType");
  134. UpdateForm(true, "cbTypeFrom");
  135. </Reload>
  136. <TextChanged>
  137. cbTypeTo.Text = cbTypeFrom.Text;
  138. </TextChanged>
  139. </Events>
  140. </IKComboBoxEx>
  141. <IKComboBoxEx name="cbTypeTo" DisplaySource="Condition.TypeTo" DataSource="Type" DisplayMember="Type_Product">
  142. <Events>
  143. <Reload>
  144. UpdateForm(false, "cbTypeTo");
  145. Search("SearchType");
  146. UpdateForm(true, "cbTypeTo");
  147. </Reload>
  148. </Events>
  149. </IKComboBoxEx>
  150. <IKButton name="btnExcel">
  151. <Events>
  152. <Click>
  153. if(!rbCP.Checked &amp;&amp; !rbCPS.Checked &amp;&amp; !rbPP.Checked&amp;&amp; !rbPPS.Checked &amp;&amp;!rbPCP.Checked)
  154. {
  155. MessageBox("请选择格式!",@Title);
  156. return;
  157. }
  158. UpdateForm(false,"");
  159. #Condition.Name_Creator = GetCurrentUser();
  160. #Condition.CreateDate=GetCurrentTime();
  161. @StartDate_SaleBill=DBNull();
  162. @EndDate_SaleBill=DBNull();
  163. @CustomerNoFrom = DBNull();
  164. @CustomerNoTo = DBNull();
  165. @ProductNoFrom = DBNull();
  166. @ProductNoTo = DBNull();
  167. @Level_CustomerFrom = DBNull();
  168. @Level_CustomerTo = DBNull();
  169. @StartNo_Principal = DBNull();
  170. @EndNo_Principal = DBNull();
  171. @TypeFrom = DBNull();
  172. @TypeTo = DBNull();
  173. if(dtStart.Checked)
  174. @StartDate_SaleBill=dtStart.Value;
  175. else
  176. #Condition.StartDate_SaleBill=DBNull();
  177. if(dtEnd.Checked)
  178. @EndDate_SaleBill=dtEnd.Value;
  179. else
  180. #Condition.EndDate_SaleBill=DBNull();
  181. if(tbCustomerNoFrom.CValue != "")
  182. @CustomerNoFrom = tbCustomerNoFrom.CValue;
  183. if(tbCustomerNoTo.CValue != "")
  184. @CustomerNoTo = tbCustomerNoTo.CValue;
  185. if(cbLevel_CustomerFrom.Text != "")
  186. @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
  187. if(cbLevel_CustomerTo.Text != "")
  188. @Level_CustomerTo = cbLevel_CustomerTo.Text;
  189. if(cbPrincipalFrom.Text!="")
  190. {
  191. if(!cbPrincipalFrom.CheckSelectedItem())
  192. {
  193. MessageBox("请选择有效的业务负责人!",@Title);
  194. cbPrincipalFrom.Focus();
  195. return;
  196. }
  197. else
  198. {
  199. @StartNo_Principal = cbPrincipalFrom.SelectedNo;
  200. }
  201. }
  202. if(cbPrincipalTo.Text!="")
  203. {
  204. if(!cbPrincipalTo.CheckSelectedItem())
  205. {
  206. MessageBox("请选择有效的业务负责人!",@Title);
  207. cbPrincipalTo.Focus();
  208. return;
  209. }
  210. else
  211. {
  212. @EndNo_Principal = cbPrincipalTo.SelectedNo;
  213. }
  214. }
  215. if(tbProductNoFrom.CValue != "")
  216. @ProductNoFrom = tbProductNoFrom.CValue;
  217. if(tbProductNoTo.CValue != "")
  218. @ProductNoTo = tbProductNoTo.CValue;
  219. if(cbTypeFrom.Text != "")
  220. @TypeFrom = cbTypeFrom.Text;
  221. if(cbTypeTo.Text != "")
  222. @TypeTo = cbTypeTo.Text;
  223. if(rbCP.Checked)
  224. {
  225. Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  226. if(RowCount("#FrmProductSalesStatistics") ==0)
  227. {
  228. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  229. }
  230. else
  231. {
  232. ExportReport("Excel","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
  233. }
  234. }
  235. else if(rbCPS.Checked)
  236. {
  237. Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  238. if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
  239. {
  240. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  241. }
  242. else
  243. {
  244. ExportReport("Excel","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
  245. }
  246. }else if(rbPP.Checked)
  247. {
  248. Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  249. if(RowCount("#FrmProductSalesStatistics") ==0)
  250. {
  251. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  252. }
  253. else
  254. {
  255. ExportReport("Excel","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
  256. }
  257. }else if(rbPPS.Checked)
  258. {
  259. Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  260. if(RowCount("#FrmProductSalesStatistics") ==0)
  261. {
  262. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  263. }
  264. else
  265. {
  266. ExportReport("Excel","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
  267. }
  268. }
  269. else
  270. {
  271. Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  272. if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
  273. {
  274. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  275. }
  276. else
  277. {
  278. ExportReport("Excel","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
  279. }
  280. }
  281. </Click>
  282. </Events>
  283. </IKButton>
  284. <IKButton name="btnWord">
  285. <Events>
  286. <Click>
  287. if(!rbCP.Checked &amp;&amp; !rbCPS.Checked &amp;&amp; !rbPP.Checked&amp;&amp; !rbPPS.Checked &amp;&amp;!rbPCP.Checked)
  288. {
  289. MessageBox("请选择格式!",@Title);
  290. return;
  291. }
  292. UpdateForm(false,"");
  293. #Condition.Name_Creator = GetCurrentUser();
  294. #Condition.CreateDate=GetCurrentTime();
  295. @StartDate_SaleBill=DBNull();
  296. @EndDate_SaleBill=DBNull();
  297. @CustomerNoFrom = DBNull();
  298. @CustomerNoTo = DBNull();
  299. @ProductNoFrom = DBNull();
  300. @ProductNoTo = DBNull();
  301. @Level_CustomerFrom = DBNull();
  302. @Level_CustomerTo = DBNull();
  303. @StartNo_Principal = DBNull();
  304. @EndNo_Principal = DBNull();
  305. @TypeFrom = DBNull();
  306. @TypeTo = DBNull();
  307. if(dtStart.Checked)
  308. @StartDate_SaleBill=dtStart.Value;
  309. else
  310. #Condition.StartDate_SaleBill=DBNull();
  311. if(dtEnd.Checked)
  312. @EndDate_SaleBill=dtEnd.Value;
  313. else
  314. #Condition.EndDate_SaleBill=DBNull();
  315. if(tbCustomerNoFrom.CValue != "")
  316. @CustomerNoFrom = tbCustomerNoFrom.CValue;
  317. if(tbCustomerNoTo.CValue != "")
  318. @CustomerNoTo = tbCustomerNoTo.CValue;
  319. if(cbLevel_CustomerFrom.Text != "")
  320. @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
  321. if(cbLevel_CustomerTo.Text != "")
  322. @Level_CustomerTo = cbLevel_CustomerTo.Text;
  323. if(cbPrincipalFrom.Text!="")
  324. {
  325. if(!cbPrincipalFrom.CheckSelectedItem())
  326. {
  327. MessageBox("请选择有效的业务负责人!",@Title);
  328. cbPrincipalFrom.Focus();
  329. return;
  330. }
  331. else
  332. {
  333. @StartNo_Principal = cbPrincipalFrom.SelectedNo;
  334. }
  335. }
  336. if(cbPrincipalTo.Text!="")
  337. {
  338. if(!cbPrincipalTo.CheckSelectedItem())
  339. {
  340. MessageBox("请选择有效的业务负责人!",@Title);
  341. cbPrincipalTo.Focus();
  342. return;
  343. }
  344. else
  345. {
  346. @EndNo_Principal = cbPrincipalTo.SelectedNo;
  347. }
  348. }
  349. if(tbProductNoFrom.CValue != "")
  350. @ProductNoFrom = tbProductNoFrom.CValue;
  351. if(tbProductNoTo.CValue != "")
  352. @ProductNoTo = tbProductNoTo.CValue;
  353. if(cbTypeFrom.Text != "")
  354. @TypeFrom = cbTypeFrom.Text;
  355. if(cbTypeTo.Text != "")
  356. @TypeTo = cbTypeTo.Text;
  357. if(rbCP.Checked)
  358. {
  359. Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  360. if(RowCount("#FrmProductSalesStatistics") ==0)
  361. {
  362. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  363. }
  364. else
  365. {
  366. ExportReport("Word","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
  367. }
  368. }
  369. else if(rbCPS.Checked)
  370. {
  371. Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  372. if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
  373. {
  374. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  375. }
  376. else
  377. {
  378. ExportReport("Word","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
  379. }
  380. }else if(rbPP.Checked)
  381. {
  382. Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  383. if(RowCount("#FrmProductSalesStatistics") ==0)
  384. {
  385. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  386. }
  387. else
  388. {
  389. ExportReport("Word","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
  390. }
  391. }else if(rbPPS.Checked)
  392. {
  393. Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  394. if(RowCount("#FrmProductSalesStatistics") ==0)
  395. {
  396. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  397. }
  398. else
  399. {
  400. ExportReport("Word","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
  401. }
  402. }
  403. else
  404. {
  405. Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  406. if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
  407. {
  408. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  409. }
  410. else
  411. {
  412. ExportReport("Word","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
  413. }
  414. }
  415. </Click>
  416. </Events>
  417. </IKButton>
  418. <IKButton name="btnPrint">
  419. <Events>
  420. <Click>
  421. if(!rbCP.Checked &amp;&amp; !rbCPS.Checked &amp;&amp; !rbPP.Checked&amp;&amp; !rbPPS.Checked &amp;&amp;!rbPCP.Checked)
  422. {
  423. MessageBox("请选择格式!",@Title);
  424. return;
  425. }
  426. UpdateForm(false,"");
  427. #Condition.Name_Creator = GetCurrentUser();
  428. #Condition.CreateDate=GetCurrentTime();
  429. @StartDate_SaleBill=DBNull();
  430. @EndDate_SaleBill=DBNull();
  431. @CustomerNoFrom = DBNull();
  432. @CustomerNoTo = DBNull();
  433. @ProductNoFrom = DBNull();
  434. @ProductNoTo = DBNull();
  435. @Level_CustomerFrom = DBNull();
  436. @Level_CustomerTo = DBNull();
  437. @StartNo_Principal = DBNull();
  438. @EndNo_Principal = DBNull();
  439. @TypeFrom = DBNull();
  440. @TypeTo = DBNull();
  441. if(dtStart.Checked)
  442. @StartDate_SaleBill=dtStart.Value;
  443. else
  444. #Condition.StartDate_SaleBill=DBNull();
  445. if(dtEnd.Checked)
  446. @EndDate_SaleBill=dtEnd.Value;
  447. else
  448. #Condition.EndDate_SaleBill=DBNull();
  449. if(tbCustomerNoFrom.CValue != "")
  450. @CustomerNoFrom = tbCustomerNoFrom.CValue;
  451. if(tbCustomerNoTo.CValue != "")
  452. @CustomerNoTo = tbCustomerNoTo.CValue;
  453. if(cbLevel_CustomerFrom.Text != "")
  454. @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
  455. if(cbLevel_CustomerTo.Text != "")
  456. @Level_CustomerTo = cbLevel_CustomerTo.Text;
  457. if(cbPrincipalFrom.Text!="")
  458. {
  459. if(!cbPrincipalFrom.CheckSelectedItem())
  460. {
  461. MessageBox("请选择有效的业务负责人!",@Title);
  462. cbPrincipalFrom.Focus();
  463. return;
  464. }
  465. else
  466. {
  467. @StartNo_Principal = cbPrincipalFrom.SelectedNo;
  468. }
  469. }
  470. if(cbPrincipalTo.Text!="")
  471. {
  472. if(!cbPrincipalTo.CheckSelectedItem())
  473. {
  474. MessageBox("请选择有效的业务负责人!",@Title);
  475. cbPrincipalTo.Focus();
  476. return;
  477. }
  478. else
  479. {
  480. @EndNo_Principal = cbPrincipalTo.SelectedNo;
  481. }
  482. }
  483. if(tbProductNoFrom.CValue != "")
  484. @ProductNoFrom = tbProductNoFrom.CValue;
  485. if(tbProductNoTo.CValue != "")
  486. @ProductNoTo = tbProductNoTo.CValue;
  487. if(cbTypeFrom.Text != "")
  488. @TypeFrom = cbTypeFrom.Text;
  489. if(cbTypeTo.Text != "")
  490. @TypeTo = cbTypeTo.Text;
  491. if(rbCP.Checked)
  492. {
  493. Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  494. if(RowCount("#FrmProductSalesStatistics") ==0)
  495. {
  496. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  497. }
  498. else
  499. {
  500. ExportReport("PrintToPrinter","ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
  501. }
  502. }
  503. else if(rbCPS.Checked)
  504. {
  505. Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  506. if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
  507. {
  508. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  509. }
  510. else
  511. {
  512. ExportReport("PrintToPrinter","ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
  513. }
  514. }else if(rbPP.Checked)
  515. {
  516. Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  517. if(RowCount("#FrmProductSalesStatistics") ==0)
  518. {
  519. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  520. }
  521. else
  522. {
  523. ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
  524. }
  525. }else if(rbPPS.Checked)
  526. {
  527. Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  528. if(RowCount("#FrmProductSalesStatistics") ==0)
  529. {
  530. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  531. }
  532. else
  533. {
  534. ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
  535. }
  536. }
  537. else
  538. {
  539. Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  540. if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
  541. {
  542. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  543. }
  544. else
  545. {
  546. ExportReport("PrintToPrinter","ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
  547. }
  548. }
  549. </Click>
  550. </Events>
  551. </IKButton>
  552. <IKButton name="btnView">
  553. <Events>
  554. <Click>
  555. if(!rbCP.Checked &amp;&amp; !rbCPS.Checked &amp;&amp; !rbPP.Checked&amp;&amp; !rbPPS.Checked &amp;&amp;!rbPCP.Checked)
  556. {
  557. MessageBox("请选择格式!",@Title);
  558. return;
  559. }
  560. UpdateForm(false,"");
  561. #Condition.Name_Creator = GetCurrentUser();
  562. #Condition.CreateDate=GetCurrentTime();
  563. @StartDate_SaleBill=DBNull();
  564. @EndDate_SaleBill=DBNull();
  565. @CustomerNoFrom = DBNull();
  566. @CustomerNoTo = DBNull();
  567. @ProductNoFrom = DBNull();
  568. @ProductNoTo = DBNull();
  569. @Level_CustomerFrom = DBNull();
  570. @Level_CustomerTo = DBNull();
  571. @StartNo_Principal = DBNull();
  572. @EndNo_Principal = DBNull();
  573. @TypeFrom = DBNull();
  574. @TypeTo = DBNull();
  575. if(dtStart.Checked)
  576. @StartDate_SaleBill=dtStart.Value;
  577. else
  578. #Condition.StartDate_SaleBill=DBNull();
  579. if(dtEnd.Checked)
  580. @EndDate_SaleBill=dtEnd.Value;
  581. else
  582. #Condition.EndDate_SaleBill=DBNull();
  583. if(tbCustomerNoFrom.CValue != "")
  584. @CustomerNoFrom = tbCustomerNoFrom.CValue;
  585. if(tbCustomerNoTo.CValue != "")
  586. @CustomerNoTo = tbCustomerNoTo.CValue;
  587. if(cbLevel_CustomerFrom.Text != "")
  588. @Level_CustomerFrom = cbLevel_CustomerFrom.Text;
  589. if(cbLevel_CustomerTo.Text != "")
  590. @Level_CustomerTo = cbLevel_CustomerTo.Text;
  591. if(cbPrincipalFrom.Text!="")
  592. {
  593. if(!cbPrincipalFrom.CheckSelectedItem())
  594. {
  595. MessageBox("请选择有效的业务负责人!",@Title);
  596. cbPrincipalFrom.Focus();
  597. return;
  598. }
  599. else
  600. {
  601. @StartNo_Principal = cbPrincipalFrom.SelectedNo;
  602. }
  603. }
  604. if(cbPrincipalTo.Text!="")
  605. {
  606. if(!cbPrincipalTo.CheckSelectedItem())
  607. {
  608. MessageBox("请选择有效的业务负责人!",@Title);
  609. cbPrincipalTo.Focus();
  610. return;
  611. }
  612. else
  613. {
  614. @EndNo_Principal = cbPrincipalTo.SelectedNo;
  615. }
  616. }
  617. if(tbProductNoFrom.CValue != "")
  618. @ProductNoFrom = tbProductNoFrom.CValue;
  619. if(tbProductNoTo.CValue != "")
  620. @ProductNoTo = tbProductNoTo.CValue;
  621. if(cbTypeFrom.Text != "")
  622. @TypeFrom = cbTypeFrom.Text;
  623. if(cbTypeTo.Text != "")
  624. @TypeTo = cbTypeTo.Text;
  625. if(rbCP.Checked)
  626. {
  627. Search("SearchSalesByCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  628. if(RowCount("#FrmProductSalesStatistics") ==0)
  629. {
  630. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  631. }
  632. else
  633. {
  634. PrintReport("ProductSalesStatistics_CustomerProduct","Condition","FrmProductSalesStatistics");
  635. }
  636. }
  637. else if(rbCPS.Checked)
  638. {
  639. Search("SearchSalesByCutomerProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  640. if(RowCount("#FrmProductSalesStatisticsCTP") ==0)
  641. {
  642. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  643. }
  644. else
  645. {
  646. PrintReport("ProductSalesStatistics_CutomerProductType","Condition","FrmProductSalesStatisticsCTP");
  647. }
  648. }else if(rbPP.Checked)
  649. {
  650. Search("SearchSalesByPrincipalProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  651. if(RowCount("#FrmProductSalesStatistics") ==0)
  652. {
  653. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  654. }
  655. else
  656. {
  657. PrintReport("ProductSalesStatistics_PrincipalProduct","Condition","FrmProductSalesStatistics");
  658. }
  659. }else if(rbPPS.Checked)
  660. {
  661. Search("SearchSalesByPrincipalProductType",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  662. if(RowCount("#FrmProductSalesStatistics") ==0)
  663. {
  664. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  665. }
  666. else
  667. {
  668. PrintReport("ProductSalesStatistics_PrincipalProductType","Condition","FrmProductSalesStatistics");
  669. }
  670. }
  671. else
  672. {
  673. Search("SearchSalesByPrincipaCustomerProduct",@StartDate_SaleBill,@EndDate_SaleBill,@CustomerNoFrom ,@CustomerNoTo ,@ProductNoFrom ,@ProductNoTo ,@Level_CustomerFrom ,@Level_CustomerTo ,@StartNo_Principal ,@EndNo_Principal ,@TypeFrom ,@TypeTo,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight("销货单","特价单","查看"));
  674. if(RowCount("#FrmProductSalesStatisticsPCP") ==0)
  675. {
  676. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  677. }
  678. else
  679. {
  680. PrintReport("ProductSalesStatistics_PrincipaCustomerProduct","Condition","FrmProductSalesStatisticsPCP");
  681. }
  682. }
  683. </Click>
  684. </Events>
  685. </IKButton>
  686. </Controls>
  687. <ChildForms>
  688. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo=""
  689. MappingName="客户">
  690. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" />
  691. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" />
  692. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn" />
  693. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn" />
  694. <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn" />
  695. </ChildForm>
  696. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo=""
  697. MappingName="产品">
  698. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  699. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn" />
  700. </ChildForm>
  701. </ChildForms>
  702. <FormatString>
  703. <Format name="SearchCustomerCondition">
  704. if(GetRight("客户基本资料","全权查看"))
  705. {
  706. FormatString("");
  707. }
  708. else
  709. {
  710. FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
  711. }
  712. </Format>
  713. </FormatString>
  714. </Client>
  715. <Server>
  716. <Tables>
  717. <Table name="Condition" Type="Parent">
  718. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 convert(datetime,0) As StartDate_SaleBill,convert(datetime,0) As EndDate_SaleBill,
  719. convert(nvarchar(64),'') as CustomerNoFrom,convert(nvarchar(64),'') as CustomerNoTo,
  720. convert(nvarchar(64),'') as ProductNoFrom,convert(nvarchar(64),'') as ProductNoTo,
  721. convert(nvarchar(64),'') as Level_CustomerFrom,convert(nvarchar(64),'') as Level_CustomerTo,
  722. convert(nvarchar(64),'') As StartPrincipal,convert(nvarchar(64),'') As EndPrincipal,
  723. convert(nvarchar(64),'') As StartNo_Principal,convert(nvarchar(64),'') As EndNo_Principal,convert(nvarchar(64),'') As No_Principal,
  724. convert(nvarchar(64),'') As TypeFrom,convert(nvarchar(64),'') As TypeTo,
  725. convert(nvarchar(64),'') as Name_Creator,convert(datetime,0) As CreateDate
  726. " />
  727. </Table>
  728. </Tables>
  729. <Search>
  730. <SearchCustomerLevel CmdType="Text" CmdText="SELECT Name_TypeDef as Level_Customer FROM TypeDef WHERE Type_TypeDef = 16 ORDER BY Name_TypeDef">
  731. <Tables>
  732. <Table name="CustomerLevel" />
  733. </Tables>
  734. </SearchCustomerLevel>
  735. <SearchPrincipal CmdType="Text" CmdText="
  736. Select No_Employee,Name_Employee
  737. From Employee
  738. Order By No_Employee
  739. ">
  740. <Tables>
  741. <Table name="Principal" />
  742. </Tables>
  743. </SearchPrincipal>
  744. <SearchType CmdType="Text" CmdText="SELECT Name_TypeDef as Type_Product FROM TypeDef WHERE (Type_TypeDef = 8) ORDER BY Name_TypeDef">
  745. <Tables>
  746. <Table name="Type" />
  747. </Tables>
  748. </SearchType>
  749. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer FROM Customer ">
  750. <Tables>
  751. <Table name="AllCustomer" />
  752. </Tables>
  753. </SearchAllCustomer>
  754. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
  755. <Tables>
  756. <Table name="AllProduct" />
  757. </Tables>
  758. </SearchAllProduct>
  759. <SearchSalesByCustomerProduct CmdType="Text" CmdText="declare @cessIn decimal(14,4)
  760. Select @cessIn=CessIn_SystemSetting From SystemSetting
  761. declare @sqlCmd nvarchar(4000)
  762. SELECT A.No_Customer,A.ShortName_Customer, A.No_Product, A.Name_Product,
  763. ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
  764. (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
  765. ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
  766. ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
  767. (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
  768. FROM
  769. (
  770. (
  771. SELECT Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,
  772. GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
  773. When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
  774. else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
  775. CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
  776. FROM SaleBill
  777. LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  778. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  779. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  780. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  781. Where SaleBill.ID_Assessor IS Not Null
  782. AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
  783. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  784. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  785. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  786. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  787. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  788. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  789. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
  790. )
  791. union all
  792. (
  793. SELECT Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,
  794. CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
  795. GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
  796. When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
  797. else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
  798. ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
  799. FROM SaleRtnBill
  800. LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
  801. LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
  802. LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  803. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  804. WHERE SaleRtnBill.ID_Assessor IS NOT NULL
  805. AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
  806. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  807. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  808. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  809. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  810. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  811. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  812. )
  813. )A
  814. GROUP BY A.No_Customer,A.ShortName_Customer,A.No_Product,A.Name_Product
  815. ORDER BY No_Customer
  816. ">
  817. <Params>
  818. <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
  819. <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
  820. <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
  821. <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
  822. <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
  823. <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
  824. <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
  825. <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
  826. <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
  827. <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
  828. <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
  829. <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
  830. <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
  831. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
  832. </Params>
  833. <Tables>
  834. <Table name="FrmProductSalesStatistics"/>
  835. </Tables>
  836. </SearchSalesByCustomerProduct>
  837. <SearchSalesByPrincipalProduct CmdType="Text" CmdText="declare @cessIn decimal(14,4)
  838. Select @cessIn=CessIn_SystemSetting From SystemSetting
  839. declare @sqlCmd nvarchar(4000)
  840. SELECT A.Principal_SaleBill,A.NoProduct,A.NameProduct,
  841. ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
  842. (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
  843. ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
  844. ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
  845. (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
  846. FROM
  847. (
  848. (
  849. SELECT Employee.Name_Employee as Principal_SaleBill,Product.No_Product as NoProduct,Product.Name_Product as NameProduct,
  850. GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
  851. When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
  852. else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
  853. CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
  854. FROM SaleBill
  855. LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  856. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  857. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  858. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  859. Where SaleBill.ID_Assessor IS Not Null
  860. AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
  861. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  862. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  863. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  864. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  865. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  866. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  867. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
  868. )
  869. union all
  870. (
  871. SELECT Employee.Name_Employee as Principal_SaleBill ,Product.No_Product as NoProduct,Product.Name_Product as NameProduct,
  872. CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
  873. GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
  874. When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
  875. else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
  876. ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
  877. FROM SaleRtnBill
  878. LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
  879. LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
  880. LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  881. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  882. WHERE SaleRtnBill.ID_Assessor IS NOT NULL
  883. AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
  884. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  885. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  886. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  887. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  888. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  889. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  890. )
  891. )A
  892. GROUP BY A.Principal_SaleBill,A.NoProduct,A.NameProduct
  893. ORDER BY A.Principal_SaleBill
  894. ">
  895. <Params>
  896. <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
  897. <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
  898. <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
  899. <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
  900. <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
  901. <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
  902. <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
  903. <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
  904. <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
  905. <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
  906. <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
  907. <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
  908. <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
  909. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
  910. </Params>
  911. <Tables>
  912. <Table name="FrmProductSalesStatistics"/>
  913. </Tables>
  914. </SearchSalesByPrincipalProduct>
  915. <SearchSalesByPrincipalProductType CmdType="Text" CmdText="
  916. declare @cessIn decimal(14,4)
  917. Select @cessIn=CessIn_SystemSetting From SystemSetting
  918. declare @sqlCmd nvarchar(4000)
  919. SELECT A.Principal_SaleBill,A.Type_Product,
  920. ISNULL(SUM(A.GoodsSaleBillAmount),0) AS GoodsSaleBillAmount,ISNULL(SUM(A.GoodsSaleRtnBillAmount),0) AS GoodsSaleRtnBillAmount,
  921. (ISNULL(SUM(A.GoodsSaleBillAmount),0)-ISNULL(SUM(A.GoodsSaleRtnBillAmount),0)) AS RealSallAmount,
  922. ISNULL(SUM(A.Quantity_SaleBillProduct),0) AS Quantity_SaleBillProduct,
  923. ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0) AS Quantity_SaleRtnBillProduct,
  924. (ISNULL(SUM(A.Quantity_SaleBillProduct),0)-ISNULL(SUM(A.Quantity_SaleRtnBillProduct),0)) as RealSallQuantity
  925. FROM
  926. (
  927. (
  928. SELECT Employee.Name_Employee as Principal_SaleBill,Product.Type_Product,SaleBill.TaxCurrency_SaleBill as TaxCurrency,
  929. GoodsSaleBillAmount = case SaleBill.TaxCurrency_SaleBill
  930. When '外加' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct)*(1+@cessIn/100)
  931. else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,
  932. CONVERT(DECIMAL,0.00) as GoodsSaleRtnBillAmount,SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL,0.00) as Quantity_SaleRtnBillProduct
  933. FROM SaleBill
  934. LEFT JOIN SaleBillProduct ON SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  935. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  936. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  937. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  938. Where SaleBill.ID_Assessor IS Not Null
  939. AND SaleBill.Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleBill.Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleBill.Date_SaleBill)
  940. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  941. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  942. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  943. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  944. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  945. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  946. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End
  947. )
  948. union all
  949. (
  950. SELECT Employee.Name_Employee as Principal_SaleBill ,Product.Type_Product,SaleRtnBill.TaxCurrency_SaleRtnBill as TaxCurrency,
  951. CONVERT(DECIMAL,0.00) as GoodsSaleBillAmount,
  952. GoodsSaleRtnBillAmount =case SaleRtnBill.TaxCurrency_SaleRtnBill
  953. When '外加' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct)*(1+@cessIn/100)
  954. else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end
  955. ,CONVERT(DECIMAL,0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct
  956. FROM SaleRtnBill
  957. LEFT JOIN SaleRtnBillProduct ON SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill
  958. LEFT JOIN Product ON Product.ID_Product = SaleRtnBillProduct.ID_Product
  959. LEFT JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  960. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  961. WHERE SaleRtnBill.ID_Assessor IS NOT NULL
  962. AND SaleRtnBill.Date_SaleRtnBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate_SaleBill),0),SaleRtnBill.Date_SaleRtnBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate_SaleBill),1),SaleRtnBill.Date_SaleRtnBill)
  963. AND No_Customer BETWEEN ISNULL(@CustomerNoFrom,No_Customer) AND ISNULL(@CustomerNoTo,No_Customer)
  964. AND No_Product BETWEEN ISNULL(@ProductNoFrom,No_Product) AND ISNULL(@ProductNoTo,No_Product)
  965. AND Level_Customer BETWEEN ISNULL(@Level_CustomerFrom,Level_Customer) AND ISNULL(@Level_CustomerTo,Level_Customer)
  966. AND Employee.No_Employee BETWEEN ISNULL(@StartNo_Principal,No_Employee) AND ISNULL(@EndNo_Principal,No_Employee)
  967. AND Type_Product BETWEEN ISNULL(@TypeFrom,Type_Product) AND ISNULL(@TypeTo,Type_Product)
  968. AND Customer.ID_Creator = isnull(@Right,Customer.ID_Creator)
  969. )
  970. )A
  971. GROUP BY A.Principal_SaleBill,A.Type_Product
  972. ORDER BY A.Principal_SaleBill
  973. ">
  974. <Params>
  975. <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
  976. <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
  977. <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
  978. <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
  979. <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
  980. <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
  981. <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
  982. <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
  983. <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
  984. <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
  985. <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
  986. <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
  987. <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
  988. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
  989. </Params>
  990. <Tables>
  991. <Table name="FrmProductSalesStatistics"/>
  992. </Tables>
  993. </SearchSalesByPrincipalProductType>
  994. <SearchSalesByPrincipaCustomerProduct CmdType="Text" CmdText="
  995. declare @cessOut decimal(14,4)
  996. declare @sqlCmd nvarchar(4000)
  997. Select @cessOut=CessOut_SystemSetting From SystemSetting
  998. set @sqlCmd=N'Select Employee.Name_Employee As Principal,Customer.No_Customer,Customer.ShortName_Customer,Product.No_Product,Product.Name_Product,ab.SaleBillMoney,ab.SaleRtnBillMoney,ab.RealMoney, ab.Quantity_SaleBillProduct,ab.Quantity_SaleRtnBillProduct,ab.RealQuantity '
  999. +N' From '
  1000. +N' ( '
  1001. +N' Select a.ID_Principal,a.ID_Customer,a.ID_Product,Sum(a.SaleBillMoney) As SaleBillMoney,Sum(a.SaleRtnBillMoney) As SaleRtnBillMoney,Sum(a.SaleBillMoney-a.SaleRtnBillMoney) As RealMoney, Sum(a.Quantity_SaleBillProduct) As Quantity_SaleBillProduct,Sum(a.Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct,Sum(a.Quantity_SaleBillProduct-a.Quantity_SaleRtnBillProduct) As RealQuantity '
  1002. +N' From '
  1003. +N' ( '
  1004. +N' ( '
  1005. +N' Select SaleBill.ID_Principal,ID_Customer,SaleBillProduct.ID_Product, '
  1006. +N' SaleBillMoney=case SaleBill.TaxCurrency_SaleBill'
  1007. +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
  1008. +N' else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,convert(decimal(14,4),0) As SaleRtnBillMoney ,'
  1009. +N' SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleRtnBillProduct '
  1010. +N' From SaleBillProduct '
  1011. +N' Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill '
  1012. +N' Where SaleBill.ID_Assessor Is Not Null '
  1013. if(@StartDate_SaleBill Is Not Null)
  1014. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) &gt;= 0 '
  1015. if(@EndDate_SaleBill Is Not Null)
  1016. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N' ,SaleBill.Date_SaleBill) &lt;= 0 '
  1017. if(@Special=0)
  1018. set @sqlCmd=@sqlCmd+N' And Special_SaleBill=0 '
  1019. set @sqlCmd=@sqlCmd+N') union all '
  1020. +N' ( '
  1021. +N' Select SaleRtnBill.ID_Principal,ID_Customer,SaleRtnBillProduct.ID_Product,convert(decimal(14,4),0) As SaleBillMoney, '
  1022. +N' SaleRtnBillMoney=case SaleRtnBill.TaxCurrency_SaleRtnBill'
  1023. +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
  1024. +N' else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end,'
  1025. +N' CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct '
  1026. +N' From SaleRtnBillProduct '
  1027. +N' Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill '
  1028. +N' Join Employee On Employee.ID_Employee=SaleRtnBill.ID_Principal '
  1029. +N' Where SaleRtnBill.ID_Assessor Is Not Null '
  1030. if(@StartDate_SaleBill Is Not Null)
  1031. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) &gt;= 0 '
  1032. if(@EndDate_SaleBill Is Not Null)
  1033. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) &lt;= 0 '
  1034. set @sqlCmd=@sqlCmd + N') '
  1035. +N' )a Group By a.ID_Principal,ID_Customer,ID_Product '
  1036. +N' )ab '
  1037. +N' Join Customer ON Customer.ID_Customer=ab.ID_Customer '
  1038. +N' Join Product On Product.ID_Product=ab.ID_Product '
  1039. +N' Join Employee ON Employee.ID_Employee=ab.ID_Principal '
  1040. if(@CustomerNoFrom Is Not Null)
  1041. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@CustomerNoFrom+nchar(39)
  1042. if(@CustomerNoTo Is Not Null)
  1043. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@CustomerNoTo+nchar(39)
  1044. if(@ProductNoFrom Is Not Null)
  1045. set @sqlCmd=@sqlCmd+N' And No_Product &gt;= '+nchar(39)+@ProductNoFrom+nchar(39)
  1046. if(@ProductNoTo Is Not Null)
  1047. set @sqlCmd=@sqlCmd+N' And No_Product &lt;= '+nchar(39)+@ProductNoTo+nchar(39)
  1048. if(@Level_CustomerFrom Is Not Null)
  1049. set @sqlCmd=@sqlCmd+N' And Level_Customer &gt;= '+nchar(39)+@Level_CustomerFrom +nchar(39)
  1050. if(@Level_CustomerTo Is Not Null)
  1051. set @sqlCmd=@sqlCmd+N' And Level_Customer &lt;= '+nchar(39)+@Level_CustomerTo+nchar(39)
  1052. if(@StartNo_Principal Is Not Null)
  1053. set @sqlCmd=@sqlCmd+N' And No_Employee &gt;= '+nchar(39)+@StartNo_Principal +nchar(39)
  1054. if(@EndNo_Principal Is Not Null)
  1055. set @sqlCmd=@sqlCmd+N' And No_Employee &lt;= '+nchar(39)+@EndNo_Principal+nchar(39)
  1056. if(@TypeFrom Is Not Null)
  1057. set @sqlCmd=@sqlCmd+N' And Type_Product &gt;= '+nchar(39)+@TypeFrom +nchar(39)
  1058. if(@TypeTo Is Not Null)
  1059. set @sqlCmd=@sqlCmd+N' And Type_Product &lt;= '+nchar(39)+@TypeTo+nchar(39)
  1060. if(@Right Is Not Null)
  1061. set @sqlCmd=@sqlCmd+N' And Customer.ID_Creator= '+nchar(39)+Convert(nvarchar(64),@Right)+nchar(39)
  1062. set @sqlCmd=@sqlCmd+N' Order By Principal,No_Customer,No_Product '
  1063. EXECUTE sp_executesql @sqlCmd
  1064. ">
  1065. <Params>
  1066. <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
  1067. <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
  1068. <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
  1069. <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
  1070. <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
  1071. <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
  1072. <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
  1073. <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
  1074. <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
  1075. <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
  1076. <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
  1077. <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
  1078. <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
  1079. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
  1080. </Params>
  1081. <Tables>
  1082. <Table name="FrmProductSalesStatisticsPCP"/>
  1083. </Tables>
  1084. </SearchSalesByPrincipaCustomerProduct>
  1085. <SearchSalesByCutomerProductType CmdType="Text" CmdText="
  1086. declare @cessOut decimal(14,4)
  1087. declare @sqlCmd nvarchar(4000)
  1088. Select @cessOut=CessOut_SystemSetting From SystemSetting
  1089. Set @sqlCmd=N'Select Customer.No_Customer,ab.Type_Product,ab.SaleBillMoney,ab.SaleRtnBillMoney,ab.RealMoney , ab.Quantity_SaleBillProduct,ab.Quantity_SaleRtnBillProduct,ab.RealQuantity '
  1090. +N' From '
  1091. +N' ( '
  1092. +N' Select a.ID_Customer,a.Type_Product,Sum(a.SaleBillMoney) As SaleBillMoney,Sum(a.SaleRtnBillMoney) As SaleRtnBillMoney,Sum(a.SaleBillMoney-a.SaleRtnBillMoney) As RealMoney , Sum(a.Quantity_SaleBillProduct) As Quantity_SaleBillProduct,Sum(a.Quantity_SaleRtnBillProduct) As Quantity_SaleRtnBillProduct,Sum(a.Quantity_SaleBillProduct-a.Quantity_SaleRtnBillProduct) As RealQuantity '
  1093. +N' From '
  1094. +N' ( '
  1095. +N' ( '
  1096. +N' Select ID_Customer,Type_Product,'
  1097. +N' SaleBillMoney=case SaleBill.TaxCurrency_SaleBill'
  1098. +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
  1099. +N' else (Quantity_SaleBillProduct*UnitPrice_SaleBillProduct) end,convert(decimal(14,4), 0) As SaleRtnBillMoney ,'
  1100. +N' SaleBillProduct.Quantity_SaleBillProduct as Quantity_SaleBillProduct,CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleRtnBillProduct '
  1101. +N' From SaleBillProduct '
  1102. +N' Join SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill '
  1103. +N' Join Product On Product.ID_Product=SaleBillProduct.ID_Product '
  1104. +N' Join Employee On Employee.ID_Employee=SaleBill.ID_Principal '
  1105. +N' Where SaleBill.ID_Assessor Is Not Null '
  1106. if(@StartDate_SaleBill Is Not Null)
  1107. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) &gt;= 0 '
  1108. if(@EndDate_SaleBill Is Not Null)
  1109. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleBill.Date_SaleBill) &lt;= 0 '
  1110. if(@ProductNoFrom Is Not Null)
  1111. set @sqlCmd=@sqlCmd+N' And No_Product &gt;= '+nchar(39)+@ProductNoFrom+nchar(39)
  1112. if(@ProductNoTo Is Not Null)
  1113. set @sqlCmd=@sqlCmd+N' And No_Product &lt;= '+nchar(39)+@ProductNoTo+nchar(39)
  1114. if(@TypeFrom Is Not Null)
  1115. set @sqlCmd=@sqlCmd+N' And Type_Product &gt;= '+nchar(39)+@TypeFrom +nchar(39)
  1116. if(@TypeTo Is Not Null)
  1117. set @sqlCmd=@sqlCmd+N' And Type_Product &lt;= '+nchar(39)+@TypeTo+nchar(39)
  1118. if(@StartNo_Principal Is Not Null)
  1119. set @sqlCmd=@sqlCmd+N' And No_Employee &gt;= '+nchar(39)+@StartNo_Principal +nchar(39)
  1120. if(@EndNo_Principal Is Not Null)
  1121. set @sqlCmd=@sqlCmd+N' And No_Employee &lt;= '+nchar(39)+@EndNo_Principal+nchar(39)
  1122. if(@Special=0)
  1123. set @sqlCmd=@sqlCmd+N' And Special_SaleBill=0 '
  1124. set @sqlCmd=@sqlCmd+N' ) '
  1125. +N' union all'
  1126. +N' ( '
  1127. +N' Select ID_Customer,Type_Product,convert(decimal(14,4),0) As SaleBillMoney,'
  1128. +N' SaleRtnBillMoney=case SaleRtnBill.TaxCurrency_SaleRtnBill'
  1129. +N' When '+nchar(39)+'外加'+nchar(39)+N' Then (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct*(1+'+convert(nvarchar(64),@cessOut)+N'/100))'
  1130. +N' else (Quantity_SaleRtnBillProduct*UnitPrice_SaleRtnBillProduct) end , '
  1131. +N' CONVERT(DECIMAL(14,4),0.00) as Quantity_SaleBillProduct,SaleRtnBillProduct.Quantity_SaleRtnBillProduct as Quantity_SaleRtnBillProduct '
  1132. +N' From SaleRtnBillProduct '
  1133. +N' Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill '
  1134. +N' Join Product On Product.ID_Product=SaleRtnBillProduct.ID_Product '
  1135. +N' Join Employee On Employee.ID_Employee=SaleRtnBill.ID_Principal '
  1136. +N' Where SaleRtnBill.ID_Assessor Is Not Null '
  1137. if(@StartDate_SaleBill Is Not Null)
  1138. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) &gt;= 0 '
  1139. if(@EndDate_SaleBill Is Not Null)
  1140. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate_SaleBill)+nchar(39)+N', SaleRtnBill.Date_SaleRtnBill) &lt;= 0 '
  1141. if(@ProductNoFrom Is Not Null)
  1142. set @sqlCmd=@sqlCmd+N' And No_Product &gt;= '+nchar(39)+@ProductNoFrom+nchar(39)
  1143. if(@ProductNoTo Is Not Null)
  1144. set @sqlCmd=@sqlCmd+N' And No_Product &lt;= '+nchar(39)+@ProductNoTo+nchar(39)
  1145. if(@TypeFrom Is Not Null)
  1146. set @sqlCmd=@sqlCmd+N' And Type_Product &gt;= '+nchar(39)+@TypeFrom +nchar(39)
  1147. if(@TypeTo Is Not Null)
  1148. set @sqlCmd=@sqlCmd+N' And Type_Product &lt;= '+nchar(39)+@TypeTo+nchar(39)
  1149. if(@StartNo_Principal Is Not Null)
  1150. set @sqlCmd=@sqlCmd+N' And No_Employee &gt;= '+nchar(39)+@StartNo_Principal +nchar(39)
  1151. if(@EndNo_Principal Is Not Null)
  1152. set @sqlCmd=@sqlCmd+N' And No_Employee &lt;= '+nchar(39)+@EndNo_Principal+nchar(39)
  1153. set @sqlCmd=@sqlCmd+N' ) '
  1154. +N' )a Group By a.ID_Customer,a.Type_Product '
  1155. +N' )ab '
  1156. +N' Join Customer On Customer.ID_Customer=ab.ID_Customer '
  1157. if(@CustomerNoFrom Is Not Null)
  1158. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@CustomerNoFrom+nchar(39)
  1159. if(@CustomerNoTo Is Not Null)
  1160. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@CustomerNoTo+nchar(39)
  1161. if(@Level_CustomerFrom Is Not Null)
  1162. set @sqlCmd=@sqlCmd+N' And Level_Customer &gt;= '+nchar(39)+@Level_CustomerFrom +nchar(39)
  1163. if(@Level_CustomerTo Is Not Null)
  1164. set @sqlCmd=@sqlCmd+N' And Level_Customer &lt;= '+nchar(39)+@Level_CustomerTo+nchar(39)
  1165. if(@Right Is Not Null)
  1166. set @sqlCmd=@sqlCmd+N' And Customer.ID_Creator= '+nchar(39)+Convert(nvarchar(64),@Right)+nchar(39)
  1167. set @sqlCmd=@sqlCmd+N' Order By No_Customer,Type_Product'
  1168. EXECUTE sp_executesql @sqlCmd
  1169. ">
  1170. <Params>
  1171. <Param name="@StartDate_SaleBill" type="SaleBill.Date_SaleBill" Index="0" />
  1172. <Param name="@EndDate_SaleBill" type="SaleBill.Date_SaleBill" Index="1" />
  1173. <Param name="@CustomerNoFrom" type="SaleBill.No_SaleBill" Index="2" />
  1174. <Param name="@CustomerNoTo" type="SaleBill.No_SaleBill" Index="3" />
  1175. <Param name="@ProductNoFrom" type="Customer.No_Customer" Index="4" />
  1176. <Param name="@ProductNoTo" type="Customer.No_Customer" Index="5" />
  1177. <Param name="@Level_CustomerFrom" type="SaleBill.No_SaleBill" Index="6" />
  1178. <Param name="@Level_CustomerTo" type="SaleBill.No_SaleBill" Index="7" />
  1179. <Param name="@StartNo_Principal" type="Location.Name_Location" Index="8" />
  1180. <Param name="@EndNo_Principal" type="Location.Name_Location" Index="9" />
  1181. <Param name="@TypeFrom" type="Location.Name_Location" Index="10" />
  1182. <Param name="@TypeTo" type="Location.Name_Location" Index="11" />
  1183. <Param name="@Right" type="SaleBill.ID_Customer" Index="12" />
  1184. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="13" />
  1185. </Params>
  1186. <Tables>
  1187. <Table name="FrmProductSalesStatisticsCTP"/>
  1188. </Tables>
  1189. </SearchSalesByCutomerProductType>
  1190. </Search>
  1191. </Server>
  1192. <Lables>
  1193. <Search>
  1194. </Search>
  1195. </Lables>
  1196. </Form>
  1197. </Forms>