FrmSaleInvoicce.xml 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Forms>
  3. <Form Name="FrmSaleInvoicce">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @Title="销项发票";
  9. GetSchema();
  10. Search("SearchCessOut");
  11. Search("SearchSaleBillProduct","p","p");
  12. Search("SearchSaleRtnBillProduct","p","p");
  13. Search("SearchProduct","p");
  14. @CessOut=#SystemSetting.CessOut_SystemSetting/100;
  15. @PriceDecimal=#SystemSetting.PriceDecimal_SystemSetting;
  16. @SysCurrency=#SystemSetting.SysCurrency_SystemSetting;
  17. SetColumnDefaultValue("SaleInvoiceProduct", "TaxRate_SaleInvoiceProduct",@CessOut);
  18. ChangeMode("Search");
  19. Search("SearchBillType");
  20. Search("SearchTemp");
  21. ]]>
  22. </Load>
  23. <Closing>
  24. ;<!--TODO-->
  25. </Closing>
  26. <Closed>
  27. ;<!--TODO-->
  28. </Closed>
  29. </Events>
  30. <Mode>
  31. <Search>
  32. <Lable name="Search" />
  33. </Search>
  34. <New>
  35. <Lable name="New" />
  36. </New>
  37. <View>
  38. <Lable name="View" />
  39. </View>
  40. <Modify>
  41. <Lable name="Modify" />
  42. </Modify>
  43. </Mode>
  44. <Controls>
  45. <IKTextButton name="tbNo" DataSource="SaleInvoice.No_SaleInvoice">
  46. <Events>
  47. <Enter>
  48. if(tbNo.ReadOnly == false)
  49. {
  50. if(tbNo.CValue != StringEmpty())
  51. {
  52. UpdateForm(false, "");
  53. if(Search("SearchSaleInvoiceWithNo", tbNo.CValue))
  54. {
  55. ChangeMode("View",#SaleInvoice.ID_Assessor);
  56. if(#SaleInvoice.Disable_SaleInvoice==true)
  57. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  58. <Lable name="CountSum"/>
  59. }
  60. else
  61. {
  62. MessageBox("该销项发票不存在!",@Title);
  63. }
  64. }
  65. else
  66. {
  67. MessageBox("请输入销项发票单号!", @Title);
  68. }
  69. }
  70. </Enter>
  71. <Click>
  72. ShowSearchBox("BillSearch","NODEPOT", "tbNo", tbNo.CValue);
  73. </Click>
  74. </Events>
  75. </IKTextButton>
  76. <IKDataTimePicker name="dtDate" DataSource="SaleInvoice.Date_SaleInvoice" />
  77. <IKComboBoxEx name="cbType" DisplaySource="SaleInvoice.TypeName">
  78. <Events>
  79. <SelectedIndexChanged>
  80. #SaleInvoice.Type_SaleInvoice=cbType.SelectedIndex;
  81. </SelectedIndexChanged>
  82. </Events>
  83. </IKComboBoxEx>
  84. <IKDataTimePicker name="dtInvoiceDate" DataSource="SaleInvoice.InvoiceDate_SaleInvoice" >
  85. <Events>
  86. <ValueChanged>
  87. if(!Equals(#SaleInvoice.ID_Customer,GuidEmpty()))
  88. {
  89. if(Equals(#SaleInvoice.GetMethod_Customer,"先款后货"))
  90. #SaleInvoice.PayDate_SaleInvoice=dtInvoiceDate.Value;
  91. else if(Equals(#SaleInvoice.GetMethod_Customer,"票到当月结"))
  92. {
  93. Search("SearchPayDate",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  94. #SaleInvoice.PayDate_SaleInvoice= #PayDate.NextEndDate;
  95. }
  96. else if(Equals(#SaleInvoice.GetMethod_Customer,"两月结"))
  97. {
  98. Search("SearchPayDate2",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  99. #SaleInvoice.PayDate_SaleInvoice=#PayDate2.NextEndDate;
  100. }
  101. else if(Equals(#SaleInvoice.GetMethod_Customer,"三月结"))
  102. {
  103. Search("SearchPayDate3",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  104. #SaleInvoice.PayDate_SaleInvoice=#PayDate3.NextEndDate;
  105. }
  106. else if(Equals(#SaleInvoice.GetMethod_Customer,"四月结"))
  107. {
  108. Search("SearchPayDate4",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  109. #SaleInvoice.PayDate_SaleInvoice=#PayDate4.NextEndDate;
  110. }
  111. else if(Equals(#SaleInvoice.GetMethod_Customer,"票到付款"))
  112. {
  113. Search("SearchPayDate5",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  114. #SaleInvoice.PayDate_SaleInvoice=#PayDate5.NextEndDate;
  115. }
  116. UpdateForm(true,"dtPayDate");
  117. }
  118. </ValueChanged>
  119. </Events>
  120. </IKDataTimePicker>
  121. <IKTextBox name="txtInvoiceNo" DataSource="SaleInvoice.No_Invoice"/>
  122. <IKButton name="btnModify">
  123. <Events>
  124. <Click>
  125. if(Equals(btnModify.Text,"修改"))
  126. {
  127. txtInvoiceNo.ReadOnly=false;
  128. btnModify.Text="保存";
  129. }
  130. else
  131. {
  132. if(Equals(txtInvoiceNo.CValue,""))
  133. {
  134. MessageBox("请填入发票编号!",@Title);
  135. txtInvoiceNo.Focus();
  136. }
  137. else
  138. {
  139. if(Search("SearchInvoiceNo",txtInvoiceNo.CValue,#SaleInvoice.No_SaleInvoice))
  140. {
  141. MessageBox("此发票号码已存在,请重新填入发票编号!",@Title);
  142. txtInvoiceNo.Focus();
  143. return;
  144. }
  145. else
  146. {
  147. #SaleInvoice.LastModUser=GetCurrentUser();
  148. #SaleInvoice.LastModUser_SaleInvoice=GetLoginUserID();
  149. #SaleInvoice.LastModDate_SaleInvoice=GetCurrentTime();
  150. UpdateForm(false,"");
  151. #SaleInvoice.Type_SaleInvoice=cbType.SelectedIndex;
  152. Update();
  153. txtInvoiceNo.ReadOnly=true;
  154. btnModify.Text="修改";
  155. }
  156. }
  157. }
  158. </Click>
  159. </Events>
  160. </IKButton>
  161. <IKTextBox name="txtMaker" DataSource="SaleInvoice.Creator" />
  162. <IKTextButton name="tbCustomerNo" DataSource="SaleInvoice.No_Customer" >
  163. <Events>
  164. <Enter>
  165. UpdateForm(false,"");
  166. if(tbCustomerNo.CValue!=StringEmpty())
  167. {
  168. if(!Search("SearchCustomer",tbCustomerNo.CValue))
  169. {
  170. MessageBox("该客户不存在!",@Title);
  171. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  172. if(@temp != "")
  173. {
  174. tbCustomerNo.CValue = @temp;
  175. ActiveControlEvent("tbCustomerNo", "Enter");
  176. }
  177. }
  178. else
  179. {
  180. if(!Equals(#Customer.SuspendDate_Customer,DBNull()))
  181. {
  182. MessageBox("该客户已暂停!",@Title);
  183. }
  184. #SaleInvoice.ID_Customer=#Customer.ID_Customer;
  185. #SaleInvoice.ShortName_Customer=#Customer.ShortName_Customer;
  186. #SaleInvoice.RevenueRegisterNo_Customer=#Customer.RevenueRegisterNo_Customer;
  187. #SaleInvoice.Bank_SaleInvoice=#Customer.Bank_Customer;
  188. #SaleInvoice.Account_SaleInvoice=#Customer.Account_Customer;
  189. #SaleInvoice.GetMethod_Customer=#Customer.GetMethod_Customer;
  190. #SaleInvoice.InvoiceTitle_SaleInvoice=#Customer.Title_Invoice;
  191. #SaleInvoice.InvoiceAddress_SaleInvoice=#Customer.Address_Invoice;
  192. #SaleInvoice.Company_Customer=#Customer.Company_Customer;
  193. if(Equals(#SaleInvoice.GetMethod_Customer,"先款后货"))
  194. #SaleInvoice.PayDate_SaleInvoice=dtInvoiceDate.Value;
  195. else if(Equals(#SaleInvoice.GetMethod_Customer,"票到当月结"))
  196. {
  197. Search("SearchPayDate",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  198. #SaleInvoice.PayDate_SaleInvoice= #PayDate.NextEndDate;
  199. }
  200. else if(Equals(#SaleInvoice.GetMethod_Customer,"两月结"))
  201. {
  202. Search("SearchPayDate2",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  203. #SaleInvoice.PayDate_SaleInvoice=#PayDate2.NextEndDate;
  204. }
  205. else if(Equals(#SaleInvoice.GetMethod_Customer,"三月结"))
  206. {
  207. Search("SearchPayDate3",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  208. #SaleInvoice.PayDate_SaleInvoice=#PayDate3.NextEndDate;
  209. }
  210. else if(Equals(#SaleInvoice.GetMethod_Customer,"四月结"))
  211. {
  212. Search("SearchPayDate4",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  213. #SaleInvoice.PayDate_SaleInvoice=#PayDate4.NextEndDate;
  214. }
  215. else if(Equals(#SaleInvoice.GetMethod_Customer,"票到付款"))
  216. {
  217. Search("SearchPayDate5",dtInvoiceDate.Value,#Customer.DunDate_Customer);
  218. #SaleInvoice.PayDate_SaleInvoice=#PayDate5.NextEndDate;
  219. }
  220. }
  221. }
  222. else
  223. {
  224. MessageBox("请输入客户编号!",@Title);
  225. #SaleInvoice.ID_Customer=GuidEmpty();
  226. #SaleInvoice.ShortName_Customer="";
  227. #SaleInvoice.InvoiceTitle_SaleInvoice="";
  228. #SaleInvoice.InvoiceAddress_SaleInvoice="";
  229. #SaleInvoice.RevenueRegisterNo_Customer="";
  230. #SaleInvoice.Bank_SaleInvoice="";
  231. #SaleInvoice.Account_SaleInvoice="";
  232. #SaleInvoice.GetMethod_Customer="";
  233. #SaleInvoice.Company_Customer="";
  234. tbCustomerNo.Focus();
  235. }
  236. UpdateForm(true,"");
  237. </Enter>
  238. <Click>
  239. <![CDATA[
  240. if (tbCustomerNo.ReadOnly == false)
  241. {
  242. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  243. if( @temp == "" )
  244. return;
  245. tbCustomerNo.CValue = @temp;
  246. ActiveControlEvent("tbCustomerNo", "Enter");
  247. }
  248. ]]>
  249. </Click>
  250. </Events>
  251. </IKTextButton>
  252. <IKTextBox name="txtCustomerName" DataSource="SaleInvoice.ShortName_Customer"/>
  253. <IKComboBoxEx name="cbInvoiceTitle" DisplaySource="SaleInvoice.InvoiceTitle_SaleInvoice" DataSource="InvoiceTitle" DisplayMember="Title_Invoice">
  254. <Events>
  255. <Reload>
  256. UpdateForm(false, "cbInvoiceTitle");
  257. Search("SearchInvoiceTitle",#SaleInvoice.ID_Customer);
  258. UpdateForm(true, "cbInvoiceTitle");
  259. </Reload>
  260. </Events>
  261. </IKComboBoxEx>
  262. <IKComboBoxEx name="cbInvoiceAddress" DisplaySource="SaleInvoice.InvoiceAddress_SaleInvoice" DataSource="InvoiceAddress" DisplayMember="Address_Invoice">
  263. <Events>
  264. <Reload>
  265. UpdateForm(false, "cbInvoiceAddress");
  266. Search("SearchInvoiceAddress",#SaleInvoice.ID_Customer);
  267. UpdateForm(true, "cbInvoiceAddress");
  268. </Reload>
  269. </Events>
  270. </IKComboBoxEx>
  271. <IKComboBoxEx name="cbCurrency" DisplaySource="SaleInvoice.Currency_SaleInvoice" />
  272. <IKTextBox name="ikTextBox1" DataSource="SaleInvoice.RevenueRegisterNo_Customer"/>
  273. <IKComboBoxEx name="cbBank" DisplaySource="SaleInvoice.Bank_SaleInvoice" DataSource="Bank" DisplayMember="Name_TypeDef">
  274. <Events>
  275. <Reload>
  276. UpdateForm(false, "cbBank");
  277. Search("SearchBank");
  278. UpdateForm(true, "cbBank");
  279. </Reload>
  280. </Events>
  281. </IKComboBoxEx>
  282. <IKTextBox name="txtAccount" DataSource="SaleInvoice.Account_SaleInvoice" />
  283. <IKTextBox name="ikTextBox3" DataSource="SaleInvoice.GetMethod_Customer" />
  284. <IKTextBox name="txtCompany" DataSource="SaleInvoice.Company_Customer" />
  285. <IKDataTimePicker name="dtPayDate" DataSource="SaleInvoice.PayDate_SaleInvoice" />
  286. <IKTextBox name="txtAssessor" DataSource="SaleInvoice.Assessor" />
  287. <IKDateTimeText name="dtAssessDate" DataSource="SaleInvoice.AssessDate_SaleInvoice" />
  288. <IKTextBox name="txtLastModUser" DataSource="SaleInvoice.LastModUser"/>
  289. <IKDateTimeText name="dtLastModDate" DataSource="SaleInvoice.LastModDate_SaleInvoice"/>
  290. <IKNumericTextBox name="txtMoneySum" DataSource="SaleInvoice.GoodsAmount_SaleInvoice"/>
  291. <IKNumericTextBox name="txtTaxSum" DataSource="SaleInvoice.TaxAmount_SaleInvoice"/>
  292. <IKNumericTextBox name="txtSum" DataSource="SaleInvoice.Amount_SaleInvoice"/>
  293. <IKDataGridEx name="dgProduct" DataSource="SaleInvoiceProduct" TableStyleIndex="0">
  294. <DataColumn Index="0" DataSource="SaleInvoiceProduct.Name_BillType" >
  295. <IKDataGridComboBoxColumn DisplaySourceEx="SaleInvoiceProduct.Name_BillType" ValueSourceEx="SaleInvoiceProduct.Type_FromBill" DataSourceEx="BillType" DisplayMemberEx="Name_BillType" ValueMemberEx="Value_BillType">
  296. <Events>
  297. <Reload>
  298. Search("SearchBillType");
  299. SetDataGridColumnDataSource(0,"dgProduct");
  300. </Reload>
  301. </Events>
  302. </IKDataGridComboBoxColumn>
  303. </DataColumn>
  304. <DataColumn Index="1" DataSource="SaleInvoiceProduct.No_FromBill" />
  305. <DataColumn Index="2" DataSource="SaleInvoiceProduct.No_FromBillProduct" />
  306. <DataColumn Index="3" DataSource="SaleInvoiceProduct.No_Customer" />
  307. <DataColumn Index="4" DataSource="SaleInvoiceProduct.ShortName_Customer" />
  308. <DataColumn Index="5" DataSource="SaleInvoiceProduct.No_Product" >
  309. <IKDataGridTextButtonColumn>
  310. <Events>
  311. <Click>
  312. ShowSearchBox("ProductSearch","INFOMATION",#SaleInvoiceProduct.No_Product);
  313. </Click>
  314. </Events>
  315. </IKDataGridTextButtonColumn>
  316. </DataColumn>
  317. <DataColumn Index="6" DataSource="SaleInvoiceProduct.Name_Product" />
  318. <DataColumn Index="7" DataSource="SaleInvoiceProduct.InvoiceName_Product" />
  319. <DataColumn Index="8" DataSource="SaleInvoiceProduct.Unit_Product" />
  320. <DataColumn Index="9" DataSource="SaleInvoiceProduct.Quantity_SaleInvoiceProduct" />
  321. <DataColumn Index="10" DataSource="SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct" />
  322. <DataColumn Index="11" DataSource="SaleInvoiceProduct.Amount_SaleInvoiceProduct" />
  323. <DataColumn Index="12" DataSource="SaleInvoiceProduct.TaxRate_SaleInvoiceProduct" />
  324. <DataColumn Index="13" DataSource="SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct" />
  325. <DataColumn Index="14" DataSource="SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct" />
  326. <DataColumn Index="15" DataSource="SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct" />
  327. <DataColumn Index="16" DataSource="SaleInvoiceProduct.Comment_SaleInvoiceProduct" />
  328. </IKDataGridEx>
  329. <IKDateTimePicker name = "dtStart" DataSource="SaleInvoice.StartDate">
  330. <Events>
  331. <CheckedChanged>
  332. dtEnd.Checked = dtStart.Checked;
  333. </CheckedChanged>
  334. <ValueChanged>
  335. dtEnd.CValue = dtStart.CValue;
  336. </ValueChanged>
  337. </Events>
  338. </IKDateTimePicker>
  339. <IKDateTimePicker name = "dtEnd" DataSource="SaleInvoice.EndDate"/>
  340. <IKCheckBox name="ckRtn" DataSource="SaleInvoice.ckRtn"/>
  341. <IKButton name ="btnSearch">
  342. <Events>
  343. <Click>
  344. MergeTable("#SaleInvoiceProduct","#Temp");
  345. Empty("#SaleInvoiceProduct");
  346. @DateStart = null;
  347. @DateEnd = null;
  348. @ckRtn = 0;
  349. if (dtStart.Checked)
  350. @DateStart = dtStart.CValue;
  351. else
  352. {
  353. MessageBox("请选择日期!");
  354. return;
  355. }
  356. if (dtEnd.Checked)
  357. @DateEnd = dtEnd.CValue;
  358. if (ckRtn.Checked)
  359. {
  360. @ckRtn = 1;
  361. if(Search("SearchAllSaleAndRtnBill",#SaleInvoice.No_Customer,@DateStart,@DateEnd,@ckRtn))
  362. {
  363. MergeTable("#SaleInvoiceProduct1","#SaleInvoiceProduct");
  364. }
  365. }
  366. else
  367. {
  368. @ckRtn = 0;
  369. if(Search("SearchAllSale",#SaleInvoice.No_Customer,@DateStart,@DateEnd,@ckRtn))
  370. MergeTable("#SaleInvoiceProduct2","#SaleInvoiceProduct");
  371. }
  372. dgProduct.SetColumnReadOnly(14,true);
  373. <Lable name="CountSum"/>
  374. </Click>
  375. </Events>
  376. </IKButton>
  377. <IKFormToolBar name="toolBar">
  378. <Events>
  379. <ClickFirst>
  380. if(Search("SearchSaleInvoiceFirst"))
  381. {
  382. ChangeMode("View",#SaleInvoice.ID_Assessor);
  383. if(#SaleInvoice.Disable_SaleInvoice==true)
  384. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  385. <Lable name="CountSum"/>
  386. }
  387. </ClickFirst>
  388. <ClickPrev>
  389. if(Search("SearchSaleInvoicePrevious", tbNo.CValue))
  390. {
  391. ChangeMode("View",#SaleInvoice.ID_Assessor);
  392. if(#SaleInvoice.Disable_SaleInvoice==true)
  393. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  394. <Lable name="CountSum"/>
  395. }
  396. </ClickPrev>
  397. <ClickNext>
  398. if(Search("SearchSaleInvoiceNext",tbNo.CValue))
  399. {
  400. ChangeMode("View",#SaleInvoice.ID_Assessor);
  401. if(#SaleInvoice.Disable_SaleInvoice==true)
  402. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  403. <Lable name="CountSum"/>
  404. }
  405. </ClickNext>
  406. <ClickLast>
  407. if(Search("SearchSaleInvoiceLast"))
  408. {
  409. ChangeMode("View",#SaleInvoice.ID_Assessor);
  410. if(#SaleInvoice.Disable_SaleInvoice==true)
  411. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  412. <Lable name="CountSum"/>
  413. }
  414. </ClickLast>
  415. <ClickNew>
  416. <![CDATA[
  417. @NextNo = GetNextAutoNumber(true);
  418. if (!Equals(@NextNo, ""))
  419. {
  420. ChangeMode("New");
  421. #SaleInvoice.No_SaleInvoice= @NextNo;
  422. UpdateForm(true, "tbNo");
  423. }
  424. ]]>
  425. </ClickNew>
  426. <ClickEmpty>
  427. ChangeMode("Search");
  428. </ClickEmpty>
  429. <ClickSubmit>
  430. <Lable name="SubmitButtonClick" />
  431. </ClickSubmit>
  432. <ClickModify>
  433. ChangeMode("Modify");
  434. <Lable name="CountSum"/>
  435. </ClickModify>
  436. <ClickDelete>
  437. Delete();
  438. ChangeMode("Search");
  439. </ClickDelete>
  440. <ClickBlank>
  441. BeginBlank();
  442. #SaleInvoice.Disable_SaleInvoice=true;
  443. Blank();
  444. EndBlank();
  445. ChangeMode("View",#SaleInvoice.ID_Assessor);
  446. if(#SaleInvoice.Disable_SaleInvoice==true)
  447. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";
  448. <Lable name="CountSum"/>
  449. </ClickBlank>
  450. <ClickPrint>
  451. ShowPrintBox("BillSearch",#SaleInvoice.No_SaleInvoice,#SaleInvoice.No_SaleInvoice);
  452. </ClickPrint>
  453. <ClickAudit>
  454. <![CDATA[
  455. SuspendLayout();
  456. for (@i=0;@i<RowCount("#SaleInvoiceProduct");@i=@i+1)
  457. {
  458. SetPosition("#SaleInvoiceProduct", @i);
  459. if(Equals(#SaleInvoiceProduct.Name_BillType,"销货单"))
  460. {
  461. if(Search("SearchSaleBill",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  462. {
  463. if (Equals(#SaleBill.ID_Assessor,DBNull()))
  464. {
  465. tbDetail.SelectedIndex = 1;
  466. dgProduct.CurrentRowIndex = @i;
  467. MessageBox("该来源单据未经审核,审核失败!",@Title);
  468. dgProduct.Focus();
  469. ResumeLayout();
  470. return;
  471. }
  472. if (!Search("SearchCustomerRelation",#SaleInvoice.ID_Customer,#SaleBill.ID_Customer))
  473. {
  474. tbDetail.SelectedIndex = 1;
  475. dgProduct.CurrentRowIndex = @i;
  476. MessageBox("该来源单据的客户与本销项发票的客户或下级客户不一致,审核失败!",@Title);
  477. dgProduct.Focus();
  478. ResumeLayout();
  479. return;
  480. }
  481. }
  482. }
  483. if(Equals(#SaleInvoiceProduct.Name_BillType,"销售退货单"))
  484. {
  485. if(Search("SearchSaleRtnBill",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  486. {
  487. if (Equals(#SaleRtnBill.ID_Assessor,DBNull()))
  488. {
  489. tbDetail.SelectedIndex = 1;
  490. dgProduct.CurrentRowIndex = @i;
  491. MessageBox("该来源单据未经审核,提交失败!",@Title);
  492. dgProduct.Focus();
  493. ResumeLayout();
  494. return;
  495. }
  496. if (!Search("SearchCustomerRelation",#SaleInvoice.ID_Customer,#SaleRtnBill.ID_Customer))
  497. {
  498. tbDetail.SelectedIndex = 1;
  499. dgProduct.CurrentRowIndex = @i;
  500. MessageBox("该来源单据的客户与本销项发票的客户或下级客户不一致,审核失败!",@Title);
  501. dgProduct.Focus();
  502. ResumeLayout();
  503. return;
  504. }
  505. }
  506. }
  507. }
  508. ResumeLayout();
  509. ]]>
  510. BeginAudit();
  511. #SaleInvoice.ID_Assessor=GetLoginUserID();
  512. #SaleInvoice.Assessor=GetCurrentUser();
  513. #SaleInvoice.AssessDate_SaleInvoice=DateTimeNow();
  514. Audit();
  515. ChangeMode("View",#SaleInvoice.ID_Assessor);
  516. EndAudit();
  517. <Lable name="CountSum"/>
  518. </ClickAudit>
  519. <ClickUnAudit>
  520. BeginUnAudit();
  521. #SaleInvoice.ID_Assessor=DBNull();
  522. #SaleInvoice.Assessor=DBNull();
  523. #SaleInvoice.AssessDate_SaleInvoice=DataTimeNow();
  524. UnAudit();
  525. ChangeMode("View",#SaleInvoice.ID_Assessor);
  526. EndUnAudit();
  527. <Lable name="CountSum"/>
  528. </ClickUnAudit>
  529. <ClickImportItem>
  530. <![CDATA[
  531. if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="销售退货单")
  532. {
  533. if(Search("SearchContr"))
  534. {
  535. ShowSearchBox("ImportSaleRtnBillControl","BILLCONVERTEX","#SaleInvoiceProduct.Type_FromBill",22,"#SaleInvoiceProduct.Name_BillType","销售退货单");
  536. }
  537. else
  538. {
  539. ShowSearchBox("ImportSaleRtnBillUnControl","BILLCONVERTEX");
  540. }
  541. }
  542. else if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="销货单")
  543. {
  544. @ImportClicked = 1;
  545. if(Search("SearchContrSOB"))
  546. {
  547. ShowSearchBox("ImportSaleBillControl","BILLCONVERTEX","#SaleInvoiceProduct.Type_FromBill",21,"#SaleInvoiceProduct.Name_BillType","销货单");
  548. }
  549. else
  550. {
  551. ShowSearchBox("ImportSaleBillUnControl","BILLCONVERTEX");
  552. }
  553. }
  554. ]]>
  555. <!--使用前先访问ToolBar的MenuItemText属性以确定选中的是那一项-->
  556. </ClickImportItem>
  557. <ClickExport>
  558. ;
  559. </ClickExport>
  560. <ClickClose>
  561. ;
  562. </ClickClose>
  563. <ClickExpand>
  564. ;
  565. </ClickExpand>
  566. </Events>
  567. </IKFormToolBar>
  568. </Controls>
  569. <Tables>
  570. <Table name="SaleInvoiceProduct">
  571. <Events>
  572. <ColumnsChanged>
  573. <Name_BillType>
  574. <Lable name="FromBillChange"/>
  575. <Lable name="CountSum" />
  576. </Name_BillType>
  577. <No_FromBill>
  578. <Lable name="FromBillChange"/>
  579. <Lable name="CountSum" />
  580. </No_FromBill>
  581. <No_FromBillProduct>
  582. <Lable name="FromBillChange"/>
  583. <Lable name="CountSum" />
  584. </No_FromBillProduct>
  585. <No_Product>
  586. if(Equals(#SaleInvoiceProduct.No_Product,"") || !Search("SearchProduct",#SaleInvoiceProduct.No_Product))
  587. {
  588. if(!Equals(#SaleInvoiceProduct.No_Product,""))
  589. MessageBox("该产品不存在!",@Title);
  590. #SaleInvoiceProduct.ID_Product=GuidEmpty();
  591. #SaleInvoiceProduct.Name_Product="";
  592. #SaleInvoiceProduct.Unit_Product="";
  593. #SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct=0.00;
  594. #SaleInvoiceProduct.InvoiceName_Product="";
  595. @temp = ShowSearchBox("InputSearchProduct","INFOMATION",#SaleInvoiceProduct.No_Product);
  596. if(@temp != "")
  597. {
  598. ResumeColumnEvent("#SaleInvoiceProduct.No_Product");
  599. #SaleInvoiceProduct.No_Product = @temp;
  600. ClearColumnEvent();
  601. }
  602. }
  603. else
  604. {
  605. #SaleInvoiceProduct.ID_Product=#Product.ID_Product;
  606. #SaleInvoiceProduct.Name_Product=#Product.Name_Product;
  607. #SaleInvoiceProduct.Unit_Product=#Product.Unit_Product;
  608. #SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct=#Product.Price_Product;
  609. #SaleInvoiceProduct.InvoiceName_Product=#Product.InvoiceName_Product;
  610. }
  611. <Lable name="CountAmount"/>
  612. <Lable name="CountSum"/>
  613. </No_Product>
  614. <Quantity_SaleInvoiceProduct>
  615. <Lable name="CountAmount"/>
  616. <Lable name="CountSum"/>
  617. </Quantity_SaleInvoiceProduct>
  618. <UnitPrice_SaleInvoiceProduct>
  619. <Lable name="CountAmount"/>
  620. <Lable name="CountSum"/>
  621. </UnitPrice_SaleInvoiceProduct>
  622. <TaxRate_SaleInvoiceProduct>
  623. <Lable name="CountAmount"/>
  624. <Lable name="CountSum"/>
  625. </TaxRate_SaleInvoiceProduct>
  626. <TaxCurrency_SaleInvoiceProduct>
  627. <Lable name="CountAmount"/>
  628. <Lable name="CountSum"/>
  629. </TaxCurrency_SaleInvoiceProduct>
  630. </ColumnsChanged>
  631. <RowDeleted>
  632. <Lable name="CountSum"/>
  633. </RowDeleted>
  634. </Events>
  635. </Table>
  636. </Tables>
  637. <LockInfomation LockID="ID_SaleInvoice" LockNO="No_SaleInvoice" LockSearchFunction="SearchSaleInvoiceWithNo" LockAudit="ID_Assessor" LockBlank="Disable_SaleInvoice" />
  638. <LogInfomation LogNO="#SaleInvoice.No_SaleInvoice" RecordFormField="发票号码:#SaleInvoice.No_Invoice,客户编号:#SaleInvoice.No_Customer,银行帐号:#SaleInvoice.Account_Customer" RecordDataGridField="#SaleInvoiceProduct.No_Product,#SaleInvoiceProduct.Quantity_SaleInvoiceProduct,#SaleInvoiceProduct.Amount_SaleInvoiceProduct"/>
  639. <ChildForms>
  640. <ChildForm name="BillSearch" DataSource="SaleInvoice" SearchFunction="SearchAllBill" SearchFunctionByNo="SearchSaleInvoiceWithNo">
  641. <DataColumn Index="0" MappingName="#SaleInvoice.No_SaleInvoice" HeaderText="销项发票单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  642. <DataColumn Index="1" MappingName="#SaleInvoice.Date_SaleInvoice" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  643. <DataColumn Index="2" MappingName="#SaleInvoice.ShortName_Customer" HeaderText="客户简称" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  644. <DataColumn Index="3" MappingName="#SaleInvoice.No_Invoice" HeaderText="发票号码" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  645. <DataColumn Index="4" MappingName="#SaleInvoice.AllAmount" HeaderText="发票含税金额" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  646. <DataColumn Index="5" MappingName="#SaleInvoice.Disable_SaleInvoice" HeaderText="是否作废" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  647. </ChildForm>
  648. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionByNo="" MappingName="客户">
  649. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  650. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  651. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  652. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  653. <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
  654. </ChildForm>
  655. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品" ReturnDataSource="SaleInvoiceProduct" ShowCheckBox="true">
  656. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#SaleInvoiceProduct.No_Product"/>
  657. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  658. </ChildForm>
  659. <ChildForm name="InputSearchProduct" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
  660. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  661. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  662. </ChildForm>
  663. <ChildForm name="ImportSaleBillControl" >
  664. <DataGridIndex DataSource="SaleBill" SearchFunction="SearchAllSaleBill" SearchFunctionStandby="SearchAllSaleBillProduct" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleInvoiceProduct">
  665. <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" ReadOnly="true" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  666. <DataColumn Index="1" MappingName="#SaleBill.Date_SaleBill" ReadOnly="true" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  667. <DataColumn Index="2" MappingName="#SaleBill.No_Customer" ReadOnly="true" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleInvoice.No_Customer"/>
  668. <DataColumn Index="3" MappingName="#SaleBill.ShortName_Customer" ReadOnly="true" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  669. <DataColumn Index="4" MappingName="#SaleBill.TaxCurrency_SaleBill" ReadOnly="true" HeaderText="税别" Width="30" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  670. <DataColumn Index="5" MappingName="#SaleBill.Currency_SaleBill" ReadOnly="true" HeaderText="币别" Width="30" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent"/>
  671. <DataColumn Index="6" MappingName="#SaleBill.State_SaleBill" ReadOnly="true" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  672. <DataColumn Index="7" MappingName="#SaleBill.Name_Location" ReadOnly="true" HeaderText="出货仓库" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" />
  673. <DataColumn Index="8" MappingName="#SaleBill.InvoiceAddress_Company" ReadOnly="true" HeaderText="发票地址" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleInvoice.InvoiceAddress_SaleInvoice"/>
  674. <DataColumn Index="9" MappingName="#SaleBill.InvoiceTitle_Company" ReadOnly="true" HeaderText="发票抬头" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleInvoice.InvoiceTitle_SaleInvoice"/>
  675. </DataGridIndex>
  676. <ReturnFieldMapping>
  677. <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_FromBill"/>
  678. <DataColumn Index="0" MappingName="#SaleBillProduct.No_SaleBillProduct" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_FromBillProduct"/>
  679. </ReturnFieldMapping>
  680. </ChildForm>
  681. <ChildForm name="ImportSaleBillUnControl">
  682. <DataGridIndex DataSource="SaleBill" SearchFunction="SearchAllSaleBill" SearchFunctionStandby="SearchAllSaleBillProduct" SearchFunctionByNo="" MappingName=""
  683. ReturnDataSource="SaleInvoiceProduct">
  684. <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  685. ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.SaleInvoiceProduct" />
  686. <DataColumn Index="1" MappingName="#SaleBill.Date_SaleBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  687. ReturnPath="child" />
  688. <DataColumn Index="2" MappingName="#SaleBill.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  689. ReturnPath="parent" ReturnMappingName="#SaleInvoice.No_Customer" />
  690. <DataColumn Index="3" MappingName="#SaleBill.ShortName_Customer" HeaderText="客户简称" Width="90" ReadOnly="true"
  691. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  692. <DataColumn Index="4" MappingName="#SaleBill.TaxCurrency_SaleBill" HeaderText="税别" Width="90" ReadOnly="true" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" />
  693. <DataColumn Index="5" MappingName="#SaleBill.State_SaleBill" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  694. ReturnPath="child" />
  695. <DataColumn Index="6" MappingName="#SaleBill.Name_Location" HeaderText="出货仓库" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  696. ReturnPath="parent" />
  697. <DataColumn Index="7" MappingName="#SaleBill.OutStatus_SaleBill" HeaderText="发货状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReadOnly="true"
  698. ReturnPath="child" />
  699. </DataGridIndex>
  700. <ReturnFieldMapping>
  701. <DataColumn Index="0" MappingName="#SaleBillProduct.No_Product" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_Product"/>
  702. </ReturnFieldMapping>
  703. </ChildForm>
  704. <ChildForm name="ImportSaleRtnBillControl">
  705. <DataGridIndex DataSource="SaleRtnBill" SearchFunction="SearchAllSaleRtnBill" SearchFunctionStandby="SearchAllSaleRtnBillProduct" SearchFunctionByNo=""
  706. MappingName="" ReturnDataSource="SaleInvoiceProduct">
  707. <DataColumn Index="0" MappingName="#SaleRtnBill.No_SaleRtnBill" HeaderText="单据编号" Width="90" ReadOnly="true"
  708. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_FromBill" />
  709. <DataColumn Index="1" MappingName="#SaleRtnBill.Date_SaleRtnBill" HeaderText="制单日期" Width="90" ReadOnly="true"
  710. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  711. <DataColumn Index="2" MappingName="#SaleRtnBill.No_Customer" HeaderText="客户编号" Width="90" ReadOnly="true" ColumnType="IKDataGridTextBoxColumn"
  712. ReturnPath="parent" ReturnMappingName="#SaleInvoice.No_Customer"/>
  713. <DataColumn Index="3" MappingName="#SaleRtnBill.ShortName_Customer" HeaderText="客户简称" Width="90" ReadOnly="true"
  714. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  715. <DataColumn Index="4" MappingName="#SaleRtnBill.State_SaleRtnBill" HeaderText="单据状态" Width="90" ReadOnly="true"
  716. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  717. <DataColumn Index="5" MappingName="#SaleRtnBill.Name_Location" HeaderText="入库仓库" Width="90" ReadOnly="true"
  718. ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" />
  719. </DataGridIndex>
  720. <ReturnFieldMapping>
  721. <DataColumn Index="0" MappingName="#SaleRtnBillProduct.No_SaleRtnBillProduct" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_FromBillProduct"/>
  722. </ReturnFieldMapping>
  723. </ChildForm>
  724. <ChildForm name="ImportSaleRtnBillUnControl">
  725. <DataGridIndex DataSource="SaleRtnBill" SearchFunction="SearchAllSaleRtnBill" SearchFunctionStandby="SearchAllSaleRtnBillProduct" SearchFunctionByNo=""
  726. MappingName="" ReturnDataSource="SaleInvoiceProduct">
  727. <DataColumn Index="0" MappingName="#SaleRtnBill.No_SaleRtnBill" HeaderText="单据编号" Width="90" ReadOnly="true"
  728. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.Comment_SaleInvoiceProduct" />
  729. <DataColumn Index="1" MappingName="#SaleRtnBill.Date_SaleRtnBill" HeaderText="制单日期" Width="90" ReadOnly="true"
  730. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  731. <DataColumn Index="2" MappingName="#SaleRtnBill.No_Customer" HeaderText="客户编号" Width="90" ReadOnly="true" ColumnType="IKDataGridTextBoxColumn"
  732. ReturnPath="parent" ReturnMappingName="#SaleInvoice.No_Customer"/>
  733. <DataColumn Index="3" MappingName="#SaleRtnBill.ShortName_Customer" HeaderText="客户简称" Width="90" ReadOnly="true"
  734. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  735. <DataColumn Index="4" MappingName="#SaleRtnBill.State_SaleRtnBill" HeaderText="单据状态" Width="90" ReadOnly="true"
  736. ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" />
  737. <DataColumn Index="5" MappingName="#SaleRtnBill.Name_Location" HeaderText="入库仓库" Width="90" ReadOnly="true"
  738. ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" />
  739. </DataGridIndex>
  740. <ReturnFieldMapping>
  741. <DataColumn Index="0" MappingName="#SaleRtnBillProduct.No_Product" ReturnPath="child" ReturnMappingName="#SaleInvoiceProduct.No_Product"/>
  742. </ReturnFieldMapping>
  743. </ChildForm>
  744. </ChildForms>
  745. <ImportedInfo>
  746. UpdateForm(true, "tbCustomerNo");
  747. @InvoiceAddress=#SaleInvoice.InvoiceAddress_SaleInvoice;
  748. @InvoiceTitle=#SaleInvoice.InvoiceTitle_SaleInvoice;
  749. ActiveControlEvent("tbCustomerNo", "Enter");
  750. #SaleInvoice.InvoiceAddress_SaleInvoice=@InvoiceAddress;
  751. #SaleInvoice.InvoiceTitle_SaleInvoice=@InvoiceTitle;
  752. UpdateForm(true, "cbInvoiceTitle");
  753. UpdateForm(true, "cbInvoiceAddress");
  754. </ImportedInfo>
  755. </Client>
  756. <Server>
  757. <Tables>
  758. <Table name="SaleInvoice" Type="Parent">
  759. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleInvoice.*,a.Name_User As Creator
  760. ,b.Name_User As Assessor,c.Name_User As LastModUser
  761. ,Customer.No_Customer,Customer.ShortName_Customer
  762. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer
  763. ,Customer.Account_Customer,Customer.GetMethod_Customer
  764. ,Customer.Company_Customer
  765. ,convert(nvarchar(64),'') As TypeName
  766. ,Convert(DateTime,getdate()) as StartDate
  767. ,Convert(DateTime,getdate()) as EndDate
  768. ,Convert(bit,0) as ckRtn
  769. FROM SaleInvoice
  770. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  771. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  772. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  773. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  774. ">
  775. </GetSchema>
  776. <New CmdType="Text" CmdText=" INSERT INTO SaleInvoice(ID_SaleInvoice
  777. ,No_SaleInvoice
  778. ,Date_SaleInvoice
  779. ,Type_SaleInvoice
  780. ,PayDate_SaleInvoice
  781. ,InvoiceDate_SaleInvoice
  782. ,No_Invoice
  783. ,ID_Customer
  784. ,InvoiceAddress_SaleInvoice
  785. ,InvoiceTitle_SaleInvoice
  786. ,Bank_SaleInvoice
  787. ,Account_SaleInvoice
  788. ,Currency_SaleInvoice
  789. ,ID_Creator
  790. ,CreateDate_SaleInvoice
  791. ,LastModUser_SaleInvoice
  792. ,LastModDate_SaleInvoice
  793. ,ID_Assessor
  794. ,AssessDate_SaleInvoice
  795. ,Amount_SaleInvoice
  796. ,IncludeTax_SaleInvoice
  797. ,GoodsAmount_SaleInvoice
  798. ,TaxAmount_SaleInvoice
  799. )
  800. VALUES(@ID_SaleInvoice
  801. ,@No_SaleInvoice
  802. ,@Date_SaleInvoice
  803. ,@Type_SaleInvoice
  804. ,@PayDate_SaleInvoice
  805. ,@InvoiceDate_SaleInvoice
  806. ,@No_Invoice
  807. ,@ID_Customer
  808. ,@InvoiceAddress_SaleInvoice
  809. ,@InvoiceTitle_SaleInvoice
  810. ,@Bank_SaleInvoice
  811. ,@Account_SaleInvoice
  812. ,@Currency_SaleInvoice
  813. ,@ID_Creator
  814. ,@CreateDate_SaleInvoice
  815. ,@LastModUser_SaleInvoice
  816. ,@LastModDate_SaleInvoice
  817. ,@ID_Assessor
  818. ,@AssessDate_SaleInvoice
  819. ,@Amount_SaleInvoice
  820. ,@IncludeTax_SaleInvoice
  821. ,@GoodsAmount_SaleInvoice
  822. ,@TaxAmount_SaleInvoice
  823. )
  824. ">
  825. <Params>
  826. <Param name="@ID_SaleInvoice" type="SaleInvoice.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  827. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" sourceColumn="No_SaleInvoice" />
  828. <Param name="@Date_SaleInvoice" type="SaleInvoice.Date_SaleInvoice" sourceColumn="Date_SaleInvoice" />
  829. <Param name="@Type_SaleInvoice" type="SaleInvoice.Type_SaleInvoice" sourceColumn="Type_SaleInvoice" />
  830. <Param name="@PayDate_SaleInvoice" type="SaleInvoice.PayDate_SaleInvoice" sourceColumn="PayDate_SaleInvoice" />
  831. <Param name="@InvoiceDate_SaleInvoice" type="SaleInvoice.InvoiceDate_SaleInvoice" sourceColumn="InvoiceDate_SaleInvoice" />
  832. <Param name="@No_Invoice" type="SaleInvoice.No_Invoice" sourceColumn="No_Invoice" />
  833. <Param name="@ID_Customer" type="SaleInvoice.ID_Customer" sourceColumn="ID_Customer" />
  834. <Param name="@InvoiceAddress_SaleInvoice" type="SaleInvoice.InvoiceAddress_SaleInvoice" sourceColumn="InvoiceAddress_SaleInvoice" />
  835. <Param name="@InvoiceTitle_SaleInvoice" type="SaleInvoice.InvoiceTitle_SaleInvoice" sourceColumn="InvoiceTitle_SaleInvoice" />
  836. <Param name="@Bank_SaleInvoice" type="SaleInvoice.Bank_SaleInvoice" sourceColumn="Bank_SaleInvoice" />
  837. <Param name="@Account_SaleInvoice" type="SaleInvoice.Account_SaleInvoice" sourceColumn="Account_SaleInvoice" />
  838. <Param name="@Currency_SaleInvoice" type="SaleInvoice.Currency_SaleInvoice" sourceColumn="Currency_SaleInvoice" />
  839. <Param name="@ID_Creator" type="SaleInvoice.ID_Creator" sourceColumn="ID_Creator" />
  840. <Param name="@CreateDate_SaleInvoice" type="SaleInvoice.CreateDate_SaleInvoice" sourceColumn="CreateDate_SaleInvoice" />
  841. <Param name="@LastModUser_SaleInvoice" type="SaleInvoice.LastModUser_SaleInvoice" sourceColumn="LastModUser_SaleInvoice" />
  842. <Param name="@LastModDate_SaleInvoice" type="SaleInvoice.LastModDate_SaleInvoice" sourceColumn="LastModDate_SaleInvoice" />
  843. <Param name="@ID_Assessor" type="SaleInvoice.ID_Assessor" sourceColumn="ID_Assessor" />
  844. <Param name="@AssessDate_SaleInvoice" type="SaleInvoice.AssessDate_SaleInvoice" sourceColumn="AssessDate_SaleInvoice" />
  845. <Param name="@Amount_SaleInvoice" type="SaleInvoice.Amount_SaleInvoice" sourceColumn="Amount_SaleInvoice" />
  846. <Param name="@IncludeTax_SaleInvoice" type="SaleInvoice.IncludeTax_SaleInvoice" sourceColumn="IncludeTax_SaleInvoice" />
  847. <Param name="@GoodsAmount_SaleInvoice" type="SaleInvoice.GoodsAmount_SaleInvoice" sourceColumn="GoodsAmount_SaleInvoice" />
  848. <Param name="@TaxAmount_SaleInvoice" type="SaleInvoice.TaxAmount_SaleInvoice" sourceColumn="TaxAmount_SaleInvoice" />
  849. </Params>
  850. </New>
  851. <Update CmdType="Text" CmdText=" UPDATE SaleInvoice
  852. SET No_SaleInvoice=@No_SaleInvoice
  853. ,Date_SaleInvoice=@Date_SaleInvoice
  854. ,Type_SaleInvoice=@Type_SaleInvoice
  855. ,PayDate_SaleInvoice=@PayDate_SaleInvoice
  856. ,InvoiceDate_SaleInvoice=@InvoiceDate_SaleInvoice
  857. ,No_Invoice=@No_Invoice
  858. ,ID_Customer=@ID_Customer
  859. ,InvoiceAddress_SaleInvoice=@InvoiceAddress_SaleInvoice
  860. ,InvoiceTitle_SaleInvoice=@InvoiceTitle_SaleInvoice
  861. ,Bank_SaleInvoice=@Bank_SaleInvoice
  862. ,Account_SaleInvoice=@Account_SaleInvoice
  863. ,Currency_SaleInvoice=@Currency_SaleInvoice
  864. ,ID_Creator=@ID_Creator
  865. ,CreateDate_SaleInvoice=@CreateDate_SaleInvoice
  866. ,LastModUser_SaleInvoice=@LastModUser_SaleInvoice
  867. ,LastModDate_SaleInvoice=@LastModDate_SaleInvoice
  868. ,ID_Assessor=@ID_Assessor
  869. ,AssessDate_SaleInvoice=@AssessDate_SaleInvoice
  870. ,Amount_SaleInvoice=@Amount_SaleInvoice
  871. ,IncludeTax_SaleInvoice=@IncludeTax_SaleInvoice
  872. ,GoodsAmount_SaleInvoice=@GoodsAmount_SaleInvoice
  873. ,TaxAmount_SaleInvoice=@TaxAmount_SaleInvoice
  874. WHERE ID_SaleInvoice=@ID_SaleInvoice
  875. ">
  876. <Params>
  877. <Param name="@ID_SaleInvoice" type="SaleInvoice.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  878. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" sourceColumn="No_SaleInvoice" />
  879. <Param name="@Date_SaleInvoice" type="SaleInvoice.Date_SaleInvoice" sourceColumn="Date_SaleInvoice" />
  880. <Param name="@Type_SaleInvoice" type="SaleInvoice.Type_SaleInvoice" sourceColumn="Type_SaleInvoice" />
  881. <Param name="@PayDate_SaleInvoice" type="SaleInvoice.PayDate_SaleInvoice" sourceColumn="PayDate_SaleInvoice" />
  882. <Param name="@InvoiceDate_SaleInvoice" type="SaleInvoice.InvoiceDate_SaleInvoice" sourceColumn="InvoiceDate_SaleInvoice" />
  883. <Param name="@No_Invoice" type="SaleInvoice.No_Invoice" sourceColumn="No_Invoice" />
  884. <Param name="@ID_Customer" type="SaleInvoice.ID_Customer" sourceColumn="ID_Customer" />
  885. <Param name="@InvoiceAddress_SaleInvoice" type="SaleInvoice.InvoiceAddress_SaleInvoice" sourceColumn="InvoiceAddress_SaleInvoice" />
  886. <Param name="@InvoiceTitle_SaleInvoice" type="SaleInvoice.InvoiceTitle_SaleInvoice" sourceColumn="InvoiceTitle_SaleInvoice" />
  887. <Param name="@Bank_SaleInvoice" type="SaleInvoice.Bank_SaleInvoice" sourceColumn="Bank_SaleInvoice" />
  888. <Param name="@Account_SaleInvoice" type="SaleInvoice.Account_SaleInvoice" sourceColumn="Account_SaleInvoice" />
  889. <Param name="@Currency_SaleInvoice" type="SaleInvoice.Currency_SaleInvoice" sourceColumn="Currency_SaleInvoice" />
  890. <Param name="@ID_Creator" type="SaleInvoice.ID_Creator" sourceColumn="ID_Creator" />
  891. <Param name="@CreateDate_SaleInvoice" type="SaleInvoice.CreateDate_SaleInvoice" sourceColumn="CreateDate_SaleInvoice" />
  892. <Param name="@LastModUser_SaleInvoice" type="SaleInvoice.LastModUser_SaleInvoice" sourceColumn="LastModUser_SaleInvoice" />
  893. <Param name="@LastModDate_SaleInvoice" type="SaleInvoice.LastModDate_SaleInvoice" sourceColumn="LastModDate_SaleInvoice" />
  894. <Param name="@ID_Assessor" type="SaleInvoice.ID_Assessor" sourceColumn="ID_Assessor" />
  895. <Param name="@AssessDate_SaleInvoice" type="SaleInvoice.AssessDate_SaleInvoice" sourceColumn="AssessDate_SaleInvoice" />
  896. <Param name="@Amount_SaleInvoice" type="SaleInvoice.Amount_SaleInvoice" sourceColumn="Amount_SaleInvoice" />
  897. <Param name="@IncludeTax_SaleInvoice" type="SaleInvoice.IncludeTax_SaleInvoice" sourceColumn="IncludeTax_SaleInvoice" />
  898. <Param name="@GoodsAmount_SaleInvoice" type="SaleInvoice.GoodsAmount_SaleInvoice" sourceColumn="GoodsAmount_SaleInvoice" />
  899. <Param name="@TaxAmount_SaleInvoice" type="SaleInvoice.TaxAmount_SaleInvoice" sourceColumn="TaxAmount_SaleInvoice" />
  900. </Params>
  901. </Update>
  902. <Delete CmdType="Text" CmdText=" DELETE FROM SaleInvoiceProduct WHERE ID_SaleInvoice=@ID_SaleInvoice
  903. DELETE FROM SaleInvoice WHERE ID_SaleInvoice=@ID_SaleInvoice
  904. ">
  905. <Params>
  906. <Param name="@ID_SaleInvoice" type="SaleInvoice.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  907. </Params>
  908. </Delete>
  909. <Audit CmdType="Text" CmdText=" UPDATE Customer
  910. SET Customer.ToGetBalance_Customer = Customer.ToGetBalance_Customer+@Amount_SaleInvoice
  911. WHERE Customer.ID_Customer=@ID_Customer
  912. DECLARE @No_SaleBill NVARCHAR(64)
  913. DECLARE CUR CURSOR
  914. FOR
  915. SELECT No_FromBill
  916. FROM SaleInvoiceProduct
  917. WHERE ID_SaleInvoice=@ID_SaleInvoice
  918. OPEN CUR
  919. FETCH NEXT FROM CUR INTO @No_SaleBill
  920. WHILE @@FETCH_STATUS=0
  921. BEGIN
  922. UPDATE SaleBill SET Assess_SaleBill=1 WHERE No_SaleBill=@No_SaleBill
  923. UPDATE SaleRtnBill SET Assess_SaleRtnBill=1 WHERE No_SaleRtnBill=@No_SaleBill
  924. FETCH NEXT FROM CUR INTO @No_SaleBill
  925. END
  926. DEALLOCATE CUR
  927. UPDATE SaleInvoice SET ID_Assessor=@ID_Assessor,AssessDate_SaleInvoice=@AssessDate_SaleInvoice WHERE ID_SaleInvoice=@ID_SaleInvoice
  928. ">
  929. <Params>
  930. <Param name="@ID_SaleInvoice" type="SaleInvoice.ID_SaleInvoice" sourceColumn="ID_SaleInvoice"/>
  931. <Param name="@ID_Assessor" type="SaleInvoice.ID_Assessor" sourceColumn="ID_Assessor"/>
  932. <Param name="@ID_Customer" type="SaleInvoice.ID_Customer" sourceColumn="ID_Customer"/>
  933. <Param name="@AssessDate_SaleInvoice" type="SaleInvoice.AssessDate_SaleInvoice" sourceColumn="AssessDate_SaleInvoice"/>
  934. <Param name="@Amount_SaleInvoice" type="SaleInvoice.Amount_SaleInvoice" sourceColumn="Amount_SaleInvoice" />
  935. </Params>
  936. </Audit>
  937. <Blank CmdType="Text" CmdText="
  938. UPDATE Customer
  939. SET ToGetBalance_Customer = ToGetBalance_Customer-@Amount_SaleInvoice
  940. WHERE ID_Customer=@ID_Customer
  941. DECLARE @No_SaleBill NVARCHAR(64)
  942. DECLARE CUR CURSOR
  943. FOR
  944. SELECT No_FromBill
  945. FROM SaleInvoiceProduct
  946. WHERE ID_SaleInvoice=@ID_SaleInvoice
  947. OPEN CUR
  948. FETCH NEXT FROM CUR INTO @No_SaleBill
  949. WHILE @@FETCH_STATUS=0
  950. BEGIN
  951. UPDATE SaleBill SET Assess_SaleBill=0 WHERE No_SaleBill=@No_SaleBill
  952. UPDATE SaleRtnBill SET Assess_SaleRtnBill=0 WHERE No_SaleRtnBill=@No_SaleBill
  953. FETCH NEXT FROM CUR INTO @No_SaleBill
  954. END
  955. DEALLOCATE CUR
  956. UPDATE SaleInvoice
  957. SET Disable_SaleInvoice=@Disable_SaleInvoice
  958. Where ID_SaleInvoice=@ID_SaleInvoice
  959. ">
  960. <Params>
  961. <Param name="@ID_SaleInvoice" type="SaleInvoice.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  962. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" sourceColumn="No_SaleInvoice" />
  963. <Param name="@ID_Customer" type="SaleInvoice.ID_Customer" sourceColumn="ID_Customer"/>
  964. <Param name="@Disable_SaleInvoice" type="SaleInvoice.Disable_SaleInvoice" sourceColumn="Disable_SaleInvoice"/>
  965. <Param name="@Amount_SaleInvoice" type="SaleInvoice.Amount_SaleInvoice" sourceColumn="Amount_SaleInvoice" />
  966. <Param name="@StrikedAmount_SaleInvoice" type="SaleInvoice.StrikedAmount_SaleInvoice" sourceColumn="StrikedAmount_SaleInvoice" />
  967. </Params>
  968. </Blank>
  969. </Table>
  970. <Table name="SaleInvoiceProduct" Type="Child">
  971. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleInvoiceProduct.*,
  972. convert(nvarchar(64),'') As Name_BillType
  973. ,Product.No_Product
  974. ,Product.Name_Product
  975. ,Product.InvoiceName_Product
  976. ,Product.Unit_Product
  977. ,convert(bit,0) AS Negative
  978. ,Convert(nvarchar(64),'') As No_Customer
  979. ,Convert(nvarchar(64),'') As ShortName_Customer
  980. FROM SaleInvoiceProduct
  981. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  982. ">
  983. </GetSchema>
  984. <New CmdType="Text" CmdText=" INSERT INTO SaleInvoiceProduct(ID_SaleInvoiceProduct
  985. ,ID_SaleInvoice
  986. ,Type_FromBill
  987. ,No_FromBill
  988. ,No_FromBillProduct
  989. ,ID_Product
  990. ,Quantity_SaleInvoiceProduct
  991. ,UnitPrice_SaleInvoiceProduct
  992. ,TaxRate_SaleInvoiceProduct
  993. ,Comment_SaleInvoiceProduct
  994. ,Amount_SaleInvoiceProduct
  995. ,TaxAmount_SaleInvoiceProduct
  996. ,GoodsAmount_SaleInvoiceProduct
  997. ,TaxCurrency_SaleInvoiceProduct)
  998. Values(@ID_SaleInvoiceProduct
  999. ,@ID_SaleInvoice
  1000. ,@Type_FromBill
  1001. ,@No_FromBill
  1002. ,@No_FromBillProduct
  1003. ,@ID_Product
  1004. ,@Quantity_SaleInvoiceProduct
  1005. ,@UnitPrice_SaleInvoiceProduct
  1006. ,@TaxRate_SaleInvoiceProduct
  1007. ,@Comment_SaleInvoiceProduct
  1008. ,@Amount_SaleInvoiceProduct
  1009. ,@TaxAmount_SaleInvoiceProduct
  1010. ,@GoodsAmount_SaleInvoiceProduct
  1011. ,@TaxCurrency_SaleInvoiceProduct)
  1012. ">
  1013. <Params>
  1014. <Param name="@ID_SaleInvoiceProduct" type="SaleInvoiceProduct.ID_SaleInvoiceProduct" sourceColumn="ID_SaleInvoiceProduct" />
  1015. <Param name="@ID_SaleInvoice" type="SaleInvoiceProduct.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  1016. <Param name="@Type_FromBill" type="SaleInvoiceProduct.Type_FromBill" sourceColumn="Type_FromBill" />
  1017. <Param name="@No_FromBill" type="SaleInvoiceProduct.No_FromBill" sourceColumn="No_FromBill" />
  1018. <Param name="@No_FromBillProduct" type="SaleInvoiceProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct" />
  1019. <Param name="@ID_Product" type="SaleInvoiceProduct.ID_Product" sourceColumn="ID_Product" />
  1020. <Param name="@Quantity_SaleInvoiceProduct" type="SaleInvoiceProduct.Quantity_SaleInvoiceProduct" sourceColumn="Quantity_SaleInvoiceProduct" />
  1021. <Param name="@UnitPrice_SaleInvoiceProduct" type="SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct" sourceColumn="UnitPrice_SaleInvoiceProduct" />
  1022. <Param name="@TaxRate_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxRate_SaleInvoiceProduct" sourceColumn="TaxRate_SaleInvoiceProduct" />
  1023. <Param name="@Comment_SaleInvoiceProduct" type="SaleInvoiceProduct.Comment_SaleInvoiceProduct" sourceColumn="Comment_SaleInvoiceProduct" />
  1024. <Param name="@Amount_SaleInvoiceProduct" type="SaleInvoiceProduct.Amount_SaleInvoiceProduct" sourceColumn="Amount_SaleInvoiceProduct" />
  1025. <Param name="@TaxAmount_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct" sourceColumn="TaxAmount_SaleInvoiceProduct" />
  1026. <Param name="@GoodsAmount_SaleInvoiceProduct" type="SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct" sourceColumn="GoodsAmount_SaleInvoiceProduct" />
  1027. <Param name="@TaxCurrency_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct" sourceColumn="TaxCurrency_SaleInvoiceProduct" />
  1028. </Params>
  1029. </New>
  1030. <Update CmdType="Text" CmdText=" UPDATE SaleInvoiceProduct
  1031. SET ID_SaleInvoice=@ID_SaleInvoice
  1032. ,Type_FromBill=@Type_FromBill
  1033. ,No_FromBill=@No_FromBill
  1034. ,No_FromBillProduct=@No_FromBillProduct
  1035. ,ID_Product=@ID_Product
  1036. ,Quantity_SaleInvoiceProduct=@Quantity_SaleInvoiceProduct
  1037. ,UnitPrice_SaleInvoiceProduct=@UnitPrice_SaleInvoiceProduct
  1038. ,TaxRate_SaleInvoiceProduct=@TaxRate_SaleInvoiceProduct
  1039. ,Comment_SaleInvoiceProduct=@Comment_SaleInvoiceProduct
  1040. ,Amount_SaleInvoiceProduct=@Amount_SaleInvoiceProduct
  1041. ,TaxAmount_SaleInvoiceProduct=@TaxAmount_SaleInvoiceProduct
  1042. ,GoodsAmount_SaleInvoiceProduct=@GoodsAmount_SaleInvoiceProduct
  1043. ,TaxCurrency_SaleInvoiceProduct=@TaxCurrency_SaleInvoiceProduct
  1044. WHERE ID_SaleInvoiceProduct=@ID_SaleInvoiceProduct
  1045. ">
  1046. <Params>
  1047. <Param name="@ID_SaleInvoiceProduct" type="SaleInvoiceProduct.ID_SaleInvoiceProduct" sourceColumn="ID_SaleInvoiceProduct" />
  1048. <Param name="@ID_SaleInvoice" type="SaleInvoiceProduct.ID_SaleInvoice" sourceColumn="ID_SaleInvoice" />
  1049. <Param name="@Type_FromBill" type="SaleInvoiceProduct.Type_FromBill" sourceColumn="Type_FromBill" />
  1050. <Param name="@No_FromBill" type="SaleInvoiceProduct.No_FromBill" sourceColumn="No_FromBill" />
  1051. <Param name="@No_FromBillProduct" type="SaleInvoiceProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct" />
  1052. <Param name="@ID_Product" type="SaleInvoiceProduct.ID_Product" sourceColumn="ID_Product" />
  1053. <Param name="@Quantity_SaleInvoiceProduct" type="SaleInvoiceProduct.Quantity_SaleInvoiceProduct" sourceColumn="Quantity_SaleInvoiceProduct" />
  1054. <Param name="@UnitPrice_SaleInvoiceProduct" type="SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct" sourceColumn="UnitPrice_SaleInvoiceProduct" />
  1055. <Param name="@TaxRate_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxRate_SaleInvoiceProduct" sourceColumn="TaxRate_SaleInvoiceProduct" />
  1056. <Param name="@Comment_SaleInvoiceProduct" type="SaleInvoiceProduct.Comment_SaleInvoiceProduct" sourceColumn="Comment_SaleInvoiceProduct" />
  1057. <Param name="@Amount_SaleInvoiceProduct" type="SaleInvoiceProduct.Amount_SaleInvoiceProduct" sourceColumn="Amount_SaleInvoiceProduct" />
  1058. <Param name="@TaxAmount_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct" sourceColumn="TaxAmount_SaleInvoiceProduct" />
  1059. <Param name="@GoodsAmount_SaleInvoiceProduct" type="SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct" sourceColumn="GoodsAmount_SaleInvoiceProduct" />
  1060. <Param name="@TaxCurrency_SaleInvoiceProduct" type="SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct" sourceColumn="TaxCurrency_SaleInvoiceProduct" />
  1061. </Params>
  1062. </Update>
  1063. <Delete CmdType="Text" CmdText=" DELETE FROM SaleInvoiceProduct WHERE ID_SaleInvoiceProduct=@ID_SaleInvoiceProduct">
  1064. <Params>
  1065. <Param name="@ID_SaleInvoiceProduct" type="SaleInvoiceProduct.ID_SaleInvoiceProduct" sourceColumn="ID_SaleInvoiceProduct" />
  1066. </Params>
  1067. </Delete>
  1068. </Table>
  1069. </Tables>
  1070. <Search>
  1071. <SearchAllBill CmdType="Text" CmdText="
  1072. SELECT [ID_SaleInvoice]
  1073. ,[No_SaleInvoice]
  1074. ,[Date_SaleInvoice]
  1075. ,[Type_SaleInvoice]
  1076. ,[InvoiceDate_SaleInvoice]
  1077. ,[No_Invoice]
  1078. ,SaleInvoice.[ID_Customer]
  1079. ,[InvoiceAddress_SaleInvoice]
  1080. ,[InvoiceTitle_SaleInvoice]
  1081. ,[Bank_SaleInvoice]
  1082. ,[Account_SaleInvoice]
  1083. ,[Currency_SaleInvoice]
  1084. ,[PayDate_SaleInvoice]
  1085. ,SaleInvoice.[ID_Creator]
  1086. ,[CreateDate_SaleInvoice]
  1087. ,[LastModDate_SaleInvoice]
  1088. ,[LastModUser_SaleInvoice]
  1089. ,[ID_Assessor]
  1090. ,[AssessDate_SaleInvoice]
  1091. ,case [Disable_SaleInvoice] when 1 then '是' when 0 then '否' end as [Disable_SaleInvoice]
  1092. ,[Amount_SaleInvoice]
  1093. ,[IncludeTax_SaleInvoice]
  1094. ,[GoodsAmount_SaleInvoice]
  1095. ,[TaxAmount_SaleInvoice]
  1096. ,[StrikedAmount_SaleInvoice]
  1097. ,[DiscountAmount_SaleInvoice]
  1098. ,[Company_SaleInvoice],
  1099. (GoodsAmount_SaleInvoice + TaxAmount_SaleInvoice ) as AllAmount
  1100. ,a.Name_User As Creator ,b.Name_User As Assessor
  1101. ,c.Name_User As LastModUser,Customer.No_Customer,Customer.ShortName_Customer
  1102. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer,Customer.Account_Customer
  1103. ,Customer.GetMethod_Customer,convert(nvarchar(64),'') As TypeName,Customer.Company_Customer
  1104. FROM SaleInvoice
  1105. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1106. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1107. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1108. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer">
  1109. <Tables>
  1110. <Table name="AllBill" />
  1111. </Tables>
  1112. </SearchAllBill>
  1113. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.No_Customer,Customer.ShortName_Customer
  1114. ,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer
  1115. FROM Customer ">
  1116. <Tables>
  1117. <Table name="AllCustomer" />
  1118. </Tables>
  1119. </SearchAllCustomer>
  1120. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product FROM Product ">
  1121. <Tables>
  1122. <Table name="AllProduct" />
  1123. </Tables>
  1124. </SearchAllProduct>
  1125. <SearchCustomer CmdType="Text" CmdText=" SELECT Top 1 Customer.ID_Customer,ShortName_Customer,RevenueRegisterNo_Customer
  1126. ,Bank_Customer,Account_Customer,GetMethod_Customer,SuspendDate_Customer
  1127. ,DunDate_Customer,Title_Invoice ,Address_Invoice,Company_Customer
  1128. From Customer
  1129. Left Join Invoice On Invoice.ID_Customer = Customer.ID_Customer And Invoice.Common_Invoice = 1
  1130. WHERE No_Customer=@No_Customer
  1131. And IsCustomersCustomer_Customer = 0
  1132. ">
  1133. <Params>
  1134. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1135. </Params>
  1136. <Tables>
  1137. <Table name="Customer"/>
  1138. </Tables>
  1139. </SearchCustomer>
  1140. <SearchInvoiceTitle CmdType="Text" CmdText=" SELECT Title_Invoice FROM Invoice WHERE ID_Customer=@ID_Customer">
  1141. <Params>
  1142. <Param name="@ID_Customer" type="Customer.ID_Customer" Index="0" />
  1143. </Params>
  1144. <Tables>
  1145. <Table name="InvoiceTitle"/>
  1146. </Tables>
  1147. </SearchInvoiceTitle>
  1148. <SearchInvoiceAddress CmdType="Text" CmdText=" SELECT Address_Invoice FROM Invoice WHERE ID_Customer=@ID_Customer">
  1149. <Params>
  1150. <Param name="@ID_Customer" type="Customer.ID_Customer" Index="0" />
  1151. </Params>
  1152. <Tables>
  1153. <Table name="InvoiceAddress"/>
  1154. </Tables>
  1155. </SearchInvoiceAddress>
  1156. <SearchBank CmdType="Text" CmdText="SELECT Name_TypeDef FROM TypeDef WHERE Type_TypeDef = 6">
  1157. <Tables>
  1158. <Table name="Bank" />
  1159. </Tables>
  1160. </SearchBank>
  1161. <SearchCompany CmdType="Text" CmdText="SELECT Name_TypeDef FROM TypeDef WHERE Type_TypeDef = 30">
  1162. <Tables>
  1163. <Table name="Company" />
  1164. </Tables>
  1165. </SearchCompany>
  1166. <SearchSaleBill CmdType="Text" CmdText="SELECT SaleBill.InvoiceAddress_Company,SaleBill.InvoiceTitle_Company
  1167. ,ID_Assessor,ID_Customer,ID_Product,TaxCurrency_SaleBill
  1168. FROM SaleBill
  1169. Join SaleBillProduct On SaleBillProduct.ID_SaleBill=SaleBill.ID_SaleBill
  1170. WHERE No_SaleBill=@No_SaleBill AND No_SaleBillProduct=@No_SaleBillProduct
  1171. ">
  1172. <Params>
  1173. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  1174. <Param name="@No_SaleBillProduct" type="SaleBillProduct.No_SaleBillProduct" Index="1" />
  1175. </Params>
  1176. <Tables>
  1177. <Table name="SaleBill"/>
  1178. </Tables>
  1179. </SearchSaleBill>
  1180. <SearchSaleRtnBill CmdType="Text" CmdText=" SELECT ID_Assessor,ID_Customer,ID_Product,SaleRtnBill.TaxCurrency_SaleRtnBill
  1181. FROM SaleRtnBillProduct
  1182. LEFT JOIN SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1183. WHERE No_SaleRtnBill=@No_SaleRtnBill AND No_SaleRtnBillProduct=@No_SaleRtnBillProduct
  1184. ">
  1185. <Params>
  1186. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" Index="0" />
  1187. <Param name="@No_SaleRtnBillProduct" type="SaleRtnBillProduct.No_SaleRtnBillProduct" Index="1" />
  1188. </Params>
  1189. <Tables>
  1190. <Table name="SaleRtnBill"/>
  1191. </Tables>
  1192. </SearchSaleRtnBill>
  1193. <SearchSaleBillProduct CmdType="Text" CmdText="SELECT SaleBill.TaxCurrency_SaleBill
  1194. ,SaleBillProduct.ID_Product
  1195. ,SaleBillProduct.Quantity_SaleBillProduct
  1196. ,SaleBillProduct.UnitPrice_SaleBillProduct
  1197. ,SaleBillProduct.Discount_SaleBillProduct
  1198. ,Product.No_Product
  1199. ,Product.Name_Product
  1200. ,Product.InvoiceName_Product
  1201. ,Product.Unit_Product
  1202. ,Customer.No_Customer
  1203. ,Customer.ShortName_Customer
  1204. FROM SaleBillProduct
  1205. LEFT JOIN SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  1206. LEFT JOIN Product On Product.ID_Product=SaleBillProduct.ID_Product
  1207. Left join Customer on Customer.ID_Customer = SaleBill.ID_Customer
  1208. WHERE No_SaleBill=@No_SaleBill
  1209. AND No_SaleBillProduct=@No_SaleBillProduct
  1210. ">
  1211. <Params>
  1212. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  1213. <Param name="@No_SaleBillProduct" type="SaleBillProduct.No_SaleBillProduct" Index="1" />
  1214. </Params>
  1215. <Tables>
  1216. <Table name="SaleBillProduct"/>
  1217. </Tables>
  1218. </SearchSaleBillProduct>
  1219. <SearchSaleRtnBillProduct CmdType="Text" CmdText=" SELECT SaleRtnBill.TaxCurrency_SaleRtnBill
  1220. ,SaleRtnBillProduct.ID_Product
  1221. ,SaleRtnBillProduct.Quantity_SaleRtnBillProduct
  1222. ,SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct
  1223. ,Product.No_Product
  1224. ,Product.Name_Product
  1225. ,Product.InvoiceName_Product
  1226. ,Product.Unit_Product
  1227. ,Customer.No_Customer
  1228. ,Customer.ShortName_Customer
  1229. FROM SaleRtnBillProduct
  1230. LEFT JOIN SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1231. LEFT JOIN Product On Product.ID_Product=SaleRtnBillProduct.ID_Product
  1232. Left join Customer on Customer.ID_Customer = SaleRtnBill.ID_Customer
  1233. WHERE No_SaleRtnBill=@No_SaleRtnBill AND No_SaleRtnBillProduct=@No_SaleRtnBillProduct
  1234. ">
  1235. <Params>
  1236. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" Index="0" />
  1237. <Param name="@No_SaleRtnBillProduct" type="SaleRtnBillProduct.No_SaleRtnBillProduct" Index="1" />
  1238. </Params>
  1239. <Tables>
  1240. <Table name="SaleRtnBillProduct"/>
  1241. </Tables>
  1242. </SearchSaleRtnBillProduct>
  1243. <SearchProduct CmdType="Text" CmdText=" SELECT Product.ID_Product,Product.Name_Product,Product.InvoiceName_Product
  1244. ,Product.Unit_Product,Product.Price_Product
  1245. FROM Product
  1246. WHERE No_Product=@No_Product
  1247. ">
  1248. <Params>
  1249. <Param name="@No_Product" type="Product.No_Product" Index="0" />
  1250. </Params>
  1251. <Tables>
  1252. <Table name="Product"/>
  1253. </Tables>
  1254. </SearchProduct>
  1255. <SearchCessOut CmdType="Text" CmdText="SELECT CessOut_SystemSetting,SysCurrency_SystemSetting,PriceDecimal_SystemSetting From SystemSetting">
  1256. <Tables>
  1257. <Table name="SystemSetting"/>
  1258. </Tables>
  1259. </SearchCessOut>
  1260. <SearchSaleInvoiceWithNo CmdType="Text" CmdText=" SELECT SaleInvoice.*,a.Name_User As Creator ,b.Name_User As Assessor,c.Name_User As LastModUser
  1261. ,Customer.No_Customer,Customer.ShortName_Customer,Customer.RevenueRegisterNo_Customer
  1262. ,Customer.Bank_Customer,Customer.Account_Customer,Customer.GetMethod_Customer
  1263. ,Customer.Company_Customer
  1264. ,TypeName=CASE Type_SaleInvoice When 0 Then '普通发票' ELSE '增值税发票' End
  1265. ,Convert(DateTime,getdate()) as StartDate
  1266. ,Convert(DateTime,getdate()) as EndDate
  1267. ,Convert(bit,0) as ckRtn
  1268. FROM SaleInvoice
  1269. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1270. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1271. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1272. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  1273. WHERE No_SaleInvoice=@No_SaleInvoice
  1274. SELECT SaleInvoiceProduct.*
  1275. ,Product.No_Product,Product.Name_Product
  1276. ,Product.InvoiceName_Product
  1277. ,Product.Unit_Product,BillType.Name_BillType
  1278. ,A.No_Customer As No_Customer
  1279. ,A.ShortName_Customer As ShortName_Customer
  1280. FROM SaleInvoiceProduct
  1281. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  1282. LEFT JOIN SaleInvoice On SaleInvoice.ID_SaleInvoice=SaleInvoiceProduct.ID_SaleInvoice
  1283. LEFT JOIN BillType On BillType.Value_BillType=SaleInvoiceProduct.Type_FromBill
  1284. Left Join (select No_SaleBill As No_Bill
  1285. ,Customer.No_Customer As No_Customer
  1286. ,Customer.ShortName_Customer As ShortName_Customer
  1287. From SaleBill
  1288. Left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1289. Where ID_Assessor Is Not Null
  1290. Union All
  1291. select No_SaleRtnBill As No_Bill
  1292. ,Customer.No_Customer As No_Customer
  1293. ,Customer.ShortName_Customer As ShortName_Customer
  1294. From SaleRtnBill
  1295. Left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1296. Where ID_Assessor Is Not Null) A On A.No_Bill = SaleInvoiceProduct.No_FromBill
  1297. WHERE No_SaleInvoice=@No_SaleInvoice
  1298. ">
  1299. <Params>
  1300. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" Index="0" />
  1301. </Params>
  1302. <Tables>
  1303. <Table name="SaleInvoice"/>
  1304. <Table name="SaleInvoiceProduct"/>
  1305. </Tables>
  1306. </SearchSaleInvoiceWithNo>
  1307. <SearchInvoiceNo CmdType="Text" CmdText="Select * From SaleInvoice Where No_Invoice=@No_Invoice And No_SaleInvoice!=@No_SaleInvoice">
  1308. <Params>
  1309. <Param name="@No_Invoice" type="SaleInvoice.No_Invoice" Index="0" />
  1310. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" Index="1" />
  1311. </Params>
  1312. <Tables>
  1313. <Table name="SaleInvoiceNo"/>
  1314. </Tables>
  1315. </SearchInvoiceNo>
  1316. <SearchBillType CmdType="Text" CmdText=" SELECT * FROM BillType WHERE Value_BillType = 21 OR Value_BillType = 0 OR Value_BillType = 22 ORDER BY Value_BillType">
  1317. <Tables>
  1318. <Table name="BillType" />
  1319. </Tables>
  1320. </SearchBillType>
  1321. <SearchCurrency CmdType="Text" CmdText=" CREATE TABLE GetTaxCurrency
  1322. (
  1323. [Type] nvarchar(64)
  1324. )
  1325. INSERT INTO GetTaxCurrency VALUES ('外加')
  1326. INSERT INTO GetTaxCurrency VALUES ('内含')
  1327. SELECT Type AS TaxCurrency_SaleInvoiceProduct FROM GetTaxCurrency
  1328. DROP TABLE GetTaxCurrency
  1329. ">
  1330. <Tables>
  1331. <Table name="GetTaxCurrency" />
  1332. </Tables>
  1333. </SearchCurrency>
  1334. <SearchSaleInvoiceFirst CmdType="Text" CmdText="DECLARE @ID_SaleInvoice UNIQUEIDENTIFIER
  1335. SELECT TOP 1 @ID_SaleInvoice=ID_SaleInvoice
  1336. FROM SaleInvoice ORDER BY No_SaleInvoice
  1337. SELECT SaleInvoice.*,a.Name_User As Creator ,b.Name_User As Assessor
  1338. ,c.Name_User As LastModUser,Customer.No_Customer,Customer.ShortName_Customer
  1339. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer
  1340. ,Customer.Account_Customer,Customer.GetMethod_Customer
  1341. ,Customer.Company_Customer
  1342. ,TypeName=CASE Type_SaleInvoice When 0 Then '普通发票' ELSE '增值税发票' End
  1343. FROM SaleInvoice
  1344. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1345. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1346. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1347. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  1348. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1349. SELECT SaleInvoiceProduct.*
  1350. ,Product.No_Product,Product.Name_Product
  1351. ,Product.InvoiceName_Product
  1352. ,Product.Unit_Product,BillType.Name_BillType
  1353. ,A.No_Customer As No_Customer
  1354. ,A.ShortName_Customer As ShortName_Customer
  1355. FROM SaleInvoiceProduct
  1356. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  1357. LEFT JOIN BillType On BillType.Value_BillType=SaleInvoiceProduct.Type_FromBill
  1358. Left Join (select No_SaleBill As No_Bill
  1359. ,Customer.No_Customer As No_Customer
  1360. ,Customer.ShortName_Customer As ShortName_Customer
  1361. From SaleBill
  1362. Left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1363. Where ID_Assessor Is Not Null
  1364. Union All
  1365. select No_SaleRtnBill As No_Bill
  1366. ,Customer.No_Customer As No_Customer
  1367. ,Customer.ShortName_Customer As ShortName_Customer
  1368. From SaleRtnBill
  1369. Left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1370. Where ID_Assessor Is Not Null) A On A.No_Bill = SaleInvoiceProduct.No_FromBill
  1371. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1372. ">
  1373. <Tables>
  1374. <Table name="SaleInvoice"/>
  1375. <Table name="SaleInvoiceProduct"/>
  1376. </Tables>
  1377. </SearchSaleInvoiceFirst>
  1378. <SearchSaleInvoiceLast CmdType="Text" CmdText=" DECLARE @ID_SaleInvoice UNIQUEIDENTIFIER
  1379. SELECT TOP 1 @ID_SaleInvoice=ID_SaleInvoice
  1380. FROM SaleInvoice ORDER BY No_SaleInvoice DESC
  1381. SELECT SaleInvoice.*,a.Name_User As Creator ,b.Name_User As Assessor
  1382. ,c.Name_User As LastModUser,Customer.No_Customer,Customer.ShortName_Customer
  1383. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer
  1384. ,Customer.Account_Customer,Customer.GetMethod_Customer
  1385. ,Customer.Company_Customer
  1386. ,TypeName=CASE Type_SaleInvoice When 0 Then '普通发票' ELSE '增值税发票' End
  1387. FROM SaleInvoice
  1388. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1389. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1390. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1391. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  1392. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1393. SELECT SaleInvoiceProduct.*
  1394. ,Product.No_Product,Product.Name_Product
  1395. ,Product.InvoiceName_Product
  1396. ,Product.Unit_Product,BillType.Name_BillType
  1397. ,A.No_Customer As No_Customer
  1398. ,A.ShortName_Customer As ShortName_Customer
  1399. FROM SaleInvoiceProduct
  1400. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  1401. LEFT JOIN BillType On BillType.Value_BillType=SaleInvoiceProduct.Type_FromBill
  1402. Left Join (select No_SaleBill As No_Bill
  1403. ,Customer.No_Customer As No_Customer
  1404. ,Customer.ShortName_Customer As ShortName_Customer
  1405. From SaleBill
  1406. Left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1407. Where ID_Assessor Is Not Null
  1408. Union All
  1409. select No_SaleRtnBill As No_Bill
  1410. ,Customer.No_Customer As No_Customer
  1411. ,Customer.ShortName_Customer As ShortName_Customer
  1412. From SaleRtnBill
  1413. Left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1414. Where ID_Assessor Is Not Null) A On A.No_Bill = SaleInvoiceProduct.No_FromBill
  1415. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1416. ">
  1417. <Tables>
  1418. <Table name="SaleInvoice"/>
  1419. <Table name="SaleInvoiceProduct"/>
  1420. </Tables>
  1421. </SearchSaleInvoiceLast>
  1422. <SearchSaleInvoicePrevious CmdType="Text" CmdText=" DECLARE @ID_SaleInvoice UNIQUEIDENTIFIER
  1423. SELECT TOP 1 @ID_SaleInvoice=ID_SaleInvoice FROM SaleInvoice
  1424. WHERE No_SaleInvoice &lt; @No_SaleInvoice
  1425. ORDER BY No_SaleInvoice DESC
  1426. SELECT SaleInvoice.*,a.Name_User As Creator ,b.Name_User As Assessor
  1427. ,c.Name_User As LastModUser,Customer.No_Customer,Customer.ShortName_Customer
  1428. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer
  1429. ,Customer.Account_Customer,Customer.GetMethod_Customer
  1430. ,Customer.Company_Customer
  1431. ,TypeName=CASE Type_SaleInvoice When 0 Then '普通发票' ELSE '增值税发票' End
  1432. FROM SaleInvoice
  1433. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1434. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1435. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1436. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  1437. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1438. SELECT SaleInvoiceProduct.*
  1439. ,Product.No_Product,Product.Name_Product
  1440. ,Product.InvoiceName_Product
  1441. ,Product.Unit_Product,BillType.Name_BillType
  1442. ,A.No_Customer As No_Customer
  1443. ,A.ShortName_Customer As ShortName_Customer
  1444. FROM SaleInvoiceProduct
  1445. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  1446. LEFT JOIN BillType On BillType.Value_BillType=SaleInvoiceProduct.Type_FromBill
  1447. Left Join (select No_SaleBill As No_Bill
  1448. ,Customer.No_Customer As No_Customer
  1449. ,Customer.ShortName_Customer As ShortName_Customer
  1450. From SaleBill
  1451. Left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1452. Where ID_Assessor Is Not Null
  1453. Union All
  1454. select No_SaleRtnBill As No_Bill
  1455. ,Customer.No_Customer As No_Customer
  1456. ,Customer.ShortName_Customer As ShortName_Customer
  1457. From SaleRtnBill
  1458. Left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1459. Where ID_Assessor Is Not Null) A On A.No_Bill = SaleInvoiceProduct.No_FromBill
  1460. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1461. ">
  1462. <Params>
  1463. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" Index="0" />
  1464. </Params>
  1465. <Tables>
  1466. <Table name="SaleInvoice"/>
  1467. <Table name="SaleInvoiceProduct"/>
  1468. </Tables>
  1469. </SearchSaleInvoicePrevious>
  1470. <SearchSaleInvoiceNext CmdType="Text" CmdText=" DECLARE @ID_SaleInvoice UNIQUEIDENTIFIER
  1471. SELECT TOP 1 @ID_SaleInvoice=ID_SaleInvoice FROM SaleInvoice
  1472. WHERE No_SaleInvoice &gt; @No_SaleInvoice
  1473. ORDER BY No_SaleInvoice
  1474. SELECT SaleInvoice.*,a.Name_User As Creator ,b.Name_User As Assessor
  1475. ,c.Name_User As LastModUser,Customer.No_Customer,Customer.ShortName_Customer
  1476. ,Customer.RevenueRegisterNo_Customer,Customer.Bank_Customer
  1477. ,Customer.Account_Customer,Customer.GetMethod_Customer
  1478. ,Customer.Company_Customer
  1479. ,TypeName=CASE Type_SaleInvoice When 0 Then '普通发票' ELSE '增值税发票' End
  1480. FROM SaleInvoice
  1481. LEFT JOIN AppUser a ON SaleInvoice.ID_Creator=a.ID_User
  1482. LEFT JOIN AppUser b ON SaleInvoice.ID_Assessor=b.ID_User
  1483. LEFT JOIN AppUser c ON SaleInvoice.LastModUser_SaleInvoice=c.ID_User
  1484. Left JOIN Customer On Customer.ID_Customer=SaleInvoice.ID_Customer
  1485. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1486. SELECT SaleInvoiceProduct.*
  1487. ,Product.No_Product,Product.Name_Product
  1488. ,Product.InvoiceName_Product
  1489. ,Product.Unit_Product,BillType.Name_BillType
  1490. ,A.No_Customer As No_Customer
  1491. ,A.ShortName_Customer As ShortName_Customer
  1492. FROM SaleInvoiceProduct
  1493. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product
  1494. LEFT JOIN BillType On BillType.Value_BillType=SaleInvoiceProduct.Type_FromBill
  1495. Left Join (select No_SaleBill As No_Bill
  1496. ,Customer.No_Customer As No_Customer
  1497. ,Customer.ShortName_Customer As ShortName_Customer
  1498. From SaleBill
  1499. Left join Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1500. Where ID_Assessor Is Not Null
  1501. Union All
  1502. select No_SaleRtnBill As No_Bill
  1503. ,Customer.No_Customer As No_Customer
  1504. ,Customer.ShortName_Customer As ShortName_Customer
  1505. From SaleRtnBill
  1506. Left join Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1507. Where ID_Assessor Is Not Null) A On A.No_Bill = SaleInvoiceProduct.No_FromBill
  1508. WHERE ID_SaleInvoice=@ID_SaleInvoice
  1509. ">
  1510. <Params>
  1511. <Param name="@No_SaleInvoice" type="SaleInvoice.No_SaleInvoice" Index="0" />
  1512. </Params>
  1513. <Tables>
  1514. <Table name="SaleInvoice"/>
  1515. <Table name="SaleInvoiceProduct"/>
  1516. </Tables>
  1517. </SearchSaleInvoiceNext>
  1518. <SearchContrSOB CmdType="Text" CmdText=" SELECT SystemSetting.SaleAndOutDepot_SystemSetting,SystemSetting.OutDepotAndSaleBack_SystemSetting
  1519. FROM SystemSetting
  1520. WHERE SystemSetting.OutDepotAndSaleBack_SystemSetting = 1
  1521. And SystemSetting.SaleAndOutDepot_SystemSetting=1">
  1522. <Tables>
  1523. <Table name="SystemOutIn" />
  1524. </Tables>
  1525. </SearchContrSOB>
  1526. <SearchContr CmdType="Text" CmdText=" SELECT SystemSetting.SaleBackAndInDepot_SystemSetting
  1527. FROM SystemSetting
  1528. WHERE SystemSetting.SaleBackAndInDepot_SystemSetting = 1">
  1529. <Tables>
  1530. <Table name="SystemSaleAndOutDepot" />
  1531. </Tables>
  1532. </SearchContr>
  1533. <SearchAllSaleBill CmdType="Text" CmdText="Select SaleBill.Currency_SaleBill ,SaleBill.TaxCurrency_SaleBill
  1534. ,SaleBill.ID_SaleBill,SaleBill.No_SaleBill,SaleBill.Date_SaleBill
  1535. ,Customer.No_Customer,Customer.ShortName_Customer
  1536. ,Case When SaleBill.ID_Assessor is null Then '未审核' Else '已审核' End As State_SaleBill
  1537. ,Location.Name_Location,SaleBill.InvoiceAddress_Company,SaleBill.InvoiceTitle_Company
  1538. From SaleBill
  1539. Inner Join Customer On SaleBill.ID_Customer = Customer.ID_Customer
  1540. Inner Join Location On Location.ID_Location = SaleBill.ID_Location" >
  1541. <Tables>
  1542. <Table name="AllSaleBill" />
  1543. </Tables>
  1544. </SearchAllSaleBill>
  1545. <SearchAllSaleBillProduct CmdType="Text" CmdText="Select SaleBill.No_SaleBill,Product.No_Product,SaleBillProduct.No_SaleBillProduct
  1546. ,Product.Name_Product,SaleBillProduct.Quantity_SaleBillProduct
  1547. ,SaleBillProduct.UnitPrice_SaleBillProduct,SaleBill.TaxCurrency_SaleBill
  1548. From SaleBillProduct
  1549. Inner Join Product On Product.ID_Product = SaleBillProduct.ID_Product
  1550. Inner Join SaleBill On SaleBill.ID_SaleBill =SaleBillProduct.ID_SaleBill" >
  1551. <Tables>
  1552. <Table name="AllSaleBillProduct" />
  1553. </Tables>
  1554. </SearchAllSaleBillProduct>
  1555. <SearchAllSaleRtnBill CmdType="Text" CmdText="Select SaleRtnBill.ID_SaleRtnBill,SaleRtnBill.No_SaleRtnBill
  1556. ,SaleRtnBill.Date_SaleRtnBill,Customer.No_Customer,Customer.ShortName_Customer
  1557. ,Case When SaleRtnBill.ID_Assessor is null Then '未审核' Else '已审核' End As State_SaleRtnBill
  1558. ,Location.Name_Location
  1559. From SaleRtnBill
  1560. Inner Join Customer On SaleRtnBill.ID_Customer = Customer.ID_Customer
  1561. Inner Join Location On Location.ID_Location = SaleRtnBill.ID_Location">
  1562. <Tables>
  1563. <Table name="AllSaleRtnBill" />
  1564. </Tables>
  1565. </SearchAllSaleRtnBill>
  1566. <SearchAllSaleRtnBillProduct CmdType="Text" CmdText="Select SaleRtnBill.No_SaleRtnBill,Product.No_Product
  1567. ,SaleRtnBillProduct.No_SaleRtnBillProduct,Product.Name_Product
  1568. ,SaleRtnBillProduct.Quantity_SaleRtnBillProduct
  1569. ,SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct
  1570. ,SaleRtnBill.TaxCurrency_SaleRtnBill
  1571. From SaleRtnBillProduct
  1572. Inner Join Product On Product.ID_Product = SaleRtnBillProduct.ID_Product
  1573. Inner Join SaleRtnBill On SaleRtnBill.ID_SaleRtnBill = SaleRtnBillProduct.ID_SaleRtnBill">
  1574. <Tables>
  1575. <Table name="AllSaleRtnBillProduct" />
  1576. </Tables>
  1577. </SearchAllSaleRtnBillProduct>
  1578. <SearchAllSaleAndRtnBill CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1579. Declare @CessOut decimal(5,2)
  1580. Select @ID_Customer = ID_Customer
  1581. From Customer
  1582. Where No_Customer = @No_Customer
  1583. select @CessOut = CessOut_SystemSetting/100
  1584. from SystemSetting
  1585. Declare @Customer Table(ID_Customer Uniqueidentifier)
  1586. Insert Into @Customer Values(@ID_Customer)
  1587. Insert Into @Customer
  1588. Select ID_Customer
  1589. From Customer
  1590. Where CustomerID_Customer = @ID_Customer
  1591. SELECT '销货单' as Name_BillType
  1592. ,No_SaleBill As No_FromBill
  1593. ,No_SaleBillProduct As No_FromBillProduct
  1594. ,Customer.No_Customer as No_Customer
  1595. ,Customer.ShortName_customer as ShortName_customer
  1596. ,SaleBillProduct.ID_Product
  1597. ,isnull(SaleBillProduct.Quantity_SaleBillProduct,0) As Quantity_SaleInvoiceProduct
  1598. ,isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0) As UnitPrice_SaleInvoiceProduct
  1599. ,Product.No_Product
  1600. ,Product.Name_Product
  1601. ,Product.InvoiceName_Product
  1602. ,Product.Unit_Product
  1603. ,Amount_SaleInvoiceProduct = isnull(SaleBillProduct.Quantity_SaleBillProduct,0)*isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)
  1604. ,TaxAmount_SaleInvoiceProduct=case SaleBill.TaxCurrency_SaleBill when '外加'
  1605. then Convert(decimal(18,2),Convert(decimal(18,2),isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)*isnull(SaleBillProduct.Quantity_SaleBillProduct,0))*@CessOut)
  1606. when '内含'
  1607. then Convert(decimal(18,2),(Convert(decimal(18,2),isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)*isnull(SaleBillProduct.Quantity_SaleBillProduct,0))*@CessOut)/(1+@CessOut))
  1608. else 0 end
  1609. ,Type_FromBill = 21
  1610. ,SaleBill.TaxCurrency_SaleBill As TaxCurrency_SaleInvoiceProduct
  1611. ,GoodsAmount_SaleInvoiceProduct=case SaleBill.TaxCurrency_SaleBill When '内含'
  1612. Then (isnull(Quantity_SaleBillProduct,0)*isnull(UnitPrice_SaleBillProduct,0))/(1+@CessOut)
  1613. else (isnull(Quantity_SaleBillProduct,0)*isnull(UnitPrice_SaleBillProduct,0)) end
  1614. FROM SaleBillProduct
  1615. LEFT JOIN SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  1616. LEFT JOIN Product On Product.ID_Product=SaleBillProduct.ID_Product
  1617. LEFT JOIN Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1618. WHERE SaleBillProduct.Quantity_SaleBillProduct > 0
  1619. AND SaleBillProduct.ID_SaleBill in (Select ID_SaleBill From SaleBill)
  1620. And SaleBill.ID_Customer in (Select ID_Customer From @Customer)
  1621. And Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate),0),Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate),1),Date_SaleBill)
  1622. And SaleBill.ID_Assessor is not null
  1623. And Assess_SaleBill = 0
  1624. And SaleBill.Disable_SaleBill = 0
  1625. And @ckRtn =1
  1626. Union All
  1627. SELECT '销售退货单' as Name_BillType
  1628. ,No_SaleRtnBill As No_FromBill
  1629. ,No_SaleRtnBillProduct As No_FromBillProduct
  1630. ,Customer.No_Customer as No_Customer
  1631. ,Customer.ShortName_customer as ShortName_customer
  1632. ,SaleRtnBillProduct.ID_Product
  1633. ,isnull(SaleRtnBillProduct.Quantity_SaleRtnBillProduct,0) As Quantity_SaleInvoiceProduct
  1634. ,isnull(SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct,0) As UnitPrice_SaleInvoiceProduct
  1635. ,Product.No_Product,Product.Name_Product
  1636. ,Product.InvoiceName_Product
  1637. ,Product.Unit_Product
  1638. ,Amount_SaleInvoiceProduct=isnull(SaleRtnBillProduct.Quantity_SaleRtnBillProduct,0)*isnull(SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct,0)
  1639. ,TaxAmount_SaleInvoiceProduct=case SaleRtnBill.TaxCurrency_SaleRtnBill
  1640. when '外加'
  1641. then Convert(decimal(18,2)
  1642. ,Convert(decimal(18,2)
  1643. ,isnull(SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct,0)*isnull(SaleRtnBillProduct.Quantity_SaleRtnBillProduct,0)
  1644. )*@CessOut
  1645. )
  1646. when '内含'
  1647. then Convert(decimal(18,2)
  1648. ,(Convert(decimal(18,2)
  1649. ,isnull(SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct,0)*isnull(SaleRtnBillProduct.Quantity_SaleRtnBillProduct,0) )*@CessOut
  1650. )/(1+@CessOut)
  1651. ) else 0 end
  1652. ,Type_FromBill = 22
  1653. ,SaleRtnBill.TaxCurrency_SaleRtnBill As TaxCurrency_SaleInvoiceProduct
  1654. ,GoodsAmount_SaleInvoiceProduct=case SaleRtnBill.TaxCurrency_SaleRtnBill
  1655. When '内含'
  1656. Then (isnull(Quantity_SaleRtnBillProduct,0)*isnull(UnitPrice_SaleRtnBillProduct,0))/(1+@CessOut)
  1657. else (isnull(Quantity_SaleRtnBillProduct,0)*isnull(UnitPrice_SaleRtnBillProduct,0)) end
  1658. FROM SaleRtnBillProduct
  1659. LEFT JOIN SaleRtnBill On SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1660. LEFT JOIN Product On Product.ID_Product=SaleRtnBillProduct.ID_Product
  1661. LEFT JOIN Customer on Customer.ID_Customer=SaleRtnBill.ID_Customer
  1662. Where SaleRtnBill.ID_Assessor Is Not Null
  1663. And SaleRtnBill.ID_Customer in (Select ID_Customer From @Customer)
  1664. And @ckRtn =1
  1665. And No_FromBill in (Select No_SaleBill From SaleBill
  1666. Where Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate),0),Date_SaleBill)
  1667. AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate),1),Date_SaleBill)
  1668. And SaleBill.ID_Assessor is not null
  1669. And SaleBill.Assess_SaleBill = 0
  1670. And SaleBill.Disable_SaleBill = 0
  1671. )
  1672. And Assess_SaleRtnBill = 0
  1673. And Disable_SaleRtnBill = 0
  1674. ">
  1675. <Params>
  1676. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1677. <Param name="@StartDate" type="Customer.BeginDate_Customer" Index="1" />
  1678. <Param name="@EndDate" type="Customer.BeginDate_Customer" Index="2" />
  1679. <Param name="@ckRtn" type="Customer.IsCustomersCustomer_Customer" Index="3" />
  1680. </Params>
  1681. <Tables>
  1682. <Table name="SaleInvoiceProduct1"/>
  1683. </Tables>
  1684. </SearchAllSaleAndRtnBill>
  1685. <SearchAllSale CmdType="Text" CmdText=" Declare @ID_Customer Uniqueidentifier
  1686. Declare @CessOut decimal(5,2)
  1687. Select @ID_Customer = ID_Customer
  1688. From Customer
  1689. Where No_Customer = @No_Customer
  1690. select @CessOut = CessOut_SystemSetting/100 from SystemSetting
  1691. Declare @Customer Table(ID_Customer Uniqueidentifier)
  1692. Insert Into @Customer Values(@ID_Customer)
  1693. Insert Into @Customer
  1694. Select ID_Customer
  1695. From Customer
  1696. Where CustomerID_Customer = @ID_Customer
  1697. SELECT '销货单' as Name_BillType
  1698. ,No_SaleBill As No_FromBill
  1699. ,No_SaleBillProduct As No_FromBillProduct
  1700. ,Customer.No_Customer as No_Customer
  1701. ,Customer.ShortName_customer as ShortName_customer
  1702. ,SaleBillProduct.ID_Product
  1703. ,isnull(SaleBillProduct.Quantity_SaleBillProduct,0) As Quantity_SaleInvoiceProduct
  1704. ,isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0) As UnitPrice_SaleInvoiceProduct
  1705. ,Product.No_Product
  1706. ,Product.Name_Product
  1707. ,Product.InvoiceName_Product
  1708. ,Product.Unit_Product
  1709. ,Amount_SaleInvoiceProduct = isnull(SaleBillProduct.Quantity_SaleBillProduct,0)*isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)
  1710. ,case SaleBill.TaxCurrency_SaleBill when '外加'
  1711. then Convert(decimal(18,2),Convert(decimal(18,2),isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)*isnull(SaleBillProduct.Quantity_SaleBillProduct,0))*@CessOut)
  1712. when '内含'
  1713. then Convert(decimal(18,2),(Convert(decimal(18,2),isnull(SaleBillProduct.UnitPrice_SaleBillProduct,0)*isnull(SaleBillProduct.Quantity_SaleBillProduct,0))*@CessOut)/(1+@CessOut))
  1714. else 0 end as TaxAmount_SaleInvoiceProduct
  1715. ,Type_FromBill = 21
  1716. ,SaleBill.TaxCurrency_SaleBill As TaxCurrency_SaleInvoiceProduct
  1717. ,GoodsAmount_SaleInvoiceProduct=case SaleBill.TaxCurrency_SaleBill When '内含'
  1718. Then (isnull(Quantity_SaleBillProduct,0)*isnull(UnitPrice_SaleBillProduct,0))/(1+@CessOut)
  1719. else (isnull(Quantity_SaleBillProduct,0)*isnull(UnitPrice_SaleBillProduct,0)) end
  1720. FROM SaleBillProduct
  1721. LEFT JOIN SaleBill On SaleBill.ID_SaleBill=SaleBillProduct.ID_SaleBill
  1722. LEFT JOIN Product On Product.ID_Product=SaleBillProduct.ID_Product
  1723. LEFT JOIN Customer on Customer.ID_Customer=SaleBill.ID_Customer
  1724. WHERE SaleBillProduct.Quantity_SaleBillProduct > 0
  1725. AND SaleBillProduct.ID_SaleBill in (Select ID_SaleBill From SaleBill)
  1726. And SaleBill.ID_Customer in (Select ID_Customer From @Customer)
  1727. And Date_SaleBill Between isnull(DateAdd(day,DateDiff(day,0,@StartDate),0),Date_SaleBill) AND Isnull(DateAdd(day,DateDiff(day,0,@EndDate),1),Date_SaleBill)
  1728. And SaleBill.ID_Assessor is not null
  1729. And Assess_SaleBill = 0
  1730. And SaleBill.Disable_SaleBill = 0
  1731. And @ckRtn =0
  1732. ">
  1733. <Params>
  1734. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1735. <Param name="@StartDate" type="Customer.BeginDate_Customer" Index="1" />
  1736. <Param name="@EndDate" type="Customer.BeginDate_Customer" Index="2" />
  1737. <Param name="@ckRtn" type="Customer.IsCustomersCustomer_Customer" Index="3" />
  1738. </Params>
  1739. <Tables>
  1740. <Table name="SaleInvoiceProduct2"/>
  1741. </Tables>
  1742. </SearchAllSale>
  1743. <SearchCustomerRelation CmdType="Text" CmdText ="if (@CustomerIDSaleInvoice = @CustomerIDBill)
  1744. Begin
  1745. select *
  1746. from Customer
  1747. where id_customer = @CustomerIDSaleInvoice
  1748. End
  1749. else
  1750. Begin
  1751. select *
  1752. from Customer
  1753. where id_customer =@CustomerIDBill
  1754. and CustomerID_Customer = @CustomerIDSaleInvoice
  1755. End">
  1756. <Params>
  1757. <Param name="@CustomerIDSaleInvoice" type="Customer.ID_Customer" Index="0" />
  1758. <Param name="@CustomerIDBill" type="Customer.ID_Customer" Index="1" />
  1759. </Params>
  1760. <Tables>
  1761. <Table name="CustomerRelation"/>
  1762. </Tables>
  1763. </SearchCustomerRelation>
  1764. <SearchTemp CmdType="Text" CmdText="SELECT TOP 0 SaleInvoiceProduct.*,
  1765. convert(nvarchar(64),'') As Name_BillType
  1766. ,Product.No_Product
  1767. ,Product.Name_Product
  1768. ,Product.InvoiceName_Product
  1769. ,Product.Unit_Product
  1770. ,convert(bit,0) AS Negative
  1771. ,Convert(nvarchar(64),'') As No_Customer
  1772. ,Convert(nvarchar(64),'') As ShortName_Customer
  1773. FROM SaleInvoiceProduct
  1774. LEFT JOIN Product On Product.ID_Product=SaleInvoiceProduct.ID_Product">
  1775. <Tables>
  1776. <Table name="Temp"/>
  1777. </Tables>
  1778. </SearchTemp>
  1779. <DeleteRow CmdType="Text" CmdText=" Delete SaleInvoiceProduct Where ID_SaleInvoiceProduct = @ID_SaleInvoiceProduct
  1780. Select 1
  1781. ">
  1782. <Params>
  1783. <Param name="@ID_SaleInvoiceProduct" type="SaleInvoiceProduct.ID_SaleInvoiceProduct" Index="0" />
  1784. </Params>
  1785. <Tables>
  1786. <Table name="delete"/>
  1787. </Tables>
  1788. </DeleteRow>
  1789. <SearchPayDate CmdType="Text" CmdText=" select dateadd(month,datediff(month,0,@date)+2,0)-1+ @DunDate as NextEndDate
  1790. ">
  1791. <Params>
  1792. <Param name="@date" type="SaleInvoice.PayDate_SaleInvoice" Index="0" />
  1793. <Param name="@DunDate" type="Customer.DunDate_Customer" Index="1" />
  1794. </Params>
  1795. <Tables>
  1796. <Table name="PayDate"/>
  1797. </Tables>
  1798. </SearchPayDate>
  1799. <SearchPayDate2 CmdType="Text" CmdText=" select dateadd(month,datediff(month,0,@date)+3,0)-1+ @DunDate as NextEndDate
  1800. ">
  1801. <Params>
  1802. <Param name="@date" type="SaleInvoice.PayDate_SaleInvoice" Index="0" />
  1803. <Param name="@DunDate" type="Customer.DunDate_Customer" Index="1" />
  1804. </Params>
  1805. <Tables>
  1806. <Table name="PayDate2"/>
  1807. </Tables>
  1808. </SearchPayDate2>
  1809. <SearchPayDate3 CmdType="Text" CmdText=" select dateadd(month,datediff(month,0,@date)+4,0)-1+ @DunDate as NextEndDate
  1810. ">
  1811. <Params>
  1812. <Param name="@date" type="SaleInvoice.PayDate_SaleInvoice" Index="0" />
  1813. <Param name="@DunDate" type="Customer.DunDate_Customer" Index="1" />
  1814. </Params>
  1815. <Tables>
  1816. <Table name="PayDate3"/>
  1817. </Tables>
  1818. </SearchPayDate3>
  1819. <SearchPayDate4 CmdType="Text" CmdText=" select dateadd(month,datediff(month,0,@date)+5,0)-1+ @DunDate as NextEndDate
  1820. ">
  1821. <Params>
  1822. <Param name="@date" type="SaleInvoice.PayDate_SaleInvoice" Index="0" />
  1823. <Param name="@DunDate" type="Customer.DunDate_Customer" Index="1" />
  1824. </Params>
  1825. <Tables>
  1826. <Table name="PayDate4"/>
  1827. </Tables>
  1828. </SearchPayDate4>
  1829. <SearchPayDate5 CmdType="Text" CmdText=" select dateadd(month,datediff(month,0,@date)+1,10)-1+ @DunDate as NextEndDate
  1830. ">
  1831. <Params>
  1832. <Param name="@date" type="SaleInvoice.PayDate_SaleInvoice" Index="0" />
  1833. <Param name="@DunDate" type="Customer.DunDate_Customer" Index="1" />
  1834. </Params>
  1835. <Tables>
  1836. <Table name="PayDate5"/>
  1837. </Tables>
  1838. </SearchPayDate5>
  1839. </Search>
  1840. </Server>
  1841. <Lables>
  1842. <Search>
  1843. Empty();
  1844. NewInstance();
  1845. tbNo.ReadOnly=false;
  1846. dtDate.Enabled=false;
  1847. cbType.Enabled=false;
  1848. dtInvoiceDate.Enabled=false;
  1849. txtInvoiceNo.ReadOnly=true;
  1850. btnModify.Enabled=false;
  1851. tbCustomerNo.ReadOnly=true;
  1852. cbInvoiceTitle.Enabled=false;
  1853. cbInvoiceAddress.Enabled=false;
  1854. cbBank.Enabled=false;
  1855. txtAccount.ReadOnly=true;
  1856. dtPayDate.Enabled=false;
  1857. dgProduct.ReadOnly=true;
  1858. txtMoneySum.CValue=0.00;
  1859. txtTaxSum.CValue=0.00;
  1860. txtSum.CValue=0.00;
  1861. dtStart.Enabled = false;
  1862. dtEnd.Enabled = false;
  1863. ckRtn.Enabled = false;
  1864. btnSearch.Enabled=false;
  1865. #SaleInvoice.Creator=DBNull();
  1866. #SaleInvoice.ID_Creator=DBNull();
  1867. #SaleInvoice.Assessor=DBNull();
  1868. #SaleInvoice.ID_Assessor=DBNull();
  1869. #SaleInvoice.AssessDate_SaleInvoice=DBNull();
  1870. #SaleInvoice.LastModUser_SaleInvoice=DBNull();
  1871. #SaleInvoice.LastModUser=DBNull();
  1872. #SaleInvoice.LastModDate_SaleInvoice=DBNull();
  1873. toolBar.EnableSubmit=false;
  1874. toolBar.EnableModify=false;
  1875. toolBar.EnableDelete=false;
  1876. toolBar.EnableAudit=false;
  1877. toolBar.EnableNew=GetRight(@Title,"新增");
  1878. toolBar.EnablePrint=false;
  1879. toolBar.EnableBlank=false;
  1880. toolBar.EnableImport = false;
  1881. OperateControlEvent("dtInvoiceDate","ValueChanged",false);
  1882. UpdateForm(true,"");
  1883. OperateControlEvent("dtInvoiceDate","ValueChanged",true);
  1884. tbNo.Focus();
  1885. cbType.Text="";
  1886. @Status=0;
  1887. </Search>
  1888. <New>
  1889. Empty();
  1890. NewInstance();
  1891. tbNo.ReadOnly=true;
  1892. dtDate.Enabled=true;
  1893. cbType.Enabled=true;
  1894. dtInvoiceDate.Enabled=true;
  1895. txtInvoiceNo.ReadOnly=false;
  1896. btnModify.Enabled=false;
  1897. tbCustomerNo.ReadOnly=false;
  1898. cbInvoiceTitle.Enabled=true;
  1899. cbInvoiceAddress.Enabled=true;
  1900. cbBank.Enabled=true;
  1901. txtAccount.ReadOnly=false;
  1902. dtPayDate.Enabled=false;
  1903. dgProduct.ReadOnly=false;
  1904. txtMoneySum.CValue=0.00;
  1905. txtTaxSum.CValue=0.00;
  1906. txtSum.CValue=0.00;
  1907. dtStart.Enabled = true;
  1908. dtEnd.Enabled = true;
  1909. ckRtn.Enabled = true;
  1910. btnSearch.Enabled=true;
  1911. dtDate.Focus();
  1912. #SaleInvoice.TypeName="增值税发票";
  1913. #SaleInvoice.Currency_SaleInvoice= @SysCurrency;
  1914. #SaleInvoice.ID_SaleInvoice=NewGuid();
  1915. #SaleInvoice.Creator=GetCurrentUser();
  1916. #SaleInvoice.ID_Creator=GetLoginUserID();
  1917. #SaleInvoice.Assessor=DBNull();
  1918. #SaleInvoice.ID_Assessor=DBNull();
  1919. #SaleInvoice.AssessDate_SaleInvoice=DBNull();
  1920. #SaleInvoice.LastModUser_SaleInvoice=DBNull();
  1921. #SaleInvoice.LastModUser=DBNull();
  1922. #SaleInvoice.LastModDate_SaleInvoice=DBNull();
  1923. toolBar.EnableSubmit=GetRight(@Title,"新增");
  1924. toolBar.EnableModify=false;
  1925. toolBar.EnableDelete=false;
  1926. toolBar.EnableAudit=false;
  1927. toolBar.EnableNew=false;
  1928. toolBar.EnablePrint=false;
  1929. toolBar.EnableBlank=false;
  1930. toolBar.EnableImport = true;
  1931. OperateControlEvent("dtInvoiceDate","ValueChanged",false);
  1932. UpdateForm(true,"");
  1933. OperateControlEvent("dtInvoiceDate","ValueChanged",true);
  1934. <!--cbType.SelectedIndex=1;-->
  1935. @Status=1;
  1936. </New>
  1937. <View>
  1938. tbNo.ReadOnly=true;
  1939. dtDate.Enabled=false;
  1940. cbType.Enabled=false;
  1941. dtInvoiceDate.Enabled=false;
  1942. txtInvoiceNo.ReadOnly=true;
  1943. if(!Equals(#SaleInvoice.ID_Assessor,DBNull())&amp;&amp;#SaleInvoice.Disable_SaleInvoice==false)
  1944. btnModify.Enabled=true;
  1945. else
  1946. btnModify.Enabled=false;
  1947. tbCustomerNo.ReadOnly=true;
  1948. cbInvoiceTitle.Enabled=false;
  1949. cbInvoiceAddress.Enabled=false;
  1950. cbBank.Enabled=false;
  1951. txtAccount.ReadOnly=true;
  1952. dtPayDate.Enabled=false;
  1953. dgProduct.ReadOnly=true;
  1954. dtStart.Enabled = false;
  1955. dtEnd.Enabled = false;
  1956. ckRtn.Enabled = false;
  1957. btnSearch.Enabled=false;
  1958. toolBar.EnableSubmit=false;
  1959. toolBar.EnableNew=GetRight(@Title,"新增");
  1960. if(Equals(#SaleInvoice.ID_Assessor, DBNull()))
  1961. {
  1962. toolBar.EnableAudit=GetRight(@Title,"审核");
  1963. toolBar.EnableModify=GetRight(@Title,"修改");
  1964. toolBar.EnableDelete=GetRight(@Title,"删除");
  1965. toolBar.EnableBlank=false;
  1966. }
  1967. else
  1968. {
  1969. toolBar.EnableAudit=false;
  1970. toolBar.EnableModify=false;
  1971. toolBar.EnableDelete=false;
  1972. if(#SaleInvoice.Disable_SaleInvoice==false)
  1973. toolBar.EnableBlank=GetRight(@Title,"审核");
  1974. else
  1975. toolBar.EnableBlank=false;
  1976. }
  1977. toolBar.EnablePrint=GetRight(@Title,"打印");
  1978. toolBar.EnableImport = false;
  1979. OperateControlEvent("dtInvoiceDate","ValueChanged",false);
  1980. UpdateForm(true,"");
  1981. OperateControlEvent("dtInvoiceDate","ValueChanged",true);
  1982. <!--if(#SaleInvoice.Disable_SaleInvoice==true)
  1983. ikGradualLabel1.Text=ikGradualLabel1.Text+"(已作废)";-->
  1984. @Status=2;
  1985. </View>
  1986. <Modify>
  1987. tbNo.ReadOnly=true;
  1988. dtDate.Enabled=false;
  1989. cbType.Enabled=true;
  1990. dtInvoiceDate.Enabled=true;
  1991. txtInvoiceNo.ReadOnly=false;
  1992. btnModify.Enabled=false;
  1993. tbCustomerNo.ReadOnly=false;
  1994. cbInvoiceTitle.Enabled=true;
  1995. cbInvoiceAddress.Enabled=true;
  1996. cbBank.Enabled=true;
  1997. txtAccount.ReadOnly=false;
  1998. dtPayDate.Enabled=false;
  1999. dgProduct.ReadOnly=false;
  2000. dtStart.Enabled = true;
  2001. dtEnd.Enabled = true;
  2002. ckRtn.Enabled = true;
  2003. btnSearch.Enabled=true;
  2004. #SaleInvoice.LastModUser=GetCurrentUser();
  2005. #SaleInvoice.LastModUser_SaleInvoice=GetLoginUserID();
  2006. #SaleInvoice.LastModDate_SaleInvoice=GetCurrentTime();
  2007. toolBar.EnableSubmit=GetRight(@Title,"修改");
  2008. toolBar.EnableModify=false;
  2009. toolBar.EnableDelete=false;
  2010. toolBar.EnableAudit=false;
  2011. toolBar.EnableNew=false;
  2012. toolBar.EnablePrint=false;
  2013. toolBar.EnableImport = true;
  2014. OperateControlEvent("dtInvoiceDate","ValueChanged",false);
  2015. UpdateForm(true,"");
  2016. OperateControlEvent("dtInvoiceDate","ValueChanged",true);
  2017. @Status=3;
  2018. </Modify>
  2019. <SubmitButtonClick>
  2020. <![CDATA[
  2021. if(cbType.Text==StringEmpty())
  2022. {
  2023. MessageBox("请输入有效的发票种类!",@Title);
  2024. tbDetail.SelectedIndex = 0;
  2025. cbType.Focus();
  2026. return;
  2027. }
  2028. if(!Equals(txtInvoiceNo.CValue,""))
  2029. {
  2030. if(Search("SearchInvoiceNo",txtInvoiceNo.CValue,tbNo.CValue))
  2031. {
  2032. MessageBox("该发票号码已存在!",@Title);
  2033. tbDetail.SelectedIndex = 0;
  2034. txtInvoiceNo.Focus();
  2035. return;
  2036. }
  2037. }
  2038. if(!Search("SearchCustomer",tbCustomerNo.CValue)|| !Equals(#SaleInvoice.ID_Customer,#Customer.ID_Customer))
  2039. {
  2040. MessageBox("请输入有效客户,回车以示确认!",@Title);
  2041. tbDetail.SelectedIndex = 0;
  2042. tbCustomerNo.Focus();
  2043. return;
  2044. }
  2045. if(!cbInvoiceTitle.CheckSelectedItem())
  2046. {
  2047. MessageBox("请输入有效的发票抬头!",@Title);
  2048. tbDetail.SelectedIndex = 0;
  2049. cbInvoiceTitle.Focus();
  2050. return;
  2051. }
  2052. if(!cbInvoiceAddress.CheckSelectedItem())
  2053. {
  2054. MessageBox("请输入有效的发票地址!",@Title);
  2055. tbDetail.SelectedIndex = 0;
  2056. cbInvoiceAddress.Focus();
  2057. return;
  2058. }
  2059. if(!cbBank.CheckSelectedItem())
  2060. {
  2061. MessageBox("请输入有效的开户行!",@Title);
  2062. tbDetail.SelectedIndex = 0;
  2063. cbBank.Focus();
  2064. return;
  2065. }
  2066. if(txtAccount.CValue==StringEmpty())
  2067. {
  2068. MessageBox("请输入有效的银行帐号!",@Title);
  2069. tbDetail.SelectedIndex = 0;
  2070. txtAccount.Focus();
  2071. return;
  2072. }
  2073. if(RowCount("SaleInvoiceProduct")==0)
  2074. {
  2075. MessageBox("请输入销项发票产品!",@Title);
  2076. tbDetail.SelectedIndex = 1;
  2077. dgProduct.Focus();
  2078. return;
  2079. }
  2080. UpdateForm(false, "");
  2081. SuspendLayout();
  2082. for(@index=0;@index<RowCount("#Temp");@index=@index+1)
  2083. {
  2084. SetPosition("#Temp",@index);
  2085. Search("DeleteRow",#Temp.ID_SaleInvoiceProduct);
  2086. }
  2087. for(@i=0;@i<RowCount("#SaleInvoiceProduct");@i=@i+1)
  2088. {
  2089. SetPosition("#SaleInvoiceProduct",@i);
  2090. if (Equals(#SaleInvoiceProduct.Name_BillType,"销货单"))
  2091. {
  2092. if(Search("SearchSaleBill",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2093. {
  2094. if (Equals(#SaleBill.ID_Assessor,DBNull()))
  2095. {
  2096. tbDetail.SelectedIndex = 1;
  2097. dgProduct.CurrentRowIndex = @i;
  2098. MessageBox("该来源单据未经审核,提交失败!",@Title);
  2099. dgProduct.Focus();
  2100. ResumeLayout();
  2101. return;
  2102. }
  2103. if (!Search("SearchCustomerRelation",#SaleInvoice.ID_Customer,#SaleBill.ID_Customer))
  2104. {
  2105. tbDetail.SelectedIndex = 1;
  2106. dgProduct.CurrentRowIndex = @i;
  2107. MessageBox("该来源单据的客户与本销项发票的客户或下级客户不一致,提交失败!",@Title);
  2108. dgProduct.Focus();
  2109. ResumeLayout();
  2110. return;
  2111. }
  2112. if(#SaleBill.InvoiceAddress_Company!=#SaleInvoice.InvoiceAddress_SaleInvoice||#SaleBill.InvoiceTitle_Company!=#SaleInvoice.InvoiceTitle_SaleInvoice)
  2113. {
  2114. tbDetail.SelectedIndex = 1;
  2115. dgProduct.CurrentRowIndex=@i;
  2116. @ClickResult = MessageBox("销货单中的发票抬头(发票地址)与页面不一致,是否继续?",@Title,MB_OKCANCEL);
  2117. if (@ClickResult == DialogResult("CANCEL"))
  2118. {
  2119. dgProduct.Focus();
  2120. ResumeLayout();
  2121. return;
  2122. }
  2123. }
  2124. if(!Equals(#SaleInvoiceProduct.ID_Product,#SaleBill.ID_Product))
  2125. {
  2126. tbDetail.SelectedIndex = 1;
  2127. dgProduct.CurrentRowIndex = @i;
  2128. MessageBox("该来源单据产品单中指定的产品与后改写的产品不匹配!",@Title);
  2129. dgProduct.Focus();
  2130. ResumeLayout();
  2131. return;
  2132. }
  2133. }
  2134. }
  2135. if (Equals(#SaleInvoiceProduct.Name_BillType,"销售退货单"))
  2136. {
  2137. if(Search("SearchSaleRtnBill",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2138. {
  2139. if (Equals(#SaleRtnBill.ID_Assessor,DBNull()))
  2140. {
  2141. tbDetail.SelectedIndex = 1;
  2142. dgProduct.CurrentRowIndex = @i;
  2143. MessageBox("该来源单据未经审核,提交失败!",@Title);
  2144. dgProduct.Focus();
  2145. ResumeLayout();
  2146. return;
  2147. }
  2148. if (!Search("SearchCustomerRelation",#SaleInvoice.ID_Customer,#SaleRtnBill.ID_Customer))
  2149. {
  2150. tbDetail.SelectedIndex = 1;
  2151. dgProduct.CurrentRowIndex = @i;
  2152. MessageBox("该来源单据的客户与本销项发票的客户或下级不一致,提交失败!",@Title);
  2153. dgProduct.Focus();
  2154. ResumeLayout();
  2155. return;
  2156. }
  2157. if(!Equals(#SaleInvoiceProduct.ID_Product,#SaleRtnBill.ID_Product))
  2158. {
  2159. tbDetail.SelectedIndex = 1;
  2160. dgProduct.CurrentRowIndex = @i;
  2161. MessageBox("该来源单据产品单中指定的产品与后改写的产品不匹配!",@Title);
  2162. dgProduct.Focus();
  2163. ResumeLayout();
  2164. return;
  2165. }
  2166. }
  2167. }
  2168. if(Equals(#SaleInvoiceProduct.No_Product,""))
  2169. {
  2170. tbDetail.SelectedIndex = 1;
  2171. dgProduct.CurrentRowIndex=@i;
  2172. MessageBox("请输入产品编号!",@Title);
  2173. ResumeLayout();
  2174. return;
  2175. }
  2176. if(Equals(#SaleInvoiceProduct.ID_Product,GuidEmpty()))
  2177. {
  2178. tbDetail.SelectedIndex = 1;
  2179. dgProduct.CurrentRowIndex=@i;
  2180. MessageBox("该产品不存在!",@Title);
  2181. ResumeLayout();
  2182. return;
  2183. }
  2184. if(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct<=0)
  2185. {
  2186. tbDetail.SelectedIndex = 1;
  2187. dgProduct.CurrentRowIndex=@i;
  2188. MessageBox("数量不得小于等于0!",@Title);
  2189. ResumeLayout();
  2190. return;
  2191. }
  2192. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,""))
  2193. {
  2194. tbDetail.SelectedIndex = 1;
  2195. dgProduct.CurrentRowIndex=@i;
  2196. MessageBox("请输入税别!",@Title);
  2197. ResumeLayout();
  2198. return;
  2199. }
  2200. if(Equals(#SaleInvoiceProduct.ID_SaleInvoiceProduct,GuidEmpty()))
  2201. {
  2202. #SaleInvoiceProduct.ID_SaleInvoiceProduct=NewGuid();
  2203. }
  2204. #SaleInvoiceProduct.ID_SaleInvoice=#SaleInvoice.ID_SaleInvoice;
  2205. }
  2206. ResumeLayout();
  2207. if(@Status==1)
  2208. { #SaleInvoice.CreateDate_SaleInvoice=GetCurrentTime();
  2209. #SaleInvoice.No_SaleInvoice = New("#SaleInvoice.No_SaleInvoice", dtDate.CValue);
  2210. }
  2211. else if(@Status==3)
  2212. {
  2213. #SaleInvoice.LastModUser=GetCurrentUser();
  2214. #SaleInvoice.LastModUser_SaleInvoice=GetLoginUserID();
  2215. #SaleInvoice.LastModDate_SaleInvoice=GetCurrentTime();
  2216. Update();
  2217. }
  2218. ChangeMode("View",#SaleInvoice.ID_Assessor);
  2219. ]]>
  2220. </SubmitButtonClick>
  2221. <CountSum>
  2222. <![CDATA[
  2223. if (RowCount("#SaleInvoiceProduct") == 0)
  2224. {
  2225. txtMoneySum.CValue=0;
  2226. txtTaxSum.CValue=0;
  2227. txtSum.CValue=0;
  2228. }
  2229. else
  2230. {
  2231. @txtMoneySumTemp=0;
  2232. @txtTaxSumTemp=0;
  2233. SuspendLayout();
  2234. for(@i=0;@i<RowCount("#SaleInvoiceProduct");@i++)
  2235. {
  2236. SetPosition("#SaleInvoiceProduct",@i);
  2237. if(#SaleInvoiceProduct.Type_FromBill==22)
  2238. {
  2239. @txtMoneySumTemp=FormatNumber(@txtMoneySumTemp-#SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct,@PriceDecimal);
  2240. @txtTaxSumTemp=FormatNumber(@txtTaxSumTemp-#SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct,@PriceDecimal);
  2241. }
  2242. else
  2243. {
  2244. @txtMoneySumTemp=FormatNumber(@txtMoneySumTemp+#SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct,@PriceDecimal);
  2245. @txtTaxSumTemp=FormatNumber(@txtTaxSumTemp+#SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct,@PriceDecimal);
  2246. }
  2247. }
  2248. ResumeLayout();
  2249. txtMoneySum.CValue=@txtMoneySumTemp;
  2250. txtTaxSum.CValue=@txtTaxSumTemp;
  2251. txtSum.CValue=txtMoneySum.CValue+txtTaxSum.CValue;
  2252. }
  2253. UpdateForm(false,"txtSum");
  2254. UpdateForm(false,"txtMoneySum");
  2255. UpdateForm(false,"txtTaxSum");
  2256. ]]>
  2257. </CountSum>
  2258. <FromBillChange>
  2259. if(!Equals(#SaleInvoiceProduct.Name_BillType,"")&amp;&amp;!Equals(#SaleInvoiceProduct.No_FromBill,"")&amp;&amp; !Equals(#SaleInvoiceProduct.No_FromBillProduct,""))
  2260. {
  2261. if(Equals(#SaleInvoiceProduct.Name_BillType,"销货单")&amp;&amp;Search("SearchSaleBillProduct",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2262. {
  2263. #SaleInvoiceProduct.ID_Product=#SaleBillProduct.ID_Product;
  2264. #SaleInvoiceProduct.No_Product=#SaleBillProduct.No_Product;
  2265. #SaleInvoiceProduct.Name_Product=#SaleBillProduct.Name_Product;
  2266. #SaleInvoiceProduct.Unit_Product=#SaleBillProduct.Unit_Product;
  2267. #SaleInvoiceProduct.Quantity_SaleInvoiceProduct=#SaleBillProduct.Quantity_SaleBillProduct;
  2268. #SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct=#SaleBillProduct.UnitPrice_SaleBillProduct;
  2269. #SaleInvoiceProduct.InvoiceName_Product=#SaleBillProduct.InvoiceName_Product;
  2270. #SaleInvoiceProduct.Amount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2271. #SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct=#SaleBillProduct.TaxCurrency_SaleBill;
  2272. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含"))
  2273. {
  2274. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber((#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct)/(1+#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct),@PriceDecimal);
  2275. }
  2276. else
  2277. {
  2278. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2279. }
  2280. #SaleInvoiceProduct.No_Customer=#SaleBillProduct.No_Customer;
  2281. #SaleInvoiceProduct.ShortName_Customer=#SaleBillProduct.ShortName_Customer;
  2282. #SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Amount_SaleInvoiceProduct*#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct,@PriceDecimal);
  2283. }
  2284. if(Equals(#SaleInvoiceProduct.Name_BillType,"销售退货单")&amp;&amp;Search("SearchSaleRtnBillProduct",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2285. {
  2286. #SaleInvoiceProduct.ID_Product=#SaleRtnBillProduct.ID_Product;
  2287. #SaleInvoiceProduct.No_Product=#SaleRtnBillProduct.No_Product;
  2288. #SaleInvoiceProduct.Name_Product=#SaleRtnBillProduct.Name_Product;
  2289. #SaleInvoiceProduct.Unit_Product=#SaleRtnBillProduct.Unit_Product;
  2290. #SaleInvoiceProduct.Quantity_SaleInvoiceProduct=#SaleRtnBillProduct.Quantity_SaleRtnBillProduct;
  2291. #SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct=#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct;
  2292. #SaleInvoiceProduct.InvoiceName_Product=#SaleRtnBillProduct.InvoiceName_Product;
  2293. #SaleInvoiceProduct.Amount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2294. #SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct=#SaleRtnBillProduct.TaxCurrency_SaleRtnBill;
  2295. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含"))
  2296. {
  2297. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber((#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct)/(1+#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct),@PriceDecimal);
  2298. }
  2299. else
  2300. {
  2301. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2302. }
  2303. #SaleInvoiceProduct.No_Customer=#SaleRtnBillProduct.No_Customer;
  2304. #SaleInvoiceProduct.ShortName_Customer=#SaleRtnBillProduct.ShortName_Customer;
  2305. #SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Amount_SaleInvoiceProduct*#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct,@PriceDecimal);
  2306. }
  2307. dgProduct.SetColumnReadOnly(14, true);
  2308. }
  2309. </FromBillChange>
  2310. <CountAmount>
  2311. if(Equals(#SaleInvoiceProduct.Name_BillType,"销货单")&amp;&amp;Search("SearchSaleBillProduct",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2312. {
  2313. dgProduct.SetColumnReadOnly(14,true);
  2314. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含"))
  2315. {
  2316. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber((#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct)/(1+#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct),@PriceDecimal);
  2317. }
  2318. else
  2319. {
  2320. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2321. }
  2322. }
  2323. if(Equals(#SaleInvoiceProduct.Name_BillType,"销售退货单")&amp;&amp;Search("SearchSaleRtnBillProduct",#SaleInvoiceProduct.No_FromBill,#SaleInvoiceProduct.No_FromBillProduct))
  2324. {
  2325. dgProduct.SetColumnReadOnly(14,true);
  2326. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含"))
  2327. {
  2328. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber((#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct)/(1+#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct),@PriceDecimal);
  2329. }
  2330. else
  2331. {
  2332. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2333. }
  2334. }
  2335. if(Equals(#SaleInvoiceProduct.Name_BillType,"")&amp;&amp;Equals(#SaleInvoiceProduct.No_FromBill,"")&amp;&amp;Equals(#SaleInvoiceProduct.No_FromBillProduct,""))
  2336. {
  2337. if(!Equals(#SaleInvoiceProduct.No_Product,"")&amp;&amp;!Equals(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct,"")&amp;&amp;!Equals(#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,""))
  2338. {
  2339. dgProduct.SetColumnReadOnly(14, false);
  2340. if(!Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,""))
  2341. {
  2342. if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含"))
  2343. {
  2344. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct=FormatNumber((#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct)/(1+#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct),@PriceDecimal);
  2345. }
  2346. else if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"外加"))
  2347. {
  2348. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2349. }
  2350. else if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"零税"))
  2351. {
  2352. #SaleInvoiceProduct.TaxRate_SaleInvoiceProduct = 0.00;
  2353. #SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct = 0.00;
  2354. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2355. }
  2356. else if(Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"免税"))
  2357. {
  2358. #SaleInvoiceProduct.TaxRate_SaleInvoiceProduct = 0.00;
  2359. #SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct = 0.00;
  2360. #SaleInvoiceProduct.GoodsAmount_SaleInvoiceProduct = FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2361. }
  2362. else if(!Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"免税")||!Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"零税")||!Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"内含")||!Equals(#SaleInvoiceProduct.TaxCurrency_SaleInvoiceProduct,"外加"))
  2363. {
  2364. MessageBox("您输入的税别不正确,请重新输入!",@Title);
  2365. return;
  2366. }
  2367. }
  2368. }
  2369. }
  2370. #SaleInvoiceProduct.Amount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Quantity_SaleInvoiceProduct*#SaleInvoiceProduct.UnitPrice_SaleInvoiceProduct,@PriceDecimal);
  2371. #SaleInvoiceProduct.TaxAmount_SaleInvoiceProduct=FormatNumber(#SaleInvoiceProduct.Amount_SaleInvoiceProduct*#SaleInvoiceProduct.TaxRate_SaleInvoiceProduct,@PriceDecimal);
  2372. </CountAmount>
  2373. </Lables>
  2374. </Form>
  2375. </Forms>