FrmReceivableStrike.xml 152 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmReceivableStrike">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title = "应收帐款冲帐";
  9. @ErrorDetail="";
  10. GetSchema();
  11. Search("SearchReceiver");
  12. Search("SearchSystemSetting");
  13. Search("SearchFromBillInInvoice","p");
  14. @SysCurrency=#SystemSetting.SysCurrency_SystemSetting;
  15. ChangeMode("Search");
  16. dgReceiveMoney.NoMember = "No_ReceivablesStrikeMethod";
  17. dgBill.NoMember = "No_ReceivablesStrikeBills";
  18. ]]>
  19. </Load>
  20. <Closing>
  21. ;
  22. </Closing>
  23. <Closed>
  24. ;
  25. </Closed>
  26. </Events>
  27. <Mode>
  28. <Search>
  29. <Lable name="Search" />
  30. </Search>
  31. <New>
  32. <Lable name="New" />
  33. </New>
  34. <View>
  35. <Lable name="View" />
  36. </View>
  37. <Modify>
  38. <Lable name="Modify" />
  39. </Modify>
  40. </Mode>
  41. <Controls>
  42. <IKDateTimePicker name="dtDate" DataSource="ReceivablesStrike.Date_ReceivablesStrike"></IKDateTimePicker>
  43. <IKTextButton name="tbNo" DataSource="ReceivablesStrike.No_ReceivablesStrike">
  44. <Events>
  45. <Enter>
  46. <![CDATA[
  47. if (tbNo.ReadOnly == false)
  48. {
  49. if (tbNo.CValue != StringEmpty())
  50. {
  51. UpdateForm(false, "");
  52. if (Search("SearchReceivablesStrikeWithNo", tbNo.CValue))
  53. {
  54. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  55. }
  56. else
  57. {
  58. MessageBox("该应收帐款冲帐单据不存在!", @Title);
  59. return;
  60. }
  61. }
  62. else
  63. {
  64. MessageBox("请输入应收帐款冲帐单号!", @Title);
  65. return;
  66. }
  67. }
  68. ]]>
  69. <Lable name="CountSum" />
  70. </Enter>
  71. <Click>
  72. ShowSearchBox("BillSearch","NODEPOT", "tbNo", tbNo.CValue);
  73. </Click>
  74. </Events>
  75. </IKTextButton>
  76. <IKCheckBox name="cbPrev" DataSource="ReceivablesStrike.Prev_ReceivablesStrike">
  77. <Events>
  78. <CheckedChanged>
  79. <![CDATA[
  80. if (cbPrev.Checked)
  81. {
  82. if(RowCount("#ReceivablesStrikeBills")>0)
  83. {
  84. Empty("#ReceivablesStrikeBills");
  85. SuspendLayout();
  86. for (@i =0;@i<RowCount("#ReceivablesStrikeMethod");@i++)
  87. {
  88. SetPosition("#ReceivablesStrikeMethod", @i);
  89. if(#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod > 0)
  90. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod=0.00;
  91. }
  92. ResumeLayout();
  93. }
  94. btnSearchByInvoice.Enabled = false;
  95. btnAutoStrike.Enabled = false;
  96. btnSearch.Enabled = false;
  97. }
  98. else
  99. {
  100. btnSearchByInvoice.Enabled = false;
  101. btnAutoStrike.Enabled = true;
  102. btnSearch.Enabled = true;
  103. }
  104. ]]>
  105. <Lable name="CountSum" />
  106. </CheckedChanged>
  107. </Events>
  108. </IKCheckBox>
  109. <IKTextButton name="tbCustomerNo" DataSource="ReceivablesStrike.No_Customer">
  110. <Events>
  111. <Enter>
  112. <![CDATA[
  113. if (tbCustomerNo.ReadOnly == false)
  114. {
  115. UpdateForm(false, "");
  116. if(tbCustomerNo.CValue!=StringEmpty())
  117. {
  118. if (!Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  119. {
  120. MessageBox("该客户不存在!", @Title);
  121. @temp = ShowSearchBox("CustomerSearch", "INFOMATION", tbCustomerNo.CValue);
  122. if (@temp != "")
  123. {
  124. tbCustomerNo.CValue = @temp;
  125. ActiveControlEvent("tbCustomerNo", "Enter");
  126. return;
  127. }
  128. }
  129. else
  130. {
  131. if (Search("SearchCustomersCustomer",tbCustomerNo.CValue))
  132. {
  133. MessageBox("该客户为 "+ #CustomersCustomer.No_Customer +" 的客户,不能填单!");
  134. tbCustomerNo.Text = "";
  135. return;
  136. }
  137. if(!Equals(#Customer.SuspendDate_Customer,DBNull()))
  138. {
  139. MessageBox("该客户已停用!",@Title);
  140. }
  141. #ReceivablesStrike.ID_Customer = #Customer.ID_Customer;
  142. #ReceivablesStrike.ShortName_Customer = #Customer.ShortName_Customer;
  143. #ReceivablesStrike.GetCurrency_ReceivablesStrike = #Customer.PayLimitCurrency;
  144. #ReceivablesStrike.PrePayBalance_Customer = #Customer.PrePayBalance_Customer;
  145. if(Search("SearchPreGet",tbCustomerNo.CValue))
  146. {
  147. Empty("#ReceivablesStrikeMethod");
  148. MergeTable("#ReceivablesStrikeMethod1","#ReceivablesStrikeMethod");
  149. }
  150. if(Search("SearchLastBalace",tbCustomerNo.CValue))
  151. {
  152. ntbOpeningToGetBalance.CValue = #Balance.Balance;
  153. }
  154. }
  155. }
  156. else
  157. {
  158. MessageBox("请输入客户编号!",@Title);
  159. #ReceivablesStrike.ID_Customer = GuidEmpty();
  160. #ReceivablesStrike.ShortName_Customer = "";
  161. #ReceivablesStrike.PrePayBalance_Customer = 0;
  162. #ReceivablesStrike.GetCurrency_ReceivablesStrike = "";
  163. tbCustomerNo.Focus();
  164. }
  165. UpdateForm(true, "");
  166. }
  167. ]]>
  168. </Enter>
  169. <Click>
  170. <![CDATA[
  171. if (tbCustomerNo.ReadOnly == false)
  172. {
  173. @temp = ShowSearchBox("CustomerSearch", "INFOMATION", tbCustomerNo.CValue);
  174. if ( @temp == "" )
  175. return;
  176. tbCustomerNo.CValue = @temp;
  177. ActiveControlEvent("tbCustomerNo", "Enter");
  178. }
  179. ]]>
  180. </Click>
  181. </Events>
  182. </IKTextButton>
  183. <IKTextBox name="txtCustomerName" DataSource="ReceivablesStrike.ShortName_Customer"></IKTextBox>
  184. <IKComboBoxEx name="cbGetCurrency" DisplaySource="ReceivablesStrike.GetCurrency_ReceivablesStrike" DataSource="ReceivablesStrike"></IKComboBoxEx>
  185. <IKComboBoxEx name="cbBillCurrency" DisplaySource="ReceivablesStrike.BillCurrency_ReceivablesStrike" DataSource="ReceivablesStrike"></IKComboBoxEx>
  186. <IKNumericTextBox name="txtRate" DataSource="ReceivablesStrike.Rate_ReceivablesStrike"></IKNumericTextBox>
  187. <IKComboBoxEx name="cbReceiver" ValueSource="ReceivablesStrike.ID_Receiver" DisplaySource="ReceivablesStrike.Name_Employee" NoSource="ReceivablesStrike.No_Receiver" DataSource="Receiver" DisplayMember="Name_Employee" NoMember="No_Employee" ValueMember="ID_Employee">
  188. <Events>
  189. <Reload>
  190. UpdateForm(false, "cbReceiver");
  191. Search("SearchReceiver");
  192. UpdateForm(true, "cbReceiver");
  193. </Reload>
  194. </Events>
  195. </IKComboBoxEx>
  196. <IKTextBox name="txtMaker" DataSource="ReceivablesStrike.Name_Creator"></IKTextBox>
  197. <IKTextBox name="txtAssessor" DataSource="ReceivablesStrike.Name_Assessor"></IKTextBox>
  198. <IKTextBox name="dtAssessDate" DataSource="ReceivablesStrike.AssessDate_ReceivablesStrike"></IKTextBox>
  199. <IKTextBox name="txtLastModUser" DataSource="ReceivablesStrike.Name_LastModUser"></IKTextBox>
  200. <IKTextBox name="dtLastModDate" DataSource="ReceivablesStrike.LastModDate_ReceivablesStrike"></IKTextBox>
  201. <IKTextBox name="txtComment" DataSource="ReceivablesStrike.Comment_ReceivablesStrike"></IKTextBox>
  202. <IKComboBoxEx name="cbPayment" DisplaySource="ReceivablesStrike.Payment_ReceivablesStrike" DataSource="Method" DisplayMember="Result">
  203. <Events>
  204. <Reload>
  205. UpdateForm(false, "cbPayment");
  206. Search("SearchReceivablesStrikeMethod");
  207. UpdateForm(true, "cbPayment");
  208. </Reload>
  209. </Events>
  210. </IKComboBoxEx>
  211. <IKTextBox name="txtMoney" DataSource="ReceivablesStrike.Money_ReceivablesStrike"></IKTextBox>
  212. <IKButton name="btnSearchByInvoice">
  213. <Events>
  214. <Click>
  215. <![CDATA[
  216. @DateStart = DBNull();
  217. @DateEnd = DBNull();
  218. if (dtStart.Checked)
  219. {
  220. @DateStart = dtStart.CValue;
  221. }
  222. if (dtEnd.Checked)
  223. {
  224. @DateEnd = dtEnd.CValue;
  225. }
  226. ShowSearchBox("", "STRIKEIMPORT", "销项发票", "#ReceivablesStrikeBills", @DateStart, @DateEnd);
  227. if (RowCount("#ReceivablesStrikeBills") > 0)
  228. {
  229. for (@i=0; @i<RowCount("#ReceivablesStrikeBills"); @i=@i+1)
  230. {
  231. dgBill.CurrentRowIndex = @i;
  232. }
  233. dgBill.CurrentRowIndex = 0;
  234. }
  235. ]]>
  236. </Click>
  237. </Events>
  238. </IKButton>
  239. <IKButton name="btnSearch">
  240. <Events>
  241. <Click>
  242. <![CDATA[
  243. @DateStart = DBNull();
  244. @DateEnd = DBNull();
  245. if (dtStart.Checked)
  246. {
  247. @DateStart = dtStart.CValue;
  248. }
  249. if (dtEnd.Checked)
  250. {
  251. @DateEnd = dtEnd.CValue;
  252. }
  253. if (Search("SearchSaleInvoice",@DateStart,@DateEnd,tbCustomerNo.CValue))
  254. {
  255. Empty("#ReceivablesStrikeBills");
  256. MergeTable("#ReceivablesStrikeBill1","#ReceivablesStrikeBills");
  257. }
  258. ]]>
  259. </Click>
  260. </Events>
  261. </IKButton>
  262. <IKButton name="btnOK">
  263. <Events>
  264. <Click>
  265. <![CDATA[
  266. if (tbCustomerNo.CValue == "" || !Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  267. {
  268. MessageBox("请输入有效的客户,回车以示确认!",@Title);
  269. tbCustomerNo.Focus();
  270. return;
  271. }
  272. if(!cbReceiver.CheckSelectedItem())
  273. {
  274. MessageBox("请输入有效的收款人!",@Title);
  275. cbReceiver.Focus();
  276. return;
  277. }
  278. if(txtMoney.CValue<= 0)
  279. {
  280. MessageBox("收款金额必须大于0 !",@Title);
  281. txtMoney.Focus();
  282. return;
  283. }
  284. if(!cbPayment.CheckSelectedItem())
  285. {
  286. MessageBox("请输入有效的收款方式",@Title);
  287. cbPayment.Focus();
  288. return;
  289. }
  290. Search("SearchPreGetHead");
  291. if(Search("SearchIsHavePreGet"))
  292. {
  293. if(#PreGet.No_PreGet ==0)
  294. {
  295. Search("CreateNewPreGet2",dtDate.CValue
  296. ,#ReceivablesStrike.ID_Customer
  297. ,#ReceivablesStrike.GetCurrency_ReceivablesStrike
  298. ,#ReceivablesStrike.BillCurrency_ReceivablesStrike
  299. ,#ReceivablesStrike.Rate_ReceivablesStrike
  300. ,cbPayment.SelectedName
  301. ,txtMoney.CValue
  302. ,cbReceiver.SelectedName
  303. ,#ReceivablesStrike.ID_Creator
  304. ,dtDate.CValue
  305. ,#ReceivablesStrike.LastModUser_ReceivablesStrike
  306. ,#ReceivablesStrike.LastModDate_ReceivablesStrike
  307. ,#ReceivablesStrike.ID_Creator
  308. ,dtDate.CValue
  309. ,txtComment.CValue
  310. ,#PreGetHead.Value1_CodeGenerate
  311. ,dtDate.CValue);
  312. }
  313. else
  314. {
  315. Search("CreateNewPreGet",dtDate.CValue
  316. ,#ReceivablesStrike.ID_Customer
  317. ,#ReceivablesStrike.GetCurrency_ReceivablesStrike
  318. ,#ReceivablesStrike.BillCurrency_ReceivablesStrike
  319. ,#ReceivablesStrike.Rate_ReceivablesStrike
  320. ,cbPayment.SelectedName
  321. ,txtMoney.CValue
  322. ,cbReceiver.SelectedName
  323. ,#ReceivablesStrike.ID_Creator
  324. ,dtDate.CValue
  325. ,#ReceivablesStrike.LastModUser_ReceivablesStrike
  326. ,#ReceivablesStrike.LastModDate_ReceivablesStrike
  327. ,#ReceivablesStrike.ID_Creator
  328. ,dtDate.CValue
  329. ,txtComment.CValue
  330. ,#PreGetHead.Value1_CodeGenerate
  331. ,dtDate.CValue);
  332. }
  333. }
  334. Search("UpdateAmount",tbCustomerNo.CValue,txtMoney.CValue);
  335. Search("UpdatePrePayBalance",tbCustomerNo.CValue,txtMoney.CValue);
  336. if(Search("SearchPreGet",tbCustomerNo.CValue))
  337. {
  338. Empty("#ReceivablesStrikeMethod");
  339. MergeTable("#ReceivablesStrikeMethod1","#ReceivablesStrikeMethod");
  340. }
  341. btnOK.Enabled = false;
  342. txtComment.CValue = "";
  343. ]]>
  344. </Click>
  345. </Events>
  346. </IKButton>
  347. <IKButton name="btnVerify">
  348. <Events>
  349. <Click>
  350. <Lable name="Verify" />
  351. MessageBox("校验已通过!",@Title);
  352. </Click>
  353. </Events>
  354. </IKButton>
  355. <IKButton name="btnAutoStrike">
  356. <Events>
  357. <Click>
  358. <![CDATA[
  359. @SumMoney = 0;
  360. @SumMoneyPerGet = 0;
  361. @SumStrike = 0;
  362. @SumAmount = 0;
  363. SuspendLayout();
  364. for (@a=0;@a<RowCount("#ReceivablesStrikeBills");@a++)
  365. {
  366. SetPosition("#ReceivablesStrikeBills", @a);
  367. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = 0;
  368. }
  369. for (@b=0;@b<RowCount("#ReceivablesStrikeMethod");@b++)
  370. {
  371. SetPosition("#ReceivablesStrikeMethod", @b);
  372. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = 0;
  373. }
  374. for (@i =0;@i<RowCount("#ReceivablesStrikeMethod");@i++)
  375. {
  376. SetPosition("#ReceivablesStrikeMethod", @i);
  377. @SumMoney += #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  378. }
  379. for (@l =0;@l<RowCount("#ReceivablesStrikeBills");@l++)
  380. {
  381. SetPosition("#ReceivablesStrikeBills", @l);
  382. @SumMoneyPerGet += #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  383. }
  384. if (@SumMoney > @SumMoneyPerGet)
  385. {
  386. @SumStrike = @SumMoneyPerGet;
  387. }
  388. else
  389. {
  390. @SumStrike = @SumMoney;
  391. }
  392. for (@j=0;@j<RowCount("#ReceivablesStrikeBills");@j++)
  393. {
  394. SetPosition("#ReceivablesStrikeBills", @j);
  395. if (@SumStrike > 0)
  396. {
  397. if (@SumStrike >= #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills)
  398. {
  399. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  400. }
  401. else
  402. {
  403. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = @SumStrike;
  404. }
  405. @SumStrike = @SumStrike - #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills;
  406. }
  407. }
  408. if (@SumMoney > @SumMoneyPerGet)
  409. {
  410. @SumStrike = @SumMoneyPerGet;
  411. }
  412. else
  413. {
  414. @SumStrike = @SumMoney;
  415. }
  416. for (@k=0;@k<RowCount("#ReceivablesStrikeMethod");@k++)
  417. {
  418. SetPosition("#ReceivablesStrikeMethod", @k);
  419. if (@SumStrike > 0)
  420. {
  421. if (@SumStrike > #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod)
  422. {
  423. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  424. }
  425. else
  426. {
  427. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = @SumStrike;
  428. }
  429. @SumStrike = @SumStrike - #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  430. }
  431. }
  432. ResumeLayout();
  433. ]]>
  434. <Lable name="CountSum" />
  435. </Click>
  436. </Events>
  437. </IKButton>
  438. <IKDataGridEx name="dgReceiveMoney" DataSource="ReceivablesStrikeMethod" TableStyleIndex="0">
  439. <DataColumn Index="0" DataSource="ReceivablesStrikeMethod.No_ReceivablesStrikeMethod" />
  440. <DataColumn Index="1" DataSource="ReceivablesStrikeMethod.No_PreGet"/>
  441. <DataColumn Index="2" DataSource="ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod" />
  442. <DataColumn Index="3" DataSource="ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod" />
  443. <DataColumn Index="4" DataSource="ReceivablesStrikeMethod.Comment_PreGet" />
  444. </IKDataGridEx>
  445. <IKDataGridEx name="dgBill" DataSource="ReceivablesStrikeBills" TableStyleIndex="0">
  446. <DataColumn Index="0" DataSource="ReceivablesStrikeBills.No_ReceivablesStrikeBills" />
  447. <DataColumn Index="1" DataSource="ReceivablesStrikeBills.No_SaleInvoice" />
  448. <DataColumn Index="2" DataSource="ReceivablesStrikeBills.No_Invoice" />
  449. <DataColumn Index="3" DataSource="ReceivablesStrikeBills.PayDate_ReceivablesStrikeBills" />
  450. <DataColumn Index="4" DataSource="ReceivablesStrikeBills.Amount_FromBill" />
  451. <DataColumn Index="5" DataSource="ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills" />
  452. <DataColumn Index="6" DataSource="ReceivablesStrikeBills.Strike_ReceivablesStrikeBills" />
  453. <DataColumn Index="7" DataSource="ReceivablesStrikeBills.Discount_ReceivablesStrikeBills" />
  454. <DataColumn Index="8" DataSource="ReceivablesStrikeBills.StrikedAmount_ReceivablesStrikeBills" />
  455. </IKDataGridEx>
  456. <IKFormToolBar name="toolBar">
  457. <Events>
  458. <ClickFirst>
  459. if (Search("SearchReceivablesStrikeFirst", tbNo.CValue))
  460. {
  461. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  462. <Lable name="CountSum" />
  463. }
  464. </ClickFirst>
  465. <ClickPrev>
  466. if (Search("SearchReceivablesStrikePrevious", tbNo.CValue))
  467. {
  468. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  469. <Lable name="CountSum" />
  470. }
  471. </ClickPrev>
  472. <ClickNext>
  473. if (Search("SearchReceivablesStrikeNext", tbNo.CValue))
  474. {
  475. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  476. <Lable name="CountSum" />
  477. }
  478. </ClickNext>
  479. <ClickLast>
  480. if (Search("SearchReceivablesStrikeLast", tbNo.CValue))
  481. {
  482. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  483. <Lable name="CountSum" />
  484. }
  485. </ClickLast>
  486. <ClickEmpty>
  487. ChangeMode("Search");
  488. </ClickEmpty>
  489. <ClickNew>
  490. <![CDATA[
  491. @NextNo = GetNextAutoNumber(true);
  492. if (!Equals(@NextNo, ""))
  493. {
  494. ChangeMode("New");
  495. #ReceivablesStrike.No_ReceivablesStrike = @NextNo;
  496. UpdateForm(true, "tbNo");
  497. }
  498. ]]>
  499. </ClickNew>
  500. <ClickSubmit>
  501. <!--<Lable name="Verify" />-->
  502. <Lable name="SubmitButtonClick" />
  503. </ClickSubmit>
  504. <ClickModify>
  505. ChangeMode("Modify");
  506. <Lable name="CountSum" />
  507. </ClickModify>
  508. <ClickDelete>
  509. <![CDATA[
  510. Delete();
  511. ChangeMode("Search");
  512. ]]>
  513. </ClickDelete>
  514. <ClickPrint>
  515. PrintReport();
  516. </ClickPrint>
  517. <ClickAudit>
  518. <![CDATA[
  519. BeginAudit();
  520. if (tbCustomerNo.CValue == "" || !Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  521. {
  522. MessageBox("请输入有效的客户,回车以示确认!",@Title);
  523. tbCustomerNo.Focus();
  524. return;
  525. }
  526. else
  527. {
  528. SuspendLayout();
  529. for (@V=0;@V<RowCount("#ReceivablesStrikeMethod");@V++)
  530. {
  531. SetPosition("#ReceivablesStrikeMethod", @V);
  532. if (Search("SearchNoAssessorPreGet",tbCustomerNo.CValue))
  533. {
  534. MessageBox("有未审核的收款单号,请重新填单!");
  535. tbCustomerNo.Text = "";
  536. return;
  537. }
  538. if(Search("SearchISDelete",tbCustomerNo.CValue,#ReceivablesStrikeMethod.No_PreGet))
  539. {
  540. if(#ISDelete.No_PreGet==0)
  541. {
  542. MessageBox("有不存在的收款单号,请重新填单!");
  543. tbCustomerNo.Text = "";
  544. return;
  545. }
  546. }
  547. }
  548. ResumeLayout();
  549. }
  550. #ReceivablesStrike.ID_Assessor = GetLoginUserID();
  551. #ReceivablesStrike.Name_Assessor = GetCurrentUser();
  552. #ReceivablesStrike.AssessDate_ReceivablesStrike = DateTimeNow();
  553. if (cbPrev.Checked)
  554. {
  555. @sumMethod = 0;
  556. @sumBills = 0;
  557. @sumPrePayValue = 0;
  558. @SumMoneyPerGet =0;
  559. @SumMoney = 0;
  560. @SumStrike = 0;
  561. if(Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  562. {
  563. SuspendLayout();
  564. for (@a=0;@a<RowCount("#ReceivablesStrikeBills");@a++)
  565. {
  566. SetPosition("#ReceivablesStrikeBills", @a);
  567. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = 0;
  568. }
  569. for (@b=0;@b<RowCount("#ReceivablesStrikeMethod");@b++)
  570. {
  571. SetPosition("#ReceivablesStrikeMethod", @b);
  572. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = 0;
  573. }
  574. for (@i =0;@i<RowCount("#ReceivablesStrikeMethod");@i++)
  575. {
  576. SetPosition("#ReceivablesStrikeMethod", @i);
  577. @SumMoney += #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  578. }
  579. @SumMoneyPerGet += #Customer.OpeningToGetBalance_Customer;
  580. for (@l =0;@l<RowCount("#ReceivablesStrikeBills");@l++)
  581. {
  582. SetPosition("#ReceivablesStrikeBills", @l);
  583. @SumMoneyPerGet += #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  584. }
  585. if (@SumMoney > @SumMoneyPerGet)
  586. {
  587. @SumStrike = @SumMoneyPerGet;
  588. }
  589. else
  590. {
  591. @SumStrike = @SumMoney;
  592. }
  593. for (@j=0;@j<RowCount("#ReceivablesStrikeBills");@j++)
  594. {
  595. SetPosition("#ReceivablesStrikeBills", @j);
  596. @SumMoneyPerGet += #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  597. if (@SumStrike > 0)
  598. {
  599. if (@SumStrike >= #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills)
  600. {
  601. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  602. }
  603. else
  604. {
  605. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = @SumStrike;
  606. }
  607. @SumStrike = @SumStrike - #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills;
  608. }
  609. }
  610. if (@SumMoney > @SumMoneyPerGet)
  611. {
  612. @SumStrike = @SumMoneyPerGet;
  613. }
  614. else
  615. {
  616. @SumStrike = @SumMoney;
  617. }
  618. for (@k=0;@k<RowCount("#ReceivablesStrikeMethod");@k++)
  619. {
  620. SetPosition("#ReceivablesStrikeMethod", @k);
  621. if (@SumStrike > 0)
  622. {
  623. if (@SumStrike > #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod)
  624. {
  625. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  626. }
  627. else
  628. {
  629. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = @SumStrike;
  630. }
  631. @SumStrike = @SumStrike - #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  632. }
  633. }
  634. for (@g=0; @g<RowCount("#ReceivablesStrikeMethod"); @g=@g+1)
  635. {
  636. SetPosition("#ReceivablesStrikeMethod", @g);
  637. @sumPrePayValue += #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  638. }
  639. ResumeLayout();
  640. }
  641. if(Search("SearchOpenging",tbCustomerNo.CValue))
  642. {
  643. if(#Customer.PrePayValue_Customer == #Customer.OpeningToGetBalance_Customer)
  644. {
  645. MessageBox("期初应收帐款已全部冲完,审核失败!",@Title);
  646. return;
  647. }
  648. else
  649. {
  650. Search("UpdatePrePayValue",#ReceivablesStrike.No_Customer,@sumPrePayValue);
  651. }
  652. if(Search("SearchLastBalace",tbCustomerNo.CValue))
  653. {
  654. ntbOpeningToGetBalance.CValue = #Balance.Balance;
  655. }
  656. }
  657. }
  658. Audit();
  659. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  660. EndAudit();
  661. ]]>
  662. <Lable name="CountSum" />
  663. </ClickAudit>
  664. <ClickUnAudit>
  665. <![CDATA[
  666. @sumPrePayValue = 0;
  667. BeginUnAudit();
  668. #ReceivablesStrike.ID_Assessor = DBNull();
  669. #ReceivablesStrike.Name_Assessor = "";
  670. if (cbPrev.Checked)
  671. {
  672. SuspendLayout();
  673. for (@g=0; @g<RowCount("#ReceivablesStrikeMethod"); @g=@g+1)
  674. {
  675. SetPosition("#ReceivablesStrikeMethod", @g);
  676. @sumPrePayValue += #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  677. }
  678. ResumeLayout();
  679. if(Search("SearchOpenging",tbCustomerNo.CValue))
  680. {
  681. Search("ClearPrePayValue",tbCustomerNo.CValue,@sumPrePayValue);
  682. }
  683. }
  684. UnAudit();
  685. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  686. EndUnAudit();
  687. ]]>
  688. <Lable name="CountSum" />
  689. </ClickUnAudit>
  690. <ClickImport>
  691. ;
  692. </ClickImport>
  693. <ClickExport>
  694. ;
  695. </ClickExport>
  696. <ClickClose>
  697. ;
  698. </ClickClose>
  699. <ClickExpand>
  700. if (toolBar.ExpandForm==true)
  701. {
  702. pnRight.Visible=true;<!--PanelRight is not existed-->
  703. }
  704. else
  705. {
  706. pnRight.Visible=false;
  707. }
  708. </ClickExpand>
  709. </Events>
  710. </IKFormToolBar>
  711. </Controls>
  712. <Tables>
  713. <Table name="ReceivablesStrikeBills">
  714. <Events>
  715. <ColumnsChanged>
  716. <No_SaleInvoice>
  717. <Lable name="GetFromBill" />
  718. </No_SaleInvoice>
  719. <Discount_ReceivablesStrikeBills>
  720. #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills=#ReceivablesStrikeBills.Amount_FromBill-#ReceivablesStrikeBills.StrikedAmount_ReceivablesStrikeBills-#ReceivablesStrikeBills.Discount_ReceivablesStrikeBills;
  721. <Lable name="CountSum" />
  722. </Discount_ReceivablesStrikeBills>
  723. </ColumnsChanged>
  724. <RowDeleted>
  725. <Lable name="CountSum" />
  726. </RowDeleted>
  727. </Events>
  728. </Table>
  729. </Tables>
  730. <LockInfomation LockID="ID_ReceivablesStrike" LockNO="No_ReceivablesStrike" LockSearchFunction="SearchReceivablesStrikeWithNo" LockAudit="ID_Assessor"/>
  731. <LogInfomation LogNO="#ReceivablesStrike.No_ReceivablesStrike" RecordFormField="客户编号:#ReceivablesStrike.No_Customer" RecordDataGridField="#ReceivablesStrikeBills.No_SaleInvoice,#ReceivablesStrikeBills.Strike_ReceivablesStrikeBills,#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod"/>
  732. <ChildForms>
  733. <ChildForm name="BillSearch" DataSource="ReceivablesStrike" SearchFunction="SearchAllBill" SearchFunctionByNo="SearchReceivablesStrikeWithNo">
  734. <DataColumn Index="0" MappingName="#ReceivablesStrike.No_ReceivablesStrike" HeaderText="应收帐款冲帐单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  735. <DataColumn Index="1" MappingName="#ReceivablesStrike.Date_ReceivablesStrike" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  736. <DataColumn Index="2" MappingName="#ReceivablesStrike.ShortName_Customer" HeaderText="客户简称" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  737. </ChildForm>
  738. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionByNo="" MappingName="客户">
  739. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  740. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  741. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  742. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  743. <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
  744. </ChildForm>
  745. </ChildForms>
  746. </Client>
  747. <Server>
  748. <Tables>
  749. <Table name="ReceivablesStrike" Type="Parent">
  750. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 ReceivablesStrike.*
  751. ,Customer.No_Customer
  752. ,Customer.ShortName_Customer
  753. ,Customer.PrePayBalance_Customer
  754. ,Employee.No_Employee AS No_Receiver
  755. ,Employee.Name_Employee
  756. ,a.Name_User AS Name_Creator
  757. ,b.Name_User AS Name_Assessor
  758. ,c.Name_User AS Name_LastModUser
  759. ,CONVERT(decimal(18,6), 0) AS SumSale
  760. ,CONVERT(decimal(18,6), 0) AS SumRtn
  761. ,CONVERT(decimal(18,6), 0) AS SumReceive
  762. ,Convert(decimal(18,6), 0) As Earlybalance_ReceivablesStrike
  763. FROM ReceivablesStrike
  764. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  765. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  766. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  767. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  768. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  769. " />
  770. <New CmdType="Text" CmdText="INSERT INTO ReceivablesStrike(ID_ReceivablesStrike
  771. ,No_ReceivablesStrike
  772. ,Date_ReceivablesStrike
  773. ,ID_Customer
  774. ,GetCurrency_ReceivablesStrike
  775. ,BillCurrency_ReceivablesStrike
  776. ,Rate_ReceivablesStrike
  777. ,ID_Receiver
  778. ,ID_Creator
  779. ,Comment_ReceivablesStrike
  780. ,CreateDate_ReceivablesStrike
  781. ,Prev_ReceivablesStrike
  782. ,Money_ReceivablesStrike
  783. ,Payment_ReceivablesStrike)
  784. VALUES (@ID_ReceivablesStrike
  785. ,@No_ReceivablesStrike
  786. ,@Date_ReceivablesStrike
  787. ,@ID_Customer
  788. ,@GetCurrency_ReceivablesStrike
  789. ,@BillCurrency_ReceivablesStrike
  790. ,@Rate_ReceivablesStrike
  791. ,@ID_Receiver
  792. ,@ID_Creator
  793. ,@Comment_ReceivablesStrike
  794. ,@CreateDate_ReceivablesStrike
  795. ,@Prev_ReceivablesStrike
  796. ,@Money_ReceivablesStrike
  797. ,@Payment_ReceivablesStrike)">
  798. <Params>
  799. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrike.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  800. <Param name="@No_ReceivablesStrike" type="ReceivablesStrike.No_ReceivablesStrike" sourceColumn="No_ReceivablesStrike" />
  801. <Param name="@Date_ReceivablesStrike" type="ReceivablesStrike.Date_ReceivablesStrike" sourceColumn="Date_ReceivablesStrike" />
  802. <Param name="@ID_Customer" type="ReceivablesStrike.ID_Customer" sourceColumn="ID_Customer" />
  803. <Param name="@GetCurrency_ReceivablesStrike" type="ReceivablesStrike.GetCurrency_ReceivablesStrike" sourceColumn="GetCurrency_ReceivablesStrike" />
  804. <Param name="@BillCurrency_ReceivablesStrike" type="ReceivablesStrike.BillCurrency_ReceivablesStrike" sourceColumn="BillCurrency_ReceivablesStrike" />
  805. <Param name="@Rate_ReceivablesStrike" type="ReceivablesStrike.Rate_ReceivablesStrike" sourceColumn="Rate_ReceivablesStrike" />
  806. <Param name="@ID_Receiver" type="ReceivablesStrike.ID_Receiver" sourceColumn="ID_Receiver" />
  807. <Param name="@ID_Creator" type="ReceivablesStrike.ID_Creator" sourceColumn="ID_Creator" />
  808. <Param name="@Comment_ReceivablesStrike" type="ReceivablesStrike.Comment_ReceivablesStrike" sourceColumn="Comment_ReceivablesStrike" />
  809. <Param name="@CreateDate_ReceivablesStrike" type="ReceivablesStrike.CreateDate_ReceivablesStrike" sourceColumn="CreateDate_ReceivablesStrike" />
  810. <Param name="@Prev_ReceivablesStrike" type="ReceivablesStrike.Prev_ReceivablesStrike" sourceColumn="Prev_ReceivablesStrike" />
  811. <Param name="@Money_ReceivablesStrike" type="ReceivablesStrike.Money_ReceivablesStrike" sourceColumn="Money_ReceivablesStrike" />
  812. <Param name="@Payment_ReceivablesStrike" type="ReceivablesStrike.Payment_ReceivablesStrike" sourceColumn="Payment_ReceivablesStrike" />
  813. </Params>
  814. </New>
  815. <Update CmdType="Text" CmdText=" UPDATE ReceivablesStrike
  816. SET Date_ReceivablesStrike = @Date_ReceivablesStrike
  817. ,ID_Customer = @ID_Customer
  818. ,GetCurrency_ReceivablesStrike = @GetCurrency_ReceivablesStrike
  819. ,BillCurrency_ReceivablesStrike = @BillCurrency_ReceivablesStrike
  820. ,Rate_ReceivablesStrike = @Rate_ReceivablesStrike
  821. ,ID_Receiver = @ID_Receiver
  822. ,Comment_ReceivablesStrike = @Comment_ReceivablesStrike
  823. ,LastModUser_ReceivablesStrike = @LastModUser_ReceivablesStrike
  824. ,LastModDate_ReceivablesStrike = @LastModDate_ReceivablesStrike
  825. ,Prev_ReceivablesStrike = @Prev_ReceivablesStrike
  826. ,Money_ReceivablesStrike = @Money_ReceivablesStrike
  827. ,Payment_ReceivablesStrike = @Payment_ReceivablesStrike
  828. WHERE ID_ReceivablesStrike = @ID_ReceivablesStrike">
  829. <Params>
  830. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrike.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  831. <Param name="@Date_ReceivablesStrike" type="ReceivablesStrike.Date_ReceivablesStrike" sourceColumn="Date_ReceivablesStrike" />
  832. <Param name="@ID_Customer" type="ReceivablesStrike.ID_Customer" sourceColumn="ID_Customer" />
  833. <Param name="@GetCurrency_ReceivablesStrike" type="ReceivablesStrike.GetCurrency_ReceivablesStrike" sourceColumn="GetCurrency_ReceivablesStrike" />
  834. <Param name="@BillCurrency_ReceivablesStrike" type="ReceivablesStrike.BillCurrency_ReceivablesStrike" sourceColumn="BillCurrency_ReceivablesStrike" />
  835. <Param name="@Rate_ReceivablesStrike" type="ReceivablesStrike.Rate_ReceivablesStrike" sourceColumn="Rate_ReceivablesStrike" />
  836. <Param name="@ID_Receiver" type="ReceivablesStrike.ID_Receiver" sourceColumn="ID_Receiver" />
  837. <Param name="@Comment_ReceivablesStrike" type="ReceivablesStrike.Comment_ReceivablesStrike" sourceColumn="Comment_ReceivablesStrike" />
  838. <Param name="@LastModUser_ReceivablesStrike" type="ReceivablesStrike.LastModUser_ReceivablesStrike" sourceColumn="LastModUser_ReceivablesStrike" />
  839. <Param name="@LastModDate_ReceivablesStrike" type="ReceivablesStrike.LastModDate_ReceivablesStrike" sourceColumn="LastModDate_ReceivablesStrike" />
  840. <Param name="@Prev_ReceivablesStrike" type="ReceivablesStrike.Prev_ReceivablesStrike" sourceColumn="Prev_ReceivablesStrike" />
  841. <Param name="@Money_ReceivablesStrike" type="ReceivablesStrike.Money_ReceivablesStrike" sourceColumn="Money_ReceivablesStrike" />
  842. <Param name="@Payment_ReceivablesStrike" type="ReceivablesStrike.Payment_ReceivablesStrike" sourceColumn="Payment_ReceivablesStrike" />
  843. </Params>
  844. </Update>
  845. <Audit CmdType="Text" CmdText=" Declare @No_SaleInvoice nvarchar(64)
  846. Declare @Strike_ReceivablesStrikeBills decimal(18,6)
  847. Declare @Discount_ReceivablesStrikeBills decimal(18,6)
  848. Declare @Type_ReceivablesStrikeMethod nvarchar(64)
  849. Declare @Amount_ReceivablesStrikeMethod decimal(18,6)
  850. Declare @ID_Assessor_SaleInvoice uniqueidentifier
  851. Declare @Disable_SaleInvoice bit
  852. Declare @Amount_SaleInvoice decimal(18,6)
  853. Declare @StrikedAmount_SaleInvoice decimal(18,6)
  854. Declare @error nvarchar(256)
  855. DECLARE @StrikePrePay decimal(18,6)
  856. DECLARE @StrikeAll decimal(18,6)
  857. declare @ID_PreGet uniqueidentifier
  858. SELECT @StrikePrePay = isnull(SUM(IsNull(ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod,0)),0)
  859. FROM ReceivablesStrikeMethod
  860. WHERE ReceivablesStrikeMethod.ID_ReceivablesStrike = @ID_ReceivablesStrike
  861. AND ReceivablesStrikeMethod.Type_ReceivablesStrikeMethod = '冲减预收款'
  862. SELECT @StrikeAll = isnull(SUM(IsNull(ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod,0)),0)
  863. FROM ReceivablesStrikeMethod
  864. WHERE ReceivablesStrikeMethod.ID_ReceivablesStrike = @ID_ReceivablesStrike
  865. IF (@ID_Assessor IS NOT NULL)
  866. BEGIN
  867. IF ((SELECT PrePayBalance_Customer FROM Customer
  868. WHERE ID_Customer = @ID_Customer) &lt; @StrikePrePay)
  869. BEGIN
  870. SET @error = N'该客户的预收帐款余额小于此次冲账所使用的金额,审核失败!'
  871. RAISERROR(@error,16,1)
  872. RETURN
  873. END
  874. END
  875. else
  876. BEGIN
  877. SET @StrikePrePay = - @StrikePrePay
  878. SET @StrikeAll = - @StrikeAll
  879. END
  880. IF (@Prev_ReceivablesStrike = 0)
  881. BEGIN
  882. DECLARE CUR
  883. CURSOR FOR
  884. SELECT ReceivablesStrikeBills.No_SaleInvoice
  885. ,Strike_ReceivablesStrikeBills
  886. ,Discount_ReceivablesStrikeBills
  887. ,SaleInvoice.ID_Assessor
  888. ,SaleInvoice.Disable_SaleInvoice
  889. ,SaleInvoice.Amount_SaleInvoice
  890. ,SaleInvoice.StrikedAmount_SaleInvoice
  891. FROM ReceivablesStrikeBills
  892. Left Join SaleInvoice On SaleInvoice.No_SaleInvoice=ReceivablesStrikeBills.No_SaleInvoice
  893. WHERE ID_ReceivablesStrike = @ID_ReceivablesStrike
  894. OPEN CUR
  895. FETCH NEXT FROM CUR INTO @No_SaleInvoice
  896. ,@Strike_ReceivablesStrikeBills
  897. ,@Discount_ReceivablesStrikeBills
  898. ,@ID_Assessor_SaleInvoice
  899. ,@Disable_SaleInvoice
  900. ,@Amount_SaleInvoice
  901. ,@StrikedAmount_SaleInvoice
  902. WHILE @@FETCH_STATUS = 0
  903. BEGIN
  904. IF (@ID_Assessor IS NULL)
  905. BEGIN
  906. set @Strike_ReceivablesStrikeBills = -@Strike_ReceivablesStrikeBills
  907. set @Discount_ReceivablesStrikeBills = -@Discount_ReceivablesStrikeBills
  908. set @Money_ReceivablesStrike = -@Money_ReceivablesStrike
  909. END
  910. IF (@ID_Assessor IS NOT NULL)
  911. BEGIN
  912. IF(@ID_Assessor_SaleInvoice IS NULL)
  913. BEGIN
  914. SET @error = N'编号为' + @No_SaleInvoice + '的销项发票尚未经过审核,审核失败!'
  915. RAISERROR(@error,16,1)
  916. RETURN
  917. END
  918. IF(@Disable_SaleInvoice=1)
  919. BEGIN
  920. SET @error = N'编号为' + @No_SaleInvoice+ '的发票已作废,审核失败!'
  921. RAISERROR(@error,16,1)
  922. RETURN
  923. END
  924. IF (((@Strike_ReceivablesStrikeBills + @Discount_ReceivablesStrikeBills) &gt; ( @Amount_SaleInvoice-@StrikedAmount_SaleInvoice) And @Amount_SaleInvoice &gt; 0)
  925. Or ((@Strike_ReceivablesStrikeBills + @Discount_ReceivablesStrikeBills) &lt; ( @Amount_SaleInvoice-@StrikedAmount_SaleInvoice) And @Amount_SaleInvoice &lt; 0) )
  926. BEGIN
  927. SET @error = N'编号为' + @No_SaleInvoice + '的发票未冲减金额小于本次冲帐和本次折让的和,审核失败!'
  928. RAISERROR(@error,16,1)
  929. RETURN
  930. END
  931. END
  932. Update SaleInvoice
  933. Set StrikedAmount_SaleInvoice=(StrikedAmount_SaleInvoice+@Strike_ReceivablesStrikeBills + @Discount_ReceivablesStrikeBills)
  934. Where No_SaleInvoice=@No_SaleInvoice
  935. FETCH NEXT FROM CUR INTO @No_SaleInvoice
  936. ,@Strike_ReceivablesStrikeBills
  937. ,@Discount_ReceivablesStrikeBills
  938. ,@ID_Assessor_SaleInvoice
  939. ,@Disable_SaleInvoice
  940. ,@Amount_SaleInvoice
  941. ,@StrikedAmount_SaleInvoice
  942. END
  943. CLOSE CUR
  944. DEALLOCATE CUR
  945. END
  946. DECLARE CUR_PreGet
  947. CURSOR FOR
  948. SELECT ID_PreGet,Amount_ReceivablesStrikeMethod
  949. FROM ReceivablesStrikeMethod
  950. WHERE ID_ReceivablesStrike = @ID_ReceivablesStrike
  951. OPEN CUR_PreGet
  952. FETCH NEXT FROM CUR_PreGet INTO @ID_PreGet,@Amount_ReceivablesStrikeMethod
  953. WHILE @@FETCH_STATUS = 0
  954. BEGIN
  955. IF (@ID_Assessor IS NOT NULL)
  956. BEGIN
  957. Update PreGet Set Balance_PreGet=Balance_PreGet+@Amount_ReceivablesStrikeMethod
  958. Where ID_PreGet=@ID_PreGet
  959. END
  960. IF (@ID_Assessor IS NULL)
  961. BEGIN
  962. Update PreGet Set Balance_PreGet=Balance_PreGet-@Amount_ReceivablesStrikeMethod
  963. Where ID_PreGet=@ID_PreGet
  964. END
  965. FETCH NEXT FROM CUR_PreGet INTO @ID_PreGet,@Amount_ReceivablesStrikeMethod
  966. END
  967. CLOSE CUR_PreGet
  968. DEALLOCATE CUR_PreGet
  969. UPDATE Customer SET PrePayBalance_Customer = (PrePayBalance_Customer - @StrikeAll)
  970. ,ToGetBalance_Customer = (ToGetBalance_Customer - @StrikeAll)
  971. WHERE ID_Customer = @ID_Customer
  972. UPDATE ReceivablesStrike SET ID_Assessor = @ID_Assessor
  973. ,AssessDate_ReceivablesStrike = @AssessDate_ReceivablesStrike
  974. WHERE ID_ReceivablesStrike = @ID_ReceivablesStrike
  975. ">
  976. <Params>
  977. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrike.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  978. <Param name="@ID_Customer" type="ReceivablesStrike.ID_Customer" sourceColumn="ID_Customer" />
  979. <Param name="@ID_Assessor" type="ReceivablesStrike.ID_Assessor" sourceColumn="ID_Assessor" />
  980. <Param name="@AssessDate_ReceivablesStrike" type="ReceivablesStrike.AssessDate_ReceivablesStrike" sourceColumn="AssessDate_ReceivablesStrike" />
  981. <Param name="@Prev_ReceivablesStrike" type="ReceivablesStrike.Prev_ReceivablesStrike" sourceColumn="Prev_ReceivablesStrike" />
  982. <Param name="@Money_ReceivablesStrike" type="ReceivablesStrike.Money_ReceivablesStrike" sourceColumn="Money_ReceivablesStrike" />
  983. </Params>
  984. </Audit>
  985. <Delete CmdType="Text" CmdText=" DELETE ReceivablesStrikeMethod
  986. WHERE ReceivablesStrikeMethod.ID_ReceivablesStrike = @ID_ReceivablesStrike
  987. DELETE ReceivablesStrikeBills
  988. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  989. DELETE ReceivablesStrike
  990. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike">
  991. <Params>
  992. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrike.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  993. </Params>
  994. </Delete>
  995. <FKErrorReport ErrorMessage="该单据已被其他单据引用,删除失败!" />
  996. <UNIQUEErrorReport ErrorMessage="该应收帐款冲帐单号已存在,提交失败!" />
  997. </Table>
  998. <Table name="ReceivablesStrikeMethod" Type="Child">
  999. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 ReceivablesStrikeMethod.*
  1000. ,Convert(decimal(18,6),0) As LeaveAmount_ReceivablesStrikeMethod
  1001. ,Convert(Nvarchar(64),'') As No_PreGet
  1002. ,Convert(Nvarchar(64),'') As Comment_PreGet
  1003. FROM ReceivablesStrikeMethod" />
  1004. <New CmdType="Text" CmdText="INSERT INTO ReceivablesStrikeMethod (ID_ReceivablesStrikeMethod
  1005. ,No_ReceivablesStrikeMethod
  1006. ,ID_ReceivablesStrike
  1007. ,Type_ReceivablesStrikeMethod
  1008. ,Amount_ReceivablesStrikeMethod
  1009. ,Comment_ReceivablesStrikeMethod
  1010. ,ID_PreGet)
  1011. VALUES (@ID_ReceivablesStrikeMethod
  1012. ,@No_ReceivablesStrikeMethod
  1013. ,@ID_ReceivablesStrike
  1014. ,@Type_ReceivablesStrikeMethod
  1015. ,@Amount_ReceivablesStrikeMethod
  1016. ,@Comment_ReceivablesStrikeMethod
  1017. ,@ID_PreGet)
  1018. ">
  1019. <Params>
  1020. <Param name="@ID_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.ID_ReceivablesStrikeMethod" sourceColumn="ID_ReceivablesStrikeMethod" />
  1021. <Param name="@No_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.No_ReceivablesStrikeMethod" sourceColumn="No_ReceivablesStrikeMethod" />
  1022. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrikeMethod.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  1023. <Param name="@Type_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Type_ReceivablesStrikeMethod" sourceColumn="Type_ReceivablesStrikeMethod" />
  1024. <Param name="@Amount_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod" sourceColumn="Amount_ReceivablesStrikeMethod" />
  1025. <Param name="@Comment_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Comment_ReceivablesStrikeMethod" sourceColumn="Comment_ReceivablesStrikeMethod" />
  1026. <Param name="@ID_PreGet" type="ReceivablesStrikeMethod.ID_PreGet" sourceColumn="ID_PreGet" />
  1027. </Params>
  1028. </New>
  1029. <Update CmdType="Text" CmdText=" UPDATE ReceivablesStrikeMethod
  1030. SET Type_ReceivablesStrikeMethod = @Type_ReceivablesStrikeMethod
  1031. ,Amount_ReceivablesStrikeMethod = @Amount_ReceivablesStrikeMethod
  1032. ,Comment_ReceivablesStrikeMethod = @Comment_ReceivablesStrikeMethod
  1033. ,ID_PreGet = @ID_PreGet
  1034. WHERE ID_ReceivablesStrikeMethod = @ID_ReceivablesStrikeMethod
  1035. ">
  1036. <Params>
  1037. <Param name="@ID_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.ID_ReceivablesStrikeMethod" sourceColumn="ID_ReceivablesStrikeMethod" />
  1038. <Param name="@Type_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Type_ReceivablesStrikeMethod" sourceColumn="Type_ReceivablesStrikeMethod" />
  1039. <Param name="@Amount_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod" sourceColumn="Amount_ReceivablesStrikeMethod" />
  1040. <Param name="@Comment_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Comment_ReceivablesStrikeMethod" sourceColumn="Comment_ReceivablesStrikeMethod" />
  1041. <Param name="@ID_PreGet" type="ReceivablesStrikeMethod.ID_PreGet" sourceColumn="ID_PreGet" />
  1042. </Params>
  1043. </Update>
  1044. <Delete CmdType="Text" CmdText=" DELETE ReceivablesStrikeMethod
  1045. WHERE ID_ReceivablesStrikeMethod = @ID_ReceivablesStrikeMethod
  1046. ">
  1047. <Params>
  1048. <Param name="@ID_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.ID_ReceivablesStrikeMethod" sourceColumn="ID_ReceivablesStrikeMethod" />
  1049. </Params>
  1050. </Delete>
  1051. </Table>
  1052. <Table name="ReceivablesStrikeBills" Type="Child">
  1053. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 ReceivablesStrikeBills.*
  1054. FROM ReceivablesStrikeBills
  1055. " />
  1056. <New CmdType="Text" CmdText=" INSERT INTO ReceivablesStrikeBills (ID_ReceivablesStrikeBills
  1057. ,No_ReceivablesStrikeBills
  1058. ,ID_ReceivablesStrike,No_SaleInvoice
  1059. ,No_Invoice
  1060. ,PayDate_ReceivablesStrikeBills
  1061. ,Amount_FromBill
  1062. ,ToGetAmount_ReceivablesStrikeBills
  1063. ,Strike_ReceivablesStrikeBills
  1064. ,Discount_ReceivablesStrikeBills
  1065. ,StrikedAmount_ReceivablesStrikeBills )
  1066. VALUES (@ID_ReceivablesStrikeBills
  1067. ,@No_ReceivablesStrikeBills
  1068. ,@ID_ReceivablesStrike
  1069. ,@No_SaleInvoice
  1070. ,@No_Invoice
  1071. ,@PayDate_ReceivablesStrikeBills
  1072. ,@Amount_FromBill
  1073. ,@ToGetAmount_ReceivablesStrikeBills
  1074. ,@Strike_ReceivablesStrikeBills
  1075. ,@Discount_ReceivablesStrikeBills
  1076. ,@StrikedAmount_ReceivablesStrikeBills )
  1077. ">
  1078. <Params>
  1079. <Param name="@ID_ReceivablesStrikeBills" type="ReceivablesStrikeBills.ID_ReceivablesStrikeBills" sourceColumn="ID_ReceivablesStrikeBills" />
  1080. <Param name="@No_ReceivablesStrikeBills" type="ReceivablesStrikeBills.No_ReceivablesStrikeBills" sourceColumn="No_ReceivablesStrikeBills" />
  1081. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrikeBills.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  1082. <Param name="@No_SaleInvoice" type="ReceivablesStrikeBills.No_SaleInvoice" sourceColumn="No_SaleInvoice" />
  1083. <Param name="@No_Invoice" type="ReceivablesStrikeBills.No_Invoice" sourceColumn="No_Invoice" />
  1084. <Param name="@PayDate_ReceivablesStrikeBills" type="ReceivablesStrikeBills.PayDate_ReceivablesStrikeBills" sourceColumn="PayDate_ReceivablesStrikeBills" />
  1085. <Param name="@Amount_FromBill" type="ReceivablesStrikeBills.Amount_FromBill" sourceColumn="Amount_FromBill" />
  1086. <Param name="@ToGetAmount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills" sourceColumn="ToGetAmount_ReceivablesStrikeBills" />
  1087. <Param name="@Strike_ReceivablesStrikeBills" type="ReceivablesStrikeBills.Strike_ReceivablesStrikeBills" sourceColumn="Strike_ReceivablesStrikeBills" />
  1088. <Param name="@Discount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.Discount_ReceivablesStrikeBills" sourceColumn="Discount_ReceivablesStrikeBills" />
  1089. <Param name="@StrikedAmount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.StrikedAmount_ReceivablesStrikeBills" sourceColumn="StrikedAmount_ReceivablesStrikeBills" />
  1090. </Params>
  1091. </New>
  1092. <Update CmdType="Text" CmdText=" UPDATE ReceivablesStrikeBills
  1093. SET No_ReceivablesStrikeBills = @No_ReceivablesStrikeBills
  1094. ,No_SaleInvoice = @No_SaleInvoice
  1095. ,No_Invoice = @No_Invoice
  1096. ,PayDate_ReceivablesStrikeBills = @PayDate_ReceivablesStrikeBills
  1097. ,Amount_FromBill = @Amount_FromBill
  1098. ,ToGetAmount_ReceivablesStrikeBills = @ToGetAmount_ReceivablesStrikeBills
  1099. ,Strike_ReceivablesStrikeBills = @Strike_ReceivablesStrikeBills
  1100. ,Discount_ReceivablesStrikeBills = @Discount_ReceivablesStrikeBills
  1101. ,StrikedAmount_ReceivablesStrikeBills =@StrikedAmount_ReceivablesStrikeBills
  1102. WHERE ID_ReceivablesStrikeBills = @ID_ReceivablesStrikeBills
  1103. ">
  1104. <Params>
  1105. <Param name="@ID_ReceivablesStrikeBills" type="ReceivablesStrikeBills.ID_ReceivablesStrikeBills" sourceColumn="ID_ReceivablesStrikeBills" />
  1106. <Param name="@No_ReceivablesStrikeBills" type="ReceivablesStrikeBills.No_ReceivablesStrikeBills" sourceColumn="No_ReceivablesStrikeBills" />
  1107. <Param name="@ID_ReceivablesStrike" type="ReceivablesStrikeBills.ID_ReceivablesStrike" sourceColumn="ID_ReceivablesStrike" />
  1108. <Param name="@No_SaleInvoice" type="ReceivablesStrikeBills.No_SaleInvoice" sourceColumn="No_SaleInvoice" />
  1109. <Param name="@No_Invoice" type="ReceivablesStrikeBills.No_Invoice" sourceColumn="No_Invoice" />
  1110. <Param name="@PayDate_ReceivablesStrikeBills" type="ReceivablesStrikeBills.PayDate_ReceivablesStrikeBills" sourceColumn="PayDate_ReceivablesStrikeBills" />
  1111. <Param name="@Amount_FromBill" type="ReceivablesStrikeBills.Amount_FromBill" sourceColumn="Amount_FromBill" />
  1112. <Param name="@ToGetAmount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills" sourceColumn="ToGetAmount_ReceivablesStrikeBills" />
  1113. <Param name="@Strike_ReceivablesStrikeBills" type="ReceivablesStrikeBills.Strike_ReceivablesStrikeBills" sourceColumn="Strike_ReceivablesStrikeBills" />
  1114. <Param name="@Discount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.Discount_ReceivablesStrikeBills" sourceColumn="Discount_ReceivablesStrikeBills" />
  1115. <Param name="@StrikedAmount_ReceivablesStrikeBills" type="ReceivablesStrikeBills.StrikedAmount_ReceivablesStrikeBills" sourceColumn="StrikedAmount_ReceivablesStrikeBills" />
  1116. </Params>
  1117. </Update>
  1118. <Delete CmdType="Text" CmdText=" DELETE ReceivablesStrikeBills
  1119. WHERE ID_ReceivablesStrikeBills = @ID_ReceivablesStrikeBills
  1120. ">
  1121. <Params>
  1122. <Param name="@ID_ReceivablesStrikeBills" type="ReceivablesStrikeBills.ID_ReceivablesStrikeBills" sourceColumn="ID_ReceivablesStrikeBills" />
  1123. </Params>
  1124. </Delete>
  1125. </Table>
  1126. </Tables>
  1127. <Search>
  1128. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer
  1129. ,Customer.ShortName_Customer
  1130. ,Customer.Type_Customer
  1131. ,Customer.Level_Customer
  1132. ,Customer.IsGeneric_Customer
  1133. FROM Customer
  1134. ">
  1135. <Tables>
  1136. <Table name="AllCustomer" />
  1137. </Tables>
  1138. </SearchAllCustomer>
  1139. <SearchAllBill CmdType="Text" CmdText=" SELECT ReceivablesStrike.*
  1140. ,Customer.No_Customer
  1141. ,Customer.ShortName_Customer
  1142. ,Customer.PrePayBalance_Customer
  1143. ,Employee.No_Employee AS No_Receiver
  1144. ,a.Name_User AS Name_Creator
  1145. ,b.Name_User AS Name_Assessor
  1146. ,c.Name_User AS Name_LastModUser
  1147. ,CONVERT(decimal(18,6), 0) AS SumSale
  1148. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1149. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1150. FROM ReceivablesStrike
  1151. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1152. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1153. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1154. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1155. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike ">
  1156. <Tables>
  1157. <Table name="AllBill" />
  1158. </Tables>
  1159. </SearchAllBill>
  1160. <SearchReceivablesStrikeWithNo CmdType="Text" CmdText=" DECLARE @ID_ReceivablesStrike uniqueidentifier
  1161. SELECT @ID_ReceivablesStrike = ReceivablesStrike.ID_ReceivablesStrike
  1162. FROM ReceivablesStrike
  1163. WHERE ReceivablesStrike.No_ReceivablesStrike = @No_ReceivablesStrike
  1164. SELECT ReceivablesStrike.*
  1165. ,Customer.No_Customer
  1166. ,Customer.ShortName_Customer
  1167. ,Customer.PrePayBalance_Customer
  1168. ,Employee.No_Employee AS No_Receiver
  1169. ,Employee.Name_Employee
  1170. ,a.Name_User AS Name_Creator
  1171. ,b.Name_User AS Name_Assessor
  1172. ,c.Name_User AS Name_LastModUser
  1173. ,CONVERT(decimal(18,6), 0) AS SumSale
  1174. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1175. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1176. FROM ReceivablesStrike
  1177. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1178. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1179. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1180. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1181. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  1182. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1183. SELECT PreGet.*
  1184. ,A.*
  1185. ,(IsNull(Amount_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1186. FROM
  1187. (
  1188. SELECT ID_ReceivablesStrike
  1189. ,ID_PreGet
  1190. ,No_ReceivablesStrikeMethod
  1191. ,ID_ReceivablesStrikeMethod
  1192. ,Sum(Amount_ReceivablesStrikeMethod) As Amount_ReceivablesStrikeMethod
  1193. FROM ReceivablesStrikeMethod
  1194. Group By ID_ReceivablesStrike,ID_PreGet,No_ReceivablesStrikeMethod,ID_ReceivablesStrikeMethod
  1195. ) A
  1196. Left Join PreGet On PreGet.ID_PreGet = A.ID_PreGet
  1197. WHERE A.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1198. --AND IsNull(Amount_ReceivablesStrikeMethod,0) > 0
  1199. ORDER BY A.No_ReceivablesStrikeMethod
  1200. SELECT ReceivablesStrikeBills.* From ReceivablesStrikeBills
  1201. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1202. --AND isnull(Strike_ReceivablesStrikeBills,0) > 0
  1203. ORDER BY ReceivablesStrikeBills.No_ReceivablesStrikeBills
  1204. ">
  1205. <Params>
  1206. <Param name="@No_ReceivablesStrike" type="ReceivablesStrike.No_ReceivablesStrike" Index="0" />
  1207. </Params>
  1208. <Tables>
  1209. <Table name="ReceivablesStrike" />
  1210. <Table name="ReceivablesStrikeMethod" />
  1211. <Table name="ReceivablesStrikeBills" />
  1212. </Tables>
  1213. </SearchReceivablesStrikeWithNo>
  1214. <SearchCustomerWithNo CmdType="Text" CmdText=" SELECT ID_Customer
  1215. ,No_Customer
  1216. ,ShortName_Customer
  1217. ,Name_Customer
  1218. ,RegistedAddress_Customer
  1219. ,Country_Customer
  1220. ,PostalCode_Customer
  1221. ,Type_Customer
  1222. ,IsGeneric_Customer
  1223. ,PayLimitCurrency
  1224. ,PayLimit_Customer
  1225. ,GetMethod_Customer
  1226. ,CreateDate_Customer
  1227. ,ID_Creator
  1228. ,SendAddr_Customer
  1229. ,Comment_Customer
  1230. ,Industry_Customer
  1231. ,Zone_Customer
  1232. ,Source_Customer
  1233. ,Level_Customer
  1234. ,Bank_Customer
  1235. ,Account_Customer
  1236. ,RevenueRegisterNo_Customer
  1237. ,LastDiscount_Customer
  1238. ,SuspendDate_Customer
  1239. ,ToGetBalance_Customer
  1240. ,PrePayBalance_Customer
  1241. ,(isnull(OpeningToGetBalance_Customer,0)-isnull(PrePayValue_Customer,0)) as OpeningToGetBalance_Customer
  1242. ,OpeningPrePayBalance_Customer
  1243. ,LastTax_Customer
  1244. ,LastModDate_Customer
  1245. ,LastModUser_Customer
  1246. ,DunDate_Customer, LastPrincipal_Customer
  1247. ,LowDiscount_Customer, IsCustomersCustomer_Customer
  1248. ,BeginDate_Customer, Saleroom_Customer, PerValue_Customer
  1249. ,CustomerID_Customer, ID_RegionalLeader, Note_Customer
  1250. ,PrePayValue_Customer
  1251. FROM Customer
  1252. WHERE Customer.No_Customer = @No_Customer
  1253. ">
  1254. <Params>
  1255. <Param name="@No_Customer" type="ReceivablesStrike.No_Customer" Index="0" />
  1256. </Params>
  1257. <Tables>
  1258. <Table name="Customer" />
  1259. </Tables>
  1260. </SearchCustomerWithNo>
  1261. <SearchReceiver CmdType="Text" CmdText=" SELECT Employee.No_Employee
  1262. ,Employee.ID_Employee
  1263. ,Employee.Name_Employee
  1264. FROM Employee
  1265. WHERE Employee.SuspendDate_Employee IS NULL
  1266. ">
  1267. <Tables>
  1268. <Table name="Receiver" />
  1269. </Tables>
  1270. </SearchReceiver>
  1271. <SearchReceivablesStrikeMethod CmdType="Text" CmdText="SELECT '现金' AS Result
  1272. UNION
  1273. SELECT '刷卡' AS Result
  1274. UNION
  1275. SELECT '支票' AS Result
  1276. UNION
  1277. SELECT '冲减预付款' AS Result
  1278. UNION
  1279. SELECT '抵帐' AS Result
  1280. UNION
  1281. SELECT '转帐' AS Result
  1282. UNION
  1283. SELECT '银行汇票' AS Result
  1284. UNION
  1285. SELECT '银行承兑汇票' AS Result">
  1286. <Tables>
  1287. <Table name="Method" />
  1288. </Tables>
  1289. </SearchReceivablesStrikeMethod>
  1290. <SearchBillType CmdType="Text" CmdText=" SELECT * FROM BillType
  1291. WHERE Value_BillType = 21 OR Value_BillType = 22
  1292. OR Value_BillType=0
  1293. ORDER BY Value_BillType
  1294. ">
  1295. <Tables>
  1296. <Table name="BillType" />
  1297. </Tables>
  1298. </SearchBillType>
  1299. <SearchFromBillInInvoice CmdType="Text" CmdText=" Select SaleInvoice.No_Invoice
  1300. ,Amount_SaleInvoice
  1301. ,PayDate_SaleInvoice
  1302. ,StrikedAmount_SaleInvoice
  1303. ,ID_Assessor
  1304. ,Disable_SaleInvoice
  1305. ,ID_Customer
  1306. From SaleInvoice
  1307. Where No_SaleInvoice=@No_SaleInvoice
  1308. ">
  1309. <Params>
  1310. <Param name="@No_SaleInvoice" type="ReceivablesStrikeBills.No_SaleInvoice" Index="0" />
  1311. </Params>
  1312. <Tables>
  1313. <Table name="FromBill" />
  1314. </Tables>
  1315. </SearchFromBillInInvoice>
  1316. <SearchReceivablesStrikeFirst CmdType="Text" CmdText=" DECLARE @ID_ReceivablesStrike uniqueidentifier
  1317. SELECT TOP 1 @ID_ReceivablesStrike = ReceivablesStrike.ID_ReceivablesStrike
  1318. FROM ReceivablesStrike
  1319. ORDER BY ReceivablesStrike.No_ReceivablesStrike
  1320. SELECT ReceivablesStrike.*
  1321. ,Customer.No_Customer
  1322. ,Customer.ShortName_Customer
  1323. ,Customer.PrePayBalance_Customer
  1324. ,Employee.No_Employee AS No_Receiver
  1325. ,Employee.Name_Employee
  1326. ,a.Name_User AS Name_Creator
  1327. ,b.Name_User AS Name_Assessor
  1328. ,c.Name_User AS Name_LastModUser
  1329. ,CONVERT(decimal(18,6), 0) AS SumSale
  1330. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1331. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1332. FROM ReceivablesStrike
  1333. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1334. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1335. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1336. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1337. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  1338. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1339. SELECT PreGet.*
  1340. ,A.*
  1341. ,(IsNull(Amount_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1342. FROM
  1343. (
  1344. SELECT ID_ReceivablesStrike
  1345. ,ID_PreGet
  1346. ,No_ReceivablesStrikeMethod
  1347. ,ID_ReceivablesStrikeMethod
  1348. ,Sum(Amount_ReceivablesStrikeMethod) As Amount_ReceivablesStrikeMethod
  1349. FROM ReceivablesStrikeMethod
  1350. Group By ID_ReceivablesStrike,ID_PreGet,No_ReceivablesStrikeMethod,ID_ReceivablesStrikeMethod
  1351. ) A
  1352. Left Join PreGet On PreGet.ID_PreGet = A.ID_PreGet
  1353. WHERE A.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1354. --AND IsNull(Amount_ReceivablesStrikeMethod,0) > 0
  1355. ORDER BY A.No_ReceivablesStrikeMethod
  1356. SELECT ReceivablesStrikeBills.* From ReceivablesStrikeBills
  1357. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1358. --AND isnull(Strike_ReceivablesStrikeBills,0) > 0
  1359. ORDER BY ReceivablesStrikeBills.No_ReceivablesStrikeBills
  1360. ">
  1361. <Tables>
  1362. <Table name="ReceivablesStrike" />
  1363. <Table name="ReceivablesStrikeMethod" />
  1364. <Table name="ReceivablesStrikeBills" />
  1365. </Tables>
  1366. </SearchReceivablesStrikeFirst>
  1367. <SearchReceivablesStrikePrevious CmdType="Text" CmdText=" DECLARE @ID_ReceivablesStrike uniqueidentifier
  1368. SELECT TOP 1 @ID_ReceivablesStrike = ReceivablesStrike.ID_ReceivablesStrike
  1369. FROM ReceivablesStrike
  1370. WHERE ReceivablesStrike.No_ReceivablesStrike &lt; @No_ReceivablesStrike ORDER BY ReceivablesStrike.No_ReceivablesStrike DESC
  1371. SELECT ReceivablesStrike.*
  1372. ,Customer.No_Customer
  1373. ,Customer.ShortName_Customer
  1374. ,Customer.PrePayBalance_Customer
  1375. ,Employee.No_Employee AS No_Receiver
  1376. ,Employee.Name_Employee
  1377. ,a.Name_User AS Name_Creator
  1378. ,b.Name_User AS Name_Assessor
  1379. ,c.Name_User AS Name_LastModUser
  1380. ,CONVERT(decimal(18,6), 0) AS SumSale
  1381. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1382. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1383. FROM ReceivablesStrike
  1384. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1385. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1386. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1387. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1388. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  1389. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1390. SELECT PreGet.*
  1391. ,A.*
  1392. ,(IsNull(Amount_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1393. FROM
  1394. (
  1395. SELECT ID_ReceivablesStrike
  1396. ,ID_PreGet
  1397. ,No_ReceivablesStrikeMethod
  1398. ,ID_ReceivablesStrikeMethod
  1399. ,Sum(Amount_ReceivablesStrikeMethod) As Amount_ReceivablesStrikeMethod
  1400. FROM ReceivablesStrikeMethod
  1401. Group By ID_ReceivablesStrike,ID_PreGet,No_ReceivablesStrikeMethod,ID_ReceivablesStrikeMethod
  1402. ) A
  1403. Left Join PreGet On PreGet.ID_PreGet = A.ID_PreGet
  1404. WHERE A.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1405. --AND IsNull(Amount_ReceivablesStrikeMethod,0) > 0
  1406. ORDER BY A.No_ReceivablesStrikeMethod
  1407. SELECT ReceivablesStrikeBills.* From ReceivablesStrikeBills
  1408. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1409. --AND isnull(Strike_ReceivablesStrikeBills,0) > 0
  1410. ORDER BY ReceivablesStrikeBills.No_ReceivablesStrikeBills
  1411. ">
  1412. <Params>
  1413. <Param name="@No_ReceivablesStrike" type="ReceivablesStrike.No_ReceivablesStrike" Index="0" />
  1414. </Params>
  1415. <Tables>
  1416. <Table name="ReceivablesStrike" />
  1417. <Table name="ReceivablesStrikeMethod" />
  1418. <Table name="ReceivablesStrikeBills" />
  1419. </Tables>
  1420. </SearchReceivablesStrikePrevious>
  1421. <SearchReceivablesStrikeNext CmdType="Text" CmdText=" DECLARE @ID_ReceivablesStrike uniqueidentifier
  1422. SELECT TOP 1 @ID_ReceivablesStrike = ReceivablesStrike.ID_ReceivablesStrike
  1423. FROM ReceivablesStrike
  1424. WHERE ReceivablesStrike.No_ReceivablesStrike &gt; @No_ReceivablesStrike
  1425. ORDER BY ReceivablesStrike.No_ReceivablesStrike
  1426. SELECT ReceivablesStrike.*
  1427. ,Customer.No_Customer
  1428. ,Customer.ShortName_Customer
  1429. ,Customer.PrePayBalance_Customer
  1430. ,Employee.No_Employee AS No_Receiver
  1431. ,Employee.Name_Employee
  1432. ,a.Name_User AS Name_Creator
  1433. ,b.Name_User AS Name_Assessor
  1434. ,c.Name_User AS Name_LastModUser
  1435. ,CONVERT(decimal(18,6), 0) AS SumSale
  1436. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1437. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1438. FROM ReceivablesStrike
  1439. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1440. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1441. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1442. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1443. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  1444. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1445. SELECT PreGet.*
  1446. ,A.*
  1447. ,(IsNull(Amount_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1448. FROM
  1449. (
  1450. SELECT ID_ReceivablesStrike
  1451. ,ID_PreGet
  1452. ,No_ReceivablesStrikeMethod
  1453. ,ID_ReceivablesStrikeMethod
  1454. ,Sum(Amount_ReceivablesStrikeMethod) As Amount_ReceivablesStrikeMethod
  1455. FROM ReceivablesStrikeMethod
  1456. Group By ID_ReceivablesStrike,ID_PreGet,No_ReceivablesStrikeMethod,ID_ReceivablesStrikeMethod
  1457. ) A
  1458. Left Join PreGet On PreGet.ID_PreGet = A.ID_PreGet
  1459. WHERE A.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1460. --AND IsNull(Amount_ReceivablesStrikeMethod,0) > 0
  1461. ORDER BY A.No_ReceivablesStrikeMethod
  1462. SELECT ReceivablesStrikeBills.* From ReceivablesStrikeBills
  1463. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1464. --AND isnull(Strike_ReceivablesStrikeBills,0) > 0
  1465. ORDER BY ReceivablesStrikeBills.No_ReceivablesStrikeBills
  1466. ">
  1467. <Params>
  1468. <Param name="@No_ReceivablesStrike" type="ReceivablesStrike.No_ReceivablesStrike" Index="0" />
  1469. </Params>
  1470. <Tables>
  1471. <Table name="ReceivablesStrike" />
  1472. <Table name="ReceivablesStrikeMethod" />
  1473. <Table name="ReceivablesStrikeBills" />
  1474. </Tables>
  1475. </SearchReceivablesStrikeNext>
  1476. <SearchReceivablesStrikeLast CmdType="Text" CmdText=" DECLARE @ID_ReceivablesStrike uniqueidentifier
  1477. SELECT TOP 1 @ID_ReceivablesStrike = ReceivablesStrike.ID_ReceivablesStrike
  1478. FROM ReceivablesStrike
  1479. ORDER BY ReceivablesStrike.No_ReceivablesStrike DESC
  1480. SELECT ReceivablesStrike.*
  1481. ,Customer.No_Customer
  1482. ,Customer.ShortName_Customer
  1483. ,Customer.PrePayBalance_Customer
  1484. ,Employee.No_Employee AS No_Receiver
  1485. ,Employee.Name_Employee
  1486. ,a.Name_User AS Name_Creator
  1487. ,b.Name_User AS Name_Assessor
  1488. ,c.Name_User AS Name_LastModUser
  1489. ,CONVERT(decimal(18,6), 0) AS SumSale
  1490. ,CONVERT(decimal(18,6), 0) AS SumRtn
  1491. ,CONVERT(decimal(18,6), 0) AS SumReceive
  1492. FROM ReceivablesStrike
  1493. LEFT JOIN Customer ON Customer.ID_Customer = ReceivablesStrike.ID_Customer
  1494. LEFT JOIN Employee ON Employee.ID_Employee = ReceivablesStrike.ID_Receiver
  1495. LEFT JOIN AppUser a ON a.ID_User = ReceivablesStrike.ID_Creator
  1496. LEFT JOIN AppUser b ON b.ID_User = ReceivablesStrike.ID_Assessor
  1497. LEFT JOIN AppUser c ON c.ID_User = ReceivablesStrike.LastModUser_ReceivablesStrike
  1498. WHERE ReceivablesStrike.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1499. SELECT PreGet.*
  1500. ,A.*
  1501. ,(IsNull(Amount_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1502. FROM
  1503. (
  1504. SELECT ID_ReceivablesStrike
  1505. ,ID_PreGet
  1506. ,No_ReceivablesStrikeMethod
  1507. ,ID_ReceivablesStrikeMethod
  1508. ,Sum(Amount_ReceivablesStrikeMethod) As Amount_ReceivablesStrikeMethod
  1509. FROM ReceivablesStrikeMethod
  1510. Group By ID_ReceivablesStrike,ID_PreGet,No_ReceivablesStrikeMethod,ID_ReceivablesStrikeMethod
  1511. ) A
  1512. Left Join PreGet On PreGet.ID_PreGet = A.ID_PreGet
  1513. WHERE A.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1514. --AND IsNull(Amount_ReceivablesStrikeMethod,0) > 0
  1515. ORDER BY A.No_ReceivablesStrikeMethod
  1516. SELECT ReceivablesStrikeBills.* From ReceivablesStrikeBills
  1517. WHERE ReceivablesStrikeBills.ID_ReceivablesStrike = @ID_ReceivablesStrike
  1518. --AND isnull(Strike_ReceivablesStrikeBills,0) > 0
  1519. ORDER BY ReceivablesStrikeBills.No_ReceivablesStrikeBills
  1520. ">
  1521. <Tables>
  1522. <Table name="ReceivablesStrike" />
  1523. <Table name="ReceivablesStrikeMethod" />
  1524. <Table name="ReceivablesStrikeBills" />
  1525. </Tables>
  1526. </SearchReceivablesStrikeLast>
  1527. <SearchSystemSetting CmdType="Text" CmdText="SELECT SysCurrency_SystemSetting From SystemSetting">
  1528. <Tables>
  1529. <Table name="SystemSetting"/>
  1530. </Tables>
  1531. </SearchSystemSetting>
  1532. <SearchPreGet CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1533. Select @ID_Customer = ID_Customer
  1534. From Customer
  1535. Where No_Customer = @No_Customer
  1536. select IDENTITY(int,1,1) as No_ReceivablesStrikeMethod,* into #t from
  1537. (
  1538. Select PreGet.ID_PreGet
  1539. ,No_PreGet
  1540. ,(IsNull(Amount_PreGet,0)-IsNull(Balance_PreGet,0)) As LeaveAmount_ReceivablesStrikeMethod
  1541. ,Convert(Decimal(18,6),0) As Amount_ReceivablesStrikeMethod
  1542. ,Comment_PreGet
  1543. From PreGet
  1544. Where PreGet.ID_Assessor Is Not Null
  1545. And ID_Customer = @ID_Customer
  1546. And (IsNull(Amount_PreGet,0)-IsNull(Balance_PreGet,0)) > 0
  1547. )a
  1548. order by No_PreGet
  1549. select Convert(nvarchar(64),No_ReceivablesStrikeMethod) as No_ReceivablesStrikeMethod
  1550. ,ID_PreGet
  1551. ,No_PreGet
  1552. ,LeaveAmount_ReceivablesStrikeMethod
  1553. ,Amount_ReceivablesStrikeMethod
  1554. ,Comment_PreGet
  1555. from #t
  1556. order by No_ReceivablesStrikeMethod
  1557. drop table #t
  1558. ">
  1559. <Params>
  1560. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1561. </Params>
  1562. <Tables>
  1563. <Table name="ReceivablesStrikeMethod1"/>
  1564. </Tables>
  1565. </SearchPreGet>
  1566. <SearchIsHavePreGet CmdType="Text" CmdText=" Select Count(*) As No_PreGet From PreGet
  1567. ">
  1568. <Tables>
  1569. <Table name="PreGet"/>
  1570. </Tables>
  1571. </SearchIsHavePreGet>
  1572. <SearchSaleInvoice CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1573. Select @ID_Customer = ID_Customer
  1574. From Customer
  1575. Where No_Customer = @No_Customer
  1576. select Identity(INT,1,1) As No_ReceivablesStrikeBills
  1577. ,* into #temptable
  1578. From
  1579. (Select No_SaleInvoice
  1580. ,No_Invoice
  1581. ,PayDate_SaleInvoice As PayDate_ReceivablesStrikeBills
  1582. ,Amount_SaleInvoice As Amount_FromBill
  1583. ,(IsNull(Amount_SaleInvoice,0) - IsNull(StrikedAmount_SaleInvoice,0)) As ToGetAmount_ReceivablesStrikeBills
  1584. ,0 As Strike_ReceivablesStrikeBills
  1585. ,IsNull(DiscountAmount_SaleInvoice,0) As Discount_ReceivablesStrikeBills
  1586. ,IsNull(StrikedAmount_SaleInvoice,0) As StrikedAmount_ReceivablesStrikeBills
  1587. ,InvoiceDate_SaleInvoice
  1588. From SaleInvoice
  1589. Where ID_Assessor Is Not Null
  1590. And Disable_SaleInvoice = 0
  1591. And (IsNull(Amount_SaleInvoice,0) - IsNull(StrikedAmount_SaleInvoice,0))>0
  1592. And ID_Customer = @ID_Customer
  1593. And InvoiceDate_SaleInvoice Between isnull(DateAdd(day,DateDiff(day,0,@DateStart),0),InvoiceDate_SaleInvoice)
  1594. AND Isnull(DateAdd(day,DateDiff(day,0,@DateEnd),1),InvoiceDate_SaleInvoice)
  1595. ) A
  1596. Order By InvoiceDate_SaleInvoice,No_SaleInvoice
  1597. Select Convert(nvarchar(64),No_ReceivablesStrikeBills) As No_ReceivablesStrikeBills
  1598. ,No_SaleInvoice
  1599. ,No_Invoice
  1600. ,PayDate_ReceivablesStrikeBills
  1601. ,Amount_FromBill
  1602. ,ToGetAmount_ReceivablesStrikeBills
  1603. ,Strike_ReceivablesStrikeBills
  1604. ,Discount_ReceivablesStrikeBills
  1605. ,StrikedAmount_ReceivablesStrikeBills
  1606. From #temptable
  1607. Drop Table #temptable
  1608. ">
  1609. <Params>
  1610. <Param name="@DateStart" type="Customer.BeginDate_Customer" Index="0" />
  1611. <Param name="@DateEnd" type="Customer.BeginDate_Customer" Index="1" />
  1612. <Param name="@No_Customer" type="Customer.No_Customer" Index="2" />
  1613. </Params>
  1614. <Tables>
  1615. <Table name="ReceivablesStrikeBill1"/>
  1616. </Tables>
  1617. </SearchSaleInvoice>
  1618. <CreateNewPreGet CmdType="Text" CmdText =" DECLARE @BillNo Nvarchar(64)
  1619. Select Top 1 @BillNo= No_PreGet
  1620. From PreGet
  1621. Where Convert(nvarchar(10),Date_PreGet,120) = Convert(nvarchar(10),@GetDate,120)
  1622. Order By No_PreGet DESC
  1623. Select @BillNo = @Head +Right(convert(char(8),@GetDate,112),6)+ isnull(substring(convert(nvarchar(max),Convert(decimal(28,0),substring(@BillNo,len(@Head)+1,len(@BillNo) - len(@Head)))+1),len(convert(nvarchar(max) ,Convert(decimal(28,0),substring( @BillNo , len(@Head) + 1 , len(@BillNo) - len(@Head)))+1)) - 3 , 4 ),'0001')
  1624. DECLARE @PreGetID Uniqueidentifier
  1625. SELECT @PreGetID = newid()
  1626. DECLARE @VoucherNo_PreGet nvarchar(64)
  1627. SELECT @VoucherNo_PreGet = ''
  1628. DECLARE @VoucherDate_PreGet Datetime
  1629. SELECT @VoucherDate_PreGet = Convert(Datetime,getDate(),120)
  1630. DECLARE @Balance_PreGet decimal(18,6)
  1631. SELECT @Balance_PreGet = PrePayBalance_Customer From Customer
  1632. DECLARE @ID_Receiver Uniqueidentifier
  1633. SELECT @ID_Receiver = ID_Employee from Employee
  1634. Where Name_Employee = @Name_Employee
  1635. INSERT INTO PreGet(ID_PreGet
  1636. ,No_PreGet
  1637. ,Date_PreGet
  1638. ,ID_Customer
  1639. ,GetCurrency_PreGet
  1640. ,Currency_PreGet
  1641. ,Rate_PreGet
  1642. ,Method_PreGet
  1643. ,Amount_PreGet
  1644. ,VoucherNo_PreGet
  1645. ,VoucherDate_PreGet
  1646. ,ID_Receiver
  1647. ,Balance_PreGet
  1648. ,ID_Creator
  1649. ,CreateDate_PreGet
  1650. ,LastModUser_PreGet
  1651. ,LastModDate_PreGet
  1652. ,ID_Assessor
  1653. ,AssessDate_PreGet
  1654. ,Comment_PreGet)
  1655. VALUES(@PreGetID
  1656. ,@BillNo
  1657. ,@Date_PreGet
  1658. ,@ID_Customer
  1659. ,@GetCurrency_PreGet
  1660. ,@Currency_PreGet
  1661. ,@Rate_PreGet
  1662. ,@Method_PreGet
  1663. ,@Amount_PreGet
  1664. ,@VoucherNo_PreGet
  1665. ,@VoucherDate_PreGet
  1666. ,@ID_Receiver
  1667. ,@Balance_PreGet
  1668. ,@ID_Creator
  1669. ,@CreateDate_PreGet
  1670. ,@LastModUser_PreGet
  1671. ,@LastModDate_PreGet
  1672. ,@ID_Assessor
  1673. ,@AssessDate_PreGet
  1674. ,@Comment_PreGet)
  1675. select @PreGetID
  1676. ">
  1677. <Params>
  1678. <Param name="@Date_PreGet" type="PreGet.Date_PreGet" Index="0" />
  1679. <Param name="@ID_Customer" type="PreGet.ID_Customer" Index="1" />
  1680. <Param name="@GetCurrency_PreGet" type="PreGet.GetCurrency_PreGet" Index="2" />
  1681. <Param name="@Currency_PreGet" type="PreGet.Currency_PreGet" Index="3" />
  1682. <Param name="@Rate_PreGet" type="PreGet.Rate_PreGet" Index="4" />
  1683. <Param name="@Method_PreGet" type="PreGet.Method_PreGet" Index="5" />
  1684. <Param name="@Amount_PreGet" type="PreGet.Amount_PreGet" Index="6" />
  1685. <Param name="@Name_Employee" type="PreGet.Comment_PreGet" Index="7" />
  1686. <Param name="@ID_Creator" type="PreGet.ID_Creator" Index="8" />
  1687. <Param name="@CreateDate_PreGet" type="PreGet.CreateDate_PreGet" Index="9" />
  1688. <Param name="@LastModUser_PreGet" type="PreGet.LastModUser_PreGet" Index="10" />
  1689. <Param name="@LastModDate_PreGet" type="PreGet.LastModDate_PreGet" Index="11" />
  1690. <Param name="@ID_Assessor" type="PreGet.ID_Assessor" Index="12" />
  1691. <Param name="@AssessDate_PreGet" type="PreGet.AssessDate_PreGet" Index="13" />
  1692. <Param name="@Comment_PreGet" type="PreGet.Comment_PreGet" Index="14" />
  1693. <Param name="@Head" type="PreGet.Value1_CodeGenerate" Index="15" />
  1694. <Param name="@GetDate" type="PreGet.Date_PreGet" Index="16" />
  1695. </Params>
  1696. <Tables>
  1697. <Table name="NewPreGet"/>
  1698. </Tables>
  1699. </CreateNewPreGet>
  1700. <CreateNewPreGet2 CmdType="Text" CmdText =" DECLARE @BillNo Nvarchar(64)
  1701. Select @BillNo = @Head+Right(convert(char( 8 ),@GetDate,112),6)+right('0000'+convert(varchar,1),4)
  1702. DECLARE @PreGetID Uniqueidentifier
  1703. SELECT @PreGetID = newid()
  1704. DECLARE @VoucherNo_PreGet nvarchar(64)
  1705. SELECT @VoucherNo_PreGet = ''
  1706. DECLARE @VoucherDate_PreGet Datetime
  1707. SELECT @VoucherDate_PreGet = Convert(Datetime,getDate(),120)
  1708. DECLARE @Balance_PreGet decimal(18,6)
  1709. SELECT @Balance_PreGet = PrePayBalance_Customer From Customer
  1710. DECLARE @ID_Receiver Uniqueidentifier
  1711. SELECT @ID_Receiver = ID_Employee from Employee
  1712. Where Name_Employee = @Name_Employee
  1713. INSERT INTO PreGet(ID_PreGet
  1714. ,No_PreGet
  1715. ,Date_PreGet
  1716. ,ID_Customer
  1717. ,GetCurrency_PreGet
  1718. ,Currency_PreGet
  1719. ,Rate_PreGet
  1720. ,Method_PreGet
  1721. ,Amount_PreGet
  1722. ,VoucherNo_PreGet
  1723. ,VoucherDate_PreGet
  1724. ,ID_Receiver
  1725. ,Balance_PreGet
  1726. ,ID_Creator
  1727. ,CreateDate_PreGet
  1728. ,LastModUser_PreGet
  1729. ,LastModDate_PreGet
  1730. ,ID_Assessor
  1731. ,AssessDate_PreGet
  1732. ,Comment_PreGet)
  1733. VALUES(@PreGetID
  1734. ,@BillNo
  1735. ,@Date_PreGet
  1736. ,@ID_Customer
  1737. ,@GetCurrency_PreGet
  1738. ,@Currency_PreGet
  1739. ,@Rate_PreGet
  1740. ,@Method_PreGet
  1741. ,@Amount_PreGet
  1742. ,@VoucherNo_PreGet
  1743. ,@VoucherDate_PreGet
  1744. ,@ID_Receiver
  1745. ,@Balance_PreGet
  1746. ,@ID_Creator
  1747. ,@CreateDate_PreGet
  1748. ,@LastModUser_PreGet
  1749. ,@LastModDate_PreGet
  1750. ,@ID_Assessor
  1751. ,@AssessDate_PreGet
  1752. ,@Comment_PreGet)
  1753. select @PreGetID
  1754. ">
  1755. <Params>
  1756. <Param name="@Date_PreGet" type="PreGet.Date_PreGet" Index="0" />
  1757. <Param name="@ID_Customer" type="PreGet.ID_Customer" Index="1" />
  1758. <Param name="@GetCurrency_PreGet" type="PreGet.GetCurrency_PreGet" Index="2" />
  1759. <Param name="@Currency_PreGet" type="PreGet.Currency_PreGet" Index="3" />
  1760. <Param name="@Rate_PreGet" type="PreGet.Rate_PreGet" Index="4" />
  1761. <Param name="@Method_PreGet" type="PreGet.Method_PreGet" Index="5" />
  1762. <Param name="@Amount_PreGet" type="PreGet.Amount_PreGet" Index="6" />
  1763. <Param name="@Name_Employee" type="PreGet.Comment_PreGet" Index="7" />
  1764. <Param name="@ID_Creator" type="PreGet.ID_Creator" Index="8" />
  1765. <Param name="@CreateDate_PreGet" type="PreGet.CreateDate_PreGet" Index="9" />
  1766. <Param name="@LastModUser_PreGet" type="PreGet.LastModUser_PreGet" Index="10" />
  1767. <Param name="@LastModDate_PreGet" type="PreGet.LastModDate_PreGet" Index="11" />
  1768. <Param name="@ID_Assessor" type="PreGet.ID_Assessor" Index="12" />
  1769. <Param name="@AssessDate_PreGet" type="PreGet.AssessDate_PreGet" Index="13" />
  1770. <Param name="@Comment_PreGet" type="PreGet.Comment_PreGet" Index="14" />
  1771. <Param name="@Head" type="PreGet.Value1_CodeGenerate" Index="15" />
  1772. <Param name="@GetDate" type="PreGet.Date_PreGet" Index="16" />
  1773. </Params>
  1774. <Tables>
  1775. <Table name="NewPreGet2"/>
  1776. </Tables>
  1777. </CreateNewPreGet2>
  1778. <SearchPreGetHead CmdType="Text" CmdText="Select * From CodeGenerate Where FuncCode_CodeGenerate = 'FrmPreGet'">
  1779. <Tables>
  1780. <Table name="PreGetHead"/>
  1781. </Tables>
  1782. </SearchPreGetHead>
  1783. <SearchCustomersCustomer CmdType="Text" CmdText=" Select *
  1784. From Customer
  1785. Where ID_Customer = ( Select CustomerID_Customer
  1786. From Customer
  1787. Where No_Customer = @No_Customer
  1788. And IsCustomersCustomer_Customer = 1)">
  1789. <Params>
  1790. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1791. </Params>
  1792. <Tables>
  1793. <Table name="CustomersCustomer"/>
  1794. </Tables>
  1795. </SearchCustomersCustomer>
  1796. <SearchNoAssessorPreGet CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1797. Select @ID_Customer = ID_Customer
  1798. From Customer
  1799. Where No_Customer = @No_Customer
  1800. Select No_PreGet From PreGet
  1801. where ID_Customer = @ID_Customer
  1802. And PreGet.ID_Assessor is null
  1803. ">
  1804. <Params>
  1805. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1806. </Params>
  1807. <Tables>
  1808. <Table name="NoAssessorPreGet"/>
  1809. </Tables>
  1810. </SearchNoAssessorPreGet>
  1811. <SearchISDelete CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1812. Select @ID_Customer = ID_Customer
  1813. From Customer
  1814. Where No_Customer = @No_Customer
  1815. Select Count(1) AS No_PreGet From PreGet
  1816. Where No_PreGet = @No_PreGet
  1817. And ID_Customer = @ID_Customer
  1818. ">
  1819. <Params>
  1820. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1821. <Param name="@No_PreGet" type="Customer.No_Customer" Index="1" />
  1822. </Params>
  1823. <Tables>
  1824. <Table name="ISDelete"/>
  1825. </Tables>
  1826. </SearchISDelete>
  1827. <SearchOpenging CmdType="Text" CmdText=" Select *
  1828. From Customer
  1829. Where No_Customer = @No_Customer
  1830. ">
  1831. <Params>
  1832. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1833. </Params>
  1834. <Tables>
  1835. <Table name="Customer"/>
  1836. </Tables>
  1837. </SearchOpenging>
  1838. <SearchLastBalace CmdType="Text" CmdText=" Select (openingToGetBalance_Customer-PrePayValue_Customer) As Balance
  1839. From Customer
  1840. where No_Customer = @No_Customer
  1841. ">
  1842. <Params>
  1843. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1844. </Params>
  1845. <Tables>
  1846. <Table name="Balance"/>
  1847. </Tables>
  1848. </SearchLastBalace>
  1849. <UpdateAmount CmdType="Text" CmdText=" Update Customer
  1850. Set PerValue_Customer = IsNull(PerValue_Customer,0) + @Amount_PreGet
  1851. Where No_Customer = @No_Customer
  1852. Select 1
  1853. ">
  1854. <Params>
  1855. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1856. <Param name="@Amount_PreGet" type="PreGet.Amount_PreGet" Index="1" />
  1857. </Params>
  1858. <Tables>
  1859. <Table name="UpdateAmount"/>
  1860. </Tables>
  1861. </UpdateAmount>
  1862. <UpdatePrePayBalance CmdType="Text" CmdText=" UPDATE Customer
  1863. SET PrePayBalance_Customer= IsNull(PrePayBalance_Customer,0) +@Amount_PreGet
  1864. WHERE No_Customer=@No_Customer
  1865. Select 1
  1866. ">
  1867. <Params>
  1868. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1869. <Param name="@Amount_PreGet" type="PreGet.Amount_PreGet" Index="1" />
  1870. </Params>
  1871. <Tables>
  1872. <Table name="UpdatePrePayBalance"/>
  1873. </Tables>
  1874. </UpdatePrePayBalance>
  1875. <UpdatePrePayValue CmdType="Text" CmdText=" Update Customer
  1876. Set PrePayValue_Customer = isnull(PrePayValue_Customer,0) + isnull(@Amount_ReceivablesStrikeMethod,0)
  1877. Where No_Customer = @No_Customer
  1878. Select 1
  1879. ">
  1880. <Params>
  1881. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1882. <Param name="@Amount_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod" Index="1" />
  1883. </Params>
  1884. <Tables>
  1885. <Table name="UpdatePrePayValue"/>
  1886. </Tables>
  1887. </UpdatePrePayValue>
  1888. <ClearPrePayValue CmdType="Text" CmdText=" Update Customer
  1889. Set PrePayValue_Customer = isnull(PrePayValue_Customer,0) - isnull(@Amount_ReceivablesStrikeMethod,0)
  1890. Where No_Customer = @No_Customer
  1891. Select 1">
  1892. <Params>
  1893. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1894. <Param name="@Amount_ReceivablesStrikeMethod" type="ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod" Index="1" />
  1895. </Params>
  1896. <Tables>
  1897. <Table name="ClearPrePayValue"/>
  1898. </Tables>
  1899. </ClearPrePayValue>
  1900. </Search>
  1901. </Server>
  1902. <Lables>
  1903. <Search>
  1904. Empty();
  1905. NewInstance();
  1906. dtDate.Enabled = false;
  1907. tbNo.ReadOnly = false;
  1908. tbCustomerNo.ReadOnly = true;
  1909. cbReceiver.Enabled = false;
  1910. txtComment.ReadOnly = true;
  1911. dgReceiveMoney.ReadOnly = true;
  1912. txtSum.CValue = 0.00;
  1913. ntbOpeningToGetBalance.CValue = 0.00;
  1914. dtStart.Enabled = false;
  1915. dtEnd.Enabled = false;
  1916. dgBill.ReadOnly = true;
  1917. toolBar.EnableNew = GetRight(@Title,"新增");
  1918. toolBar.EnableSubmit = false;
  1919. toolBar.EnableModify = false;
  1920. toolBar.EnableDelete = false;
  1921. toolBar.EnableAudit = false;
  1922. toolBar.EnableUnAudit = false;
  1923. toolBar.EnablePrint = false;
  1924. cbPrev.Enabled = false;
  1925. cbPayment.Enabled =false;
  1926. txtMoney.ReadOnly = true;
  1927. btnOK.Enabled = false;
  1928. btnSearchByInvoice.Enabled = false;
  1929. btnAutoStrike.Enabled = false;
  1930. btnVerify.Enabled = false;
  1931. #ReceivablesStrike.GetCurrency_ReceivablesStrike = "";
  1932. #ReceivablesStrike.BillCurrency_ReceivablesStrike = "";
  1933. #ReceivablesStrike.Rate_ReceivablesStrike = 0;
  1934. #ReceivablesStrike.AssessDate_ReceivablesStrike = DBNull();
  1935. #ReceivablesStrike.LastModDate_ReceivablesStrike = DBNull();
  1936. UpdateForm(true, "");
  1937. tbNo.Focus();
  1938. @Status = 0;
  1939. </Search>
  1940. <New>
  1941. Empty();
  1942. NewInstance();
  1943. dtDate.Enabled = true;
  1944. tbNo.ReadOnly = true;
  1945. tbCustomerNo.ReadOnly = false;
  1946. cbReceiver.Enabled = true;
  1947. txtComment.ReadOnly = false;
  1948. dgReceiveMoney.ReadOnly = true;
  1949. dgBill.ReadOnly = false;
  1950. txtSum.CValue = 0.00;
  1951. ntbOpeningToGetBalance = 0.00;
  1952. dtStart.Enabled = true;
  1953. dtEnd.Enabled = true;
  1954. toolBar.EnableNew = false;
  1955. toolBar.EnableSubmit = GetRight(@Title,"新增");
  1956. toolBar.EnableModify = false;
  1957. toolBar.EnableDelete = false;
  1958. toolBar.EnableAudit = false;
  1959. toolBar.EnableUnAudit = false;
  1960. toolBar.EnablePrint = false;
  1961. cbPrev.Enabled = true;
  1962. cbPayment.Enabled = true;
  1963. txtMoney.ReadOnly = false;
  1964. btnOK.Enabled = true;
  1965. btnSearchByInvoice.Enabled = true;
  1966. btnAutoStrike.Enabled = true;
  1967. btnVerify.Enabled = true;
  1968. dgReceiveMoney.AllowNew(false);
  1969. dgReceiveMoney.AllowDelete(false);
  1970. dgReceiveMoney.SetColumnReadOnly(1, false);
  1971. dgReceiveMoney.RowHeaderCheck = false;
  1972. dgBill.AllowNew(true);
  1973. dgBill.AllowDelete(true);
  1974. dgBill.SetColumnReadOnly(1, false);
  1975. dgBill.RowHeaderCheck = true;
  1976. #ReceivablesStrike.ID_ReceivablesStrike = NewGuid();
  1977. #ReceivablesStrike.ID_Creator = GetLoginUserID();
  1978. #ReceivablesStrike.Name_Creator = GetCurrentUser();
  1979. #ReceivablesStrike.ID_Assessor = DBNull();
  1980. #ReceivablesStrike.AssessDate_ReceivablesStrike = DBNull();
  1981. #ReceivablesStrike.LastModUser_ReceivablesStrike = DBNull();
  1982. #ReceivablesStrike.LastModDate_ReceivablesStrike = DBNull();
  1983. #ReceivablesStrike.GetCurrency_ReceivablesStrike = @SysCurrency;
  1984. #ReceivablesStrike.BillCurrency_ReceivablesStrike = @SysCurrency;
  1985. #ReceivablesStrike.Rate_ReceivablesStrike = 1;
  1986. SetColumnDefaultValue("ReceivablesStrikeBills", "PayDate_ReceivablesStrikeBills", DBNull());
  1987. UpdateForm(true, "");
  1988. @Status = 1;
  1989. </New>
  1990. <View>
  1991. dtDate.Enabled = false;
  1992. tbNo.ReadOnly = true;
  1993. tbCustomerNo.ReadOnly = true;
  1994. cbReceiver.Enabled = false;
  1995. txtComment.ReadOnly = true;
  1996. dgReceiveMoney.ReadOnly = true;
  1997. dgBill.ReadOnly = true;
  1998. dtStart.Enabled = false;
  1999. dtEnd.Enabled = false;
  2000. toolBar.EnableNew = GetRight(@Title,"新增");
  2001. toolBar.EnableSubmit = false;
  2002. if (Equals(#ReceivablesStrike.ID_Assessor, DBNull()))
  2003. {
  2004. toolBar.EnableModify = GetRight(@Title,"修改");
  2005. toolBar.EnableDelete = GetRight(@Title,"删除");
  2006. toolBar.EnableAudit = GetRight(@Title,"审核");
  2007. toolBar.EnableUnAudit = false;
  2008. }
  2009. else
  2010. {
  2011. toolBar.EnableModify = false;
  2012. toolBar.EnableDelete = false;
  2013. toolBar.EnableAudit = false;
  2014. toolBar.EnableUnAudit = GetRight(@Title,"取消审核");
  2015. }
  2016. toolBar.EnablePrint = GetRight(@Title,"打印");
  2017. cbPrev.Enabled = false;
  2018. cbPayment.Enabled = false;
  2019. txtMoney.ReadOnly = true;
  2020. btnOK.Enabled = false;
  2021. btnSearchByInvoice.Enabled = false;
  2022. btnAutoStrike.Enabled = false;
  2023. btnVerify.Enabled = false;
  2024. UpdateForm(true, "");
  2025. @Status = 2;
  2026. </View>
  2027. <Modify>
  2028. dtDate.Enabled = false;
  2029. tbNo.ReadOnly = true;
  2030. tbCustomerNo.ReadOnly = true;
  2031. cbReceiver.Enabled = true;
  2032. txtComment.ReadOnly = false;
  2033. dgReceiveMoney.ReadOnly = true;
  2034. dgBill.ReadOnly = false;
  2035. dtStart.Enabled = true;
  2036. dtEnd.Enabled = true;
  2037. toolBar.EnableNew = false;
  2038. toolBar.EnableSubmit = GetRight(@Title,"修改");
  2039. toolBar.EnableModify = false;
  2040. toolBar.EnableDelete = false;
  2041. toolBar.EnableAudit = false;
  2042. toolBar.EnableUnAudit = false;
  2043. toolBar.EnablePrint = false;
  2044. @NotAssess = Equals(#ReceivablesStrike.AssessDate_ReceivablesStrike, DBNull());
  2045. cbPrev.Enabled = @NotAssess;
  2046. cbPayment.Enabled = true;
  2047. txtMoney.ReadOnly = false;
  2048. btnOK.Enabled = false;
  2049. if (cbPrev.Checked)
  2050. {
  2051. btnSearchByInvoice.Enabled = false;
  2052. btnAutoStrike.Enabled = false;
  2053. }
  2054. else
  2055. {
  2056. btnSearchByInvoice.Enabled = @NotAssess;
  2057. btnAutoStrike.Enabled = true;
  2058. }
  2059. btnVerify.Enabled = true;
  2060. dgReceiveMoney.AllowNew(false);
  2061. dgReceiveMoney.AllowDelete(false);
  2062. dgReceiveMoney.SetColumnReadOnly(1, false);
  2063. dgReceiveMoney.RowHeaderCheck = false;
  2064. dgBill.AllowNew(@NotAssess);
  2065. dgBill.AllowDelete(@NotAssess);
  2066. dgBill.SetColumnReadOnly(1, !@NotAssess);
  2067. dgBill.RowHeaderCheck = @NotAssess;
  2068. #ReceivablesStrike.LastModUser_ReceivablesStrike = GetLoginUserID();
  2069. #ReceivablesStrike.Name_LastModUser = GetCurrentUser();
  2070. #ReceivablesStrike.LastModDate_ReceivablesStrike = DateTimeNow();
  2071. SetColumnDefaultValue("ReceivablesStrikeBills", "PayDate_ReceivablesStrikeBills", DBNull());
  2072. UpdateForm(true, "");
  2073. @Status = 3;
  2074. </Modify>
  2075. <SubmitButtonClick>
  2076. <![CDATA[
  2077. @sumMethod = 0;
  2078. @sumBills = 0;
  2079. @sumPrePayValue = 0;
  2080. @SumMoneyPerGet =0;
  2081. @SumMoney = 0;
  2082. @SumStrike = 0;
  2083. if (tbCustomerNo.CValue == "" || !Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  2084. {
  2085. MessageBox("请输入有效的客户,回车以示确认!",@Title);
  2086. tbCustomerNo.Focus();
  2087. return;
  2088. }
  2089. else
  2090. {
  2091. SuspendLayout();
  2092. for (@V=0;@V<RowCount("#ReceivablesStrikeMethod");@V++)
  2093. {
  2094. SetPosition("#ReceivablesStrikeMethod", @V);
  2095. if (Search("SearchNoAssessorPreGet",tbCustomerNo.CValue))
  2096. {
  2097. MessageBox("有未审核的收款单号,请重新填单!");
  2098. tbCustomerNo.Text = "";
  2099. return;
  2100. }
  2101. if(Search("SearchISDelete",tbCustomerNo.CValue,#ReceivablesStrikeMethod.No_PreGet))
  2102. {
  2103. if(#ISDelete.No_PreGet==0)
  2104. {
  2105. MessageBox("有不存在的收款单号,请重新填单!");
  2106. tbCustomerNo.Text = "";
  2107. return;
  2108. }
  2109. }
  2110. }
  2111. ResumeLayout();
  2112. }
  2113. if (!cbReceiver.CheckSelectedItem())
  2114. {
  2115. MessageBox("请选择有效的收款人!",@Title);
  2116. cbReceiver.Focus();
  2117. return;
  2118. }
  2119. if (#ReceivablesStrike.PrePayBalance_Customer < SumOfCol("#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod", "Type_ReceivablesStrikeMethod = '冲减预收款'", false))
  2120. {
  2121. MessageBox("该客户的预收帐款余额不得小于此次冲账所使用的金额!",@Title);
  2122. dgReceiveMoney.Focus();
  2123. tbDetail.SelectedIndex = 0;
  2124. return;
  2125. }
  2126. if (cbPrev.Checked)
  2127. {
  2128. if(Search("SearchCustomerWithNo", #ReceivablesStrike.No_Customer))
  2129. {
  2130. SuspendLayout();
  2131. for (@a=0;@a<RowCount("#ReceivablesStrikeBills");@a++)
  2132. {
  2133. SetPosition("#ReceivablesStrikeBills", @a);
  2134. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = 0;
  2135. }
  2136. for (@b=0;@b<RowCount("#ReceivablesStrikeMethod");@b++)
  2137. {
  2138. SetPosition("#ReceivablesStrikeMethod", @b);
  2139. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = 0;
  2140. }
  2141. for (@i =0;@i<RowCount("#ReceivablesStrikeMethod");@i++)
  2142. {
  2143. SetPosition("#ReceivablesStrikeMethod", @i);
  2144. @SumMoney += #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  2145. }
  2146. @SumMoneyPerGet += #Customer.OpeningToGetBalance_Customer;
  2147. for (@l =0;@l<RowCount("#ReceivablesStrikeBills");@l++)
  2148. {
  2149. SetPosition("#ReceivablesStrikeBills", @l);
  2150. @SumMoneyPerGet += #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  2151. }
  2152. if (@SumMoney > @SumMoneyPerGet)
  2153. {
  2154. @SumStrike = @SumMoneyPerGet;
  2155. }
  2156. else
  2157. {
  2158. @SumStrike = @SumMoney;
  2159. }
  2160. for (@j=0;@j<RowCount("#ReceivablesStrikeBills");@j++)
  2161. {
  2162. SetPosition("#ReceivablesStrikeBills", @j);
  2163. @SumMoneyPerGet += #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  2164. if (@SumStrike > 0)
  2165. {
  2166. if (@SumStrike >= #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills)
  2167. {
  2168. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills;
  2169. }
  2170. else
  2171. {
  2172. #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills = @SumStrike;
  2173. }
  2174. @SumStrike = @SumStrike - #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills;
  2175. }
  2176. }
  2177. if (@SumMoney > @SumMoneyPerGet)
  2178. {
  2179. @SumStrike = @SumMoneyPerGet;
  2180. }
  2181. else
  2182. {
  2183. @SumStrike = @SumMoney;
  2184. }
  2185. for (@k=0;@k<RowCount("#ReceivablesStrikeMethod");@k++)
  2186. {
  2187. SetPosition("#ReceivablesStrikeMethod", @k);
  2188. if (@SumStrike > 0)
  2189. {
  2190. if (@SumStrike > #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod)
  2191. {
  2192. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = #ReceivablesStrikeMethod.LeaveAmount_ReceivablesStrikeMethod;
  2193. }
  2194. else
  2195. {
  2196. #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod = @SumStrike;
  2197. }
  2198. @SumStrike = @SumStrike - #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  2199. }
  2200. }
  2201. ResumeLayout();
  2202. }
  2203. }
  2204. SuspendLayout();
  2205. for (@i=0; @i<RowCount("#ReceivablesStrikeMethod"); @i=@i+1)
  2206. {
  2207. SetPosition("#ReceivablesStrikeMethod", @i);
  2208. @sumMethod += #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  2209. if (Equals(#ReceivablesStrikeMethod.ID_ReceivablesStrikeMethod,GuidEmpty()))
  2210. #ReceivablesStrikeMethod.ID_ReceivablesStrikeMethod = NewGuid();
  2211. #ReceivablesStrikeMethod.ID_ReceivablesStrike = #ReceivablesStrike.ID_ReceivablesStrike;
  2212. }
  2213. for (@i=0; @i<RowCount("#ReceivablesStrikeBills"); @i=@i+1)
  2214. {
  2215. SetPosition("#ReceivablesStrikeBills", @i);
  2216. @sumBills += #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills;
  2217. if (Equals(#ReceivablesStrikeBills.ID_ReceivablesStrikeBills,GuidEmpty()))
  2218. #ReceivablesStrikeBills.ID_ReceivablesStrikeBills = NewGuid();
  2219. #ReceivablesStrikeBills.ID_ReceivablesStrike = #ReceivablesStrike.ID_ReceivablesStrike;
  2220. }
  2221. ResumeLayout();
  2222. UpdateForm(false, "");
  2223. SuspendLayout();
  2224. for (@g=0; @g<RowCount("#ReceivablesStrikeMethod"); @g=@g+1)
  2225. {
  2226. SetPosition("#ReceivablesStrikeMethod", @g);
  2227. @sumPrePayValue += #ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod;
  2228. }
  2229. ResumeLayout();
  2230. if (cbPrev.Checked)
  2231. {
  2232. if(Search("SearchOpenging",tbCustomerNo.CValue))
  2233. {
  2234. if(#Customer.PrePayValue_Customer == #Customer.OpeningToGetBalance_Customer)
  2235. {
  2236. MessageBox("期初应收帐款已全部冲完,提交失败!",@Title);
  2237. return;
  2238. }
  2239. }
  2240. }
  2241. if (@Status == 1)
  2242. {
  2243. #ReceivablesStrike.CreateDate_ReceivablesStrike = DateTimeNow();
  2244. #ReceivablesStrike.No_ReceivablesStrike = New("#ReceivablesStrike.No_ReceivablesStrike", dtDate.CValue);
  2245. }
  2246. else if (@Status == 3)
  2247. {
  2248. #ReceivablesStrike.LastModDate_ReceivablesStrike = DateTimeNow();
  2249. Update();
  2250. }
  2251. ChangeMode("View",#ReceivablesStrike.ID_Assessor);
  2252. ]]>
  2253. </SubmitButtonClick>
  2254. <GetFromBill>
  2255. <![CDATA[
  2256. if(Search("SearchFromBillInInvoice",#ReceivablesStrikeBills.No_SaleInvoice))
  2257. {
  2258. if(Equals(#FromBill.ID_Assessor,DBNull()))
  2259. {
  2260. MessageBox("该销项发票未经审核!",@Title);
  2261. return;
  2262. }
  2263. else if(#FromBill.Disable_SaleInvoice == true)
  2264. {
  2265. MessageBox("该销项发票已作废!",@Title);
  2266. return;
  2267. }
  2268. else if(#FromBill.Amount_SaleInvoice == #FromBill.StrikedAmount_SaleInvoice)
  2269. {
  2270. MessageBox("该销项发票金额已全部冲减完毕!",@Title);
  2271. return;
  2272. }
  2273. #ReceivablesStrikeBills.No_Invoice=#FromBill.No_Invoice;
  2274. #ReceivablesStrikeBills.PayDate_ReceivablesStrikeBills=#FromBill.PayDate_SaleInvoice;
  2275. #ReceivablesStrikeBills.Amount_FromBill=#FromBill.Amount_SaleInvoice;
  2276. #ReceivablesStrikeBills.StrikedAmount_ReceivablesStrikeBills=#FromBill.StrikedAmount_SaleInvoice;
  2277. #ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills=#FromBill.Amount_SaleInvoice-#FromBill.StrikedAmount_SaleInvoice;
  2278. }
  2279. else
  2280. {
  2281. MessageBox("该销项发票不存在!",@Title);
  2282. return;
  2283. }
  2284. ]]>
  2285. </GetFromBill>
  2286. <CountSum>
  2287. <![CDATA[
  2288. txtSum.CValue=SumOfCol("#ReceivablesStrikeBills.Strike_ReceivablesStrikeBills");
  2289. ]]>
  2290. </CountSum>
  2291. <Verify>
  2292. <![CDATA[
  2293. UpdateForm(false, "");
  2294. if (!Search("SearchCustomerWithNo", tbCustomerNo.CValue) || !Equals(#ReceivablesStrike.ID_Customer,#Customer.ID_Customer))
  2295. {
  2296. MessageBox("请输入有效的客户编号,并按回车确认!",@Title);
  2297. tbCustomerNo.Focus();
  2298. return;
  2299. }
  2300. if(!cbReceiver.CheckSelectedItem())
  2301. {
  2302. MessageBox("请选择有效的收款人!",@Title);
  2303. cbReceiver.Focus();
  2304. tbDetail.SelectedIndex = 0;
  2305. return;
  2306. }
  2307. if (RowCount("#ReceivablesStrikeMethod") == 0)
  2308. {
  2309. MessageBox("收款方式及收款金额列表不能为空!",@Title);
  2310. tbDetail.SelectedIndex = 0;
  2311. dgReceiveMoney.Focus();
  2312. return;
  2313. }
  2314. if (!cbPrev.Checked && RowCount("#ReceivablesStrikeBills") == 0)
  2315. {
  2316. MessageBox("冲帐单据列表不能为空!",@Title);
  2317. tbDetail.SelectedIndex = 1;
  2318. dgBill.Focus();
  2319. return;
  2320. }
  2321. SuspendLayout();
  2322. for (@i=0; @i<RowCount("#ReceivablesStrikeMethod"); @i=@i+1)
  2323. {
  2324. SetPosition("#ReceivablesStrikeMethod", @i);
  2325. if (#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod < 0)
  2326. {
  2327. MessageBox("收款金额不得小于0!",@Title);
  2328. tbDetail.SelectedIndex = 0;
  2329. dgReceiveMoney.Focus();
  2330. ResumeLayout();
  2331. dgReceiveMoney.CurrentRowIndex = @i;
  2332. return;
  2333. }
  2334. }
  2335. @AllStrikeAmount = SumOfCol("#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod");
  2336. if (@AllStrikeAmount == 0)
  2337. {
  2338. MessageBox("本次入帐金额不得为0!",@Title);
  2339. dgReceiveMoney.Focus();
  2340. ResumeLayout();
  2341. tbDetail.SelectedIndex = 0;
  2342. return;
  2343. }
  2344. for (@i=0; @i<RowCount("#ReceivablesStrikeBills"); @i=@i+1)
  2345. {
  2346. SetPosition("#ReceivablesStrikeBills", @i);
  2347. if (Equals(#ReceivablesStrike.Prev_ReceivablesStrike, false))
  2348. {
  2349. if (Equals(#ReceivablesStrikeBills.No_SaleInvoice, ""))
  2350. {
  2351. MessageBox("请填入销项发票单号!",@Title);
  2352. dgBill.Focus();
  2353. ResumeLayout();
  2354. tbDetail.SelectedIndex = 1;
  2355. dgBill.CurrentRowIndex = @i;
  2356. return;
  2357. }
  2358. if(Search("SearchFromBillInInvoice",#ReceivablesStrikeBills.No_SaleInvoice))
  2359. {
  2360. if(Equals(#FromBill.ID_Assessor,DBNull()))
  2361. {
  2362. MessageBox("该销项发票未经审核!",@Title);
  2363. dgBill.Focus();
  2364. ResumeLayout();
  2365. tbDetail.SelectedIndex = 1;
  2366. dgBill.CurrentRowIndex = @i;
  2367. return;
  2368. }
  2369. else if(#FromBill.Disable_SaleInvoice==1)
  2370. {
  2371. MessageBox("该销项发票已作废!",@Title);
  2372. dgBill.Focus();
  2373. ResumeLayout();
  2374. tbDetail.SelectedIndex = 1;
  2375. dgBill.CurrentRowIndex = @i;
  2376. return;
  2377. }
  2378. else if(#FromBill.Amount_SaleInvoice == #FromBill.StrikedAmount_SaleInvoice)
  2379. {
  2380. MessageBox("该销项发票金额已全部冲减完毕!",@Title);
  2381. dgBill.Focus();
  2382. ResumeLayout();
  2383. tbDetail.SelectedIndex = 1;
  2384. dgBill.CurrentRowIndex = @i;
  2385. return;
  2386. }
  2387. else if(!Equals(#FromBill.ID_Customer,#ReceivablesStrike.ID_Customer))
  2388. {
  2389. MessageBox("该销项发票的客户与本单据的客户不一致!",@Title);
  2390. dgBill.Focus();
  2391. ResumeLayout();
  2392. tbDetail.SelectedIndex = 1;
  2393. dgBill.CurrentRowIndex = @i;
  2394. return;
  2395. }
  2396. }
  2397. else
  2398. {
  2399. MessageBox("该销项发票不存在!",@Title);
  2400. dgBill.Focus();
  2401. ResumeLayout();
  2402. tbDetail.SelectedIndex = 1;
  2403. dgBill.CurrentRowIndex = @i;
  2404. return;
  2405. }
  2406. }
  2407. if (#ReceivablesStrikeBills.Discount_ReceivablesStrikeBills * #ReceivablesStrikeBills.Amount_FromBill < 0)
  2408. {
  2409. MessageBox("本次折让金额错误!",@Title);
  2410. dgBill.Focus();
  2411. ResumeLayout();
  2412. tbDetail.SelectedIndex = 1;
  2413. dgBill.CurrentRowIndex = @i;
  2414. return;
  2415. }
  2416. if (#ReceivablesStrikeBills.Strike_ReceivablesStrikeBills*#ReceivablesStrikeBills.Amount_FromBill < 0)
  2417. {
  2418. MessageBox("本次冲帐金额错误!",@Title);
  2419. dgBill.Focus();
  2420. ResumeLayout();
  2421. tbDetail.SelectedIndex = 1;
  2422. dgBill.CurrentRowIndex = @i;
  2423. return;
  2424. }
  2425. if ((#ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills - #ReceivablesStrikeBills.Strike_ReceivablesStrikeBills )*#ReceivablesStrikeBills.ToGetAmount_ReceivablesStrikeBills < 0)
  2426. {
  2427. MessageBox("本次冲帐不得大于本次应收!",@Title);
  2428. dgBill.Focus();
  2429. ResumeLayout();
  2430. tbDetail.SelectedIndex = 1;
  2431. dgBill.CurrentRowIndex = @i;
  2432. return;
  2433. }
  2434. }
  2435. ResumeLayout();
  2436. if (SumOfCol("#ReceivablesStrikeMethod.Amount_ReceivablesStrikeMethod")!=SumOfCol("#ReceivablesStrikeBills.Strike_ReceivablesStrikeBills"))
  2437. {
  2438. MessageBox("本次冲帐金额和入帐金额不相等!",@Title);
  2439. dgBill.Focus();
  2440. tbDetail.SelectedIndex = 1;
  2441. return;
  2442. }
  2443. ]]>
  2444. </Verify>
  2445. </Lables>
  2446. </Form>
  2447. </Forms>