FrmCustomerAccountStatistics.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmCustomerAccountStatistics">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="客户账款统计";
  9. GetSchema();
  10. txtCoNo.CValue=GetCurrentCompanyNo();
  11. txtCoName.CValue=GetCurrentCompanyShortName();
  12. Empty();
  13. NewInstance();
  14. #UI.StartDate = GetCurrentTime();
  15. #UI.EndDate = GetCurrentTime();
  16. ]]>
  17. </Load>
  18. <Closing>
  19. ;
  20. </Closing>
  21. <Closed>
  22. ;
  23. </Closed>
  24. </Events>
  25. <Mode>
  26. <Search>
  27. <Lable name="Search"/>
  28. </Search>
  29. </Mode>
  30. <Controls>
  31. <IKDateTimePicker name="dtStart" DataSource="UI.StartDate">
  32. <Events>
  33. <CheckedChanged>
  34. dtEnd.Checked = dtStart.Checked;
  35. </CheckedChanged>
  36. <ValueChanged>
  37. dtEnd.CValue = dtStart.CValue;
  38. </ValueChanged>
  39. </Events>
  40. </IKDateTimePicker>
  41. <IKDateTimePicker name="dtEnd" DataSource="UI.EndDate"/>
  42. <IKTextButton name="tbCustomerNo1" DataSource="UI.StartNo_Customer">
  43. <Events>
  44. <Click>
  45. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo1.CValue);
  46. if( @temp == "" )
  47. return;
  48. tbCustomerNo1.CValue = @temp;
  49. </Click>
  50. <TextBoxButtonTextChanged>
  51. tbCustomerNo2.CValue = tbCustomerNo1.CValue;
  52. </TextBoxButtonTextChanged>
  53. </Events>
  54. </IKTextButton>
  55. <IKTextButton name="tbCustomerNo2" DataSource="UI.EndNo_Customer">
  56. <Events>
  57. <Click>
  58. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo2.CValue);
  59. if( @temp == "" )
  60. return;
  61. tbCustomerNo2.CValue = @temp;
  62. </Click>
  63. </Events>
  64. </IKTextButton>
  65. <IKButton name="btnView">
  66. <Events>
  67. <Click>
  68. UpdateForm(false,"");
  69. @StartDate=DBNull();
  70. @EndDate=DBNull();
  71. @StartNo_Customer = DBNull();
  72. @EndNo_Customer = DBNull();
  73. if(dtStart.Checked)
  74. @StartDate=dtStart.Value;
  75. else
  76. #UI.StartDate=DBNull();
  77. if(dtEnd.Checked)
  78. @EndDate=dtEnd.Value;
  79. else
  80. #UI.EndDate=DBNull();
  81. if(tbCustomerNo1.CValue != "")
  82. @StartNo_Customer = tbCustomerNo1.CValue;
  83. if(tbCustomerNo2.CValue != "")
  84. @EndNo_Customer = tbCustomerNo2.CValue;
  85. Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
  86. if(RowCount("#FrmCustomerAccountStatistics")==0)
  87. {
  88. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  89. }
  90. else
  91. {
  92. PrintReport("UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
  93. }
  94. </Click>
  95. </Events>
  96. </IKButton>
  97. <IKButton name="btnExcel">
  98. <Events>
  99. <Click>
  100. UpdateForm(false,"");
  101. @StartDate=DBNull();
  102. @EndDate=DBNull();
  103. @StartNo_Customer = DBNull();
  104. @EndNo_Customer = DBNull();
  105. if(dtStart.Checked)
  106. @StartDate=dtStart.Value;
  107. else
  108. #UI.StartDate=DBNull();
  109. if(dtEnd.Checked)
  110. @EndDate=dtEnd.Value;
  111. else
  112. #UI.EndDate=DBNull();
  113. if(tbCustomerNo1.CValue != "")
  114. @StartNo_Customer = tbCustomerNo1.CValue;
  115. if(tbCustomerNo2.CValue != "")
  116. @EndNo_Customer = tbCustomerNo2.CValue;
  117. Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
  118. if(RowCount("#FrmCustomerAccountStatistics")==0)
  119. {
  120. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  121. }
  122. else
  123. {
  124. PrintReport("Excel","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
  125. }
  126. </Click>
  127. </Events>
  128. </IKButton>
  129. <IKButton name="btnWord">
  130. <Events>
  131. <Click>
  132. UpdateForm(false,"");
  133. @StartDate=DBNull();
  134. @EndDate=DBNull();
  135. @StartNo_Customer = DBNull();
  136. @EndNo_Customer = DBNull();
  137. if(dtStart.Checked)
  138. @StartDate=dtStart.Value;
  139. else
  140. #UI.StartDate=DBNull();
  141. if(dtEnd.Checked)
  142. @EndDate=dtEnd.Value;
  143. else
  144. #UI.EndDate=DBNull();
  145. if(tbCustomerNo1.CValue != "")
  146. @StartNo_Customer = tbCustomerNo1.CValue;
  147. if(tbCustomerNo2.CValue != "")
  148. @EndNo_Customer = tbCustomerNo2.CValue;
  149. Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
  150. if(RowCount("#FrmCustomerAccountStatistics")==0)
  151. {
  152. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  153. }
  154. else
  155. {
  156. PrintReport("Word","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
  157. }
  158. </Click>
  159. </Events>
  160. </IKButton>
  161. <IKButton name="btnPrint">
  162. <Events>
  163. <Click>
  164. UpdateForm(false,"");
  165. @StartDate=DBNull();
  166. @EndDate=DBNull();
  167. @StartNo_Customer = DBNull();
  168. @EndNo_Customer = DBNull();
  169. if(dtStart.Checked)
  170. @StartDate=dtStart.Value;
  171. else
  172. #UI.StartDate=DBNull();
  173. if(dtEnd.Checked)
  174. @EndDate=dtEnd.Value;
  175. else
  176. #UI.EndDate=DBNull();
  177. if(tbCustomerNo1.CValue != "")
  178. @StartNo_Customer = tbCustomerNo1.CValue;
  179. if(tbCustomerNo2.CValue != "")
  180. @EndNo_Customer = tbCustomerNo2.CValue;
  181. Search("SearchCustomerAccountStatistics",@StartDate,@EndDate,@StartNo_Customer,@EndNo_Customer);
  182. if(RowCount("#FrmCustomerAccountStatistics")==0)
  183. {
  184. MessageBox("没有查找到与此相匹配的纪录,未产生报表!",@Title);
  185. }
  186. else
  187. {
  188. PrintReport("PrintToPrinter","UIFrmCustomerAccountStatistics","UI","FrmCustomerAccountStatistics");
  189. }
  190. </Click>
  191. </Events>
  192. </IKButton>
  193. </Controls>
  194. <ChildForms>
  195. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo="" MappingName="客户">
  196. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  197. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  198. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  199. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  200. <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
  201. </ChildForm>
  202. </ChildForms>
  203. <FormatString>
  204. <Format name="SearchCustomerCondition">
  205. if(GetRight("客户基本资料","全权查看"))
  206. {
  207. FormatString("");
  208. }
  209. else
  210. {
  211. FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
  212. }
  213. </Format>
  214. </FormatString>
  215. </Client>
  216. <Server>
  217. <Tables>
  218. <Table name="UI" Type="Parent">
  219. <GetSchema CmdType="Text" CmdText="Select TOP 0 convert(datetime,0) As StartDate
  220. ,convert(datetime,0) As EndDate
  221. ,convert(nvarchar(64),'') As StartNo_Customer
  222. ,convert(nvarchar(64),'') As EndNo_Customer"/>
  223. </Table>
  224. </Tables>
  225. <Search>
  226. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer FROM Customer ">
  227. <Tables>
  228. <Table name="AllCustomer" />
  229. </Tables>
  230. </SearchAllCustomer>
  231. <SearchCustomerAccountStatistics CmdType="Text" CmdText="declare @sqlCmd nvarchar(4000)
  232. set @sqlCmd=N' Select No_Customer'
  233. +N' ,ShortName_Customer'
  234. +N' ,'+nchar(39)+'期初'+nchar(39)+N' As BillType'
  235. +N' ,'+nchar(39)+''+nchar(39)+N' As BillNo'
  236. +N' ,'+nchar(39)+''+nchar(39)+N' As BillDate'
  237. +N' ,(OpeningPrePayBalance_Customer + IsNull(B.BiginBalance_PreGet,0)) As PrePayMoney'
  238. +N' ,(OpeningToGetBalance_Customer + IsNull(C.Amount_SaleBill,0) - IsNull(D.Amount_SaleRtnBill,0)) As ToGetMoney'
  239. +N' ,((OpeningPrePayBalance_Customer + IsNull(B.BiginBalance_PreGet,0)) - (OpeningToGetBalance_Customer + IsNull(C.Amount_SaleBill,0) - IsNull(D.Amount_SaleRtnBill,0))) As Balance'
  240. +N' From'
  241. +N' ('
  242. +N' Select ID_Customer'
  243. +N' ,No_Customer'
  244. +N' ,ShortName_Customer'
  245. +N' ,OpeningPrePayBalance_Customer'
  246. +N' ,OpeningToGetBalance_Customer'
  247. +N' From Customer'
  248. +N' Where ID_Customer Is Not Null'
  249. if(@StartNo_Customer Is Not Null)
  250. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@StartNo_Customer+nchar(39)
  251. if(@EndNo_Customer Is Not Null)
  252. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@EndNo_Customer+nchar(39)
  253. set @sqlCmd=@sqlCmd+N' ) A'
  254. +N' Left Join'
  255. +N' ('
  256. +N' Select ID_Customer'
  257. +N' ,Sum(Amount_PreGet) As BiginBalance_PreGet'
  258. +N' From PreGet'
  259. +N' Where PreGet.ID_Assessor Is Not Null'
  260. if (@StartDate Is Not Null)
  261. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_PreGet) &lt;=0 '
  262. set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
  263. +N' )B On B.ID_Customer = A.ID_Customer'
  264. +N' Left Join'
  265. +N' ('
  266. +N' Select ID_Customer'
  267. +N' ,Sum(Amount_SaleBill) As Amount_SaleBill'
  268. +N' From SaleBill'
  269. +N' Where SaleBill.ID_Assessor Is Not Null'
  270. if (@StartDate Is Not Null)
  271. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleBill) &lt;=0 '
  272. set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
  273. +N' ) C On C.ID_Customer = A.ID_Customer'
  274. +N' Left Join'
  275. +N' ('
  276. +N' Select ID_Customer'
  277. +N' ,Sum(Amount_SaleRtnBill) As Amount_SaleRtnBill'
  278. +N' From SaleRtnBill'
  279. +N' Where SaleRtnBill.ID_Assessor Is Not Null'
  280. if (@StartDate Is Not Null)
  281. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleRtnBill) &lt;=0 '
  282. set @sqlCmd=@sqlCmd+N' Group By ID_Customer'
  283. +N' ) D On D.ID_Customer = A.ID_Customer'
  284. +N' Union All'
  285. +N' Select No_Customer'
  286. +N' ,ShortName_Customer'
  287. +N' ,'+nchar(39)+'销货单'+nchar(39)+N' As BillType'
  288. +N' ,No_SaleBill As BillNo'
  289. +N' ,Date_SaleBill As BillDate'
  290. +N' ,0 As PrePayMoney'
  291. +N' ,Amount_SaleBill As ToGetMoney'
  292. +N' ,0 As Balance'
  293. +N' From SaleBill'
  294. +N' Left Join Customer On Customer.ID_Customer = SaleBill.ID_Customer'
  295. +N' Where SaleBill.ID_Assessor Is Not Null'
  296. if(@StartDate Is Not Null)
  297. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleBill) &gt;=0 '
  298. if(@EndDate Is Not Null)
  299. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_SaleBill) &lt;=0 '
  300. if(@StartNo_Customer Is Not Null)
  301. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@StartNo_Customer+nchar(39)
  302. if(@EndNo_Customer Is Not Null)
  303. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@EndNo_Customer+nchar(39)
  304. set @sqlCmd=@sqlCmd+N' Union All'
  305. +N' Select No_Customer'
  306. +N' ,ShortName_Customer'
  307. +N' ,'+nchar(39)+'退货单'+nchar(39)+N' As BillType'
  308. +N' ,No_SaleRtnBill As BillNo'
  309. +N' ,Date_SaleRtnBill As BillDate'
  310. +N' ,0 As PrePayMoney'
  311. +N' ,Amount_SaleRtnBill As ToGetMoney'
  312. +N' ,0 As Balance'
  313. +N' From SaleRtnBill'
  314. +N' Left Join Customer On Customer.ID_Customer = SaleRtnBill.ID_Customer'
  315. +N' Where SaleRtnBill.ID_Assessor Is Not Null And IsPrevBill_SaleRtnBill = 0'
  316. if(@StartDate Is Not Null)
  317. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_SaleRtnBill) &gt;=0 '
  318. if(@EndDate Is Not Null)
  319. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_SaleRtnBill) &lt;=0 '
  320. if(@StartNo_Customer Is Not Null)
  321. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@StartNo_Customer+nchar(39)
  322. if(@EndNo_Customer Is Not Null)
  323. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@EndNo_Customer+nchar(39)
  324. set @sqlCmd=@sqlCmd+N' Union All'
  325. +N' Select No_Customer'
  326. +N' ,ShortName_Customer'
  327. +N' ,'+nchar(39)+'预收帐款'+nchar(39)+N' As BillType'
  328. +N' ,No_PreGet As BillNo'
  329. +N' ,Date_PreGet As BillDate'
  330. +N' ,Amount_PreGet As PrePayMoney'
  331. +N' ,0 As ToGetMoney'
  332. +N' ,0 As Balance'
  333. +N' From PreGet'
  334. +N' Left Join Customer On Customer.ID_Customer = PreGet.ID_Customer'
  335. +N' Where PreGet.ID_Assessor Is Not Null'
  336. if(@StartDate Is Not Null)
  337. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@StartDate)+nchar(39)+N',Date_PreGet) &gt;=0 '
  338. if(@EndDate Is Not Null)
  339. set @sqlCmd=@sqlCmd+N' And DateDiff(day,'+nchar(39)+convert(nvarchar(64),@EndDate)+nchar(39)+N',Date_PreGet) &lt;=0 '
  340. if(@StartNo_Customer Is Not Null)
  341. set @sqlCmd=@sqlCmd+N' And No_Customer &gt;= '+nchar(39)+@StartNo_Customer+nchar(39)
  342. if(@EndNo_Customer Is Not Null)
  343. set @sqlCmd=@sqlCmd+N' And No_Customer &lt;= '+nchar(39)+@EndNo_Customer+nchar(39)
  344. set @sqlCmd=@sqlCmd+N' Order By No_Customer,BillNo,BillDate'
  345. EXECUTE sp_executesql @sqlCmd">
  346. <Params>
  347. <Param name="@StartDate" type="SaleBill.Date_SaleBill" Index="0" />
  348. <Param name="@EndDate" type="SaleBill.Date_SaleBill" Index="1" />
  349. <Param name="@StartNo_Customer" type="Customer.No_Customer" Index="2" />
  350. <Param name="@EndNo_Customer" type="Customer.No_Customer" Index="3" />
  351. </Params>
  352. <Tables>
  353. <Table name="FrmCustomerAccountStatistics"/>
  354. </Tables>
  355. </SearchCustomerAccountStatistics>
  356. </Search>
  357. </Server>
  358. </Form>
  359. </Forms>