FrmSaleRtnBill.xml 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmSaleRtnBill">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @SetFlag=1;
  9. @Title="销售退货单";
  10. GetSchema();
  11. Search("SearchLocation");
  12. Search("SearchSystemSetting");
  13. Search("SearchProductWithNo","p");
  14. Search("SearchFromBillProductNo",1,"p","p");
  15. @SysCurrency=#SystemSetting.SysCurrency_SystemSetting;
  16. if(#SystemSetting.SaleRtnSourceBill_SystemSetting)
  17. toolBar.EnableImportItem(0,false);
  18. else
  19. toolBar.EnableImportItem(1,false);
  20. @CessOut = #SystemSetting.CessOut_SystemSetting / 100;
  21. @ImportClicked = 0;
  22. dgProduct.ColumnVisibleByColumnName("Cost_Product",true);
  23. ChangeMode("Search");
  24. dgProduct.NoMember="No_SaleRtnBillProduct";
  25. Search("SearchBillType");
  26. ]]></Load>
  27. <Closing>
  28. ;
  29. </Closing>
  30. <Closed>
  31. ;
  32. </Closed>
  33. </Events>
  34. <Mode>
  35. <Search>
  36. <Lable name="Search"/>
  37. </Search>
  38. <New>
  39. <Lable name="New"/>
  40. </New>
  41. <View>
  42. <Lable name="View"/>
  43. </View>
  44. <Modify>
  45. <Lable name="Modify"/>
  46. </Modify>
  47. </Mode>
  48. <Controls>
  49. <IKDateTimePicker name="dtpDate" DataSource="SaleRtnBill.Date_SaleRtnBill"/>
  50. <IKTextButton name="tbNo" DataSource="SaleRtnBill.No_SaleRtnBill">
  51. <Events>
  52. <Enter>
  53. <![CDATA[
  54. if(tbNo.ReadOnly == false)
  55. {
  56. if(tbNo.CValue != StringEmpty())
  57. {
  58. UpdateForm(false, "");
  59. if(Search("SearchBillWithNo", tbNo.CValue))
  60. {
  61. if(GetRight("客户基本资料","全权查看")||Equals(GetLoginUserID(),#SaleRtnBill.CustomerCreator))
  62. ChangeMode("View");
  63. else
  64. {
  65. @EnterNo=tbNo.CValue;
  66. ChangeMode("Search");
  67. tbNo.CValue=@EnterNo;
  68. MessageBox("你没有查看该单据资料的权限!",@Title);
  69. return;
  70. }
  71. }
  72. else
  73. {
  74. MessageBox("该销退单不存在!",@Title);
  75. tbNo.Focus();
  76. }
  77. }
  78. else
  79. {
  80. MessageBox("请输入销退单号",@Title);
  81. tbNo.Focus();
  82. }
  83. }
  84. ]]>
  85. <Lable name="Money"/>
  86. </Enter>
  87. <Click>
  88. ShowSearchBox("BillSearch","HAVEDEPOT", "tbNo",tbNo.CValue);
  89. </Click>
  90. </Events>
  91. </IKTextButton>
  92. <IKCheckBox name="ckPrevBill" DataSource="SaleRtnBill.IsPrevBill_SaleRtnBill"/>
  93. <IKTextButton name="tbCustomerNo" DataSource="SaleRtnBill.No_Customer">
  94. <Events>
  95. <Enter><![CDATA[
  96. if(!tbCustomerNo.ReadOnly)
  97. {
  98. if(tbCustomerNo.CValue != StringEmpty())
  99. {
  100. UpdateForm(false, "");
  101. if(Search("SearchCustomerWithNo", tbCustomerNo.CValue))
  102. {
  103. if(!Equals(#Customer.SuspendDate_Customer,DBNull()))
  104. {
  105. MessageBox("该客户已停用!",@Title);
  106. tbCustomerNo.Focus();
  107. }
  108. #SaleRtnBill.ShortName_Customer=#Customer.ShortName_Customer;
  109. #SaleRtnBill.ID_Customer = #Customer.ID_Customer;
  110. #SaleRtnBill.TaxCurrency_SaleRtnBill = #Customer.LastTax_Customer;
  111. UpdateForm(true, "");
  112. }
  113. else
  114. {
  115. MessageBox("该客户不存在!",@Title);
  116. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  117. if(@temp != "")
  118. {
  119. tbCustomerNo.CValue = @temp;
  120. ActiveControlEvent("tbCustomerNo", "Enter");
  121. }
  122. }
  123. }
  124. else
  125. {
  126. MessageBox("请输入客户编号",@Title);
  127. tbCustomerNo.Focus();
  128. }
  129. }
  130. ]]>
  131. </Enter>
  132. <Click>
  133. <![CDATA[
  134. if (tbCustomerNo.ReadOnly == false )
  135. {
  136. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  137. if( @temp == "" )
  138. return;
  139. tbCustomerNo.CValue = @temp;
  140. ActiveControlEvent("tbCustomerNo", "Enter");
  141. UpdateForm(true, "txtCustomerShortName");
  142. UpdateForm(true, "cbPrincipal");
  143. }
  144. ]]>
  145. </Click>
  146. </Events>
  147. </IKTextButton>
  148. <IKTextBox name="txtCustomerShortName" DataSource="SaleRtnBill.ShortName_Customer"/>
  149. <IKComboBoxEx name="cbTaxCurrency" DisplaySource="SaleRtnBill.TaxCurrency_SaleRtnBill">
  150. <Events>
  151. <SelectedIndexChanged>
  152. <Lable name="Money"/>
  153. </SelectedIndexChanged>
  154. </Events>
  155. </IKComboBoxEx>
  156. <IKComboBoxEx name="cbCurrency" DisplaySource="SaleRtnBill.Currency_SaleRtnBill" DataSource="SaleRtnBill" DisplayMember="Currency_SaleRtnBill"/>
  157. <IKComboBoxEx name="cbLocation" ValueSource="SaleRtnBill.ID_Location" NoSource="SaleRtnBill.No_Location" DisplaySource="SaleRtnBill.Name_Location" DataSource="Location" ValueMember="ID_Location" NoMember="No_Location" DisplayMember="Name_Location">
  158. <Events>
  159. <Reload>
  160. UpdateForm(false, "cbLocation");
  161. Search("SearchLocation");
  162. UpdateForm(true, "cbLocation");
  163. </Reload>
  164. </Events>
  165. </IKComboBoxEx>
  166. <IKComboBoxEx name="cbPrincipal" ValueSource="SaleRtnBill.ID_Principal" DisplaySource="SaleRtnBill.Principal_SaleRtnBill" NoSource="SaleRtnBill.No_Principal" DataSource="Employee" ValueMember="ID_Employee" DisplayMember="Name_Employee" NoMember="No_Employee" >
  167. <Events>
  168. <Reload>
  169. UpdateForm(false, "cbPrincipal");
  170. Search("SearchPrincipal");
  171. UpdateForm(true, "cbPrincipal");
  172. </Reload>
  173. </Events>
  174. </IKComboBoxEx>
  175. <IKComboBoxEx name="cbReason" DisplaySource="SaleRtnBill.Reason_SaleRtnBill" DataSource="Reason" DisplayMember="Result">
  176. <Events>
  177. <Reload>
  178. UpdateForm(false, "cbReason");
  179. Search("SearchReason");
  180. UpdateForm(true, "cbReason");
  181. </Reload>
  182. </Events>
  183. </IKComboBoxEx>
  184. <IKComboBoxEx name="cbComment" DisplaySource="SaleRtnBill.Comment_SaleRtnBill" DataSource="Comment" DisplayMember="Result">
  185. <Events>
  186. <Reload>
  187. UpdateForm(false, "cbComment");
  188. Search("SearchComment");
  189. UpdateForm(true, "cbComment");
  190. </Reload>
  191. </Events>
  192. </IKComboBoxEx>
  193. <IKButton name="btnDelete">
  194. <Events>
  195. <Click>
  196. if(MessageBox("确定作废当前单据吗?",@Title,MB_YESNO)==DialogResult("YES"))
  197. {
  198. if(Search("SearchInDepot",#SaleRtnBill.ID_SaleRtnBill))
  199. {
  200. if(#InDepot.Quantity_InDepot > 0)
  201. {
  202. MessageBox("该单据已有相应的销售退货入库记录,作废失败!",@Title);
  203. return;
  204. }
  205. }
  206. BeginUnAudit();
  207. #SaleRtnBill.ID_Assessor = DBNull();
  208. #SaleRtnBill.Name_Assessor = "";
  209. #SaleRtnBill.Disable_SaleRtnBill=true;
  210. UnAudit(false);
  211. ChangeMode("View");
  212. EndUnAudit();
  213. Search("UpdateCustomer",#SaleRtnBill.ID_Customer,#SaleRtnBill.Amount_SaleRtnBill,"1");
  214. }
  215. <Lable name="CountSum" />
  216. </Click>
  217. </Events>
  218. </IKButton>
  219. <IKTextBox name="ikTextBox1" DataSource="SaleRtnBill.PName_SaleRtnBill"/>
  220. <IKTextBox name="txtMaker" DataSource="SaleRtnBill.Name_Creator"/>
  221. <IKTextBox name="txtAudi" DataSource="SaleRtnBill.Name_Assessor"/>
  222. <IKDateTimeText name="dtAssessDate" DataSource="SaleRtnBill.AssessDate_SaleRtnBill"/>
  223. <IKTextBox name="txtLastModUser" DataSource="SaleRtnBill.LastModUserName_SaleRtnBill"/>
  224. <IKDateTimeText name="dtLastModDate" DataSource="SaleRtnBill.LastModDate_SaleRtnBill"/>
  225. <IKDataGridEx name="dgProduct" DataSource="SaleRtnBillProduct" TableStyleIndex="0">
  226. <DataColumn Index="0" DataSource="SaleRtnBillProduct.No_SaleRtnBillProduct" />
  227. <DataColumn Index="1" DataSource="SaleRtnBillProduct.ProductNo_SaleRtnBillProduct" >
  228. <IKDataGridTextButtonColumn>
  229. <Events>
  230. <Click>
  231. @SetFlag=1;
  232. ShowSearchBox("ProductSearch","INFOMATION",#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct);
  233. </Click>
  234. <SetFlagBeforeClick>
  235. @SetFlag=0;
  236. </SetFlagBeforeClick>
  237. </Events>
  238. </IKDataGridTextButtonColumn>
  239. </DataColumn>
  240. <DataColumn Index="2" DataSource="SaleRtnBillProduct.ProductName_SaleRtnBillProduct" />
  241. <DataColumn Index="3" DataSource="SaleRtnBillProduct.Quantity_SaleRtnBillProduct" />
  242. <DataColumn Index="4" DataSource="SaleRtnBillProduct.ProductUnit_SaleRtnBillProduct" />
  243. <DataColumn Index="5" DataSource="SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct" />
  244. <DataColumn Index="6" DataSource="SaleRtnBillProduct.Cost_Product" />
  245. <DataColumn Index="7" DataSource="SaleRtnBillProduct.Cash_SaleRtnBillProduct" />
  246. <DataColumn Index="8" DataSource="SaleRtnBillProduct.Comment_SaleRtnBillProduct" />
  247. <DataColumn Index="9" DataSource="SaleRtnBillProduct.FromBill_SaleRtnBillProduct" >
  248. <IKDataGridComboBoxColumn DisplaySourceEx="SaleRtnBillProduct.FromBill_SaleRtnBillProduct" ValueSourceEx="SaleRtnBillProduct.Type_FromBill" DataSourceEx="BillType" DisplayMemberEx="Name_BillType" ValueMemberEx="Value_BillType">
  249. <Events>
  250. <Reload>
  251. Search("SearchBillType");
  252. SetDataGridColumnDataSource(9,"dgProduct");
  253. </Reload>
  254. </Events>
  255. </IKDataGridComboBoxColumn>
  256. </DataColumn>
  257. <DataColumn Index="10" DataSource="SaleRtnBillProduct.No_FromBill" />
  258. <DataColumn Index="11" DataSource="SaleRtnBillProduct.No_FromBillProduct" />
  259. </IKDataGridEx>
  260. <IKNumericTextBox name="txtNum" DataSource="SaleRtnBill.CountColume_SaleRtnBillProduct" />
  261. <IKNumericTextBox name="txtMoneySum" DataSource="SaleRtnBill.GoodsAmount_SaleRtnBill" />
  262. <IKNumericTextBox name="txtTaxSum" DataSource="SaleRtnBill.TaxAmount_SaleRtnBill" />
  263. <IKNumericTextBox name="txtSum" DataSource="SaleRtnBill.Amount_SaleRtnBill" />
  264. <IKFormToolBar name="toolBar">
  265. <Events>
  266. <ClickFirst>
  267. if(Search("SearchSaleRtnBillFirst",GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID()))
  268. {
  269. ChangeMode("View");
  270. }
  271. <Lable name="Money"/>
  272. </ClickFirst>
  273. <ClickPrev>
  274. if(Search("SearchSaleRtnBillPrevious", tbNo.CValue,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID()))
  275. {
  276. ChangeMode("View");
  277. }
  278. <Lable name="Money"/>
  279. </ClickPrev>
  280. <ClickNext>
  281. if(Search("SearchSaleRtnBillNext", tbNo.CValue,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID()))
  282. {
  283. ChangeMode("View");
  284. }
  285. <Lable name="Money"/>
  286. </ClickNext>
  287. <ClickLast>
  288. if(Search("SearchSaleRtnBillLast",GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID()))
  289. {
  290. ChangeMode("View");
  291. }
  292. <Lable name="Money"/>
  293. </ClickLast>
  294. <ClickEmpty>
  295. ChangeMode("Search");
  296. </ClickEmpty>
  297. <ClickSubmit>
  298. <Lable name="SubmitButtonClick"/>
  299. </ClickSubmit>
  300. <ClickNew>
  301. if(!Equals(@No=GetNextAutoNumber(true),""))
  302. {
  303. ChangeMode("New");
  304. tbNo.CValue=#SaleRtnBill.No_SaleRtnBill=@No;
  305. cbTaxCurrency.SelectedName="外加";
  306. }
  307. </ClickNew>
  308. <ClickModify>
  309. ChangeMode("Modify");
  310. <Lable name="Money"/>
  311. </ClickModify>
  312. <ClickPrint>
  313. ShowPrintBox("BillSearch",#SaleRtnBill.No_SaleRtnBill,#SaleRtnBill.No_SaleRtnBill);
  314. </ClickPrint>
  315. <ClickDelete>
  316. Delete(); ChangeMode("Search");
  317. </ClickDelete>
  318. <ClickAudit>
  319. <![CDATA[
  320. BeginAudit();
  321. SuspendLayout();
  322. if(Equals(ckPrevBill.CValue,true) || Equals(#SystemSetting.OutDepotAndSaleBack_SystemSetting,false))
  323. {
  324. for(@i=0;@i<RowCount("#SaleRtnBillProduct");@i++)
  325. {
  326. SetPosition("#SaleRtnBillProduct", @i);
  327. dgProduct.CurrentRowIndex = @i;
  328. if(#SaleRtnBillProduct.Type_FromBill!=0&&!Equals(#SaleRtnBillProduct.No_FromBill,StringEmpty())&&Search("SearchFromBillProductNo",#SaleRtnBillProduct.Type_FromBill,#SaleRtnBillProduct.No_FromBill,#SaleRtnBillProduct.No_FromBillProduct))
  329. {
  330. if(Equals(#SaleOutDepotBillProduct.ID_Assessor,DBNull()))
  331. {
  332. if(MessageBox("该来源单据未经审核,确定要审核吗?",@Title,MB_OKCANCEL)==DialogResult("CANCEL"))
  333. {
  334. ResumeLayout();
  335. return;
  336. }
  337. }
  338. }
  339. if(!ckPrevBill.Checked )
  340. {
  341. MessageBox("产品序号为"+ string(@i+1)+"的产品的来源单据的税别与本单据不符,审核失败!",@Title);
  342. ResumeLayout();
  343. return;
  344. }
  345. }
  346. }
  347. ResumeLayout();
  348. #SaleRtnBill.ID_Assessor=GetLoginUserID();
  349. #SaleRtnBill.Name_Assessor=GetCurrentUser();
  350. #SaleRtnBill.AssessDate_SaleRtnBill=DateTimeNow();
  351. Audit();
  352. Search("UpdateCustomer",#SaleRtnBill.ID_Customer,#SaleRtnBill.Amount_SaleRtnBill,"0");
  353. ChangeMode("View");
  354. EndAudit();
  355. ]]>
  356. <Lable name="Money"/>
  357. </ClickAudit>
  358. <ClickUnAudit>
  359. <![CDATA[
  360. BeginUnAudit();
  361. #SaleRtnBill.ID_Assessor=DBNull();
  362. #SaleRtnBill.Name_Assessor=DBNull();
  363. UnAudit();
  364. Search("UpdateCustomer",#SaleRtnBill.ID_Customer,#SaleRtnBill.Amount_SaleRtnBill,"1");
  365. ChangeMode("View");
  366. EndUnAudit();
  367. ]]>
  368. <Lable name="Money"/>
  369. </ClickUnAudit>
  370. <ClickAssess>
  371. #SaleRtnBill.Assess_SaleRtnBill = 1;
  372. <Lable name = "AssessClick"/>
  373. toolBar.EnableAssess = false;
  374. toolBar.EnableUnAssess = GetRight(@Title,"取消审核");
  375. </ClickAssess>
  376. <ClickUnAssess>
  377. #SaleRtnBill.Assess_SaleRtnBill = 0;
  378. <Lable name = "AssessClick"/>
  379. toolBar.EnableAssess = GetRight(@Title,"审核");
  380. toolBar.EnableUnAssess = false;
  381. </ClickUnAssess>
  382. <ClickImportItem>
  383. <![CDATA[
  384. @OrgTaxCurrency=#SaleRtnBill.TaxCurrency_SaleRtnBill;
  385. @RowCount=RowCount("#SaleRtnBillProduct");
  386. if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="销货出库单")
  387. {
  388. @ImportClicked = 1;
  389. if(Search("SearchContrOutIn"))
  390. {
  391. ShowSearchBox("ImportSaleOutDepotBillControl","BILLCONVERT","#SaleRtnBillProduct.Type_FromBill",2,"#SaleRtnBillProduct.FromBill_SaleRtnBillProduct","销货出库单");
  392. }
  393. else
  394. {
  395. ShowSearchBox("ImportSaleOutDepotBillUnControl","BILLCONVERT");
  396. }
  397. tbCustomerNo.Focus();
  398. }
  399. else
  400. if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="销货单")
  401. {
  402. @ImportClicked = 1;
  403. if(Search("SearchContrSOB"))
  404. {
  405. ShowSearchBox("ImportSaleBillControl","BILLCONVERT","#SaleRtnBillProduct.Type_FromBill",21,"#SaleRtnBillProduct.FromBill_SaleRtnBillProduct","销货单");
  406. }
  407. else
  408. {
  409. ShowSearchBox("ImportSaleBillUnControl","BILLCONVERT");
  410. }
  411. }
  412. if(!Equals(#SaleRtnBill.TaxCurrency_SaleRtnBill,@OrgTaxCurrency))
  413. {
  414. @Answer=MessageBox("单据税别不同,是否变为新税别?",@Title,MB_YESNO);
  415. if(@Answer==DialogResult("NO"))
  416. {
  417. if(@OrgTaxCurrency=="内含")
  418. {
  419. SuspendLayout();
  420. for(@k=@RowCount;@k<RowCount("SaleRtnBillProduct");@k++)
  421. {
  422. SetPosition("#SaleRtnBillProduct", @k);
  423. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct*(1+@CessOut),#SystemSetting.PriceDecimal_SystemSetting);
  424. }
  425. ResumeLayout();
  426. }
  427. else if(#SaleRtnBill.TaxCurrency_SaleRtnBill=="内含")
  428. {
  429. SuspendLayout();
  430. for(@k=@RowCount;@k<RowCount("SaleRtnBillProduct");@k++)
  431. {
  432. SetPosition("#SaleRtnBillProduct", @k);
  433. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct/(1+@CessOut),#SystemSetting.PriceDecimal_SystemSetting);
  434. }
  435. ResumeLayout();
  436. }
  437. #SaleRtnBill.TaxCurrency_SaleRtnBill=@OrgTaxCurrency;
  438. }
  439. else
  440. {
  441. if(@OrgTaxCurrency=="内含")
  442. {
  443. SuspendLayout();
  444. for(@k=0;@k<@RowCount;@k++)
  445. {
  446. SetPosition("#SaleRtnBillProduct", @k);
  447. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct/(1+@CessOut),#SystemSetting.PriceDecimal_SystemSetting);
  448. }
  449. ResumeLayout();
  450. }
  451. else if(#SaleRtnBill.TaxCurrency_SaleRtnBill=="内含")
  452. {
  453. SuspendLayout();
  454. for(@k=0;@k<@RowCount;@k++)
  455. {
  456. SetPosition("#SaleRtnBillProduct", @k);
  457. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct*(1+@CessOut),#SystemSetting.PriceDecimal_SystemSetting);
  458. }
  459. ResumeLayout();
  460. }
  461. }
  462. }
  463. UpdateForm(true, "cbTaxCurrency");
  464. ]]>
  465. <!--使用前先访问ToolBar的MenuItemText属性以确定选中的是那一项-->
  466. </ClickImportItem>
  467. <ClickExportItem>
  468. if(toolBar.MenuItemText=="库存异动作业")
  469. {
  470. if(Search("SearchContr"))
  471. {
  472. ExportBillProductStart("#ModifyDepotBillProduct.Type_FromBill",22,"#ModifyDepotBillProduct.SourceBillName_ModifyDepotBillProduct","销售退货单","#ModifyDepotBillProduct.No_FromBill",#SaleRtnBill.No_SaleRtnBill,"#ModifyDepotBill.ModifyDepotBill_ModifyDepotBill","销退入库","#ModifyDepotBill.ChangedDepot_ModifyDepotBill",#SaleRtnBill.Name_Location);
  473. ExportBillProduct("dgProduct","#SaleRtnBillProduct","#ModifyDepotBillProduct.No_FromBillProduct","#SaleRtnBillProduct.No_SaleRtnBillProduct");
  474. }
  475. else
  476. {
  477. ExportBillProductStart("#ModifyDepotBillProduct.Comment_ModifyDepotBillProduct","销售退货单:"+#SaleRtnBill.No_SaleRtnBill,"#ModifyDepotBill.ModifyDepotBill_ModifyDepotBill","销退入库","#ModifyDepotBill.ChangedDepot_ModifyDepotBill",#SaleRtnBill.Name_Location);
  478. ExportBillProduct("dgProduct","#SaleRtnBillProduct","#ModifyDepotBillProduct.ProductNo_FromBillProduct","#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct");
  479. }
  480. }
  481. <!--初始化目标数据-->
  482. <!--使用前先访问ToolBar的MenuItemText属性以确定选中的是那一项-->
  483. </ClickExportItem>
  484. </Events>
  485. </IKFormToolBar>
  486. </Controls>
  487. <Tables>
  488. <Table name="SaleRtnBillProduct">
  489. <Events>
  490. <ColumnsChanged>
  491. <FromBill_SaleRtnBillProduct>
  492. <Lable name="SeachProduct"/>
  493. #SaleRtnBillProduct.Cash_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct*#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  494. <Lable name="Money"/>
  495. </FromBill_SaleRtnBillProduct>
  496. <No_FromBill>
  497. <Lable name="SeachProduct"/>
  498. #SaleRtnBillProduct.Cash_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct*#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  499. <Lable name="Money"/>
  500. </No_FromBill>
  501. <No_FromBillProduct>
  502. <Lable name="SeachProduct"/>
  503. #SaleRtnBillProduct.Cash_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct*#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  504. <Lable name="Money"/>
  505. </No_FromBillProduct>
  506. <ProductNo_SaleRtnBillProduct>
  507. if(@SetFlag==0)
  508. {
  509. return;
  510. }
  511. if( Equals(#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct,StringEmpty()) || !Search("SearchProductWithNo",#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct))
  512. {
  513. if(!Equals(#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct,StringEmpty()))
  514. MessageBox("该产品不存在!",@Title);
  515. #SaleRtnBillProduct.ID_Product = GuidEmpty();
  516. #SaleRtnBillProduct.ProductName_SaleRtnBillProduct = "";
  517. #SaleRtnBillProduct.ProductUnit_SaleRtnBillProduct = "";
  518. @temp = ShowSearchBox("InputSearchProduct","INFOMATION",#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct);
  519. if(@temp != "")
  520. {
  521. ResumeColumnEvent("#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct");
  522. #SaleRtnBillProduct.ProductNo_SaleRtnBillProduct = @temp;
  523. ClearColumnEvent();
  524. }
  525. }
  526. else
  527. {
  528. if(!Equals(#Product.SuspendDate_Product,DBNull()))
  529. MessageBox("该产品已停用!",@Title);
  530. #SaleRtnBillProduct.ID_Product=#Product.ID_Product;
  531. #SaleRtnBillProduct.ProductName_SaleRtnBillProduct=#Product.Name_Product;
  532. #SaleRtnBillProduct.ProductUnit_SaleRtnBillProduct=#Product.Unit_Product;
  533. #SaleRtnBillProduct.Cost_Product=#Product.Cost_Product;
  534. }
  535. </ProductNo_SaleRtnBillProduct>
  536. <Quantity_SaleRtnBillProduct>
  537. #SaleRtnBillProduct.Quantity_SaleRtnBillProduct = FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct, #SystemSetting.QuantityDecimal_SystemSetting);
  538. #SaleRtnBillProduct.Cash_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct*#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct,#SystemSetting.PriceDecimal_SystemSetting);
  539. <Lable name="Money"/>
  540. </Quantity_SaleRtnBillProduct>
  541. <UnitPrice_SaleRtnBillProduct>
  542. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct = FormatNumber(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct, #SystemSetting.UnitPriceDecimal_SystemSetting);
  543. #SaleRtnBillProduct.Cash_SaleRtnBillProduct=FormatNumber(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct*#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  544. <Lable name="Money"/>
  545. </UnitPrice_SaleRtnBillProduct>
  546. </ColumnsChanged>
  547. <RowDeleted>
  548. <Lable name="Money"/>
  549. </RowDeleted>
  550. </Events>
  551. </Table>
  552. </Tables>
  553. <LockInfomation LockID="ID_SaleRtnBill" LockNO="No_SaleRtnBill" LockSearchFunction="SearchBillWithNo" LockAudit="ID_Assessor"/>
  554. <LogInfomation LogNO="#SaleRtnBill.No_SaleRtnBill" RecordFormField="" RecordDataGridField="#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct,#SaleRtnBillProduct.Quantity_SaleRtnBillProduct,#SaleRtnBillProduct.Cash_SaleRtnBillProduct"/>
  555. <ChildForms>
  556. <ChildForm name="BillSearch" DataSource="SaleRtnBill" SearchFunction="SearchAllBill" SearchFunctionCondition="SearchBillCondition" SearchFunctionByNo="SearchBillWithNo">
  557. <DataColumn Index="0" MappingName="#SaleRtnBill.No_SaleRtnBill" HeaderText="销售退货单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  558. <DataColumn Index="1" MappingName="#SaleRtnBill.Date_SaleRtnBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  559. <DataColumn Index="2" MappingName="#SaleRtnBill.No_Customer" HeaderText="客户编号" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  560. <DataColumn Index="3" MappingName="#SaleRtnBill.ShortName_Customer" HeaderText="客户名称" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  561. <DataColumn Index="4" MappingName="#SaleRtnBill.Reason_SaleRtnBill" HeaderText="退货原因" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  562. <DataColumn Index="5" MappingName="#SaleRtnBill.Principal_SaleRtnBill" HeaderText="业务负责" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  563. <DataColumn Index="6" MappingName="#SaleRtnBill.TaxCurrency_SaleRtnBill" HeaderText="税别" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  564. </ChildForm>
  565. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo="" MappingName="客户">
  566. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  567. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  568. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  569. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  570. <DataColumn Index="4" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
  571. <DataColumn Index="5" MappingName="#Customer.Zone_Customer" HeaderText="地区" Width="90" ColumnType="IKDataGridTextBoxColumn" />
  572. <DataColumn Index="6" MappingName="#Customer.SendAddr_Customer" HeaderText="送货地址" Width="100" ColumnType="IKDataGridTextBoxColumn" />
  573. <DataColumn Index="7" MappingName="#Customer.Name_Linkman" HeaderText="主要联系人" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  574. <DataColumn Index="8" MappingName="#Customer.No_Telephone" HeaderText="客户电话" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  575. <DataColumn Index="9" MappingName="#Customer.No_Fax" HeaderText="传真" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  576. </ChildForm>
  577. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品" ReturnDataSource="SaleRtnBillProduct" ShowCheckBox="true">
  578. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct"/>
  579. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  580. <DataColumn Index="2" MappingName="#Product.Type_Product" HeaderText="产品类型" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  581. <DataColumn Index="3" MappingName="#Product.Price_Product" HeaderText="标准售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  582. <DataColumn Index="4" MappingName="#Product.LowSalePrice_Product" HeaderText="最低售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  583. <DataColumn Index="5" MappingName="#Product.SafetyQty_Product" HeaderText="安全存量" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  584. </ChildForm>
  585. <ChildForm name="InputSearchProduct" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品">
  586. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  587. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  588. <DataColumn Index="2" MappingName="#Product.Type_Product" HeaderText="产品类型" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  589. <DataColumn Index="3" MappingName="#Product.Price_Product" HeaderText="标准售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  590. <DataColumn Index="4" MappingName="#Product.LowSalePrice_Product" HeaderText="最低售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  591. <DataColumn Index="5" MappingName="#Product.SafetyQty_Product" HeaderText="安全存量" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  592. </ChildForm>
  593. <ChildForm name="ImportSaleOutDepotBillControl" >
  594. <DataGridIndex DataSource="SaleOutDepotBill" SearchFunction="SearchAllSaleOutDepotBill" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleRtnBillProduct">
  595. <DataColumn Index="0" MappingName="#SaleOutDepotBill.No_SaleOutDepotBill" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.No_FromBill"/>
  596. <DataColumn Index="1" MappingName="#SaleOutDepotBill.Date_SaleOutDepotBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  597. <DataColumn Index="2" MappingName="#SaleOutDepotBill.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.No_Customer"/>
  598. <DataColumn Index="3" MappingName="#SaleOutDepotBill.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  599. <DataColumn Index="4" MappingName="#SaleOutDepotBill.State_SaleOutDepotBill" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  600. <DataColumn Index="5" MappingName="#SaleOutDepotBill.Name_Location" HeaderText="出货仓库" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.Name_Location"/>
  601. </DataGridIndex>
  602. <DataGridIndex DataSource="SaleOutDepotBillProduct" SearchFunction="SearchAllSaleOutDepotBillProduct" SearchFunctionByNo="" MappingName="">
  603. <DataColumn Index="0" MappingName="#SaleOutDepotBillProduct.No_Product" HeaderText="产品编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  604. <DataColumn Index="1" MappingName="#SaleOutDepotBillProduct.No_SaleOutDepotBillProduct" HeaderText="产品序号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.No_FromBillProduct"/>
  605. <DataColumn Index="2" MappingName="#SaleOutDepotBillProduct.Name_Product" HeaderText="产品名称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  606. <DataColumn Index="3" MappingName="#SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct" HeaderText="数量" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  607. <DataColumn Index="4" MappingName="#SaleOutDepotBillProduct.UnitPrice_SaleOutDepotBillProduct" HeaderText="单价" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  608. </DataGridIndex>
  609. </ChildForm>
  610. <ChildForm name="ImportSaleOutDepotBillUnControl" >
  611. <DataGridIndex DataSource="SaleOutDepotBill" SearchFunction="SearchAllSaleOutDepotBill" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleRtnBillProduct">
  612. <DataColumn Index="0" MappingName="#SaleOutDepotBill.No_SaleOutDepotBill" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.Comment_SaleRtnBillProduct"/>
  613. <DataColumn Index="1" MappingName="#SaleOutDepotBill.Date_SaleOutDepotBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  614. <DataColumn Index="2" MappingName="#SaleOutDepotBill.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.No_Customer"/>
  615. <DataColumn Index="3" MappingName="#SaleOutDepotBill.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  616. <DataColumn Index="4" MappingName="#SaleOutDepotBill.State_SaleOutDepotBill" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  617. <DataColumn Index="5" MappingName="#SaleOutDepotBill.Name_Location" HeaderText="出货仓库" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.Name_Location"/>
  618. </DataGridIndex>
  619. <DataGridIndex DataSource="SaleOutDepotBillProduct" SearchFunction="SearchAllSaleOutDepotBillProduct" SearchFunctionByNo="" MappingName="">
  620. <DataColumn Index="0" MappingName="#SaleOutDepotBillProduct.No_Product" HeaderText="产品编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct"/>
  621. <DataColumn Index="1" MappingName="#SaleOutDepotBillProduct.No_SaleOutDepotBillProduct" HeaderText="产品序号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  622. <DataColumn Index="2" MappingName="#SaleOutDepotBillProduct.Name_Product" HeaderText="产品名称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  623. <DataColumn Index="3" MappingName="#SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct" HeaderText="数量" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  624. <DataColumn Index="4" MappingName="#SaleOutDepotBillProduct.UnitPrice_SaleOutDepotBillProduct" HeaderText="单价" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  625. </DataGridIndex>
  626. </ChildForm>
  627. <ChildForm name="ImportSaleBillControl" >
  628. <DataGridIndex DataSource="SaleBill" SearchFunction="SearchAllSaleBill" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleRtnBillProduct">
  629. <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.No_FromBill"/>
  630. <DataColumn Index="1" MappingName="#SaleBill.Date_SaleBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  631. <DataColumn Index="2" MappingName="#SaleBill.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.No_Customer"/>
  632. <DataColumn Index="3" MappingName="#SaleBill.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  633. <DataColumn Index="4" MappingName="#SaleBill.TaxCurrency_SaleBill" HeaderText="税别" Width="30" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.TaxCurrency_SaleRtnBill"/>
  634. <DataColumn Index="5" MappingName="#SaleBill.Currency_SaleBill" HeaderText="币别" Width="30" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.Currency_SaleRtnBill"/>
  635. <DataColumn Index="6" MappingName="#SaleBill.State_SaleBill" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  636. <DataColumn Index="7" MappingName="#SaleBill.Name_Location" HeaderText="出货仓库" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.Name_Location"/>
  637. <DataColumn Index="8" MappingName="#SaleBill.No_Principal" HeaderText="业务负责编号" Width="0" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.No_Principal"/>
  638. <DataColumn Index="9" MappingName="#SaleBill.Principal_SaleBill" HeaderText="业务负责" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.Principal_SaleRtnBill"/>
  639. <DataColumn Index="10" MappingName="#SaleBill.ID_Principal" HeaderText="ID" Width="0" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleRtnBill.ID_Principal"/>
  640. </DataGridIndex>
  641. <DataGridIndex DataSource="SaleBillProduct" SearchFunction="SearchAllSaleBillProduct" SearchFunctionByNo="" MappingName="">
  642. <DataColumn Index="0" MappingName="#SaleBillProduct.No_Product" HeaderText="产品编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  643. <DataColumn Index="1" MappingName="#SaleBillProduct.No_SaleBillProduct" HeaderText="产品序号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleRtnBillProduct.No_FromBillProduct"/>
  644. <DataColumn Index="2" MappingName="#SaleBillProduct.Name_Product" HeaderText="产品名称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  645. <DataColumn Index="3" MappingName="#SaleBillProduct.Quantity_SaleBillProduct" HeaderText="数量" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  646. <DataColumn Index="4" MappingName="#SaleBillProduct.UnitPrice_SaleBillProduct" HeaderText="单价" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  647. </DataGridIndex>
  648. </ChildForm>
  649. </ChildForms>
  650. <FormatString>
  651. <Format name="SearchCustomerCondition">
  652. if(GetRight("客户基本资料","全权查看"))
  653. {
  654. FormatString("");
  655. }
  656. else
  657. {
  658. FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
  659. }
  660. </Format>
  661. <Format name="SearchBillCondition">
  662. if(GetRight("客户基本资料","全权查看"))
  663. {
  664. FormatString("");
  665. }
  666. else
  667. {
  668. FormatString(" Disable_SaleRtnBill=0 and Customer.ID_Creator='{0}' ",GetLoginUserID());
  669. }
  670. </Format>
  671. </FormatString>
  672. <ImportedInfo>
  673. <![CDATA[
  674. UpdateForm(true,"cbPrincipal");
  675. @TaxCurrency = #SaleRtnBill.TaxCurrency_SaleRtnBill;
  676. UpdateForm(true, "tbCustomerNo");
  677. UpdateForm(true, "cbCurrency");
  678. tbCustomerNo.Focus();
  679. Search("SearchLocation");
  680. cbLocation.Text = #SaleRtnBill.Name_Location;
  681. ActiveControlEvent("tbCustomerNo", "Enter");
  682. #SaleRtnBill.TaxCurrency_SaleRtnBill = @TaxCurrency;
  683. UpdateForm(true, "cbTaxCurrency");
  684. ]]>
  685. </ImportedInfo>
  686. </Client>
  687. <Server>
  688. <Tables>
  689. <Table name="SaleRtnBill" Type="Parent">
  690. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleRtnBill.*,
  691. Customer.No_Customer,
  692. Customer.ShortName_Customer,
  693. Location.Name_Location,
  694. Location.No_Location,
  695. AppUser.LoginName_User as Name_Creator,
  696. A1.LoginName_User as Name_Assessor,
  697. A2.LoginName_User as LastModUserName_SaleRtnBill,
  698. convert(decimal(18,6),0) AS CountColume_SaleRtnBillProduct,
  699. convert(decimal(18,6),0) AS TaxCurrencyCash_SaleRtnBillProduct,
  700. convert(decimal(18,6),0) AS CurrencyCash_SaleRtnBillProduct,
  701. convert(nvarchar(64),'') AS No_Principal,
  702. convert(nvarchar(64),'') AS Principal_SaleRtnBill
  703. FROM SaleRtnBill
  704. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  705. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  706. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  707. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  708. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location"/>
  709. <New CmdType="Text" CmdText="INSERT INTO SaleRtnBill (ID_SaleRtnBill, No_SaleRtnBill, Date_SaleRtnBill, IsPrevBill_SaleRtnBill, ID_Location, ID_Customer, ID_Principal, Reason_SaleRtnBill, TaxCurrency_SaleRtnBill, Currency_SaleRtnBill, ID_Creator, ID_Assessor, AssessDate_SaleRtnBill, Comment_SaleRtnBill, Disable_SaleRtnBill, CreateDate_SaleRtnBill, LastModUser_SaleRtnBill, LastModDate_SaleRtnBill,Amount_SaleRtnBill,GoodsAmount_SaleRtnBill,TaxAmount_SaleRtnBill,PName_SaleRtnBill)
  710. VALUES(@ID_SaleRtnBill, @No_SaleRtnBill, @Date_SaleRtnBill, @IsPrevBill_SaleRtnBill, @ID_Location, @ID_Customer, @ID_Principal, @Reason_SaleRtnBill, @TaxCurrency_SaleRtnBill, @Currency_SaleRtnBill, @ID_Creator, @ID_Assessor, @AssessDate_SaleRtnBill, @Comment_SaleRtnBill, @Disable_SaleRtnBill, @CreateDate_SaleRtnBill, @LastModUser_SaleRtnBill, @LastModDate_SaleRtnBill,@Amount_SaleRtnBill,@GoodsAmount_SaleRtnBill,@TaxAmount_SaleRtnBill,@PName_SaleRtnBill)">
  711. <Params>
  712. <Param name="@ID_SaleRtnBill" type="SaleRtnBill.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill"/>
  713. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" sourceColumn="No_SaleRtnBill"/>
  714. <Param name="@Date_SaleRtnBill" type="SaleRtnBill.Date_SaleRtnBill" sourceColumn="Date_SaleRtnBill"/>
  715. <Param name="@IsPrevBill_SaleRtnBill" type="SaleRtnBill.IsPrevBill_SaleRtnBill" sourceColumn="IsPrevBill_SaleRtnBill"/>
  716. <Param name="@ID_Location" type="SaleRtnBill.ID_Location" sourceColumn="ID_Location"/>
  717. <Param name="@ID_Customer" type="SaleRtnBill.ID_Customer" sourceColumn="ID_Customer"/>
  718. <Param name="@ID_Principal" type="SaleRtnBill.ID_Principal" sourceColumn="ID_Principal"/>
  719. <Param name="@Reason_SaleRtnBill" type="SaleRtnBill.Reason_SaleRtnBill" sourceColumn="Reason_SaleRtnBill"/>
  720. <Param name="@TaxCurrency_SaleRtnBill" type="SaleRtnBill.TaxCurrency_SaleRtnBill" sourceColumn="TaxCurrency_SaleRtnBill"/>
  721. <Param name="@Currency_SaleRtnBill" type="SaleRtnBill.Currency_SaleRtnBill" sourceColumn="Currency_SaleRtnBill"/>
  722. <Param name="@ID_Creator" type="SaleRtnBill.ID_Creator" sourceColumn="ID_Creator"/>
  723. <Param name="@ID_Assessor" type="SaleRtnBill.ID_Assessor" sourceColumn="ID_Assessor"/>
  724. <Param name="@AssessDate_SaleRtnBill" type="SaleRtnBill.AssessDate_SaleRtnBill" sourceColumn="AssessDate_SaleRtnBill"/>
  725. <Param name="@Comment_SaleRtnBill" type="SaleRtnBill.Comment_SaleRtnBill" sourceColumn="Comment_SaleRtnBill"/>
  726. <Param name="@Disable_SaleRtnBill" type="SaleRtnBill.Disable_SaleRtnBill" sourceColumn="Disable_SaleRtnBill"/>
  727. <Param name="@CreateDate_SaleRtnBill" type="SaleRtnBill.CreateDate_SaleRtnBill" sourceColumn="CreateDate_SaleRtnBill"/>
  728. <Param name="@LastModUser_SaleRtnBill" type="SaleRtnBill.LastModUser_SaleRtnBill" sourceColumn="LastModUser_SaleRtnBill"/>
  729. <Param name="@LastModDate_SaleRtnBill" type="SaleRtnBill.LastModDate_SaleRtnBill" sourceColumn="LastModDate_SaleRtnBill"/>
  730. <Param name="@Amount_SaleRtnBill" type="SaleRtnBill.Amount_SaleRtnBill" sourceColumn="Amount_SaleRtnBill"/>
  731. <Param name="@GoodsAmount_SaleRtnBill" type="SaleRtnBill.GoodsAmount_SaleRtnBill" sourceColumn="GoodsAmount_SaleRtnBill"/>
  732. <Param name="@TaxAmount_SaleRtnBill" type="SaleRtnBill.TaxAmount_SaleRtnBill" sourceColumn="TaxAmount_SaleRtnBill"/>
  733. <Param name="@PName_SaleRtnBill" type="SaleRtnBill.PName_SaleRtnBill" sourceColumn="PName_SaleRtnBill"/>
  734. </Params>
  735. </New>
  736. <Update CmdType="Text" CmdText="UPDATE SaleRtnBill SET
  737. No_SaleRtnBill = @No_SaleRtnBill,
  738. Date_SaleRtnBill = @Date_SaleRtnBill,
  739. IsPrevBill_SaleRtnBill = @IsPrevBill_SaleRtnBill,
  740. ID_Location = @ID_Location,
  741. ID_Customer = @ID_Customer,
  742. ID_Principal = @ID_Principal,
  743. Reason_SaleRtnBill = @Reason_SaleRtnBill,
  744. TaxCurrency_SaleRtnBill = @TaxCurrency_SaleRtnBill,
  745. Currency_SaleRtnBill = @Currency_SaleRtnBill,
  746. ID_Creator = @ID_Creator,
  747. ID_Assessor = @ID_Assessor,
  748. AssessDate_SaleRtnBill = @AssessDate_SaleRtnBill,
  749. Comment_SaleRtnBill = @Comment_SaleRtnBill,
  750. Disable_SaleRtnBill = @Disable_SaleRtnBill,
  751. CreateDate_SaleRtnBill = @CreateDate_SaleRtnBill,
  752. LastModUser_SaleRtnBill = @LastModUser_SaleRtnBill,
  753. LastModDate_SaleRtnBill = @LastModDate_SaleRtnBill,
  754. Amount_SaleRtnBill = @Amount_SaleRtnBill,
  755. GoodsAmount_SaleRtnBill=@GoodsAmount_SaleRtnBill,
  756. TaxAmount_SaleRtnBill=@TaxAmount_SaleRtnBill,
  757. PName_SaleRtnBill = @PName_SaleRtnBill,
  758. Assess_SaleRtnBill = @Assess_SaleRtnBill
  759. WHERE ID_SaleRtnBill = @ID_SaleRtnBill">
  760. <Params>
  761. <Param name="@ID_SaleRtnBill" type="SaleRtnBill.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill"/>
  762. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" sourceColumn="No_SaleRtnBill"/>
  763. <Param name="@Date_SaleRtnBill" type="SaleRtnBill.Date_SaleRtnBill" sourceColumn="Date_SaleRtnBill"/>
  764. <Param name="@IsPrevBill_SaleRtnBill" type="SaleRtnBill.IsPrevBill_SaleRtnBill" sourceColumn="IsPrevBill_SaleRtnBill"/>
  765. <Param name="@ID_Location" type="SaleRtnBill.ID_Location" sourceColumn="ID_Location"/>
  766. <Param name="@ID_Customer" type="SaleRtnBill.ID_Customer" sourceColumn="ID_Customer"/>
  767. <Param name="@ID_Principal" type="SaleRtnBill.ID_Principal" sourceColumn="ID_Principal"/>
  768. <Param name="@Reason_SaleRtnBill" type="SaleRtnBill.Reason_SaleRtnBill" sourceColumn="Reason_SaleRtnBill"/>
  769. <Param name="@TaxCurrency_SaleRtnBill" type="SaleRtnBill.TaxCurrency_SaleRtnBill" sourceColumn="TaxCurrency_SaleRtnBill"/>
  770. <Param name="@Currency_SaleRtnBill" type="SaleRtnBill.Currency_SaleRtnBill" sourceColumn="Currency_SaleRtnBill"/>
  771. <Param name="@ID_Creator" type="SaleRtnBill.ID_Creator" sourceColumn="ID_Creator"/>
  772. <Param name="@ID_Assessor" type="SaleRtnBill.ID_Assessor" sourceColumn="ID_Assessor"/>
  773. <Param name="@AssessDate_SaleRtnBill" type="SaleRtnBill.AssessDate_SaleRtnBill" sourceColumn="AssessDate_SaleRtnBill"/>
  774. <Param name="@Comment_SaleRtnBill" type="SaleRtnBill.Comment_SaleRtnBill" sourceColumn="Comment_SaleRtnBill"/>
  775. <Param name="@Disable_SaleRtnBill" type="SaleRtnBill.Disable_SaleRtnBill" sourceColumn="Disable_SaleRtnBill"/>
  776. <Param name="@CreateDate_SaleRtnBill" type="SaleRtnBill.CreateDate_SaleRtnBill" sourceColumn="CreateDate_SaleRtnBill"/>
  777. <Param name="@LastModUser_SaleRtnBill" type="SaleRtnBill.LastModUser_SaleRtnBill" sourceColumn="LastModUser_SaleRtnBill"/>
  778. <Param name="@LastModDate_SaleRtnBill" type="SaleRtnBill.LastModDate_SaleRtnBill" sourceColumn="LastModDate_SaleRtnBill"/>
  779. <Param name="@Amount_SaleRtnBill" type="SaleRtnBill.Amount_SaleRtnBill" sourceColumn="Amount_SaleRtnBill"/>
  780. <Param name="@GoodsAmount_SaleRtnBill" type="SaleRtnBill.GoodsAmount_SaleRtnBill" sourceColumn="GoodsAmount_SaleRtnBill"/>
  781. <Param name="@TaxAmount_SaleRtnBill" type="SaleRtnBill.TaxAmount_SaleRtnBill" sourceColumn="TaxAmount_SaleRtnBill"/>
  782. <Param name="@PName_SaleRtnBill" type="SaleRtnBill.PName_SaleRtnBill" sourceColumn="PName_SaleRtnBill"/>
  783. <Param name="@Assess_SaleRtnBill" type="SaleRtnBill.Assess_SaleRtnBill" sourceColumn="Assess_SaleRtnBill"/>
  784. </Params>
  785. </Update>
  786. <Audit CmdType="Text" CmdText=" --DECLARE @OUTDEPOT DECIMAL(14,4)
  787. --DECLARE @SALERTN DECIMAL(14,4)
  788. --DECLARE @INDEPOT DECIMAL(14,4)
  789. DECLARE @Quantity_SaleRtnBillProduct DECIMAL(14,4)
  790. DECLARE @ID_SaleSourceBillProduct UNIQUEIDENTIFIER
  791. DECLARE @ID_SaleRtnBillProduct UNIQUEIDENTIFIER
  792. DECLARE @OutDepotAndSaleBack_SystemSetting BIT
  793. DECLARE @SaleBackAndInDepot_SystemSetting BIT
  794. DECLARE @SaleAndOutDepot_SystemSetting BIT
  795. DECLARE @SaleRtnSourceBill_SystemSetting BIT --
  796. --DECLARE @ID_SaleOutDepotBillAssessor UNIQUEIDENTIFIER
  797. --DECLARE @SumSalRtn DECIMAL(14,4)
  798. --DECLARE @SumInDepot DECIMAL(14,4)
  799. DECLARE @error nvarchar(64)
  800. DECLARE @No_SaleRtnBillProduct NVARCHAR(64)
  801. DECLARE @No_FromBillProduct NVARCHAR(64)
  802. DECLARE @SumQuantity_InDepot DECIMAL(14,4)
  803. DECLARE @SumQuantity_SaleRtn DECIMAL(14,4)
  804. DECLARE @Type_FromBill int
  805. DECLARE @No_FromBill NVARCHAR(64)
  806. DECLARE @Quantity_OutDepot DECIMAL(14,4)
  807. DECLARE @Quantity_SaleRtn DECIMAL(14,4)
  808. DECLARE @Quantity_InDepot DECIMAL(14,4)
  809. DECLARE @ChildCustomer UNIQUEIDENTIFIER
  810. DECLARE @Assess_SaleRtnBill bit
  811. SELECT @SaleAndOutDepot_SystemSetting=SaleAndOutDepot_SystemSetting,@SaleBackAndInDepot_SystemSetting=SaleBackAndInDepot_SystemSetting,@OutDepotAndSaleBack_SystemSetting=OutDepotAndSaleBack_SystemSetting FROM SystemSetting
  812. DECLARE CUR CURSOR FOR SELECT Type_FromBill,No_FromBill,ID_SaleRtnBillProduct,Quantity_SaleRtnBillProduct,No_SaleRtnBillProduct,No_FromBillProduct,InQuantity_SaleRtnBillProduct
  813. FROM SaleRtnBillProduct
  814. WHERE SaleRtnBillProduct.ID_SaleRtnBill = @ID_SaleRtnBill
  815. OPEN CUR
  816. FETCH NEXT FROM CUR INTO @Type_FromBill,@No_FromBill,@ID_SaleRtnBillProduct,@Quantity_SaleRtnBillProduct,@No_SaleRtnBillProduct,@No_FromBillProduct,@Quantity_InDepot
  817. WHILE @@FETCH_STATUS = 0
  818. BEGIN
  819. IF(@ID_Assessor IS NOT NULL)
  820. BEGIN
  821. IF( @OutDepotAndSaleBack_SystemSetting=1 AND @IsPrevBill_SaleRtnBill=0)
  822. BEGIN
  823. IF(@Type_FromBill=2)
  824. BEGIN
  825. IF NOT EXISTS(SELECT * FROM SaleOutDepotBill WHERE SaleOutDepotBill.No_SaleOutDepotBill=@No_FromBill AND SaleOutDepotBill.ID_Assessor IS NOT NULL)
  826. BEGIN
  827. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品来源单据未经审核!'
  828. RAISERROR(@error,16,1)
  829. RETURN
  830. END
  831. SELECT @ChildCustomer=SaleOutDepotBill.ID_Customer FROM SaleOutDepotBill WHERE SaleOutDepotBill.No_SaleOutDepotBill=@No_FromBill
  832. IF(@ChildCustomer!=@ID_Customer)
  833. BEGIN
  834. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的来源单据的客户与本单据的客户不一致!'
  835. RAISERROR(@error,16,1)
  836. RETURN
  837. END
  838. SELECT @ID_SaleSourceBillProduct = ID_SaleSourceBillProduct FROM SaleOutDepotBill A LEFT JOIN SaleOutDepotBillProduct B ON A.ID_SaleOutDepotBill = B.ID_SaleOutDepotBill
  839. WHERE A.No_SaleOutDepotBill = @No_FromBill AND B.No_SaleOutDepotBillProduct = @No_FromBillProduct
  840. END
  841. IF(@Type_FromBill=21)
  842. BEGIN
  843. IF(@SaleAndOutDepot_SystemSetting = 0)
  844. BEGIN
  845. RAISERROR('[销货- 出库]流程未进行控管,无法从销货单转入!',16,1)
  846. RETURN
  847. END
  848. IF NOT EXISTS(SELECT * FROM SaleBill WHERE SaleBill.No_SaleBill=@No_FromBill AND SaleBill.ID_Assessor IS NOT NULL)
  849. BEGIN
  850. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品来源单据未经审核!'
  851. RAISERROR(@error,16,1)
  852. RETURN
  853. END
  854. SELECT @ChildCustomer=SaleBill.ID_Customer FROM SaleBill WHERE SaleBill.No_SaleBill=@No_FromBill
  855. IF(@ChildCustomer!=@ID_Customer)
  856. BEGIN
  857. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的来源单据的客户与本单据的客户不一致!'
  858. RAISERROR(@error,16,1)
  859. RETURN
  860. END
  861. SELECT @ID_SaleSourceBillProduct = ID_SaleSourceBillProduct FROM SaleBill A LEFT JOIN SaleBillProduct B ON A.ID_SaleBill = B.ID_SaleBill
  862. WHERE A.No_SaleBill = @No_FromBill AND B.No_SaleBillProduct = @No_FromBillProduct
  863. END
  864. SELECT @Quantity_OutDepot=Quantity_OutDepot,@Quantity_SaleRtn=Quantity_SaleRtn
  865. From SaleSourceBillProduct
  866. WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  867. IF (@Quantity_OutDepot &lt; @Quantity_SaleRtnBillProduct+@Quantity_SaleRtn)
  868. BEGIN
  869. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量大于相应出库数量,审核失败!请于关联单据处查询!'
  870. RAISERROR(@error,16,1)
  871. RETURN
  872. END
  873. IF(@Type_FromBill=2)
  874. BEGIN
  875. IF(@Quantity_SaleRtnBillProduct &gt;(Select (Quantity_SaleOutDepotBillProduct-RtnQuantity_SaleOutDepotBillProduct)
  876. From SaleOutDepotBillProduct
  877. Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill
  878. Where No_SaleOutDepotBill=@No_FromBill And No_SaleOutDepotBillProduct=@No_FromBillProduct))
  879. BEGIN
  880. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量大于相应出库数量,审核失败!请于关联单据处查询!'
  881. RAISERROR(@error,16,1)
  882. RETURN
  883. END
  884. END
  885. IF(@SaleBackAndInDepot_SystemSetting=1)
  886. BEGIN
  887. IF @Quantity_SaleRtnBillProduct &lt; @Quantity_InDepot
  888. BEGIN
  889. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量小于相应入库数量,审核失败!请于关联单据处查询!'
  890. RAISERROR(@error,16,1)
  891. RETURN
  892. END
  893. END
  894. UPDATE SaleRtnBillProduct SET ID_SaleSourceBillProduct=@ID_SaleSourceBillProduct
  895. WHERE ID_SaleRtnBillProduct=@ID_SaleRtnBillProduct
  896. UPDATE SaleSourceBillProduct SET Quantity_SaleRtn=IsNull(Quantity_SaleRtn,0)+@Quantity_SaleRtnBillProduct
  897. WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct=@ID_SaleSourceBillProduct
  898. Update SaleOutDepotBillProduct Set RtnQuantity_SaleOutDepotBillProduct=IsNull(RtnQuantity_SaleOutDepotBillProduct,0)+@Quantity_SaleRtnBillProduct
  899. Where ID_SaleOutDepotBill=(Select ID_SaleOutDepotBill From SaleOutDepotBill Where No_SaleOutDepotBill=@No_FromBill) And No_SaleOutDepotBillProduct=@No_FromBillProduct
  900. END
  901. ELSE IF(@SaleBackAndInDepot_SystemSetting=1)
  902. BEGIN
  903. IF @Quantity_SaleRtnBillProduct &lt; @Quantity_InDepot
  904. BEGIN
  905. SET @error = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量小于相应入库数量,审核失败!请于关联单据处查询!'
  906. RAISERROR(@error,16,1)
  907. RETURN
  908. END
  909. IF EXISTS(SELECT * FROM SaleSourceBillProduct WHERE ID_SaleSourceBillProduct=@ID_SaleRtnBillProduct)
  910. BEGIN
  911. UPDATE SaleSourceBillProduct SET Quantity_SaleRtn=@Quantity_SaleRtnBillProduct
  912. WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct=@ID_SaleRtnBillProduct
  913. END
  914. ELSE
  915. BEGIN
  916. INSERT INTO SaleSourceBillProduct(ID_SaleSourceBillProduct,Quantity_Sale,Quantity_OutDepot,Quantity_SaleRtn,Quantity_InDepot)
  917. VALUES(@ID_SaleRtnBillProduct,0,0,@Quantity_SaleRtnBillProduct,0)
  918. END
  919. UPDATE SaleRtnBillProduct SET SaleRtnBillProduct.ID_SaleSourceBillProduct=@ID_SaleRtnBillProduct
  920. WHERE SaleRtnBillProduct.ID_SaleRtnBillProduct=@ID_SaleRtnBillProduct
  921. END
  922. END
  923. ELSE
  924. BEGIN
  925. SELECT @Assess_SaleRtnBill = SaleRtnBill.Assess_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.ID_SaleRtnBill = @ID_SaleRtnBill
  926. IF (@Assess_SaleRtnBill = 1)
  927. BEGIN
  928. RAISERROR('该单据已经财务复核,请先取消财务复核!',16,1)
  929. RETURN
  930. END
  931. IF(@SaleBackAndInDepot_SystemSetting = 1)
  932. BEGIN
  933. SELECT @SumQuantity_SaleRtn=sum(Quantity_SaleRtnBillProduct),@SumQuantity_InDepot=sum(InQuantity_SaleRtnBillProduct)
  934. FROM SaleRtnBillProduct
  935. WHERE SaleRtnBillProduct.ID_SaleRtnBill = @ID_SaleRtnBill
  936. IF(@SumQuantity_SaleRtn=@SumQuantity_InDepot AND @SumQuantity_InDepot!=0 AND @SumQuantity_SaleRtn != 0 )
  937. BEGIN
  938. RAISERROR('该单据产品已经全部入库,取消审核失败!',16,1)
  939. RETURN
  940. END
  941. END
  942. IF(@OutDepotAndSaleBack_SystemSetting=1 AND @IsPrevBill_SaleRtnBill=0)
  943. BEGIN
  944. Update SaleOutDepotBillProduct Set RtnQuantity_SaleOutDepotBillProduct=IsNull(RtnQuantity_SaleOutDepotBillProduct,0)-@Quantity_SaleRtnBillProduct
  945. Where ID_SaleOutDepotBill=(Select ID_SaleOutDepotBill From SaleOutDepotBill Where No_SaleOutDepotBill=@No_FromBill) And No_SaleOutDepotBillProduct=@No_FromBillProduct
  946. END
  947. IF(@SaleBackAndInDepot_SystemSetting = 1 OR (@OutDepotAndSaleBack_SystemSetting=1 AND @IsPrevBill_SaleRtnBill=0))
  948. BEGIN
  949. UPDATE SaleSourceBillProduct SET Quantity_SaleRtn=IsNull(Quantity_SaleRtn,0)-@Quantity_SaleRtnBillProduct
  950. WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct=(Select ID_SaleSourceBillProduct From SaleRtnBillProduct Where ID_SaleRtnBillProduct=@ID_SaleRtnBillProduct)
  951. END
  952. END
  953. FETCH NEXT FROM CUR INTO @Type_FromBill,@No_FromBill,@ID_SaleRtnBillProduct,@Quantity_SaleRtnBillProduct,@No_SaleRtnBillProduct,@No_FromBillProduct,@Quantity_InDepot
  954. END
  955. UPDATE SaleRtnBill SET
  956. ID_Assessor = @ID_Assessor,
  957. AssessDate_SaleRtnBill = @AssessDate_SaleRtnBill,
  958. Disable_SaleRtnBill=@Disable_SaleRtnBill
  959. WHERE No_SaleRtnBill = @No_SaleRtnBill">
  960. <Params>
  961. <Param name="@ID_SaleRtnBill" type="SaleRtnBill.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill" />
  962. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" sourceColumn="No_SaleRtnBill"/>
  963. <Param name="@ID_Assessor" type="SaleRtnBill.ID_Assessor" sourceColumn="ID_Assessor"/>
  964. <Param name="@ID_Customer" type="SaleRtnBill.ID_Customer" sourceColumn="ID_Customer"/>
  965. <Param name="@AssessDate_SaleRtnBill" type="SaleRtnBill.AssessDate_SaleRtnBill" sourceColumn="AssessDate_SaleRtnBill"/>
  966. <Param name="@IsPrevBill_SaleRtnBill" type="SaleRtnBill.IsPrevBill_SaleRtnBill" sourceColumn="IsPrevBill_SaleRtnBill"/>
  967. <Param name="@Disable_SaleRtnBill" type="SaleRtnBill.Disable_SaleRtnBill" sourceColumn="Disable_SaleRtnBill" />
  968. </Params>
  969. </Audit>
  970. <Delete CmdType="Text" CmdText="DECLARE @INDEPOT DECIMAL(14,4)
  971. DECLARE @OutDepotAndSaleBack_SystemSetting BIT
  972. DECLARE @SaleBackAndInDepot_SystemSetting BIT
  973. SELECT @OutDepotAndSaleBack_SystemSetting=OutDepotAndSaleBack_SystemSetting, @SaleBackAndInDepot_SystemSetting=SaleBackAndInDepot_SystemSetting FROM SystemSetting
  974. SELECT @INDEPOT=Sum(InQuantity_SaleRtnBillProduct)
  975. FROM SaleRtnBillProduct
  976. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  977. IF @INDEPOT!=0
  978. BEGIN
  979. RAISERROR('该单据已有相应的销售退货入库记录,删除失败!',18,19)
  980. RETURN
  981. END
  982. IF @OutDepotAndSaleBack_SystemSetting=0 AND @SaleBackAndInDepot_SystemSetting=1
  983. BEGIN
  984. DELETE SaleSourceBillProduct WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct
  985. IN(SELECT ID_SaleSourceBillProduct FROM SaleRtnBillProduct WHERE SaleRtnBillProduct.ID_SaleRtnBill = @ID_SaleRtnBill)
  986. END
  987. DELETE SaleRtnBillProduct WHERE SaleRtnBillProduct.ID_SaleRtnBill = @ID_SaleRtnBill
  988. DELETE SaleRtnBill WHERE SaleRtnBill.ID_SaleRtnBill = @ID_SaleRtnBill">
  989. <Params>
  990. <Param name="@ID_SaleRtnBill" type="SaleRtnBill.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill"/>
  991. </Params>
  992. </Delete>
  993. <FKErrorReport ErrorMessage="该单据已被其他单据引用,删除失败!"/>
  994. <UNIQUEErrorReport ErrorMessage="销售退货单单号已存在,提交失败!"/>
  995. </Table>
  996. <Table name="SaleRtnBillProduct" Type="Child">
  997. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleRtnBillProduct.*,
  998. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  999. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1000. SaleRtnBill.AssessDate_SaleRtnBill,
  1001. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1002. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1003. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1004. Product.Cost_Product AS Cost_Product,
  1005. convert(decimal(18,6),0) AS Cash_SaleRtnBillProduct,
  1006. convert(nvarchar(256),'') AS Comment_SaleRtnBillProduct ,
  1007. convert(nvarchar(64),'') as No_SaleRtnBill
  1008. FROM SaleRtnBillProduct
  1009. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1010. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1011. LEFT JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1012. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct"/>
  1013. <New CmdType="Text" CmdText="
  1014. if(@ID_IndentBillOnNetProduct='00000000-0000-0000-0000-000000000000') Set @ID_IndentBillOnNetProduct=Null
  1015. INSERT INTO SaleRtnBillProduct (ID_SaleRtnBillProduct, No_SaleRtnBillProduct, ID_SaleRtnBill, Type_FromBill, No_FromBill, No_FromBillProduct, ID_Product, Quantity_SaleRtnBillProduct, UnitPrice_SaleRtnBillProduct, Comment_SaleRtnBillProduct,ID_IndentBillOnNetProduct)
  1016. values(@ID_SaleRtnBillProduct, @No_SaleRtnBillProduct, @ID_SaleRtnBill, @Type_FromBill, @No_FromBill, @No_FromBillProduct, @ID_Product, @Quantity_SaleRtnBillProduct, @UnitPrice_SaleRtnBillProduct, @Comment_SaleRtnBillProduct,@ID_IndentBillOnNetProduct)">
  1017. <Params>
  1018. <Param name="@ID_SaleRtnBillProduct" type="SaleRtnBillProduct.ID_SaleRtnBillProduct" sourceColumn="ID_SaleRtnBillProduct"/>
  1019. <Param name="@No_SaleRtnBillProduct" type="SaleRtnBillProduct.No_SaleRtnBillProduct" sourceColumn="No_SaleRtnBillProduct"/>
  1020. <Param name="@ID_SaleRtnBill" type="SaleRtnBillProduct.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill"/>
  1021. <Param name="@Type_FromBill" type="SaleRtnBillProduct.Type_FromBill" sourceColumn="Type_FromBill"/>
  1022. <Param name="@No_FromBill" type="SaleRtnBillProduct.No_FromBill" sourceColumn="No_FromBill"/>
  1023. <Param name="@No_FromBillProduct" type="SaleRtnBillProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct"/>
  1024. <Param name="@ID_Product" type="SaleRtnBillProduct.ID_Product" sourceColumn="ID_Product"/>
  1025. <Param name="@Quantity_SaleRtnBillProduct" type="SaleRtnBillProduct.Quantity_SaleRtnBillProduct" sourceColumn="Quantity_SaleRtnBillProduct"/>
  1026. <Param name="@UnitPrice_SaleRtnBillProduct" type="SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct" sourceColumn="UnitPrice_SaleRtnBillProduct"/>
  1027. <Param name="@Comment_SaleRtnBillProduct" type="SaleRtnBillProduct.Comment_SaleRtnBillProduct" sourceColumn="Comment_SaleRtnBillProduct"/>
  1028. <Param name="@ID_IndentBillOnNetProduct" type="SaleBillProduct.ID_IndentBillOnNetProduct" sourceColumn="ID_IndentBillOnNetProduct" />
  1029. </Params>
  1030. </New>
  1031. <Update CmdType="Text" CmdText="DECLARE @OutDepotAndSaleBack_SystemSetting BIT
  1032. DECLARE @SaleBackAndInDepot_SystemSetting BIT
  1033. DECLARE @Quantity_OutDepot DECIMAL(14,4)
  1034. DECLARE @Quantity_SaleRtn DECIMAL(14,4)
  1035. DECLARE @INDEPOT DECIMAL(14,4)
  1036. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1037. DECLARE @ERROR NVARCHAR(1000)
  1038. SELECT @OutDepotAndSaleBack_SystemSetting=OutDepotAndSaleBack_SystemSetting,@SaleBackAndInDepot_SystemSetting=SaleBackAndInDepot_SystemSetting FROM SystemSetting
  1039. IF @OutDepotAndSaleBack_SystemSetting=1 AND @IsPrevBill_SaleRtnBill=0 AND @AssessDate_SaleRtnBill IS NOT NULL
  1040. BEGIN
  1041. SELECT @Quantity_OutDepot=Quantity_OutDepot,@Quantity_SaleRtn=Quantity_SaleRtn
  1042. From SaleSourceBillProduct
  1043. WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1044. IF (@Quantity_OutDepot &lt; @Quantity_SaleRtnBillProduct+@Quantity_SaleRtn)
  1045. BEGIN
  1046. SET @ERROR = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量大于相应出库数量,审核失败!请于关联单据处查询!'
  1047. RAISERROR(@ERROR,16,1)
  1048. RETURN
  1049. END
  1050. IF(@Type_FromBill=2)
  1051. BEGIN
  1052. IF(@Quantity_SaleRtnBillProduct &gt;(Select (Quantity_SaleOutDepotBillProduct-RtnQuantity_SaleOutDepotBillProduct)
  1053. From SaleOutDepotBillProduct
  1054. Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill
  1055. Where No_SaleOutDepotBill=@No_FromBill And No_SaleOutDepotBillProduct=@No_FromBillProduct))
  1056. BEGIN
  1057. SET @ERROR = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量大于相应出库数量,审核失败!请于关联单据处查询!'
  1058. RAISERROR(@ERROR,16,1)
  1059. RETURN
  1060. END
  1061. END
  1062. END
  1063. IF @SaleBackAndInDepot_SystemSetting=1 AND @AssessDate_SaleRtnBill IS NOT NULL
  1064. BEGIN
  1065. IF @Quantity_SaleRtnBillProduct &lt; @InQuantity_SaleRtnBillProduct
  1066. BEGIN
  1067. SET @ERROR = N'序号为'+@No_SaleRtnBillProduct+N'的产品的累计退货数量小于相应入库数量,提交失败!请于关联单据处查询!'
  1068. RAISERROR(@ERROR,18,19)
  1069. RETURN
  1070. END
  1071. END
  1072. UPDATE SaleRtnBillProduct SET
  1073. ID_SaleRtnBillProduct=@ID_SaleRtnBillProduct,
  1074. No_SaleRtnBillProduct=@No_SaleRtnBillProduct,
  1075. ID_SaleRtnBill=@ID_SaleRtnBill,
  1076. Type_FromBill=@Type_FromBill,
  1077. No_FromBill=@No_FromBill,
  1078. No_FromBillProduct=@No_FromBillProduct,
  1079. ID_Product=@ID_Product,
  1080. Quantity_SaleRtnBillProduct=@Quantity_SaleRtnBillProduct,
  1081. UnitPrice_SaleRtnBillProduct=@UnitPrice_SaleRtnBillProduct,
  1082. Comment_SaleRtnBillProduct=@Comment_SaleRtnBillProduct,
  1083. ID_IndentBillOnNetProduct=@ID_IndentBillOnNetProduct
  1084. WHERE ID_SaleRtnBillProduct = @ID_SaleRtnBillProduct">
  1085. <Params>
  1086. <Param name="@ID_SaleRtnBillProduct" type="SaleRtnBillProduct.ID_SaleRtnBillProduct" sourceColumn="ID_SaleRtnBillProduct"/>
  1087. <Param name="@No_SaleRtnBillProduct" type="SaleRtnBillProduct.No_SaleRtnBillProduct" sourceColumn="No_SaleRtnBillProduct"/>
  1088. <Param name="@ID_SaleRtnBill" type="SaleRtnBillProduct.ID_SaleRtnBill" sourceColumn="ID_SaleRtnBill"/>
  1089. <Param name="@Type_FromBill" type="SaleRtnBillProduct.Type_FromBill" sourceColumn="Type_FromBill"/>
  1090. <Param name="@No_FromBill" type="SaleRtnBillProduct.No_FromBill" sourceColumn="No_FromBill"/>
  1091. <Param name="@No_FromBillProduct" type="SaleRtnBillProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct"/>
  1092. <Param name="@ID_Product" type="SaleRtnBillProduct.ID_Product" sourceColumn="ID_Product"/>
  1093. <Param name="@ID_SaleSourceBillProduct" type="SaleRtnBillProduct.ID_SaleSourceBillProduct" sourceColumn="ID_SaleSourceBillProduct"/>
  1094. <Param name="@Quantity_SaleRtnBillProduct" type="SaleRtnBillProduct.Quantity_SaleRtnBillProduct" sourceColumn="Quantity_SaleRtnBillProduct"/>
  1095. <Param name="@UnitPrice_SaleRtnBillProduct" type="SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct" sourceColumn="UnitPrice_SaleRtnBillProduct"/>
  1096. <Param name="@Comment_SaleRtnBillProduct" type="SaleRtnBillProduct.Comment_SaleRtnBillProduct" sourceColumn="Comment_SaleRtnBillProduct"/>
  1097. <Param name="@IsPrevBill_SaleRtnBill" type="SaleRtnBillProduct.IsPrevBill_SaleRtnBill" sourceColumn="IsPrevBill_SaleRtnBill"/>
  1098. <Param name="@AssessDate_SaleRtnBill" type="SaleRtnBillProduct.AssessDate_SaleRtnBill" sourceColumn="AssessDate_SaleRtnBill"/>
  1099. <Param name="@InQuantity_SaleRtnBillProduct" type="SaleRtnBillProduct.InQuantity_SaleRtnBillProduct" sourceColumn="InQuantity_SaleRtnBillProduct"/>
  1100. <Param name="@ID_IndentBillOnNetProduct" type="SaleBillProduct.ID_IndentBillOnNetProduct" sourceColumn="ID_IndentBillOnNetProduct" />
  1101. </Params>
  1102. </Update>
  1103. <Delete CmdType="Text" CmdText="DELETE SaleRtnBillProduct WHERE SaleRtnBillProduct.ID_SaleRtnBillProduct = @ID_SaleRtnBillProduct">
  1104. <Params>
  1105. <Param name="@ID_SaleRtnBillProduct" type="SaleRtnBillProduct.ID_SaleRtnBillProduct" sourceColumn="ID_SaleRtnBillProduct"/>
  1106. </Params>
  1107. </Delete>
  1108. </Table>
  1109. </Tables>
  1110. <Search>
  1111. <SearchAllBill CmdType="Text" CmdText=" SELECT SaleRtnBill.*,
  1112. Customer.No_Customer,
  1113. Customer.ShortName_Customer,
  1114. Customer.ID_Creator,
  1115. Location.Name_Location,
  1116. Location.No_Location,
  1117. AppUser.LoginName_User as Name_Creator,
  1118. A1.LoginName_User as Name_Assessor,
  1119. A2.LoginName_User as LastModUserName_SaleRtnBill,
  1120. convert(decimal(18,6),0) AS CountColume_SaleRtnBillProduct,
  1121. convert(decimal(18,6),0) AS TaxCurrencyCash_SaleRtnBillProduct,
  1122. convert(decimal(18,6),0) AS CurrencyCash_SaleRtnBillProduct,
  1123. Employee.No_Employee AS No_Principal,
  1124. Employee.Name_Employee AS Principal_SaleRtnBill
  1125. FROM SaleRtnBill
  1126. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1127. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1128. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1129. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1130. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1131. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal ">
  1132. <Tables>
  1133. <Table name="AllBill" />
  1134. </Tables>
  1135. </SearchAllBill>
  1136. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.*,Linkman.Name_Linkman,Linkman.Tel_Linkman,No_Telephone,No_Fax
  1137. FROM
  1138. (
  1139. SELECT Customer.ID_Customer,Customer.No_Customer,Customer.ShortName_Customer,Customer.Zone_Customer,Customer.SendAddr_Customer,RegistedAddress_Customer,SuspendDate_Customer,Customer.Type_Customer,Customer.Level_Customer,Customer.IsGeneric_Customer,
  1140. ID_Linkman=(Select Top 1 ID_Linkman From Linkman Where ID_Person=Customer.ID_Customer And IsMain_Linkman=1 order by name_linkman)
  1141. From Customer
  1142. )Customer
  1143. Left Join Linkman On Customer.ID_Linkman=Linkman.ID_Linkman
  1144. LEFT JOIN Telephone ON Telephone.ID_Person = Customer.ID_Customer and Focus_Telephone = 1
  1145. left join Fax ON Fax.ID_Person = Customer.ID_Customer and Focus_Fax = 1">
  1146. <Tables>
  1147. <Table name="AllCustomer" />
  1148. </Tables>
  1149. </SearchAllCustomer>
  1150. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product ,Type_Product, Price_Product, LowSalePrice_Product, SafetyQty_Product FROM Product ">
  1151. <Tables>
  1152. <Table name="AllProduct" />
  1153. </Tables>
  1154. </SearchAllProduct>
  1155. <SearchAllSaleOutDepotBill CmdType="Text" CmdText="Select SaleOutDepotBill.ID_SaleOutDepotBill,SaleOutDepotBill.No_SaleOutDepotBill ,SaleOutDepotBill.Date_SaleOutDepotBill,Customer.No_Customer,Customer.ShortName_Customer,Case When SaleOutDepotBill.ID_Assessor is null Then '未审核' Else '已审核' End As State_SaleOutDepotBill,Location.Name_Location From SaleOutDepotBill
  1156. Inner Join Customer On SaleOutDepotBill.ID_Customer = Customer.ID_Customer
  1157. Inner Join Location On Location.ID_Location = SaleOutDepotBill.ID_Location " >
  1158. <Tables>
  1159. <Table name="AllSaleOutDepotBill" />
  1160. </Tables>
  1161. </SearchAllSaleOutDepotBill>
  1162. <SearchAllSaleOutDepotBillProduct CmdType="Text" CmdText="Select Product.No_Product,SaleOutDepotBillProduct.No_SaleOutDepotBillProduct,Product.Name_Product,SaleOutDepotBillProduct.Quantity_SaleOutDepotBillProduct,SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct From SaleOutDepotBillProduct
  1163. Inner Join Product On Product.ID_Product = SaleOutDepotBillProduct.ID_Product
  1164. Inner Join SaleOutDepotBill On SaleOutDepotBill.ID_SaleOutDepotBill = SaleOutDepotBillProduct.ID_SaleOutDepotBill" >
  1165. <Tables>
  1166. <Table name="AllSaleOutDepotBillProduct" />
  1167. </Tables>
  1168. </SearchAllSaleOutDepotBillProduct>
  1169. <SearchBillWithNo CmdType="Text" CmdText=" DECLARE @ID_SaleRtnBill uniqueidentifier
  1170. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1171. SELECT @ID_SaleRtnBill = SaleRtnBill.ID_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.No_SaleRtnBill=@No_SaleRtnBill
  1172. SELECT @ID_SaleOutDepotBill = ID_SaleOutDepotBill FROM SaleOutDepotBill JOIN SaleRtnBillProduct ON SaleOutDepotBill.No_SaleOutDepotBill = SaleRtnBillProduct.No_FromBill
  1173. SELECT SaleRtnBill.*, Customer.No_Customer, Customer.ShortName_Customer, Location.Name_Location,Location.No_Location,Customer.ID_Creator As CustomerCreator,
  1174. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1175. SaleRtnBill.AssessDate_SaleRtnBill,
  1176. AppUser.LoginName_User as Name_Creator, Employee.No_Employee AS No_Principal,
  1177. Employee.Name_Employee AS Principal_SaleRtnBill,
  1178. A1.LoginName_User as Name_Assessor,
  1179. A2.LoginName_User as LastModUserName_SaleRtnBill
  1180. FROM SaleRtnBill
  1181. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1182. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1183. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1184. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1185. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1186. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  1187. WHERE SaleRtnBill.No_SaleRtnBill=@No_SaleRtnBill
  1188. ORDER BY No_SaleRtnBill
  1189. SELECT SaleRtnBillProduct.*,
  1190. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  1191. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1192. SaleRtnBill.AssessDate_SaleRtnBill,
  1193. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1194. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1195. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1196. SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct AS UnitCost_SaleRtnBillProduct,
  1197. SaleRtnBillProduct.Quantity_SaleRtnBillProduct * SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct AS Cash_SaleRtnBillProduct,@No_SaleRtnBill as No_SaleRtnBill
  1198. FROM SaleRtnBillProduct
  1199. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1200. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1201. JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1202. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct
  1203. AND SaleOutDepotBillProduct.ID_SaleOutDepotBill=@ID_SaleOutDepotBill
  1204. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1205. ORDER BY CAST(No_SaleRtnBillProduct AS INT)">
  1206. <Params>
  1207. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" Index="0"/>
  1208. </Params>
  1209. <Tables>
  1210. <Table name="SaleRtnBill"/>
  1211. <Table name="SaleRtnBillProduct"/>
  1212. </Tables>
  1213. </SearchBillWithNo>
  1214. <SearchCustomerWithNo CmdType="Text" CmdText="
  1215. declare @LastTax_Customer1 nvarchar(64)
  1216. declare @LastTax_Customer2 nvarchar(64)
  1217. declare @LastTax_Customer3 nvarchar(64)
  1218. declare @STaxDefault1_FunctionSetting int
  1219. declare @STaxDefault2_FunctionSetting int
  1220. declare @STaxDefault3_FunctionSetting int
  1221. select @STaxDefault1_FunctionSetting = STaxDefault1_FunctionSetting,
  1222. @STaxDefault2_FunctionSetting = STaxDefault2_FunctionSetting, @STaxDefault3_FunctionSetting = STaxDefault3_FunctionSetting
  1223. from FunctionSetting
  1224. if @STaxDefault1_FunctionSetting=0
  1225. begin
  1226. select @LastTax_Customer1 = Customer.LastTax_Customer
  1227. from Customer
  1228. WHERE Customer.No_Customer = @No_Customer
  1229. end
  1230. else if @STaxDefault1_FunctionSetting = 1
  1231. begin
  1232. select top 1 @LastTax_Customer1 = TaxCurrency_SaleRtnBill
  1233. from SaleRtnBill
  1234. order by Date_SaleRtnBill desc
  1235. end
  1236. else
  1237. begin
  1238. set @LastTax_Customer1 = '外加'
  1239. end
  1240. if @STaxDefault2_FunctionSetting=0
  1241. begin
  1242. select @LastTax_Customer2 = Customer.LastTax_Customer
  1243. from Customer
  1244. WHERE Customer.No_Customer = @No_Customer
  1245. end
  1246. else if @STaxDefault2_FunctionSetting = 1
  1247. begin
  1248. select top 1 @LastTax_Customer2 = TaxCurrency_SaleRtnBill
  1249. from SaleRtnBill
  1250. order by Date_SaleRtnBill desc
  1251. end
  1252. else
  1253. begin
  1254. set @LastTax_Customer2 = '外加'
  1255. end
  1256. if @STaxDefault3_FunctionSetting=0
  1257. begin
  1258. select @LastTax_Customer3 = Customer.LastTax_Customer
  1259. from Customer
  1260. WHERE Customer.No_Customer = @No_Customer
  1261. end
  1262. else if @STaxDefault3_FunctionSetting = 1
  1263. begin
  1264. select top 1 @LastTax_Customer3 = TaxCurrency_SaleRtnBill
  1265. from SaleRtnBill
  1266. order by Date_SaleRtnBill desc
  1267. end
  1268. else
  1269. begin
  1270. set @LastTax_Customer3 = '外加'
  1271. end
  1272. if @LastTax_Customer1 is null
  1273. set @LastTax_Customer1 = isnull(@LastTax_Customer2, @LastTax_Customer3)
  1274. DECLARE @NextNo nvarchar(64) DECLARE @ID_Customer uniqueidentifier
  1275. SET @NextNo = @No_Customer
  1276. SELECT @ID_Customer = Customer.ID_Customer FROM Customer WHERE Customer.No_Customer = @NextNo
  1277. SELECT ID_Customer, ShortName_Customer, SuspendDate_Customer,ISNULL(@LastTax_Customer1, '外加') AS LastTax_Customer
  1278. ,Employee.Name_Employee,Employee.No_Employee,LastPrincipal_Customer
  1279. FROM Customer
  1280. left join Employee on Customer.LastPrincipal_Customer = Employee.ID_Employee
  1281. WHERE Customer.ID_Customer = @ID_Customer
  1282. ORDER BY No_Customer">
  1283. <Params>
  1284. <Param name="@No_Customer" type="Customer.No_Customer" Index="0"/>
  1285. </Params>
  1286. <Tables>
  1287. <Table name="Customer"/>
  1288. </Tables>
  1289. </SearchCustomerWithNo>
  1290. <SearchPrincipal CmdType="Text" CmdText=" SELECT Employee.No_Employee,Employee.ID_Employee, Employee.Name_Employee FROM Employee Order By No_Employee
  1291. ">
  1292. <Tables>
  1293. <Table name="Employee"/>
  1294. </Tables>
  1295. </SearchPrincipal>
  1296. <SearchReason CmdType="Text" CmdText="SELECT TypeDef.Name_TypeDef AS Result FROM TypeDef WHERE Type_TypeDef = 21">
  1297. <Tables>
  1298. <Table name="Reason"/>
  1299. </Tables>
  1300. </SearchReason>
  1301. <SearchComment CmdType="Text" CmdText="SELECT TypeDef.Name_TypeDef AS Result FROM TypeDef WHERE Type_TypeDef = 28">
  1302. <Tables>
  1303. <Table name="Comment"/>
  1304. </Tables>
  1305. </SearchComment>
  1306. <SearchContr CmdType="Text" CmdText=" SELECT SystemSetting.SaleBackAndInDepot_SystemSetting FROM SystemSetting WHERE SystemSetting.SaleBackAndInDepot_SystemSetting = 1">
  1307. <Tables>
  1308. <Table name="SystemSaleAndOutDepot" />
  1309. </Tables>
  1310. </SearchContr>
  1311. <SearchContrOutIn CmdType="Text" CmdText=" SELECT SystemSetting.OutDepotAndSaleBack_SystemSetting FROM SystemSetting WHERE SystemSetting.OutDepotAndSaleBack_SystemSetting = 1">
  1312. <Tables>
  1313. <Table name="SystemOutIn" />
  1314. </Tables>
  1315. </SearchContrOutIn>
  1316. <SearchContrSOB CmdType="Text" CmdText=" SELECT SystemSetting.SaleAndOutDepot_SystemSetting,SystemSetting.OutDepotAndSaleBack_SystemSetting FROM SystemSetting WHERE SystemSetting.OutDepotAndSaleBack_SystemSetting = 1 and SystemSetting.SaleAndOutDepot_SystemSetting=1">
  1317. <Tables>
  1318. <Table name="SystemOutIn" />
  1319. </Tables>
  1320. </SearchContrSOB>
  1321. <SearchSaleRtnBillFirst CmdType="Text" CmdText="DECLARE @NextNo nvarchar(64)
  1322. DECLARE @ID_SaleRtnBill uniqueidentifier
  1323. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1324. SELECT TOP 1 @NextNo = SaleRtnBill.No_SaleRtnBill FROM SaleRtnBill
  1325. Join Customer On Customer.ID_Customer=SaleRtnBill.ID_Customer
  1326. WHERE Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  1327. ORDER BY SaleRtnBill.No_SaleRtnBill
  1328. SELECT @ID_SaleRtnBill = SaleRtnBill.ID_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.No_SaleRtnBill = @NextNo
  1329. SELECT @ID_SaleOutDepotBill = ID_SaleOutDepotBill FROM SaleOutDepotBill JOIN SaleRtnBillProduct ON SaleOutDepotBill.No_SaleOutDepotBill = SaleRtnBillProduct.No_FromBill
  1330. SELECT SaleRtnBill.*, Customer.No_Customer, Customer.ShortName_Customer, Location.Name_Location, Location.No_Location, AppUser.LoginName_User as Name_Creator, A1.LoginName_User as Name_Assessor, A2.LoginName_User as LastModUserName_SaleRtnBill
  1331. ,Employee.No_Employee AS No_Principal,
  1332. Employee.Name_Employee AS Principal_SaleRtnBill
  1333. FROM SaleRtnBill
  1334. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1335. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1336. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1337. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1338. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1339. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  1340. WHERE SaleRtnBill.ID_SaleRtnBill=@ID_SaleRtnBill
  1341. SELECT SaleRtnBillProduct.*,
  1342. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  1343. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1344. SaleRtnBill.AssessDate_SaleRtnBill,
  1345. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1346. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1347. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1348. SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct AS UnitCost_SaleRtnBillProduct,
  1349. SaleRtnBillProduct.Quantity_SaleRtnBillProduct * SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct AS Cash_SaleRtnBillProduct,@NextNo as No_SaleRtnBill
  1350. FROM SaleRtnBillProduct
  1351. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1352. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1353. JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1354. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct
  1355. AND SaleOutDepotBillProduct.ID_SaleOutDepotBill=@ID_SaleOutDepotBill
  1356. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1357. ORDER BY CAST(No_SaleRtnBillProduct AS INT)">
  1358. <Params>
  1359. <Param name="@Right" type="SaleBill.ID_Customer" Index="0" />
  1360. </Params>
  1361. <Tables>
  1362. <Table name="SaleRtnBill"/>
  1363. <Table name="SaleRtnBillProduct"/>
  1364. </Tables>
  1365. </SearchSaleRtnBillFirst>
  1366. <SearchSaleRtnBillLast CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  1367. DECLARE @ID_SaleRtnBill uniqueidentifier
  1368. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1369. SELECT TOP 1 @NextNo = SaleRtnBill.No_SaleRtnBill FROM SaleRtnBill
  1370. Join Customer On Customer.ID_Customer=SaleRtnBill.ID_Customer
  1371. WHERE Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  1372. ORDER BY SaleRtnBill.No_SaleRtnBill DESC
  1373. SELECT @ID_SaleRtnBill = SaleRtnBill.ID_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.No_SaleRtnBill = @NextNo
  1374. SELECT @ID_SaleOutDepotBill = ID_SaleOutDepotBill FROM SaleOutDepotBill JOIN SaleRtnBillProduct ON SaleOutDepotBill.No_SaleOutDepotBill = SaleRtnBillProduct.No_FromBill
  1375. SELECT SaleRtnBill.*, Customer.No_Customer, Customer.ShortName_Customer, Location.Name_Location, Location.No_Location, AppUser.LoginName_User as Name_Creator, A1.LoginName_User as Name_Assessor, A2.LoginName_User as LastModUserName_SaleRtnBill
  1376. ,Employee.No_Employee AS No_Principal,
  1377. Employee.Name_Employee AS Principal_SaleRtnBill
  1378. FROM SaleRtnBill
  1379. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1380. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1381. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1382. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1383. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1384. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  1385. WHERE SaleRtnBill.ID_SaleRtnBill=@ID_SaleRtnBill
  1386. SELECT SaleRtnBillProduct.*,
  1387. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  1388. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1389. SaleRtnBill.AssessDate_SaleRtnBill,
  1390. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1391. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1392. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1393. SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct AS UnitCost_SaleRtnBillProduct,
  1394. SaleRtnBillProduct.Quantity_SaleRtnBillProduct * SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct AS Cash_SaleRtnBillProduct,@NextNo as No_SaleRtnBill
  1395. FROM SaleRtnBillProduct
  1396. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1397. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1398. JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1399. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct
  1400. AND SaleOutDepotBillProduct.ID_SaleOutDepotBill=@ID_SaleOutDepotBill
  1401. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1402. ORDER BY CAST(No_SaleRtnBillProduct AS INT)">
  1403. <Params>
  1404. <Param name="@Right" type="SaleBill.ID_Customer" Index="0" />
  1405. </Params>
  1406. <Tables>
  1407. <Table name="SaleRtnBill"/>
  1408. <Table name="SaleRtnBillProduct"/>
  1409. </Tables>
  1410. </SearchSaleRtnBillLast>
  1411. <SearchSaleRtnBillPrevious CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  1412. DECLARE @ID_SaleRtnBill uniqueidentifier
  1413. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1414. SELECT TOP 1 @NextNo = SaleRtnBill.No_SaleRtnBill FROM SaleRtnBill
  1415. Join Customer On Customer.ID_Customer=SaleRtnBill.ID_Customer
  1416. WHERE SaleRtnBill.No_SaleRtnBill &lt; @No_SaleRtnBill
  1417. And Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  1418. ORDER BY SaleRtnBill.No_SaleRtnBill DESC
  1419. SELECT @ID_SaleRtnBill = SaleRtnBill.ID_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.No_SaleRtnBill = @NextNo
  1420. SELECT @ID_SaleOutDepotBill = ID_SaleOutDepotBill FROM SaleOutDepotBill JOIN SaleRtnBillProduct ON SaleOutDepotBill.No_SaleOutDepotBill = SaleRtnBillProduct.No_FromBill
  1421. SELECT SaleRtnBill.*, Customer.No_Customer,Customer.ShortName_Customer, Location.Name_Location, Location.No_Location, AppUser.LoginName_User as Name_Creator, A1.LoginName_User as Name_Assessor, A2.LoginName_User as LastModUserName_SaleRtnBill
  1422. ,Employee.No_Employee AS No_Principal,
  1423. Employee.Name_Employee AS Principal_SaleRtnBill
  1424. FROM SaleRtnBill
  1425. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1426. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1427. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1428. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1429. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1430. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  1431. WHERE SaleRtnBill.ID_SaleRtnBill=@ID_SaleRtnBill
  1432. SELECT SaleRtnBillProduct.*,
  1433. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  1434. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1435. SaleRtnBill.AssessDate_SaleRtnBill,
  1436. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1437. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1438. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1439. SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct AS UnitCost_SaleRtnBillProduct,
  1440. SaleRtnBillProduct.Quantity_SaleRtnBillProduct * SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct AS Cash_SaleRtnBillProduct,@NextNo as No_SaleRtnBill
  1441. FROM SaleRtnBillProduct
  1442. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1443. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1444. JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1445. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct
  1446. AND SaleOutDepotBillProduct.ID_SaleOutDepotBill=@ID_SaleOutDepotBill
  1447. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1448. ORDER BY CAST(No_SaleRtnBillProduct AS INT)">
  1449. <Params>
  1450. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" Index="0"/>
  1451. <Param name="@Right" type="SaleBill.ID_Customer" Index="1" />
  1452. </Params>
  1453. <Tables>
  1454. <Table name="SaleRtnBill"/>
  1455. <Table name="SaleRtnBillProduct"/>
  1456. </Tables>
  1457. </SearchSaleRtnBillPrevious>
  1458. <SearchSaleRtnBillNext CmdType="Text" CmdText=" DECLARE @NextNo nvarchar(64)
  1459. DECLARE @ID_SaleRtnBill uniqueidentifier
  1460. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1461. SELECT TOP 1 @NextNo = SaleRtnBill.No_SaleRtnBill FROM SaleRtnBill
  1462. Join Customer On Customer.ID_Customer=SaleRtnBill.ID_Customer
  1463. WHERE SaleRtnBill.No_SaleRtnBill &gt; @No_SaleRtnBill
  1464. And Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  1465. ORDER BY SaleRtnBill.No_SaleRtnBill
  1466. SELECT @ID_SaleRtnBill = SaleRtnBill.ID_SaleRtnBill FROM SaleRtnBill WHERE SaleRtnBill.No_SaleRtnBill = @NextNo
  1467. SELECT @ID_SaleOutDepotBill = ID_SaleOutDepotBill FROM SaleOutDepotBill JOIN SaleRtnBillProduct ON SaleOutDepotBill.No_SaleOutDepotBill = SaleRtnBillProduct.No_FromBill
  1468. SELECT SaleRtnBill.*, Customer.No_Customer, Customer.ShortName_Customer, Location.Name_Location, Location.No_Location, AppUser.LoginName_User as Name_Creator, A1.LoginName_User as Name_Assessor, A2.LoginName_User as LastModUserName_SaleRtnBill
  1469. ,Employee.No_Employee AS No_Principal,
  1470. Employee.Name_Employee AS Principal_SaleRtnBill
  1471. FROM SaleRtnBill
  1472. JOIN Customer ON Customer.ID_Customer = SaleRtnBill.ID_Customer
  1473. JOIN Location ON Location.ID_Location = SaleRtnBill.ID_Location
  1474. JOIN AppUser ON AppUser.ID_User = SaleRtnBill.ID_Creator
  1475. LEFT JOIN AppUser A1 ON A1.ID_User = SaleRtnBill.ID_Assessor
  1476. LEFT JOIN AppUser A2 ON A2.ID_User = SaleRtnBill.LastModUser_SaleRtnBill
  1477. LEFT JOIN Employee ON Employee.ID_Employee = SaleRtnBill.ID_Principal
  1478. WHERE SaleRtnBill.ID_SaleRtnBill=@ID_SaleRtnBill
  1479. SELECT SaleRtnBillProduct.*,
  1480. BillType.Name_BillType AS FromBill_SaleRtnBillProduct,
  1481. SaleRtnBill.IsPrevBill_SaleRtnBill,
  1482. SaleRtnBill.AssessDate_SaleRtnBill,
  1483. Product.No_Product AS ProductNo_SaleRtnBillProduct,
  1484. Product.Name_Product AS ProductName_SaleRtnBillProduct,
  1485. Product.Unit_Product AS ProductUnit_SaleRtnBillProduct,
  1486. SaleOutDepotBillProduct.UnitCost_SaleOutDepotBillProduct AS UnitCost_SaleRtnBillProduct,
  1487. SaleRtnBillProduct.Quantity_SaleRtnBillProduct * SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct AS Cash_SaleRtnBillProduct,@NextNo as No_SaleRtnBill
  1488. FROM SaleRtnBillProduct
  1489. JOIN SaleRtnBill ON SaleRtnBill.ID_SaleRtnBill=SaleRtnBillProduct.ID_SaleRtnBill
  1490. JOIN Product ON Product.ID_Product=SaleRtnBillProduct.ID_Product
  1491. JOIN BillType ON BillType.Value_BillType=SaleRtnBillProduct.Type_FromBill
  1492. LEFT JOIN SaleOutDepotBillProduct ON SaleOutDepotBillProduct.No_SaleOutDepotBillProduct=SaleRtnBillProduct.No_FromBillProduct
  1493. AND SaleOutDepotBillProduct.ID_SaleOutDepotBill=@ID_SaleOutDepotBill
  1494. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1495. ORDER BY CAST(No_SaleRtnBillProduct AS INT)">
  1496. <Params>
  1497. <Param name="@No_SaleRtnBill" type="SaleRtnBill.No_SaleRtnBill" Index="0"/>
  1498. <Param name="@Right" type="SaleBill.ID_Customer" Index="1" />
  1499. </Params>
  1500. <Tables>
  1501. <Table name="SaleRtnBill"/>
  1502. <Table name="SaleRtnBillProduct"/>
  1503. </Tables>
  1504. </SearchSaleRtnBillNext>
  1505. <SearchLocation CmdType="Text" CmdText="SELECT Location.ID_Location, Location.Name_Location, Location.No_Location FROM Location WHERE Location.Level_Location = 0 ORDER BY No_Location">
  1506. <Tables>
  1507. <Table name="Location"/>
  1508. </Tables>
  1509. </SearchLocation>
  1510. <SearchFromBillProductNo CmdType="Text" CmdText=" IF(@Type_FromBill=2)
  1511. BEGIN
  1512. DECLARE @ID_SaleOutDepotBill uniqueidentifier
  1513. SELECT @ID_SaleOutDepotBill = SaleOutDepotBill.ID_SaleOutDepotBill FROM SaleOutDepotBill WHERE No_SaleOutDepotBill = @No_FromBill
  1514. SELECT ID_SaleOutDepotBillProduct AS ID_FromBill,
  1515. ID_Assessor,ID_IndentBillOnNetProduct,
  1516. No_SaleOutDepotBillProduct AS No_FromBillProduct,
  1517. SaleOutDepotBillProduct.ID_SaleSourceBillProduct AS ID_SaleSourceBillProduct,
  1518. Product.ID_Product,
  1519. Product.No_Product,
  1520. Product.Name_Product,
  1521. Product.Unit_Product,
  1522. Product.SuspendDate_Product,
  1523. UnitCost_SaleOutDepotBillProduct AS UnitPrice_FromBillProduct,
  1524. Convert(decimal(5,2),100) As Discount_FromBillProduct,
  1525. CASE IsNull(DataLength(SaleOutDepotBill.ID_Assessor),0) When 0 Then 0 Else (Quantity_SaleOutDepotBillProduct-RtnQuantity_SaleOutDepotBillProduct) End As Quantity_SaleRtnBillProduct,
  1526. SaleOutDepotBill.ID_Customer AS ID_Customer
  1527. FROM
  1528. SaleOutDepotBillProduct
  1529. JOIN Product ON Product.ID_Product=SaleOutDepotBillProduct.ID_Product
  1530. JOIN SaleOutDepotBill ON SaleOutDepotBill.ID_SaleOutDepotBill=SaleOutDepotBillProduct.ID_SaleOutDepotBill
  1531. LEFT JOIN SaleSourceBillProduct ON SaleOutDepotBillProduct.ID_SaleSourceBillProduct=SaleSourceBillProduct.ID_SaleSourceBillProduct
  1532. WHERE No_SaleOutDepotBillProduct = @No_FromBillProduct AND SaleOutDepotBillProduct.ID_SaleOutDepotBill =@ID_SaleOutDepotBill
  1533. END
  1534. Else IF(@Type_FromBill=21)
  1535. BEGIN
  1536. SELECT SaleBill.TaxCurrency_SaleBill as TaxCurrency,
  1537. A.ID_SaleBill AS ID_FromBill,
  1538. ID_Assessor,
  1539. A.No_SaleBillProduct AS No_FromBillProduct,ID_IndentBillOnNetProduct,
  1540. A.ID_SaleSourceBillProduct AS ID_SaleSourceBillProduct,
  1541. A.UnitPrice_SaleBillProduct AS UnitPrice_FromBillProduct,
  1542. A.Discount_SaleBillProduct As Discount_FromBillProduct,
  1543. Product.ID_Product,
  1544. Product.No_Product,
  1545. Product.Name_Product,
  1546. Product.SuspendDate_Product,
  1547. Product.Unit_Product,
  1548. (ISNULL(Quantity_OutDepot,0)-ISNULL(Quantity_SaleRtn,0)) As Quantity_SaleRtnBillProduct ,
  1549. SaleBill.ID_Customer AS ID_Customer,TaxCurrency_SaleBill
  1550. FROM SaleBill
  1551. JOIN SaleBillProduct A ON SaleBill.ID_SaleBill = A.ID_SaleBill
  1552. JOIN Product ON Product.ID_Product = A.ID_Product
  1553. LEFT JOIN SaleSourceBillProduct ON A.ID_SaleSourceBillProduct=SaleSourceBillProduct.ID_SaleSourceBillProduct
  1554. WHERE SaleBill.No_SaleBill=@No_FromBill AND A.No_SaleBillProduct=@No_FromBillProduct
  1555. END
  1556. ELSE
  1557. BEGIN
  1558. SELECT Top 0
  1559. CONVERT(uniqueidentifier,null) As ID_FromBill,
  1560. CONVERT(uniqueidentifier,null) As ID_Assessor,
  1561. CONVERT(nvarchar(64),'') As No_FromBillProduct,
  1562. CONVERT(uniqueidentifier,null) As ID_SaleSourceBillProduct,
  1563. CONVERT(decimal(18,6),0) As UnitPrice_FromBillProduct,
  1564. CONVERT(uniqueidentifier,null) As ID_Product,
  1565. CONVERT(nvarchar(64),'') As No_Product,
  1566. CONVERT(nvarchar(64),'') As Name_Product,
  1567. CONVERT(datetime,getdate()) As SuspendDate_Product,
  1568. CONVERT(nvarchar(64),'') as Unit_Product,
  1569. CONVERT(decimal(14,4),0) As Quantity_SaleRtnBillProduct,
  1570. CONVERT(uniqueidentifier,null) As ID_Customer
  1571. END">
  1572. <Params>
  1573. <Param name="@Type_FromBill" type="SaleRtnBillProduct.Type_FromBill" Index="0" />
  1574. <Param name="@No_FromBill" type="SaleRtnBillProduct.No_FromBill" Index="1" />
  1575. <Param name="@No_FromBillProduct" type="SaleRtnBillProduct.No_FromBillProduct" Index="2" />
  1576. </Params>
  1577. <Tables>
  1578. <Table name="SaleOutDepotBillProduct"/>
  1579. </Tables>
  1580. </SearchFromBillProductNo>
  1581. <SearchProductWithNo CmdType="Text" CmdText="SELECT Product.Cost_Product, Product.ID_Product, Product.Name_Product, Product.Unit_Product, SuspendDate_Product FROM Product
  1582. WHERE No_Product=@No_Product ORDER BY No_Product">
  1583. <Params>
  1584. <Param name="@No_Product" type="Product.No_Product" Index="0" />
  1585. </Params>
  1586. <Tables>
  1587. <Table name="Product"/>
  1588. </Tables>
  1589. </SearchProductWithNo>
  1590. <SearchSystemSetting CmdType="Text" CmdText="SELECT CessOut_SystemSetting, OutDepotAndSaleBack_SystemSetting, SaleBackAndInDepot_SystemSetting,SysCurrency_SystemSetting,
  1591. UnitPriceDecimal_SystemSetting, PriceDecimal_SystemSetting, QuantityDecimal_SystemSetting,CostDecimal_SystemSetting,SaleRtnSourceBill_SystemSetting FROM SystemSetting">
  1592. <Tables>
  1593. <Table name="SystemSetting"/>
  1594. </Tables>
  1595. </SearchSystemSetting>
  1596. <SearchBillType CmdType="Text" CmdText=" DECLARE @OutDepotAndSaleBack_SystemSetting bit
  1597. DECLARE @SaleBackAndInDepot_SystemSetting bit
  1598. DECLARE @SaleRtnSourceBill_SystemSetting bit
  1599. SELECT @OutDepotAndSaleBack_SystemSetting=OutDepotAndSaleBack_SystemSetting,@SaleBackAndInDepot_SystemSetting=SaleBackAndInDepot_SystemSetting,
  1600. @SaleRtnSourceBill_SystemSetting=SaleRtnSourceBill_SystemSetting FROM SystemSetting
  1601. IF(@OutDepotAndSaleBack_SystemSetting = 1 AND @SaleBackAndInDepot_SystemSetting = 1 AND @SaleRtnSourceBill_SystemSetting = 1)
  1602. SELECT * FROM BillType WHERE Value_BillType=0 OR Value_BillType=21 ORDER BY Value_BillType
  1603. ELSE
  1604. SELECT * FROM BillType WHERE Value_BillType = 2 OR Value_BillType=0 ORDER BY Value_BillType">
  1605. <Tables>
  1606. <Table name="BillType" />
  1607. </Tables>
  1608. </SearchBillType>
  1609. <SearchAllSaleBill CmdType="Text" CmdText="Select SaleBill.ID_Principal,SaleBill.Currency_SaleBill ,SaleBill.TaxCurrency_SaleBill,SaleBill.ID_SaleBill,SaleBill.No_SaleBill,SaleBill.Date_SaleBill,Customer.No_Customer,Customer.ShortName_Customer,Case isnull(DataLength(SaleBill.ID_Assessor),0) WHEN 0 THEN CASE Disable_SaleBill WHEN 1 THEN '作废' ELSE '未审核' END ELSE '已审核' END As State_SaleBill,Location.Name_Location,
  1610. Employee.Name_Employee AS Principal_SaleBill,Employee.No_Employee AS No_Principal From SaleBill
  1611. Inner Join Customer On SaleBill.ID_Customer = Customer.ID_Customer
  1612. Inner Join Location On Location.ID_Location = SaleBill.ID_Location
  1613. Inner Join Employee ON Employee.ID_Employee = SaleBill.ID_Principal " >
  1614. <Tables>
  1615. <Table name="AllSaleBill" />
  1616. </Tables>
  1617. </SearchAllSaleBill>
  1618. <SearchAllSaleBillProduct CmdType="Text" CmdText="Select Product.No_Product,SaleBillProduct.No_SaleBillProduct,Product.Name_Product,SaleBillProduct.Quantity_SaleBillProduct,SaleBillProduct.UnitPrice_SaleBillProduct From SaleBillProduct
  1619. Inner Join Product On Product.ID_Product = SaleBillProduct.ID_Product
  1620. Inner Join SaleBill On SaleBill.ID_SaleBill =SaleBillProduct.ID_SaleBill" >
  1621. <Tables>
  1622. <Table name="AllSaleBillProduct" />
  1623. </Tables>
  1624. </SearchAllSaleBillProduct>
  1625. <SearchInDepot CmdType="Text" CmdText="
  1626. SELECT Quantity_InDepot=Sum(InQuantity_SaleRtnBillProduct)
  1627. FROM SaleRtnBillProduct
  1628. WHERE SaleRtnBillProduct.ID_SaleRtnBill=@ID_SaleRtnBill
  1629. ">
  1630. <Params>
  1631. <Param name="@ID_SaleRtnBill" type="SaleBill.ID_SaleRtnBill" Index="0" />
  1632. </Params>
  1633. <Tables>
  1634. <Table name="InDepot" />
  1635. </Tables>
  1636. </SearchInDepot>
  1637. <SearchStockSettle CmdType="Text" CmdText="
  1638. Select * From StockSettleAccounts
  1639. Where DateDiff(Day,@Date_SaleOutDepotBill,FromDate_StockSettleAccounts) &lt;=0
  1640. And DateDiff(Day,@Date_SaleOutDepotBill,EndDate_StockSettleAccounts) &gt;=0
  1641. And Status_StockSettleAccounts=0
  1642. ">
  1643. <Params>
  1644. <Param name="@Date_SaleOutDepotBill" type="PurchaseInDepotBill.Date_SaleOutDepotBill" Index="0" />
  1645. </Params>
  1646. <Tables>
  1647. <Table name="StockSettle" />
  1648. </Tables>
  1649. </SearchStockSettle>
  1650. <UpdateCustomer CmdType="Text" CmdText="if (@IsAudit = '1')
  1651. Begin
  1652. Update Customer Set Saleroom_Customer = Saleroom_Customer + @Amount_SaleRtnBill
  1653. Where Customer.ID_Customer = @ID_Customer
  1654. End
  1655. if (@IsAudit = '0')
  1656. Begin
  1657. Update Customer Set Saleroom_Customer = Saleroom_Customer - @Amount_SaleRtnBill
  1658. Where Customer.ID_Customer = @ID_Customer
  1659. End
  1660. Select 1">
  1661. <Params>
  1662. <Param name="@ID_Customer" type="Customer.ID_Customer" Index="0" />
  1663. <Param name="Amount_SaleRtnBill" type="SaleRtnBill.Amount_SaleRtnBill" Index="1" />
  1664. <Param name="IsAudit" type="SaleBill.No_SaleBill" Index="2" />
  1665. </Params>
  1666. <Tables>
  1667. <Table name="Audit" />
  1668. </Tables>
  1669. </UpdateCustomer>
  1670. </Search>
  1671. </Server>
  1672. <Lables>
  1673. <Search>
  1674. Empty();
  1675. NewInstance();
  1676. @ImportClicked = 0;
  1677. dtpDate.Enabled=false;
  1678. tbNo.ReadOnly=false;
  1679. ckPrevBill.Enabled=false;
  1680. tbCustomerNo.ReadOnly=true;
  1681. cbTaxCurrency.Enabled=false;
  1682. cbCurrency.Enabled=false;
  1683. cbLocation.Enabled=false;
  1684. cbPrincipal.Enabled=false;
  1685. cbReason.Enabled=false;
  1686. cbComment.Enabled=false;
  1687. ikTextBox1.ReadOnly=true;
  1688. dgProduct.ReadOnly=true;
  1689. toolBar.EnableSubmit=false;
  1690. toolBar.EnableModify=false;
  1691. toolBar.EnableDelete=false;
  1692. toolBar.EnableAudit=false;
  1693. toolBar.EnableUnAudit=false;
  1694. toolBar.EnableNew=GetRight(@Title,"新增");
  1695. toolBar.EnablePrint=false;
  1696. toolBar.EnableExport = false;
  1697. toolBar.EnableImport = false;
  1698. toolBar.EnableAssess = false;
  1699. toolBar.EnableUnAssess = false;
  1700. btnDelete.Enabled = false;
  1701. #SaleRtnBill.ID_Assessor=DBNull();
  1702. #SaleRtnBill.AssessDate_SaleRtnBill=DBNull();
  1703. #SaleRtnBill.LastModUser_SaleRtnBill=DBNull();
  1704. #SaleRtnBill.LastModDate_SaleRtnBill=DBNull();
  1705. UpdateForm(true, "");
  1706. tbNo.Focus();
  1707. @Status=0;
  1708. </Search>
  1709. <New>
  1710. Empty();
  1711. NewInstance();
  1712. @ImportClicked = 0;
  1713. tbNo.ReadOnly=true;
  1714. dtpDate.Enabled=true;
  1715. ckPrevBill.Enabled=true;
  1716. tbCustomerNo.ReadOnly=false;
  1717. cbTaxCurrency.Enabled=true;
  1718. cbCurrency.Enabled=false;
  1719. cbLocation.Enabled=true;
  1720. cbPrincipal.Enabled=true;
  1721. cbReason.Enabled=true;
  1722. cbComment.Enabled=true;
  1723. ikTextBox1.ReadOnly=false;
  1724. dgProduct.ReadOnly=false;
  1725. dgProduct.SetColumnReadOnly(8, false);
  1726. dgProduct.SetColumnReadOnly(9, false);
  1727. dgProduct.SetColumnReadOnly(1, false);
  1728. dgProduct.RowHeaderCheck=true;
  1729. dgProduct.AllowNew(true);
  1730. dgProduct.AllowDelete(true);
  1731. toolBar.EnableSubmit=GetRight(@Title,"新增");
  1732. toolBar.EnableModify=false;
  1733. toolBar.EnableDelete=false;
  1734. toolBar.EnableAudit=false;
  1735. toolBar.EnableUnAudit=false;
  1736. toolBar.EnableNew=false;
  1737. toolBar.EnablePrint=false;
  1738. toolBar.EnableExport = false;
  1739. toolBar.EnableImport = true;
  1740. toolBar.EnableAssess = false;
  1741. toolBar.EnableUnAssess = false;
  1742. btnDelete.Enabled = false;
  1743. #SaleRtnBill.ID_SaleRtnBill=NewGuid();
  1744. #SaleRtnBill.ID_Assessor=DBNull();
  1745. #SaleRtnBill.AssessDate_SaleRtnBill=DBNull();
  1746. #SaleRtnBill.LastModUser_SaleRtnBill=DBNull();
  1747. #SaleRtnBill.LastModDate_SaleRtnBill=DBNull();
  1748. #SaleRtnBill.ID_Creator=GetLoginUserID();
  1749. #SaleRtnBill.Name_Creator=GetCurrentUser();
  1750. #SaleRtnBill.Date_SaleRtnBill=DateTimeNow();
  1751. #SaleRtnBill.Currency_SaleRtnBill=@SysCurrency;
  1752. #SaleRtnBill.ID_Location=GetCurrentDepotID();
  1753. #SaleRtnBill.Name_Location=GetCurrentDepot();
  1754. #SaleRtnBill.No_Location=GetCurrentDepotNo();
  1755. #SaleRtnBill.Date_SaleRtnBill=GetCurrentTime();
  1756. SetColumnDefaultValue("SaleRtnBillProduct", "Quantity_SaleRtnBillProduct", 1);
  1757. UpdateForm(true, "");
  1758. dtpDate.Focus();
  1759. @Status=1;
  1760. </New>
  1761. <View>
  1762. @ImportClicked = 0;
  1763. dtpDate.Enabled=false;
  1764. tbNo.ReadOnly=false;
  1765. ckPrevBill.Enabled=false;
  1766. tbCustomerNo.ReadOnly=true;
  1767. cbTaxCurrency.Enabled=false;
  1768. cbCurrency.Enabled=false;
  1769. cbLocation.Enabled=false;
  1770. cbPrincipal.Enabled=false;
  1771. cbReason.Enabled=false;
  1772. cbComment.Enabled=false;
  1773. ikTextBox1.ReadOnly=true;
  1774. dgProduct.ReadOnly=true;
  1775. toolBar.EnableSubmit=false;
  1776. toolBar.EnableNew=GetRight(@Title,"新增");
  1777. if(Search("SearchStockSettle",#SaleRtnBill.Date_SaleRtnBill))
  1778. {
  1779. if(Equals(#SaleRtnBill.ID_Assessor, DBNull()))
  1780. {
  1781. if(#SaleRtnBill.Disable_SaleRtnBill==false)
  1782. {
  1783. toolBar.EnableAudit=GetRight(@Title,"审核");
  1784. toolBar.EnableModify=GetRight(@Title,"修改");
  1785. toolBar.EnableDelete=GetRight(@Title,"删除");
  1786. }
  1787. else
  1788. {
  1789. toolBar.EnableAudit = false;
  1790. toolBar.EnableModify = false;
  1791. toolBar.EnableDelete = false;
  1792. }
  1793. toolBar.EnableUnAudit=false;
  1794. toolBar.EnableAssess = false;
  1795. btnDelete.Enabled = false;
  1796. toolBar.EnableUnAssess = false;
  1797. }
  1798. else
  1799. {
  1800. toolBar.EnableAudit=false;
  1801. toolBar.EnableUnAudit=GetRight(@Title,"取消审核");
  1802. toolBar.EnableModify=false;
  1803. toolBar.EnableDelete=false;
  1804. btnDelete.Enabled = GetRight(@Title,"取消审核")&amp;&amp;GetRight(@Title,"删除");
  1805. if(#SaleRtnBill.Assess_SaleRtnBill == 0)
  1806. {
  1807. toolBar.EnableAssess = GetRight(@Title,"审核");
  1808. toolBar.EnableUnAssess = false;
  1809. }
  1810. else
  1811. {
  1812. toolBar.EnableUnAssess = GetRight(@Title,"取消审核");
  1813. toolBar.EnableAssess = false;
  1814. }
  1815. }
  1816. }
  1817. else
  1818. {
  1819. toolBar.EnablePrint=false;
  1820. toolBar.EnableAudit=false;
  1821. toolBar.EnableUnAudit=false;
  1822. toolBar.EnableModify=false;
  1823. toolBar.EnableDelete=false;
  1824. btnDelete.Enabled = false;
  1825. }
  1826. toolBar.EnablePrint=GetRight(@Title,"打印");
  1827. toolBar.EnableExport = true;
  1828. toolBar.EnableImport = false;
  1829. UpdateForm(true, "");
  1830. @Status=2;
  1831. </View>
  1832. <Modify>
  1833. UpdateForm(false, "");
  1834. @ImportClicked = 0;
  1835. dtpDate.Enabled=false;
  1836. ckPrevBill.Enabled=false;
  1837. tbCustomerNo.ReadOnly=false;
  1838. tbNo.ReadOnly=true;
  1839. cbCurrency.Enabled=false;
  1840. cbLocation.Enabled=true;
  1841. cbPrincipal.Enabled=true;
  1842. cbReason.Enabled=true;
  1843. cbComment.Enabled=true;
  1844. ikTextBox1.ReadOnly=false;
  1845. dgProduct.ReadOnly=false;
  1846. @HaveAccessed = !Equals(#SaleRtnBill.AssessDate_SaleRtnBill,DBNull());
  1847. dgProduct.SetColumnReadOnly(9, @HaveAccessed);
  1848. dgProduct.SetColumnReadOnly(10, @HaveAccessed);
  1849. dgProduct.SetColumnReadOnly(11, @HaveAccessed);
  1850. dgProduct.SetColumnReadOnly(1, @HaveAccessed);
  1851. dgProduct.AllowNew(!@HaveAccessed);
  1852. dgProduct.AllowDelete(!@HaveAccessed);
  1853. dgProduct.RowHeaderCheck=!@HaveAccessed;
  1854. toolBar.EnableSubmit=GetRight(@Title,"修改");
  1855. toolBar.EnableModify=false;
  1856. toolBar.EnableDelete=false;
  1857. toolBar.EnableAudit=false;
  1858. toolBar.EnableUnAudit=false;
  1859. toolBar.EnableNew=false;
  1860. toolBar.EnablePrint=false;
  1861. toolBar.EnableExport = false;
  1862. toolBar.EnableImport = false;
  1863. toolBar.EnableAssess = false;
  1864. toolBar.EnableUnAssess = false;
  1865. btnDelete.Enabled = false;
  1866. #SaleRtnBill.LastModUser_SaleRtnBill=GetLoginUserID();
  1867. #SaleRtnBill.LastModUserName_SaleRtnBill=GetCurrentUser();
  1868. #SaleRtnBill.LastModDate_SaleRtnBill=DateTimeNow();
  1869. SetColumnDefaultValue("SaleRtnBillProduct", "Quantity_SaleRtnBillProduct", 1);
  1870. @HaveAccessed = !Equals(#SaleRtnBill.AssessDate_SaleRtnBill,DBNull());
  1871. if(@HaveAccessed)
  1872. cbTaxCurrency.Enabled = false;
  1873. else
  1874. cbTaxCurrency.Enabled = true;
  1875. UpdateForm(true, "");
  1876. tbNo.Focus();
  1877. @Status=3;
  1878. </Modify>
  1879. <SeachProduct>
  1880. <![CDATA[
  1881. if(ckPrevBill.CValue==false&&!Equals(#SaleRtnBillProduct.FromBill_SaleRtnBillProduct,StringEmpty())&&!Equals(#SaleRtnBillProduct.No_FromBill,StringEmpty())&&!Equals(#SaleRtnBillProduct.No_FromBillProduct,StringEmpty()))
  1882. {
  1883. if(Search("SearchFromBillProductNo",#SaleRtnBillProduct.Type_FromBill,#SaleRtnBillProduct.No_FromBill,#SaleRtnBillProduct.No_FromBillProduct))
  1884. {
  1885. if(#SaleRtnBillProduct.Type_FromBill == 21 && !Equals(cbTaxCurrency.SelectedItem,#SaleOutDepotBillProduct.TaxCurrency_SaleBill))
  1886. {
  1887. MessageBox("该来源单据的税别与本单据的税别不一致!",@Title);
  1888. return;
  1889. }
  1890. if(!Equals(#SaleOutDepotBillProduct.SuspendDate_Product,DBNull()))
  1891. {
  1892. MessageBox("该产品已停用!",@Title);
  1893. }
  1894. #SaleRtnBillProduct.ID_Product=#SaleOutDepotBillProduct.ID_Product;
  1895. #SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct=#SaleOutDepotBillProduct.UnitPrice_FromBillProduct;
  1896. #SaleRtnBillProduct.ProductNo_SaleRtnBillProduct=#SaleOutDepotBillProduct.No_Product;
  1897. #SaleRtnBillProduct.ProductName_SaleRtnBillProduct=#SaleOutDepotBillProduct.Name_Product;
  1898. #SaleRtnBillProduct.ProductUnit_SaleRtnBillProduct=#SaleOutDepotBillProduct.Unit_Product;
  1899. #SaleRtnBillProduct.Quantity_SaleRtnBillProduct=#SaleOutDepotBillProduct.Quantity_SaleRtnBillProduct;
  1900. #SaleRtnBillProduct.ID_IndentBillOnNetProduct=#SaleOutDepotBillProduct.ID_IndentBillOnNetProduct;
  1901. }
  1902. }
  1903. ]]>
  1904. </SeachProduct>
  1905. <Money>
  1906. <![CDATA[
  1907. if(cbTaxCurrency.SelectedName=="外加")
  1908. {
  1909. txtMoneySum.CValue=#SaleRtnBill.GoodsAmount_SaleRtnBill=SumOfCol("#SaleRtnBillProduct.Cash_SaleRtnBillProduct");
  1910. txtTaxSum.CValue=#SaleRtnBill.TaxAmount_SaleRtnBill=FormatNumber(#SaleRtnBill.GoodsAmount_SaleRtnBill*#SystemSetting.CessOut_SystemSetting/100, #SystemSetting.PriceDecimal_SystemSetting);
  1911. txtSum.CValue=#SaleRtnBill.Amount_SaleRtnBill=#SaleRtnBill.GoodsAmount_SaleRtnBill+#SaleRtnBill.TaxAmount_SaleRtnBill;
  1912. }
  1913. else if(cbTaxCurrency.SelectedName=="内含")
  1914. {
  1915. txtSum.CValue=#SaleRtnBill.Amount_SaleRtnBill=SumOfCol("#SaleRtnBillProduct.Cash_SaleRtnBillProduct");
  1916. txtMoneySum.CValue=#SaleRtnBill.GoodsAmount_SaleRtnBill=FormatNumber(#SaleRtnBill.Amount_SaleRtnBill/(1+#SystemSetting.CessOut_SystemSetting/100), #SystemSetting.PriceDecimal_SystemSetting);
  1917. txtTaxSum.CValue=#SaleRtnBill.TaxAmount_SaleRtnBill=#SaleRtnBill.Amount_SaleRtnBill-#SaleRtnBill.GoodsAmount_SaleRtnBill;
  1918. }
  1919. else if(cbTaxCurrency.SelectedName=="零税"||cbTaxCurrency.SelectedName=="免税")
  1920. {
  1921. txtSum.CValue=txtMoneySum.CValue=#SaleRtnBill.Amount_SaleRtnBill=#SaleRtnBill.GoodsAmount_SaleRtnBill=SumOfCol("#SaleRtnBillProduct.Cash_SaleRtnBillProduct");
  1922. txtTaxSum.CValue=#SaleRtnBill.TaxAmount_SaleRtnBill=0;
  1923. }
  1924. txtNum.CValue=#SaleRtnBill.CountColume_SaleRtnBillProduct=SumOfCol("#SaleRtnBillProduct.Quantity_SaleRtnBillProduct");
  1925. ]]>
  1926. </Money>
  1927. <AssessClick>
  1928. Update();
  1929. </AssessClick>
  1930. <SubmitButtonClick>
  1931. <![CDATA[
  1932. if(!Search("SearchStockSettle",dtpDate.Value))
  1933. {
  1934. MessageBox("制单日期不在开帐区间内,提交失败!");
  1935. return;
  1936. }
  1937. if(!Search("SearchCustomerWithNo", tbCustomerNo.CValue) || !Equals(#SaleRtnBill.ID_Customer,#Customer.ID_Customer))
  1938. {
  1939. MessageBox("请输入客户编号后,回车以示确认!",@Title);
  1940. tbCustomerNo.Focus();
  1941. return;
  1942. }
  1943. if (!cbLocation.CheckSelectedItem())
  1944. {
  1945. MessageBox("请选择有效的入库仓库!",@Title);
  1946. cbLocation.Focus();
  1947. return;
  1948. }
  1949. if (!cbPrincipal.CheckSelectedItem())
  1950. {
  1951. MessageBox("请选择有效的负责业务人!",@Title);
  1952. cbPrincipal.Focus();
  1953. return;
  1954. }
  1955. if(RowCount("#SaleRtnBillProduct")==0)
  1956. {
  1957. MessageBox("请输入退货商品!",@Title);
  1958. return;
  1959. }
  1960. UpdateForm(false, "");
  1961. SuspendLayout();
  1962. for(@i=0;@i<RowCount("#SaleRtnBillProduct");@i++)
  1963. {
  1964. SetPosition("#SaleRtnBillProduct", @i);
  1965. if(Equals(#SystemSetting.OutDepotAndSaleBack_SystemSetting,true)&&Equals(ckPrevBill.CValue,false))
  1966. {
  1967. if(Equals(#SaleRtnBillProduct.FromBill_SaleRtnBillProduct,StringEmpty()))
  1968. {
  1969. dgProduct.CurrentRowIndex = @i;
  1970. MessageBox("请选择来源单据!",@Title);
  1971. ResumeLayout();
  1972. return;
  1973. }
  1974. if(#SaleRtnBillProduct.No_FromBill==StringEmpty())
  1975. {
  1976. dgProduct.CurrentRowIndex = @i;
  1977. MessageBox("请填入来源单据单号!",@Title);
  1978. ResumeLayout();
  1979. return;
  1980. }
  1981. if(#SaleRtnBillProduct.No_FromBillProduct==StringEmpty())
  1982. {
  1983. dgProduct.CurrentRowIndex = @i;
  1984. MessageBox("请填入来源单据产品序号!",@Title);
  1985. ResumeLayout();
  1986. return;
  1987. }
  1988. if(!Search("SearchFromBillProductNo",#SaleRtnBillProduct.Type_FromBill,#SaleRtnBillProduct.No_FromBill,#SaleRtnBillProduct.No_FromBillProduct))
  1989. {
  1990. dgProduct.CurrentRowIndex = @i;
  1991. MessageBox("该来源信息有误,请确认!",@Title);
  1992. ResumeLayout();
  1993. return;
  1994. }
  1995. else
  1996. {
  1997. if(!Equals(#SaleRtnBill.ID_Customer,#SaleOutDepotBillProduct.ID_Customer))
  1998. {
  1999. dgProduct.CurrentRowIndex = @i;
  2000. MessageBox("该来源单据的客户与本单据的客户不一致,请检查!",@Title);
  2001. ResumeLayout();
  2002. return;
  2003. }
  2004. }
  2005. if(!Equals(#SaleRtnBillProduct.ID_Product,#SaleOutDepotBillProduct.ID_Product))
  2006. {
  2007. dgProduct.CurrentRowIndex = @i;
  2008. MessageBox("该来源单据产品单中指定的产品与后改写的产品不匹配!",@Title);
  2009. ResumeLayout();
  2010. return;
  2011. }
  2012. if(!Equals(#SaleRtnBillProduct.Type_FromBill,0)&&!Equals(#SaleRtnBillProduct.No_FromBill,StringEmpty()))
  2013. {
  2014. if(Equals(#SaleOutDepotBillProduct.ID_Assessor,DBNull()))
  2015. {
  2016. dgProduct.CurrentRowIndex = @i;
  2017. if(MessageBox("该来源单据未经审核,确定要提交吗?",@Title,MB_OKCANCEL)==DialogResult("CANCEL"))
  2018. {
  2019. ResumeLayout();
  2020. return;
  2021. }
  2022. }
  2023. }
  2024. }
  2025. else
  2026. {
  2027. if(#SaleRtnBillProduct.Type_FromBill != 0 && #SaleRtnBillProduct.No_FromBill != "" && Search("SearchFromBillProductNo",#SaleRtnBillProduct.Type_FromBill,#SaleRtnBillProduct.No_FromBill,#SaleRtnBillProduct.No_FromBillProduct))
  2028. {
  2029. if(Equals(#SaleOutDepotBillProduct.ID_Assessor,DBNull()))
  2030. {
  2031. dgProduct.CurrentRowIndex = @i;
  2032. @Answer=MessageBox("该来源单据未经审核,确定要保留来源单据资料吗?",@Title,MB_YESNOCANCEL);
  2033. if(@Answer==DialogResult("NO"))
  2034. {
  2035. #SaleRtnBillProduct.Type_FromBill=0;
  2036. #SaleRtnBillProduct.No_FromBill="";
  2037. #SaleRtnBillProduct.No_FromBillProduct=="";
  2038. }
  2039. else if(@Answer==DialogResult("CANCEL"))
  2040. {
  2041. ResumeLayout();
  2042. return;
  2043. }
  2044. }
  2045. }
  2046. if (Equals(#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct,""))
  2047. {
  2048. dgProduct.CurrentRowIndex = @i;
  2049. MessageBox("请填入产品编号!",@Title);
  2050. ResumeLayout();
  2051. return;
  2052. }
  2053. if(!Search("SearchProductWithNo",#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct))
  2054. {
  2055. dgProduct.CurrentRowIndex = @i;
  2056. MessageBox("该产品不存在!",@Title);
  2057. ResumeLayout();
  2058. return;
  2059. }
  2060. }
  2061. if(#SaleRtnBillProduct.Quantity_SaleRtnBillProduct<=0)
  2062. {
  2063. dgProduct.CurrentRowIndex = @i;
  2064. MessageBox("数量不得小于等于0!",@Title);
  2065. ResumeLayout();
  2066. return;
  2067. }
  2068. if(#SaleRtnBillProduct.UnitPrice_SaleRtnBillProduct<0)
  2069. {
  2070. dgProduct.CurrentRowIndex = @i;
  2071. MessageBox("单价不得小于0!",@Title);
  2072. ResumeLayout();
  2073. return;
  2074. }
  2075. if(Equals(#SaleRtnBillProduct.ID_SaleRtnBillProduct,GuidEmpty()))
  2076. #SaleRtnBillProduct.ID_SaleRtnBillProduct = NewGuid();
  2077. #SaleRtnBillProduct.ID_SaleRtnBill=#SaleRtnBill.ID_SaleRtnBill;
  2078. }
  2079. ResumeLayout();
  2080. if(@Status==1)
  2081. {
  2082. #SaleRtnBill.CreateDate_SaleRtnBill=DateTimeNow();
  2083. #SaleRtnBill.No_SaleRtnBill = New("#SaleRtnBill.No_SaleRtnBill", dtpDate.CValue);
  2084. }
  2085. else if(@Status==3)
  2086. {
  2087. #SaleRtnBill.LastModDate_SaleRtnBill=DateTimeNow();
  2088. Update();
  2089. }
  2090. ChangeMode("View");
  2091. ]]>
  2092. </SubmitButtonClick>
  2093. </Lables>
  2094. </Form>
  2095. </Forms>