FrmInventoryChangeBill.xml 123 KB

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