FrmSaleBill.xml 223 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Forms>
  3. <Form Name="FrmSaleBill">
  4. <Client>
  5. <Events>
  6. <Load>
  7. <![CDATA[
  8. @SetFlag=1;
  9. @Title="销货单";
  10. @viewMode=false;
  11. @importing=false;
  12. GetSchema();
  13. Search("SearchCessOut");
  14. Search("SearchLocation");
  15. Search("SearchContr");
  16. Search("SearchProductWithNo","p");
  17. Search("SearchFromBillProductWithNo","p","p");
  18. Search("SearchIndentBillProductWithNo","p","p");
  19. Search("SearchIndentBillOnNetProductWithNo","p","p");
  20. Search("SearchRelation","p","p");
  21. if(!#SystemSetting.SaleAndOutDepot_SystemSetting || !#SystemSetting.OutDepotAndSaleBack_SystemSetting || !#SystemSetting.SaleRtnSourceBill_SystemSetting)
  22. toolBar.EnableExportItem(3,false);
  23. @CessOut = #System.CessOut_SystemSetting / 100;
  24. @PriceDecimal=#SystemSetting.PriceDecimal_SystemSetting;
  25. @SysCurrency=#System.SysCurrency_SystemSetting;
  26. @AuditMode = #System.SAudit_FunctionSetting;
  27. ChangeMode("Search");
  28. dgProduct.NoMember="No_SaleBillProduct";
  29. if(@AuditMode)
  30. {
  31. toolBar.VisibleAudit = false;
  32. toolBar.EnableAudit = false;
  33. }
  34. Search("SearchBillType");
  35. ]]>
  36. </Load>
  37. <Closing>
  38. ;
  39. </Closing>
  40. <Closed>
  41. ;
  42. </Closed>
  43. </Events>
  44. <Mode>
  45. <Search>
  46. <Lable name="Search" />
  47. </Search>
  48. <New>
  49. <Lable name="New" />
  50. </New>
  51. <View>
  52. <Lable name="View" />
  53. </View>
  54. <Modify>
  55. <Lable name="Modify" />
  56. </Modify>
  57. </Mode>
  58. <Controls>
  59. <IKDateTimePicker name="dtpDate" DataSource="SaleBill.Date_SaleBill"></IKDateTimePicker>
  60. <IKTextButton name="tbNo" DataSource="SaleBill.No_SaleBill">
  61. <Events>
  62. <Enter>
  63. <![CDATA[
  64. if(tbNo.ReadOnly == false)
  65. {
  66. if(tbNo.CValue != StringEmpty())
  67. {
  68. UpdateForm(false, "");
  69. if(Search("SearchSaleBillWithNo", tbNo.CValue))
  70. {
  71. @tp=#SaleBill.No_SaleBill;
  72. if(!Search("SearchCustomersIsInRegionalLeader",#SaleBill.No_Customer, GetCurrentUser()))
  73. {
  74. ChangeMode("Search");
  75. tbNo.CValue=@tp;
  76. MessageBox("你与客户不在同一个区域,不能查看!");
  77. tbNo.CValue="";
  78. return;
  79. }
  80. if((GetRight("客户基本资料","全权查看")||Equals(GetLoginUserID(),#SaleBill.CustomerCreator))&&(GetFieldRight(@Title,"特价单","查看")||!#SaleBill.Special_SaleBill)&&(GetFieldRight(@Title,"特批单","查看")||!#SaleBill.Special2_SaleBill))
  81. ChangeMode("View");
  82. else
  83. {
  84. @EnterNo=tbNo.CValue;
  85. ChangeMode("Search");
  86. tbNo.CValue=@EnterNo;
  87. MessageBox("你没有查看该单据资料的权限!",@Title);
  88. return;
  89. }
  90. }
  91. else
  92. {
  93. MessageBox("该销货单不存在!",@Title);
  94. }
  95. }
  96. else
  97. {
  98. MessageBox("请输入销货单号!",@Title);
  99. }
  100. }
  101. ]]>
  102. <Lable name="CountSum" />
  103. </Enter>
  104. <Click>
  105. ShowSearchBox("BillSearch","HAVEDEPOT", "tbNo",tbNo.CValue);
  106. </Click>
  107. </Events>
  108. </IKTextButton>
  109. <IKCheckBox name="ckSpecial" DataSource="SaleBill.Special_SaleBill"/>
  110. <IKCheckBox name="ckSpecial1" DataSource="SaleBill.Special2_SaleBill"/>
  111. <IKComboBoxEx name="cbLocation" DisplaySource="SaleBill.Name_Location" NoSource="SaleBill.No_Location" ValueSource="SaleBill.ID_Location" DataSource="Location" DisplayMember="Name_Location" NoMember="No_Location" ValueMember="ID_Location">
  112. <Events>
  113. <Reload>
  114. UpdateForm(false, "cbLocation");
  115. Search("SearchLocation");
  116. UpdateForm(true, "cbLocation");
  117. </Reload>
  118. </Events>
  119. </IKComboBoxEx>
  120. <IKTextButton name="tbCustomerNo" DataSource="SaleBill.No_Customer">
  121. <Events>
  122. <Enter>
  123. <![CDATA[
  124. if (tbCustomerNo.ReadOnly == false)
  125. {
  126. UpdateForm(false, "");
  127. if (tbCustomerNo.CValue == "" || !Search("SearchCustomerWithNo", tbCustomerNo.CValue))
  128. {
  129. if (tbCustomerNo.CValue == "")
  130. {
  131. MessageBox("请输入客户编号!", @Title);
  132. }
  133. else
  134. {
  135. MessageBox("该客户不存在!",@Title);
  136. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  137. if(@temp != "")
  138. {
  139. tbCustomerNo.CValue = @temp;
  140. ActiveControlEvent("tbCustomerNo", "Enter");
  141. }
  142. }
  143. }
  144. else
  145. {
  146. if (!Search("SearchCustomersIsInRegionalLeader",tbCustomerNo.CValue, GetCurrentUser()))
  147. {
  148. MessageBox("你与客户不在同一个区域,不能填单!");
  149. tbCustomerNo.CValue = "";
  150. return;
  151. }
  152. if (!Equals(#Customer.SuspendDate_Customer,DBNull()))
  153. {
  154. MessageBox("该客户被暂停,不能销货!",@Title);
  155. tbCustomerNo.Focus();
  156. return;
  157. }
  158. #SaleBill.ID_Customer = #Customer.ID_Customer;
  159. #SaleBill.Discount_SaleBill = #Customer.LastDiscount_Customer;
  160. #SaleBill.Name_Customer = #Customer.Name_Customer;
  161. #SaleBill.ShortName_Customer = #Customer.ShortName_Customer;
  162. #SaleBill.Type_Customer = #Customer.Type_Customer;
  163. #SaleBill.GetMethod_SaleBill = #Customer.GetMethod_Customer;
  164. #SaleBill.ToGet_SaleBill = #Customer.ToGetBalance_Customer;
  165. #SaleBill.PostalCode_Customer = #Customer.PostalCode_Customer;
  166. #SaleBill.SendAddr_SaleBill = #Customer.SendAddr_Customer;
  167. #SaleBill.TaxCurrency_SaleBill = #Customer.LastTax_Customer;
  168. #SaleBill.Principal_SaleBill = #Customer.Name_Employee;
  169. #SaleBill.No_Principal = #Customer.No_Employee;
  170. #SaleBill.ID_Principal = #Customer.LastPrincipal_Customer;
  171. if(#Customer.IsCustomersCustomer_Customer == true)
  172. {
  173. #SaleBill.OutStatus_SaleBill = "寄客户,红单不放";
  174. }
  175. if(#Customer.IsCustomersCustomer_Customer == false)
  176. {
  177. #SaleBill.OutStatus_SaleBill = "";
  178. }
  179. Empty("#ReportComment");
  180. Search("SearchTypeComment",#SaleBill.ID_Customer);
  181. MergeTable("#TypeComment","#ReportComment");
  182. if (RowCount("Linkman") > 0)
  183. {
  184. #SaleBill.Name_Linkman = #Linkman.Name_Linkman;
  185. }
  186. else
  187. {
  188. #SaleBill.Name_Linkman = DBNull();
  189. }
  190. if (RowCount("Telephone") > 0)
  191. {
  192. #SaleBill.Tel_SaleBill = #Telephone.No_Telephone;
  193. }
  194. else
  195. {
  196. #SaleBill.Tel_SaleBill = DBNull();
  197. }
  198. if (RowCount("Fax") > 0)
  199. {
  200. #SaleBill.Fax_SaleBill = #Fax.No_Fax;
  201. }
  202. else
  203. {
  204. #SaleBill.Fax_SaleBill = DBNull();
  205. }
  206. if (RowCount("Invoice") > 0)
  207. {
  208. #SaleBill.InvoiceTitle_Company = #Invoice.Title_Invoice;
  209. #SaleBill.InvoiceAddress_Company = #Invoice.Address_Invoice;
  210. }
  211. else
  212. {
  213. #SaleBill.InvoiceTitle_Company = DBNull();
  214. #SaleBill.InvoiceAddress_Company = DBNull();
  215. }
  216. }
  217. UpdateForm(true, "");
  218. }
  219. ]]>
  220. <Lable name="ChangeDiscount" />
  221. </Enter>
  222. <Click>
  223. <![CDATA[
  224. if (tbCustomerNo.ReadOnly == false)
  225. {
  226. @temp = ShowSearchBox("CustomerSearch","INFOMATION",tbCustomerNo.CValue);
  227. if( @temp == "" )
  228. return;
  229. tbCustomerNo.CValue = @temp;
  230. ActiveControlEvent("tbCustomerNo", "Enter");
  231. }
  232. ]]>
  233. </Click>
  234. </Events>
  235. </IKTextButton>
  236. <IKTextBox name="txtCustomerShortName" DataSource="SaleBill.ShortName_Customer"></IKTextBox>
  237. <IKTextBox name="txtOrderBillNo" DataSource="SaleBill.No_OrderBill"></IKTextBox>
  238. <IKComboBoxEx name="cbGetMethod" DisplaySource="SaleBill.GetMethod_SaleBill" DataSource="GetMethod" DisplayMember="Result">
  239. <Events>
  240. <Reload>
  241. UpdateForm(false, "cbGetMethod");
  242. Search("SearchGetMethod");
  243. UpdateForm(true, "cbGetMethod");
  244. </Reload>
  245. </Events>
  246. </IKComboBoxEx>
  247. <IKNumericTextBox name="ntbToGet" DataSource="SaleBill.ToGet_SaleBill"></IKNumericTextBox>
  248. <IKComboBoxEx name="cbOutStatus" DisplaySource="SaleBill.OutStatus_SaleBill" DataSource="RespiteForSaleBill" DisplayMember="Result">
  249. <Events>
  250. <Reload>
  251. UpdateForm(false, "cbOutStatus");
  252. Search("SearchRespiteForSaleBill");
  253. UpdateForm(true, "cbOutStatus");
  254. </Reload>
  255. </Events>
  256. </IKComboBoxEx>
  257. <IKNumericTextBox name="ntbDiscount" DataSource="SaleBill.Discount_SaleBill">
  258. <Events>
  259. <Enter>
  260. UpdateForm(false, "ntbDiscount");
  261. <Lable name="ChangeDiscount" />
  262. </Enter>
  263. </Events>
  264. </IKNumericTextBox>
  265. <IKComboBoxEx name="cbTaxCurrency" DisplaySource="SaleBill.TaxCurrency_SaleBill">
  266. <Events>
  267. <SelectedIndexChanged>
  268. if(!@viewMode &amp;&amp; !@importing)
  269. {
  270. <Lable name="CountPrice"/>
  271. }
  272. <Lable name="CountSum" />
  273. </SelectedIndexChanged>
  274. </Events>
  275. </IKComboBoxEx>
  276. <IKComboBoxEx name="cbCurrency" DisplaySource="SaleBill.Currency_SaleBill" DataSource="SaleBill">
  277. </IKComboBoxEx>
  278. <IKComboBoxEx name="cbPrincipal" ValueSource="SaleBill.ID_Principal" DisplaySource="SaleBill.Principal_SaleBill" NoSource="SaleBill.No_Principal" DataSource="Principal" DisplayMember="Principal_SaleBill" NoMember="No_Principal" ValueMember="ID_Employee">
  279. <Events>
  280. <Reload>
  281. UpdateForm(false, "cbPrincipal");
  282. Search("SearchAllPrincipal");
  283. UpdateForm(true, "cbPrincipal");
  284. </Reload>
  285. </Events>
  286. </IKComboBoxEx>
  287. <IKTextBox name="txtMaker" DataSource="SaleBill.Name_Creator"></IKTextBox>
  288. <IKTextBox name="txtAudi" DataSource="SaleBill.Name_Assessor"></IKTextBox>
  289. <IKDateTimeText name="dtAssessDate" DataSource="SaleBill.AssessDate_SaleBill"></IKDateTimeText>
  290. <IKTextBox name="txtLastModUser" DataSource="SaleBill.LastModUserName"></IKTextBox>
  291. <IKDateTimeText name="dtLastModDate" DataSource="SaleBill.LastModDate_SaleBill"></IKDateTimeText>
  292. <IKTextBox name="txtCustomerName" DataSource="SaleBill.Name_Customer"></IKTextBox>
  293. <IKTextBox name="txtCustomerType" DataSource="SaleBill.Type_Customer"></IKTextBox>
  294. <IKComboBoxEx name="cbLinkman" DisplaySource="SaleBill.Name_Linkman" DataSource="Linkman" DisplayMember="Name_Linkman">
  295. <Events>
  296. <Reload>
  297. UpdateForm(false, "cbLinkman");
  298. Search("SearchLinkman", tbCustomerNo.CValue);
  299. UpdateForm(true, "cbLinkman");
  300. </Reload>
  301. </Events>
  302. </IKComboBoxEx>
  303. <IKTextBox name="cbTele" DisplaySource="SaleBill.Tel_SaleBill" DataSource="Telephone" DisplayMember="No_Telephone">
  304. <Events>
  305. <Reload>
  306. UpdateForm(false, "cbTele");
  307. Search("SearchTele", tbCustomerNo.CValue);
  308. UpdateForm(true, "cbTele");
  309. </Reload>
  310. </Events>
  311. </IKTextBox>
  312. <IKTextBox name="cbFax" DisplaySource="SaleBill.Fax_SaleBill" DataSource="Fax" DisplayMember="No_Fax">
  313. <Events>
  314. <Reload>
  315. UpdateForm(false, "cbFax");
  316. Search("SearchFax", tbCustomerNo.CValue);
  317. UpdateForm(true, "cbFax");
  318. </Reload>
  319. </Events>
  320. </IKTextBox>
  321. <IKTextBox name="txtPostalcode" DataSource="SaleBill.PostalCode_Customer"></IKTextBox>
  322. <IKTextBox name="txtSendAddr" DataSource="SaleBill.SendAddr_SaleBill"></IKTextBox>
  323. <IKComboBoxEx name="cbInvoiceTitle" DisplaySource="SaleBill.InvoiceTitle_Company" ValueSource="SaleBill.InvoiceAddress_Company" DataSource="Invoice" DisplayMember="Title_Invoice" ValueMember="Address_Invoice">
  324. <Events>
  325. <Reload>
  326. UpdateForm(false, "cbInvoiceTitle");
  327. Search("SearchInvoice", tbCustomerNo.CValue);
  328. UpdateForm(true, "cbInvoiceTitle");
  329. </Reload>
  330. <SelectedIndexChanged>
  331. txtAdress.CValue=cbInvoiceTitle.SelectedValue1;
  332. </SelectedIndexChanged>
  333. </Events>
  334. </IKComboBoxEx>
  335. <IKTextBox name="txtAdress" DataSource="SaleBill.InvoiceAddress_Company"></IKTextBox>
  336. <IKNumericTextBox name="ntbNumSum" DataSource="SaleBill.NumSum"></IKNumericTextBox>
  337. <IKNumericTextBox name="ntbTaxSum" DataSource="SaleBill.TaxAmount_SaleBill"></IKNumericTextBox>
  338. <IKNumericTextBox name="ntbMoneySum" DataSource="SaleBill.GoodsAmount_SaleBill"></IKNumericTextBox>
  339. <IKNumericTextBox name="ntbSum" DataSource="SaleBill.Amount_SaleBill"></IKNumericTextBox>
  340. <IKDataGridEx name="dgProduct" DataSource="SaleBillProduct" TableStyleIndex="0">
  341. <DataColumn Index="0" DataSource="SaleBillProduct.No_SaleBillProduct" />
  342. <DataColumn Index="1" DataSource="SaleBillProduct.No_Product" >
  343. <IKDataGridTextButtonColumn>
  344. <Events>
  345. <Click>
  346. @SetFlag=1;
  347. ShowSearchBox("ProductSearch","INFOMATION",#SaleBillProduct.No_Product);
  348. </Click>
  349. <SetFlagBeforeClick>
  350. @SetFlag=0;
  351. </SetFlagBeforeClick>
  352. </Events>
  353. </IKDataGridTextButtonColumn>
  354. </DataColumn>
  355. <DataColumn Index="2" DataSource="SaleBillProduct.Name_Product" />
  356. <DataColumn Index="3" DataSource="SaleBillProduct.Quantity_SaleBillProduct" />
  357. <DataColumn Index="4" DataSource="SaleBillProduct.Unit_Product" />
  358. <DataColumn Index="5" DataSource="SaleBillProduct.OrderPrice_SaleBillProduct" />
  359. <DataColumn Index="6" DataSource="SaleBillProduct.Discount_SaleBillProduct" />
  360. <DataColumn Index="7" DataSource="SaleBillProduct.UnitPrice_SaleBillProduct"/>
  361. <DataColumn Index="8" DataSource="SaleBillProduct.Amount_SaleBillProduct" />
  362. <DataColumn Index="9" DataSource="SaleBillProduct.Comment_SaleBillProduct" />
  363. <DataColumn Index="10" DataSource="SaleBillProduct.Name_BillType">
  364. <IKDataGridComboBoxColumn DisplaySourceEx="SaleBillProduct.Name_BillType" ValueSourceEx="SaleBillProduct.Type_FromBill" DataSourceEx="BillType" DisplayMemberEx="Name_BillType" ValueMemberEx="Value_BillType">
  365. <Events>
  366. <Reload>
  367. Search("SearchBillType");
  368. SetDataGridColumnDataSource(10,"dgProduct");
  369. </Reload>
  370. </Events>
  371. </IKDataGridComboBoxColumn>
  372. </DataColumn>
  373. <DataColumn Index="11" DataSource="SaleBillProduct.No_FromBill" />
  374. <DataColumn Index="12" DataSource="SaleBillProduct.No_FromBillProduct" />
  375. </IKDataGridEx>
  376. <IKDataGridEx name="dgRemark" DataSource="BillComment" TableStyleIndex="0">
  377. <DataColumn Index="0" DataSource="BillComment.Comment_BillComment" />
  378. </IKDataGridEx>
  379. <IKDataGridEx name="dgReportComment" DataSource="ReportComment" TableStyleIndex="0">
  380. <DataColumn Index="0" DataSource="ReportComment.Comment_ReportComment" />
  381. </IKDataGridEx>
  382. <IKButton name="btnDelelte">
  383. <Events>
  384. <Click>
  385. if(#SystemSetting.SaleAndOutDepot_SystemSetting )
  386. {
  387. if(Search("SearchOutDepot",#SaleBill.ID_SaleBill))
  388. {
  389. if(#OutDepot.Quantity_OutDepot > 0)
  390. {
  391. MessageBox("该单据已有相应的销售出库记录,作废失败!",@Title);
  392. return;
  393. }
  394. if(#OutDepot.Quantity_SaleRtn > 0)
  395. {
  396. MessageBox("该单据已有相应的销售退货记录,作废失败!",@Title);
  397. return;
  398. }
  399. if(#OutDepot.Quantity_InDepot > 0)
  400. {
  401. MessageBox("该单据已有相应的销售退货入库记录,作废失败!",@Title);
  402. return;
  403. }
  404. }
  405. }
  406. BeginUnAudit();
  407. #SaleBill.ID_Assessor = DBNull();
  408. #SaleBill.Name_Assessor = "";
  409. #SaleBill.TransBack_SaleBill=0;
  410. #SaleBill.Disable_SaleBill=true;
  411. #SaleBill.OutStatus_SaleBill="已作废";
  412. UnAudit(false);
  413. ChangeMode("View");
  414. cbOutStatus.Text="已作废";
  415. EndUnAudit();
  416. Search("UpdateCustomer",#SaleBill.ID_Customer,#SaleBill.Amount_SaleBill,"0");
  417. <Lable name="CountSum" />
  418. </Click>
  419. </Events>
  420. </IKButton>
  421. <IKButton name="btnCopy">
  422. <Events>
  423. <Click>
  424. ShowText("联系人:",#SaleBill.Name_Linkman,"联系电话:",#SaleBill.Tel_SaleBill,"传真:",#SaleBill.Fax_SaleBill,"发票抬头:",#SaleBill.InvoiceTitle_Company,"结算方式:",#SaleBill.GetMethod_SaleBill,"发货状态:",#SaleBill.OutStatus_SaleBill);
  425. </Click>
  426. </Events>
  427. </IKButton>
  428. <IKFormToolBar name="toolBar">
  429. <Events>
  430. <ClickFirst>
  431. if (Search("SearchSaleBillFirst",GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight(@Title,"特价单","查看"),GetCurrentUser(),GetFieldRight(@Title,"特批单","查看")))
  432. {
  433. @tp1=#SaleBill.No_SaleBill;
  434. if(!Search("SearchCustomersIsInRegionalLeader",#SaleBill.No_Customer, GetCurrentUser()))
  435. {
  436. ChangeMode("Search");
  437. tbNo.CValue=@tp1;
  438. MessageBox("你与客户不在同一个区域,不能查看!");
  439. tbNo.CValue="";
  440. return;
  441. }
  442. ChangeMode("View");
  443. <Lable name="CountSum" />
  444. }
  445. </ClickFirst>
  446. <ClickPrev>
  447. if (Search("SearchSaleBillPrevious", tbNo.CValue,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight(@Title,"特价单","查看"),GetCurrentUser(),GetFieldRight(@Title,"特批单","查看")))
  448. {
  449. @tp2=#SaleBill.No_SaleBill;
  450. if(!Search("SearchCustomersIsInRegionalLeader",#SaleBill.No_Customer, GetCurrentUser()))
  451. {
  452. ChangeMode("Search");
  453. tbNo.CValue=@tp2;
  454. MessageBox("你与客户不在同一个区域,不能查看!");
  455. tbNo.CValue="";
  456. return;
  457. }
  458. ChangeMode("View");
  459. <Lable name="CountSum" />
  460. }
  461. </ClickPrev>
  462. <ClickNext>
  463. if (Search("SearchSaleBillNext", tbNo.CValue,GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight(@Title,"特价单","查看"),GetCurrentUser(),GetFieldRight(@Title,"特批单","查看")))
  464. {
  465. @tp3=#SaleBill.No_SaleBill;
  466. if(!Search("SearchCustomersIsInRegionalLeader",#SaleBill.No_Customer, GetCurrentUser()))
  467. {
  468. ChangeMode("Search");
  469. tbNo.CValue=@tp3;
  470. MessageBox("你与客户不在同一个区域,不能查看!");
  471. tbNo.CValue="";
  472. return;
  473. }
  474. ChangeMode("View");
  475. <Lable name="CountSum" />
  476. }
  477. </ClickNext>
  478. <ClickLast>
  479. if (Search("SearchSaleBillLast",GetRight("客户基本资料","全权查看")?DBNull():GetLoginUserID(),GetFieldRight(@Title,"特价单","查看"),GetCurrentUser(),GetFieldRight(@Title,"特批单","查看")))
  480. {
  481. @tp4=#SaleBill.No_SaleBill;
  482. if(!Search("SearchCustomersIsInRegionalLeader",#SaleBill.No_Customer, GetCurrentUser()))
  483. {
  484. ChangeMode("Search");
  485. tbNo.CValue=@tp4;
  486. MessageBox("你与客户不在同一个区域,不能查看!");
  487. tbNo.CValue="";
  488. return;
  489. }
  490. ChangeMode("View");
  491. <Lable name="CountSum" />
  492. }
  493. </ClickLast>
  494. <ClickEmpty>
  495. ChangeMode("Search");
  496. </ClickEmpty>
  497. <ClickNew>
  498. <![CDATA[
  499. @NextNo = GetNextAutoNumber(true);
  500. if (!Equals(@NextNo, ""))
  501. {
  502. ChangeMode("New");
  503. #SaleBill.No_SaleBill = @NextNo;
  504. UpdateForm(true, "tbNo");
  505. }
  506. ]]>
  507. </ClickNew>
  508. <ClickSubmit>
  509. <Lable name="SubmitButtonClick" />
  510. if(@AuditMode)
  511. {
  512. <Lable name = "AuditLable"/>
  513. <Lable name="CountSum" />
  514. }
  515. </ClickSubmit>
  516. <ClickModify>
  517. ChangeMode("Modify");
  518. <Lable name="CountSum" />
  519. </ClickModify>
  520. <ClickDelete>
  521. Delete();
  522. ChangeMode("Search");
  523. </ClickDelete>
  524. <ClickPrint>
  525. ShowPrintBox("BillSearch",#SaleBill.No_SaleBill,#SaleBill.No_SaleBill,GetFieldRight(@Title,"特价单","查看")?"1":"0");
  526. </ClickPrint>
  527. <ClickAudit>
  528. @temptogetvalue=0;
  529. UpdateForm(true, "");
  530. if(@AuditMode)
  531. return;
  532. <Lable name = "AuditLable"/>
  533. <Lable name="CountSum" />
  534. <![CDATA[
  535. SuspendLayout();
  536. for (@i=0;@i<RowCount("#SaleBillProduct");@i=@i+1)
  537. {
  538. SetPosition("#SaleBillProduct",@i);
  539. Search("AddIndentBillOnNetProduct",#SaleBillProduct.No_FromBill,#SaleBillProduct.ID_Product,#SaleBillProduct.Quantity_SaleBillProduct);
  540. }
  541. ResumeLayout();
  542. Search("UpdateCustomer",#SaleBill.ID_Customer,#SaleBill.Amount_SaleBill,"1");
  543. Search("SearchCustomerWithNo", tbCustomerNo.CValue);
  544. @temptogetvalue= #Customer.ToGetBalance_Customer;
  545. Search("UpdateToGet",@temptogetvalue,tbNo.CValue);
  546. ntbToGet.CValue=@temptogetvalue;
  547. ]]>
  548. </ClickAudit>
  549. <ClickUnAudit>
  550. @temptogetvalue2=0;
  551. BeginUnAudit();
  552. #SaleBill.ID_Assessor = DBNull();
  553. #SaleBill.Name_Assessor = "";
  554. #SaleBill.TransBack_SaleBill=0;
  555. UnAudit();
  556. ChangeMode("View");
  557. EndUnAudit();
  558. <Lable name="CountSum" />
  559. <![CDATA[
  560. SuspendLayout();
  561. for (@i=0;@i<RowCount("#SaleBillProduct");@i=@i+1)
  562. {
  563. SetPosition("#SaleBillProduct",@i);
  564. Search("ReduceIndentBillOnNetProduct",#SaleBillProduct.No_FromBill,#SaleBillProduct.ID_Product,#SaleBillProduct.Quantity_SaleBillProduct);
  565. }
  566. ResumeLayout();
  567. Search("UpdateCustomer",#SaleBill.ID_Customer,#SaleBill.Amount_SaleBill,"0");
  568. Search("SearchToGet", tbNo.CValue);
  569. @temptogetvalue2= #SearchToGet.ToGet_SaleBill;
  570. ntbToGet.CValue=@temptogetvalue2;
  571. ]]>
  572. </ClickUnAudit>
  573. <ClickAssess>
  574. #SaleBill.Assess_SaleBill = 1;
  575. <Lable name = "AssessClick"/>
  576. toolBar.EnableAssess = false;
  577. toolBar.EnableUnAssess = GetRight(@Title,"取消审核");
  578. </ClickAssess>
  579. <ClickUnAssess>
  580. #SaleBill.Assess_SaleBill = 0;
  581. <Lable name = "AssessClick"/>
  582. toolBar.EnableAssess = GetRight(@Title,"审核");
  583. toolBar.EnableUnAssess = false;
  584. </ClickUnAssess>
  585. <ClickImport>
  586. ;
  587. </ClickImport>
  588. <ClickExport>
  589. ;
  590. </ClickExport>
  591. <ClickClose>
  592. ;
  593. </ClickClose>
  594. <ClickExpand>
  595. if(toolBar.ExpandForm==true)
  596. {
  597. pnRight.Visible=true;<!--PanelRight is not existed-->
  598. }
  599. else
  600. {
  601. pnRight.Visible=false;
  602. }
  603. </ClickExpand>
  604. <ClickImportItem>
  605. <![CDATA[
  606. if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="报价单")
  607. {
  608. ShowSearchBox("ImportPriceQueryBillControl","BILLCONVERT","#SaleBillProduct.Type_FromBill",23,"#SaleBillProduct.Name_BillType","报价单");
  609. }
  610. else if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="网上订单")
  611. {
  612. ShowSearchBox("ImportIndentBillOnNetControl","BILLCONVERT","#SaleBillProduct.Type_FromBill",25,"#SaleBillProduct.Name_BillType","网上订单");
  613. }
  614. else
  615. if((@Status == 1 || @Status == 3) && toolBar.MenuItemText=="本单据")
  616. {
  617. @importing=true;
  618. ShowSearchBox("BillSearch","INFOMATIONCOPYNODEPOT","SearchSaleBillWithNo1",false,"#SaleBill.ID_SaleBill","#SaleBill.No_SaleBill","#SaleBill.Date_SaleBill","#SaleBill.ID_Assessor","#SaleBill.Name_Assessor","#SaleBill.LastModUser_SaleBill","#SaleBill.LastModUserName","#SaleBill.Name_Creator","#SaleBill.ID_Creator","#SaleBillProduct.ID_SaleBillProduct","#BillComment.ID_BillComment","#ReportComment.ID_ReportComment",RowCount("#SaleBillProduct"));
  619. @importing=false;
  620. }
  621. ]]>
  622. <!--使用前先访问ToolBar的MenuItemText属性以确定选中的是那一项-->
  623. <Lable name="CountSum" />
  624. </ClickImportItem>
  625. <ClickExportItem>
  626. <![CDATA[
  627. if(toolBar.MenuItemText=="销货出库单")
  628. {
  629. ExportBillProductStart("#SaleOutDepotBillProduct.Type_FromBill",21,"#SaleOutDepotBillProduct.Name_FromBill","销货单","#SaleOutDepotBillProduct.No_FromBill",#SaleBill.No_SaleBill,"#SaleOutDepotBill.No_Customer",#SaleBill.No_Customer,"#SaleOutDepotBill.Name_Location",#SaleBill.Name_Location);
  630. SuspendLayout();
  631. for (@i=0;@i<=RowCount("#ReportComment")-1;@i=@i+1)
  632. {
  633. SetPosition("#ReportComment", @i);
  634. ExportBillCommand("ReportComment", "#ReportComment.Comment_ReportComment", #ReportComment.Comment_ReportComment);
  635. }
  636. ResumeLayout();
  637. ExportBillCommand("ReportComment", "#ReportComment.Comment_ReportComment", #SaleBill.OutStatus_SaleBill);
  638. ExportBillProduct("dgProduct","#SaleBillProduct","#SaleOutDepotBillProduct.No_FromBillProduct","#SaleBillProduct.No_SaleBillProduct");
  639. }
  640. else if(toolBar.MenuItemText=="采购订单")
  641. {
  642. ExportBillProductStart("#PurchaseOrderBillProduct.Comment_PurchaseOrderBillProduct",#SaleBill.No_SaleBill,"#PurchaseOrderBill.TaxCurrency_PurchaseOrderBill",#SaleBill.TaxCurrency_SaleBill);
  643. ExportBillProduct("dgProduct","#SaleBillProduct","#PurchaseOrderBillProduct.No_Product","#SaleBillProduct.No_Product");
  644. }
  645. else if(toolBar.MenuItemText=="询价单")
  646. {
  647. ExportBillProductStart("#PurchaseQueryBillProduct.Comment_PurchaseQueryBillProduct",#SaleBill.No_SaleBill,"#PurchaseQueryBill.TaxCurrency_PurchaseQueryBill",#SaleBill.TaxCurrency_SaleBill);
  648. ExportBillProduct("dgProduct","#SaleBillProduct","#PurchaseQueryBillProduct.No_Product","#SaleBillProduct.No_Product");
  649. }
  650. else if(toolBar.MenuItemText=="销售退货单")
  651. {
  652. if(Search("SearchContrSOB"))
  653. {
  654. ExportBillProductStart("#SaleRtnBillProduct.Type_FromBill",21,"#SaleRtnBillProduct.FromBill_SaleRtnBillProduct","销货单","#SaleRtnBillProduct.No_FromBill",#SaleBill.No_SaleBill,"#SaleRtnBill.No_Customer",#SaleBill.No_Customer,"#SaleRtnBill.Name_Location",#SaleBill.Name_Location,"#SaleRtnBill.TaxCurrency_SaleRtnBill",#SaleBill.TaxCurrency_SaleBill,"#SaleRtnBill.ID_Principal",#SaleBill.ID_Principal,"#SaleRtnBill.Principal_SaleRtnBill",#SaleBill.Principal_SaleBill,"#SaleRtnBill.No_Principal",#SaleBill.No_Principal);
  655. ExportBillProduct("dgProduct","#SaleBillProduct","#SaleRtnBillProduct.No_FromBillProduct","#SaleBillProduct.No_SaleBillProduct");
  656. }
  657. else
  658. {
  659. ExportBillProductStart("#SaleRtnBill.No_Customer",#SaleBill.No_Customer,"#SaleRtnBillProduct.Comment_SaleRtnBillProduct","销货单:"+#SaleBill.No_SaleBill,"#SaleRtnBill.Name_Location",#SaleBill.Name_Location,"#SaleRtnBill.TaxCurrency_SaleRtnBill",#SaleBill.TaxCurrency_SaleBill,"#SaleRtnBill.ID_Principal",#SaleBill.ID_Principal,"#SaleRtnBill.Principal_SaleRtnBill",#SaleBill.Principal_SaleBill,"#SaleRtnBill.No_Principal",SaleBill.No_Principal);
  660. ExportBillProduct("dgProduct","#SaleBillProduct","#SaleRtnBillProduct.ProductNo_SaleRtnBillProduct","#SaleBillProduct.No_Product");
  661. }
  662. }
  663. ]]>
  664. </ClickExportItem>
  665. </Events>
  666. </IKFormToolBar>
  667. </Controls>
  668. <Tables>
  669. <Table name="SaleBillProduct">
  670. <Events>
  671. <ColumnsChanged>
  672. <Name_BillType>
  673. <![CDATA[
  674. #SaleBillProduct.ID_IndentBillOnNetProduct = DBNull();
  675. if (Equals(#SaleBillProduct.Type_FromBill,23) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  676. {
  677. if (Search("SearchFromBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  678. {
  679. if(!Equals(#FromBillProduct.SuspendDate_Product,DBNull()))
  680. {
  681. MessageBox("该产品已停用!",@Title);
  682. }
  683. if(#FromBillProduct.TaxCurrency_PriceQueryBill!=cbTaxCurrency.Text)
  684. {
  685. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  686. }
  687. #SaleBillProduct.ID_Product = #FromBillProduct.ID_Product;
  688. #SaleBillProduct.No_Product = #FromBillProduct.No_Product;
  689. #SaleBillProduct.Name_Product = #FromBillProduct.Name_Product;
  690. #SaleBillProduct.Quantity_SaleBillProduct = #FromBillProduct.Quantity_PriceQueryBillProduct;
  691. #SaleBillProduct.Unit_Product = #FromBillProduct.Unit_Product;
  692. #SaleBillProduct.UnitPrice_SaleBillProduct = #FromBillProduct.UnitPrice_PriceQueryBillProduct;
  693. #SaleBillProduct.Discount_SaleBillProduct = #FromBillProduct.Discount_PriceQueryBillProduct;
  694. #SaleBillProduct.LowSalePrice_Product = #FromBillProduct.LowSalePrice_Product;
  695. #SaleBillProduct.OrderPrice_SaleBillProduct = #FromBillProduct.OrderPrice_PriceQueryBillProduct;
  696. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  697. }
  698. }
  699. if(Equals(#SaleBillProduct.Type_FromBill,24) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  700. {
  701. if (Search("SearchIndentBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  702. {
  703. if(!Equals(#IndentBillProduct.SuspendDate_Product,DBNull()))
  704. {
  705. MessageBox("该产品已停用!",@Title);
  706. }
  707. if(#IndentBillProduct.TaxCurrency_IndentBill!=cbTaxCurrency.Text)
  708. {
  709. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  710. }
  711. #SaleBillProduct.ID_Product = #IndentBillProduct.ID_Product;
  712. #SaleBillProduct.No_Product = #IndentBillProduct.No_Product;
  713. #SaleBillProduct.Name_Product = #IndentBillProduct.Name_Product;
  714. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillProduct.Quantity_IndentBillProduct;
  715. #SaleBillProduct.Unit_Product = #IndentBillProduct.Unit_Product;
  716. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillProduct.UnitPrice_IndentBillProduct;
  717. #SaleBillProduct.Discount_SaleBillProduct = #IndentBillProduct.Discount_IndentBillProduct;
  718. #SaleBillProduct.LowSalePrice_Product = #IndentBillProduct.LowSalePrice_Product;
  719. #SaleBillProduct.OrderPrice_SaleBillProduct = #IndentBillProduct.OrderPrice_IndentBillProduct;
  720. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  721. }
  722. }
  723. if(Equals(#SaleBillProduct.Type_FromBill,25) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  724. {
  725. if (Search("SearchIndentBillOnNetProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  726. {
  727. if(!Equals(#IndentBillOnNetProduct.SuspendDate_Product,DBNull()))
  728. {
  729. MessageBox("该产品已停用!",@Title);
  730. }
  731. if(#IndentBillOnNetProduct.TaxCurrency_IndentBillOnNet!=cbTaxCurrency.Text)
  732. {
  733. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  734. }
  735. #SaleBillProduct.ID_Product = #IndentBillOnNetProduct.ID_Product;
  736. #SaleBillProduct.No_Product = #IndentBillOnNetProduct.No_Product;
  737. #SaleBillProduct.Name_Product = #IndentBillOnNetProduct.Name_Product;
  738. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct;
  739. #SaleBillProduct.Unit_Product = #IndentBillOnNetProduct.Unit_Product;
  740. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillOnNetProduct.UnitPrice_IndentBillOnNetProduct;
  741. #SaleBillProduct.LowSalePrice_Product = #IndentBillOnNetProduct.LowSalePrice_Product;
  742. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  743. #SaleBillProduct.ID_IndentBillOnNetProduct = #IndentBillOnNetProduct.ID_IndentBillOnNetProduct;
  744. }
  745. }
  746. ]]>
  747. <Lable name="CountSum" />
  748. </Name_BillType>
  749. <No_FromBill>
  750. <![CDATA[
  751. #SaleBillProduct.ID_IndentBillOnNetProduct = DBNull();
  752. if (Equals(#SaleBillProduct.Type_FromBill,23) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  753. {
  754. if (Search("SearchFromBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  755. {
  756. if(!Equals(#FromBillProduct.SuspendDate_Product,DBNull()))
  757. {
  758. MessageBox("该产品已停用!",@Title);
  759. }
  760. if(#FromBillProduct.TaxCurrency_PriceQueryBill!=cbTaxCurrency.Text)
  761. {
  762. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  763. }
  764. #SaleBillProduct.ID_Product = #FromBillProduct.ID_Product;
  765. #SaleBillProduct.No_Product = #FromBillProduct.No_Product;
  766. #SaleBillProduct.Name_Product = #FromBillProduct.Name_Product;
  767. #SaleBillProduct.Quantity_SaleBillProduct = #FromBillProduct.Quantity_PriceQueryBillProduct;
  768. #SaleBillProduct.Unit_Product = #FromBillProduct.Unit_Product;
  769. #SaleBillProduct.UnitPrice_SaleBillProduct = #FromBillProduct.UnitPrice_PriceQueryBillProduct;
  770. #SaleBillProduct.Discount_SaleBillProduct = #FromBillProduct.Discount_PriceQueryBillProduct;
  771. #SaleBillProduct.LowSalePrice_Product = #FromBillProduct.LowSalePrice_Product;
  772. #SaleBillProduct.OrderPrice_SaleBillProduct = #FromBillProduct.OrderPrice_PriceQueryBillProduct;
  773. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  774. }
  775. }
  776. if(Equals(#SaleBillProduct.Type_FromBill,24) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  777. {
  778. if (Search("SearchIndentBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  779. {
  780. if(!Equals(#IndentBillProduct.SuspendDate_Product,DBNull()))
  781. {
  782. MessageBox("该产品已停用!",@Title);
  783. }
  784. if(#IndentBillProduct.TaxCurrency_IndentBill!=cbTaxCurrency.Text)
  785. {
  786. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  787. }
  788. #SaleBillProduct.ID_Product = #IndentBillProduct.ID_Product;
  789. #SaleBillProduct.No_Product = #IndentBillProduct.No_Product;
  790. #SaleBillProduct.Name_Product = #IndentBillProduct.Name_Product;
  791. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillProduct.Quantity_IndentBillProduct;
  792. #SaleBillProduct.Unit_Product = #IndentBillProduct.Unit_Product;
  793. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillProduct.UnitPrice_IndentBillProduct;
  794. #SaleBillProduct.Discount_SaleBillProduct = #IndentBillProduct.Discount_IndentBillProduct;
  795. #SaleBillProduct.LowSalePrice_Product = #IndentBillProduct.LowSalePrice_Product;
  796. #SaleBillProduct.OrderPrice_SaleBillProduct = #IndentBillProduct.OrderPrice_IndentBillProduct;
  797. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  798. }
  799. }
  800. if(Equals(#SaleBillProduct.Type_FromBill,25) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  801. {
  802. if (Search("SearchIndentBillOnNetProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  803. {
  804. if(!Equals(#IndentBillOnNetProduct.SuspendDate_Product,DBNull()))
  805. {
  806. MessageBox("该产品已停用!",@Title);
  807. }
  808. if(#IndentBillOnNetProduct.TaxCurrency_IndentBillOnNet!=cbTaxCurrency.Text)
  809. {
  810. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  811. }
  812. #SaleBillProduct.ID_Product = #IndentBillOnNetProduct.ID_Product;
  813. #SaleBillProduct.No_Product = #IndentBillOnNetProduct.No_Product;
  814. #SaleBillProduct.Name_Product = #IndentBillOnNetProduct.Name_Product;
  815. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct;
  816. #SaleBillProduct.Unit_Product = #IndentBillOnNetProduct.Unit_Product;
  817. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillOnNetProduct.UnitPrice_IndentBillOnNetProduct;
  818. #SaleBillProduct.LowSalePrice_Product = #IndentBillOnNetProduct.LowSalePrice_Product;
  819. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  820. #SaleBillProduct.ID_IndentBillOnNetProduct = #IndentBillOnNetProduct.ID_IndentBillOnNetProduct;
  821. }
  822. }
  823. ]]>
  824. <Lable name="CountSum" />
  825. </No_FromBill>
  826. <No_FromBillProduct>
  827. <![CDATA[
  828. #SaleBillProduct.ID_IndentBillOnNetProduct = DBNull();
  829. if (Equals(#SaleBillProduct.Type_FromBill,23) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  830. {
  831. if (Search("SearchFromBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  832. {
  833. if(!Equals(#FromBillProduct.SuspendDate_Product,DBNull()))
  834. {
  835. MessageBox("该产品已停用!",@Title);
  836. }
  837. if(#FromBillProduct.TaxCurrency_PriceQueryBill!=cbTaxCurrency.Text)
  838. {
  839. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  840. }
  841. #SaleBillProduct.ID_Product = #FromBillProduct.ID_Product;
  842. #SaleBillProduct.No_Product = #FromBillProduct.No_Product;
  843. #SaleBillProduct.Name_Product = #FromBillProduct.Name_Product;
  844. #SaleBillProduct.Quantity_SaleBillProduct = #FromBillProduct.Quantity_PriceQueryBillProduct;
  845. #SaleBillProduct.Unit_Product = #FromBillProduct.Unit_Product;
  846. #SaleBillProduct.UnitPrice_SaleBillProduct = #FromBillProduct.UnitPrice_PriceQueryBillProduct;
  847. #SaleBillProduct.Discount_SaleBillProduct = #FromBillProduct.Discount_PriceQueryBillProduct;
  848. #SaleBillProduct.LowSalePrice_Product = #FromBillProduct.LowSalePrice_Product;
  849. #SaleBillProduct.OrderPrice_SaleBillProduct = #FromBillProduct.OrderPrice_PriceQueryBillProduct;
  850. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  851. }
  852. }
  853. if(Equals(#SaleBillProduct.Type_FromBill,24) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  854. {
  855. if (Search("SearchIndentBillProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  856. {
  857. if(!Equals(#IndentBillProduct.SuspendDate_Product,DBNull()))
  858. {
  859. MessageBox("该产品已停用!",@Title);
  860. }
  861. if(#IndentBillProduct.TaxCurrency_IndentBill!=cbTaxCurrency.Text)
  862. {
  863. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  864. }
  865. #SaleBillProduct.ID_Product = #IndentBillProduct.ID_Product;
  866. #SaleBillProduct.No_Product = #IndentBillProduct.No_Product;
  867. #SaleBillProduct.Name_Product = #IndentBillProduct.Name_Product;
  868. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillProduct.Quantity_IndentBillProduct;
  869. #SaleBillProduct.Unit_Product = #IndentBillProduct.Unit_Product;
  870. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillProduct.UnitPrice_IndentBillProduct;
  871. #SaleBillProduct.Discount_SaleBillProduct = #IndentBillProduct.Discount_IndentBillProduct;
  872. #SaleBillProduct.LowSalePrice_Product = #IndentBillProduct.LowSalePrice_Product;
  873. #SaleBillProduct.OrderPrice_SaleBillProduct = #IndentBillProduct.OrderPrice_IndentBillProduct;
  874. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  875. }
  876. }
  877. if(Equals(#SaleBillProduct.Type_FromBill,25) && !Equals(#SaleBillProduct.Type_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBill,"") && !Equals(#SaleBillProduct.No_FromBill,DBNull()) && !Equals(#SaleBillProduct.No_FromBillProduct,"") && !Equals(#SaleBillProduct.No_FromBillProduct,DBNull()))
  878. {
  879. if (Search("SearchIndentBillOnNetProductWithNo", #SaleBillProduct.No_FromBill, #SaleBillProduct.No_FromBillProduct))
  880. {
  881. if(!Equals(#IndentBillOnNetProduct.SuspendDate_Product,DBNull()))
  882. {
  883. MessageBox("该产品已停用!",@Title);
  884. }
  885. if(#IndentBillOnNetProduct.TaxCurrency_IndentBillOnNet!=cbTaxCurrency.Text)
  886. {
  887. MessageBox("来源单据与当前单据税别不一致,请检查后修改!",@Title);
  888. }
  889. #SaleBillProduct.ID_Product = #IndentBillOnNetProduct.ID_Product;
  890. #SaleBillProduct.No_Product = #IndentBillOnNetProduct.No_Product;
  891. #SaleBillProduct.Name_Product = #IndentBillOnNetProduct.Name_Product;
  892. #SaleBillProduct.Quantity_SaleBillProduct = #IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct;
  893. #SaleBillProduct.Unit_Product = #IndentBillOnNetProduct.Unit_Product;
  894. #SaleBillProduct.UnitPrice_SaleBillProduct = #IndentBillOnNetProduct.UnitPrice_IndentBillOnNetProduct;
  895. #SaleBillProduct.LowSalePrice_Product = #IndentBillOnNetProduct.LowSalePrice_Product;
  896. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  897. #SaleBillProduct.ID_IndentBillOnNetProduct = #IndentBillOnNetProduct.ID_IndentBillOnNetProduct;
  898. }
  899. }
  900. ]]>
  901. <Lable name="CountSum" />
  902. </No_FromBillProduct>
  903. <No_Product>
  904. <![CDATA[
  905. if (!Equals(#SaleBillProduct.No_Product,"") && !Equals(#SaleBillProduct.No_Product,DBNull()))
  906. {
  907. if (Search("SearchProductWithNo",#SaleBillProduct.No_Product))
  908. {
  909. if(!Equals(#Product.SuspendDate_Product,DBNull()))
  910. {
  911. MessageBox("该产品已停用!",@Title);
  912. }
  913. #SaleBillProduct.ID_Product = #Product.ID_Product;
  914. #SaleBillProduct.Name_Product = #Product.Name_Product;
  915. #SaleBillProduct.Unit_Product = #Product.Unit_Product;
  916. if(cbTaxCurrency.Text=="内含")
  917. #SaleBillProduct.OrderPrice_SaleBillProduct=FormatNumber(#Product.Price_Product*(1+@CessOut),@PriceDecimal);
  918. else
  919. #SaleBillProduct.OrderPrice_SaleBillProduct=#Product.Price_Product;
  920. if(#SaleBillProduct.Discount_SaleBillProduct!=0)
  921. {
  922. #SaleBillProduct.UnitPrice_SaleBillProduct = FormatNumber(#SaleBillProduct.OrderPrice_SaleBillProduct*#SaleBillProduct.Discount_SaleBillProduct/100,@PriceDecimal);
  923. }
  924. else
  925. {
  926. if(Search("SearchRelation",#SaleBillProduct.No_Product,tbCustomerNo.CValue))
  927. {
  928. if(cbTaxCurrency.Text=="内含")
  929. #SaleBillProduct.UnitPrice_SaleBillProduct=#PriceReference.UnitPriceWithTax_PriceReference;
  930. else
  931. #SaleBillProduct.UnitPrice_SaleBillProduct = #PriceReference.UnitPrice_PriceReference;
  932. if(#SaleBillProduct.OrderPrice_SaleBillProduct==0)
  933. #SaleBillProduct.Discount_SaleBillProduct=100;
  934. else
  935. #SaleBillProduct.Discount_SaleBillProduct =#SaleBillProduct.UnitPrice_SaleBillProduct/#SaleBillProduct.OrderPrice_SaleBillProduct*100 ;
  936. }
  937. else
  938. {
  939. #SaleBillProduct.UnitPrice_SaleBillProduct = #SaleBillProduct.OrderPrice_SaleBillProduct;
  940. #SaleBillProduct.Discount_SaleBillProduct=100;
  941. }
  942. }
  943. #SaleBillProduct.LowSalePrice_Product = #Product.LowSalePrice_Product;
  944. #SaleBillProduct.Amount_SaleBillProduct =FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, @PriceDecimal);
  945. }
  946. else
  947. {
  948. MessageBox("该产品不存在!",@Title);
  949. #SaleBillProduct.ID_Product = GuidEmpty();
  950. #SaleBillProduct.Name_Product = "";
  951. #SaleBillProduct.Unit_Product = "";
  952. #SaleBillProduct.Quantity_SaleBillProduct = 0;
  953. #SaleBillProduct.UnitPrice_SaleBillProduct = 0;
  954. #SaleBillProduct.Amount_SaleBillProduct = 0;
  955. #SaleBillProduct.OrderPrice_SaleBillProduct = 0;
  956. @temp = ShowSearchBox("InputSearchProduct","INFOMATION",#SaleBillProduct.No_Product);
  957. if(@temp != "")
  958. {
  959. ResumeColumnEvent("#SaleBillProduct.No_Product");
  960. #SaleBillProduct.No_Product = @temp;
  961. ClearColumnEvent();
  962. }
  963. }
  964. }
  965. else
  966. {
  967. #SaleBillProduct.ID_Product = GuidEmpty();
  968. #SaleBillProduct.Name_Product = "";
  969. #SaleBillProduct.Unit_Product = "";
  970. #SaleBillProduct.Quantity_SaleBillProduct = 0;
  971. #SaleBillProduct.UnitPrice_SaleBillProduct = 0;
  972. #SaleBillProduct.Amount_SaleBillProduct = 0;
  973. #SaleBillProduct.OrderPrice_SaleBillProduct = 0;
  974. }
  975. ]]>
  976. <Lable name="CountSum" />
  977. </No_Product>
  978. <Quantity_SaleBillProduct>
  979. <![CDATA[
  980. #SaleBillProduct.Quantity_SaleBillProduct = FormatNumber(#SaleBillProduct.Quantity_SaleBillProduct, @PriceDecimal);
  981. UpdateForm(false, "cbLocation");
  982. if (!Equals(#SaleBill.ID_Location,DBNull()) && !Equals(#SaleBillProduct.Quantity_SaleBillProduct,DBNull()))
  983. {
  984. @AvaQuantity = AvailableQty(#SaleBillProduct.ID_Product,#SaleBill.ID_Location);
  985. if (#SaleBillProduct.Quantity_SaleBillProduct > @AvaQuantity)
  986. {
  987. @strMessage = #SaleBillProduct.No_Product +" 目前可用数量为" + (string)@AvaQuantity + ",不能满足此次销货需求!";
  988. MessageBox(@strMessage,@Title);
  989. }
  990. }
  991. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  992. ]]>
  993. <Lable name="CountSum" />
  994. </Quantity_SaleBillProduct>
  995. <UnitPrice_SaleBillProduct>
  996. #SaleBillProduct.UnitPrice_SaleBillProduct = FormatNumber(#SaleBillProduct.UnitPrice_SaleBillProduct, @PriceDecimal);
  997. if(#SaleBillProduct.OrderPrice_SaleBillProduct==0)
  998. #SaleBillProduct.Discount_SaleBillProduct=100;
  999. else
  1000. #SaleBillProduct.Discount_SaleBillProduct =#SaleBillProduct.UnitPrice_SaleBillProduct/#SaleBillProduct.OrderPrice_SaleBillProduct*100;
  1001. #SaleBillProduct.Amount_SaleBillProduct = FormatNumber(#SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  1002. <Lable name="CountSum" />
  1003. </UnitPrice_SaleBillProduct>
  1004. <Discount_SaleBillProduct>
  1005. #SaleBillProduct.Discount_SaleBillProduct = #SaleBillProduct.Discount_SaleBillProduct;
  1006. if(#SaleBillProduct.Discount_SaleBillProduct==0)
  1007. {
  1008. if(Search("SearchRelation",#SaleBillProduct.No_Product,tbCustomerNo.CValue))
  1009. {
  1010. if(cbTaxCurrency.Text=="内含")
  1011. #SaleBillProduct.UnitPrice_SaleBillProduct=#PriceReference.UnitPriceWithTax_PriceReference;
  1012. else
  1013. #SaleBillProduct.UnitPrice_SaleBillProduct = #PriceReference.UnitPrice_PriceReference;
  1014. if(#SaleBillProduct.OrderPrice_SaleBillProduct==0)
  1015. #SaleBillProduct.Discount_SaleBillProduct=100;
  1016. else
  1017. #SaleBillProduct.Discount_SaleBillProduct =#SaleBillProduct.UnitPrice_SaleBillProduct/#SaleBillProduct.OrderPrice_SaleBillProduct*100;
  1018. }
  1019. else
  1020. {
  1021. #SaleBillProduct.UnitPrice_SaleBillProduct = #SaleBillProduct.OrderPrice_SaleBillProduct;
  1022. #SaleBillProduct.Discount_SaleBillProduct=100;
  1023. }
  1024. }
  1025. else
  1026. {
  1027. #SaleBillProduct.UnitPrice_SaleBillProduct =FormatNumber( #SaleBillProduct.OrderPrice_SaleBillProduct * #SaleBillProduct.Discount_SaleBillProduct/100,@PriceDecimal);
  1028. }
  1029. #SaleBillProduct.Amount_SaleBillProduct =FormatNumber( #SaleBillProduct.UnitPrice_SaleBillProduct * #SaleBillProduct.Quantity_SaleBillProduct, #SystemSetting.PriceDecimal_SystemSetting);
  1030. <Lable name="CountSum" />
  1031. </Discount_SaleBillProduct>
  1032. </ColumnsChanged>
  1033. <RowDeleted>
  1034. <Lable name="CountSum" />
  1035. </RowDeleted>
  1036. </Events>
  1037. </Table>
  1038. </Tables>
  1039. <LockInfomation LockID="ID_SaleBill" LockNO="No_SaleBill" LockSearchFunction="SearchSaleBillWithNo" LockAudit="ID_Assessor"/>
  1040. <LogInfomation LogNO="#SaleBill.No_SaleBill" RecordFormField="" RecordDataGridField="#SaleBillProduct.No_Product,#SaleBillProduct.Quantity_SaleBillProduct,#SaleBillProduct.Amount_SaleBillProduct"/>
  1041. <ChildFormsCheck ChildForm="ImportPriceQueryBillControl" Question="#PriceQueryBill.StateDay_PriceQueryBill" Value="无效" Message="此报价单的报价已超出有效期限,确认要转单吗?"/>
  1042. <ChildForms>
  1043. <ChildForm name="BillSearch" DataSource="SaleBill" SearchFunction="SearchAllBill" SearchFunctionCondition="SearchBillCondition" SearchFunctionByNo="SearchSaleBillWithNo">
  1044. <DataColumn Index="0" MappingName="#SaleBill.No_SaleBill" HeaderText="销售单号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1045. <DataColumn Index="1" MappingName="#SaleBill.Date_SaleBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1046. <DataColumn Index="2" MappingName="#SaleBill.No_Customer" HeaderText="客户编号" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1047. <DataColumn Index="3" MappingName="#SaleBill.ShortName_Customer" HeaderText="客户名称" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1048. <DataColumn Index="4" MappingName="#SaleBill.Principal_SaleBill" HeaderText="业务负责" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1049. <DataColumn Index="5" MappingName="#SaleBill.TaxCurrency_SaleBill" HeaderText="税别" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1050. <DataColumn Index="5" MappingName="#SaleBill.Name_Linkman" HeaderText="联系人" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1051. <DataColumn Index="6" MappingName="#SaleBill.Tel_SaleBill" HeaderText="电话" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1052. <DataColumn Index="7" MappingName="#SaleBill.Fax_SaleBill" HeaderText="传真" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1053. <DataColumn Index="8" MappingName="#SaleBill.statu" HeaderText="单据状态" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1054. </ChildForm>
  1055. <ChildForm name="CustomerSearch" DataSource="Customer" SearchFunction="SearchAllCustomer" SearchFunctionCondition="SearchCustomerCondition" SearchFunctionByNo="" MappingName="客户">
  1056. <DataColumn Index="0" MappingName="#Customer.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1057. <DataColumn Index="1" MappingName="#Customer.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1058. <DataColumn Index="2" MappingName="#Customer.Type_Customer" HeaderText="客户类型" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1059. <DataColumn Index="3" MappingName="#Customer.Level_Customer" HeaderText="客户等级" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1060. <DataColumn Index="4" MappingName="#Customer.No_RegionalLeader" HeaderText="所属区域" Width="75" ColumnType="IKDataGridTextBoxColumn"/>
  1061. <DataColumn Index="5" MappingName="#Customer.IsGeneric_Customer" HeaderText="一般客户" Width="75" ColumnType="IKDataGridBoolColumn"/>
  1062. <DataColumn Index="6" MappingName="#Customer.Zone_Customer" HeaderText="地区" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1063. <DataColumn Index="7" MappingName="#Customer.SendAddr_Customer" HeaderText="送货地址" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1064. <DataColumn Index="8" MappingName="#Customer.Name_Linkman" HeaderText="主要联系人" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1065. <DataColumn Index="9" MappingName="#Customer.No_Telephone" HeaderText="客户电话" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1066. <DataColumn Index="10" MappingName="#Customer.No_Fax" HeaderText="传真" Width="90" ColumnType="IKDataGridTextBoxColumn"/>
  1067. </ChildForm>
  1068. <ChildForm name="ProductSearch" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品" ReturnDataSource="SaleBillProduct" ShowCheckBox="true">
  1069. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn" ReturnMappingName="#SaleBillProduct.No_Product"/>
  1070. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1071. <DataColumn Index="2" MappingName="#Product.Type_Product" HeaderText="产品类型" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1072. <DataColumn Index="3" MappingName="#Product.Price_Product" HeaderText="标准售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  1073. <DataColumn Index="4" MappingName="#Product.LowSalePrice_Product" HeaderText="最低售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  1074. <DataColumn Index="5" MappingName="#Product.SafetyQty_Product" HeaderText="安全存量" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1075. </ChildForm>
  1076. <ChildForm name="InputSearchProduct" DataSource="Product" SearchFunction="SearchAllProduct" SearchFunctionByNo="" MappingName="产品" >
  1077. <DataColumn Index="0" MappingName="#Product.No_Product" HeaderText="产品编号" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1078. <DataColumn Index="1" MappingName="#Product.Name_Product" HeaderText="产品简称" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1079. <DataColumn Index="2" MappingName="#Product.Type_Product" HeaderText="产品类型" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1080. <DataColumn Index="3" MappingName="#Product.Price_Product" HeaderText="标准售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  1081. <DataColumn Index="4" MappingName="#Product.LowSalePrice_Product" HeaderText="最低售价" Width="120" ColumnType="IKDataGridTextBoxColumn" Format="F2"/>
  1082. <DataColumn Index="5" MappingName="#Product.SafetyQty_Product" HeaderText="安全存量" Width="120" ColumnType="IKDataGridTextBoxColumn"/>
  1083. </ChildForm>
  1084. <ChildForm name="ImportPriceQueryBillControl" >
  1085. <DataGridIndex DataSource="PriceQueryBill" SearchFunction="SearchAllPriceQueryBill" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleBillProduct">
  1086. <DataColumn Index="0" MappingName="#PriceQueryBill.No_PriceQueryBill" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.No_FromBill"/>
  1087. <DataColumn Index="1" MappingName="#PriceQueryBill.Date_PriceQueryBill" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1088. <DataColumn Index="2" MappingName="#PriceQueryBill.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleBill.No_Customer"/>
  1089. <DataColumn Index="3" MappingName="#PriceQueryBill.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1090. <DataColumn Index="4" MappingName="#PriceQueryBill.State_PriceQueryBill" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1091. <DataColumn Index="5" MappingName="#PriceQueryBill.StateDay_PriceQueryBill" HeaderText="有效单据" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1092. <DataColumn Index="6" MappingName="#PriceQueryBill.TaxCurrency_PriceQueryBill" HeaderText="税别" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleBill.TaxCurrency_SaleBill" />
  1093. </DataGridIndex>
  1094. <DataGridIndex DataSource="PriceQueryBillProduct" SearchFunction="SearchAllPriceQueryBillProduct" SearchFunctionByNo="" MappingName="">
  1095. <DataColumn Index="0" MappingName="#PriceQueryBillProduct.No_Product" HeaderText="产品编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1096. <DataColumn Index="1" MappingName="#PriceQueryBillProduct.No_PriceQueryBillProduct" HeaderText="产品序号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.No_FromBillProduct"/>
  1097. <DataColumn Index="2" MappingName="#PriceQueryBillProduct.Name_Product" HeaderText="产品名称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1098. <DataColumn Index="3" MappingName="#PriceQueryBillProduct.Quantity_PriceQueryBillProduct" HeaderText="数量" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  1099. <DataColumn Index="4" MappingName="#PriceQueryBillProduct.UnitPrice_PriceQueryBillProduct" HeaderText="单价" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2"/>
  1100. <DataColumn Index="5" MappingName="#PriceQueryBillProduct.Discount_PriceQueryBillProduct" HeaderText="折扣" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.Discount_SaleBillProduct" Format="F2"/>
  1101. </DataGridIndex>
  1102. </ChildForm>
  1103. <ChildForm name="ImportIndentBillOnNetControl" >
  1104. <DataGridIndex DataSource="IndentBillOnNet" SearchFunction="SearchAllIndentBillOnNet" SearchFunctionByNo="" MappingName="" ReturnDataSource="SaleBillProduct">
  1105. <DataColumn Index="0" MappingName="#IndentBillOnNet.No_IndentBillOnNet" HeaderText="单据编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.No_FromBill"/>
  1106. <DataColumn Index="1" MappingName="#IndentBillOnNet.Date_IndentBillOnNet" HeaderText="制单日期" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1107. <DataColumn Index="2" MappingName="#IndentBillOnNet.No_Customer" HeaderText="客户编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleBill.No_Customer"/>
  1108. <DataColumn Index="3" MappingName="#IndentBillOnNet.ShortName_Customer" HeaderText="客户简称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1109. <DataColumn Index="4" MappingName="#IndentBillOnNet.State_IndentBillOnNet" HeaderText="单据状态" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1110. <DataColumn Index="5" MappingName="#IndentBillOnNet.TaxCurrency_IndentBillOnNet" HeaderText="税别" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="parent" ReturnMappingName="#SaleBill.TaxCurrency_SaleBill" />
  1111. </DataGridIndex>
  1112. <DataGridIndex DataSource="IndentBillOnNetProduct" SearchFunction="SearchAllIndentBillOnNetProduct" SearchFunctionByNo="" MappingName="">
  1113. <DataColumn Index="0" MappingName="#IndentBillOnNetProduct.No_Product" HeaderText="产品编号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.No_Product"/>
  1114. <DataColumn Index="1" MappingName="#IndentBillOnNetProduct.No_IndentBillOnNetProduct" HeaderText="产品序号" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" ReturnMappingName="#SaleBillProduct.No_FromBillProduct"/>
  1115. <DataColumn Index="2" MappingName="#IndentBillOnNetProduct.Name_Product" HeaderText="产品名称" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child"/>
  1116. <DataColumn Index="3" MappingName="#IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct" HeaderText="数量" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2" ReturnMappingName="#SaleBillProduct.Quantity_SaleBillProduct"/>
  1117. <DataColumn Index="4" MappingName="#IndentBillOnNetProduct.OrderPrice_IndentBillOnNetProduct" HeaderText="单价" Width="90" ColumnType="IKDataGridTextBoxColumn" ReturnPath="child" Format="F2" ReturnMappingName="#SaleBillProduct.OrderPrice_SaleBillProduct"/>
  1118. </DataGridIndex>
  1119. </ChildForm>
  1120. </ChildForms>
  1121. <FormatString>
  1122. <Format name="SearchCustomerCondition">
  1123. if(GetRight("客户基本资料","全权查看"))
  1124. {
  1125. FormatString("");
  1126. }
  1127. else
  1128. {
  1129. FormatString(" Customer.ID_Creator='{0}' ",GetLoginUserID());
  1130. }
  1131. </Format>
  1132. <Format name="SearchBillCondition">
  1133. if(GetRight("客户基本资料","全权查看"))
  1134. {
  1135. FormatString("");
  1136. }
  1137. else
  1138. {
  1139. FormatString(" Disable_SaleBill = 0 and Customer.ID_Creator='{0}' ",GetLoginUserID());
  1140. }
  1141. </Format>
  1142. </FormatString>
  1143. <ImportedInfo>
  1144. @TaxCurrency=#SaleBill.TaxCurrency_SaleBill;
  1145. @No_Principal=#SaleBill.No_Principal;
  1146. @Name_Pricipal=#SaleBill.Principal_SaleBill;
  1147. UpdateForm(true,"ckSpecial");
  1148. UpdateForm(true,"ckSpecial1");
  1149. UpdateForm(true, "tbCustomerNo");
  1150. ActiveControlEvent("tbCustomerNo", "Enter");
  1151. #SaleBill.TaxCurrency_SaleBill=@TaxCurrency;
  1152. #SaleBill.No_Principal=@No_Principal;
  1153. #SaleBill.Principal_SaleBill=@Name_Pricipal;
  1154. if( Search("SearchPrincipalByNo",#SaleBill.No_Principal))
  1155. #SaleBill.ID_Principal = #Principal1.ID_Employee;
  1156. UpdateForm(true,"cbPrincipal");
  1157. UpdateForm(true, "cbTaxCurrency");
  1158. </ImportedInfo>
  1159. </Client>
  1160. <Server>
  1161. <Tables>
  1162. <Table name="SaleBill" Type="Parent">
  1163. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleBill.*
  1164. ,Customer.No_Customer
  1165. ,Customer.Name_Customer
  1166. ,Customer.ShortName_Customer
  1167. ,Customer.Type_Customer
  1168. ,Customer.PostalCode_Customer
  1169. ,Customer.RegistedAddress_Customer
  1170. ,a.Name_User AS Name_Creator
  1171. ,b.Name_User AS Name_Assessor
  1172. ,c.Name_User AS LastModUserName
  1173. ,Location.No_Location
  1174. ,Location.Name_Location
  1175. ,CONVERT(decimal(18,6), 0) AS NumSum
  1176. ,CONVERT(decimal(18,6), 0) AS MoneySum
  1177. ,CONVERT(decimal(18,6), 0) AS TaxSum
  1178. ,Employee.No_Employee AS No_Principal
  1179. ,Employee.Name_Employee AS Principal_SaleBill
  1180. FROM SaleBill
  1181. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  1182. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  1183. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  1184. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  1185. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  1186. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  1187. " />
  1188. <New CmdType="Text" CmdText=" INSERT INTO SaleBill (ID_SaleBill
  1189. ,No_SaleBill
  1190. ,Date_SaleBill
  1191. ,ID_Location
  1192. ,ID_Customer
  1193. ,No_OrderBill
  1194. ,GetMethod_SaleBill
  1195. ,ToGet_SaleBill
  1196. ,Name_Linkman
  1197. ,Tel_SaleBill
  1198. ,Fax_SaleBill
  1199. ,SendAddr_SaleBill
  1200. ,InvoiceAddress_Company
  1201. ,InvoiceTitle_Company
  1202. ,TaxCurrency_SaleBill
  1203. ,Currency_SaleBill
  1204. ,ID_Principal
  1205. ,ID_Creator
  1206. ,CreateDate_SaleBill
  1207. ,Amount_SaleBill
  1208. ,Discount_SaleBill
  1209. ,GoodsAmount_SaleBill
  1210. ,TaxAmount_SaleBill
  1211. ,OutStatus_SaleBill
  1212. ,Special_SaleBill
  1213. ,Special2_SaleBill)
  1214. VALUES (@ID_SaleBill
  1215. ,@No_SaleBill
  1216. ,@Date_SaleBill
  1217. ,@ID_Location
  1218. ,@ID_Customer
  1219. ,@No_OrderBill
  1220. ,@GetMethod_SaleBill
  1221. ,@ToGet_SaleBill
  1222. ,@Name_Linkman
  1223. ,@Tel_SaleBill
  1224. ,@Fax_SaleBill
  1225. ,@SendAddr_SaleBill
  1226. ,@InvoiceAddress_Company
  1227. ,@InvoiceTitle_Company
  1228. ,@TaxCurrency_SaleBill
  1229. ,@Currency_SaleBill
  1230. ,@ID_Principal
  1231. ,@ID_Creator
  1232. ,@CreateDate_SaleBill
  1233. ,@Amount_SaleBill
  1234. ,@Discount_SaleBill
  1235. ,@GoodsAmount_SaleBill
  1236. ,@TaxAmount_SaleBill
  1237. ,@OutStatus_SaleBill
  1238. ,@Special_SaleBill
  1239. ,@Special2_SaleBill)
  1240. UPDATE Customer SET Customer.LastPrincipal_Customer=@ID_Principal
  1241. ,Customer.LastDiscount_Customer = @Discount_SaleBill
  1242. ,Customer.LastTax_Customer = @TaxCurrency_SaleBill
  1243. WHERE Customer.ID_Customer = @ID_Customer
  1244. ">
  1245. <Params>
  1246. <Param name="@ID_SaleBill" type="SaleBill.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1247. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" sourceColumn="No_SaleBill" />
  1248. <Param name="@Date_SaleBill" type="SaleBill.Date_SaleBill" sourceColumn="Date_SaleBill" />
  1249. <Param name="@ID_Location" type="SaleBill.ID_Location" sourceColumn="ID_Location" />
  1250. <Param name="@ID_Customer" type="SaleBill.ID_Customer" sourceColumn="ID_Customer" />
  1251. <Param name="@No_OrderBill" type="SaleBill.No_OrderBill" sourceColumn="No_OrderBill" />
  1252. <Param name="@GetMethod_SaleBill" type="SaleBill.GetMethod_SaleBill" sourceColumn="GetMethod_SaleBill" />
  1253. <Param name="@ToGet_SaleBill" type="SaleBill.ToGet_SaleBill" sourceColumn="ToGet_SaleBill" />
  1254. <Param name="@Name_Linkman" type="SaleBill.Name_Linkman" sourceColumn="Name_Linkman" />
  1255. <Param name="@Tel_SaleBill" type="SaleBill.Tel_SaleBill" sourceColumn="Tel_SaleBill" />
  1256. <Param name="@Fax_SaleBill" type="SaleBill.Fax_SaleBill" sourceColumn="Fax_SaleBill" />
  1257. <Param name="@SendAddr_SaleBill" type="SaleBill.SendAddr_SaleBill" sourceColumn="SendAddr_SaleBill" />
  1258. <Param name="@InvoiceAddress_Company" type="SaleBill.InvoiceAddress_Company" sourceColumn="InvoiceAddress_Company" />
  1259. <Param name="@InvoiceTitle_Company" type="SaleBill.InvoiceTitle_Company" sourceColumn="InvoiceTitle_Company" />
  1260. <Param name="@TaxCurrency_SaleBill" type="SaleBill.TaxCurrency_SaleBill" sourceColumn="TaxCurrency_SaleBill" />
  1261. <Param name="@Currency_SaleBill" type="SaleBill.Currency_SaleBill" sourceColumn="Currency_SaleBill" />
  1262. <Param name="@ID_Principal" type="SaleBill.ID_Principal" sourceColumn="ID_Principal" />
  1263. <Param name="@ID_Creator" type="SaleBill.ID_Creator" sourceColumn="ID_Creator" />
  1264. <Param name="@CreateDate_SaleBill" type="SaleBill.CreateDate_SaleBill" sourceColumn="CreateDate_SaleBill" />
  1265. <Param name="@Amount_SaleBill" type="SaleBill.Amount_SaleBill" sourceColumn="Amount_SaleBill" />
  1266. <Param name="@Discount_SaleBill" type="SaleBill.Discount_SaleBill" sourceColumn="Discount_SaleBill" />
  1267. <Param name="@GoodsAmount_SaleBill" type="SaleBill.GoodsAmount_SaleBill" sourceColumn="GoodsAmount_SaleBill" />
  1268. <Param name="@TaxAmount_SaleBill" type="SaleBill.TaxAmount_SaleBill" sourceColumn="TaxAmount_SaleBill" />
  1269. <Param name="@OutStatus_SaleBill" type="SaleBill.OutStatus_SaleBill" sourceColumn="OutStatus_SaleBill" />
  1270. <Param name="@Special_SaleBill" type="SaleBill.Special_SaleBill" sourceColumn="Special_SaleBill" />
  1271. <Param name="@Special2_SaleBill" type="SaleBill.Special2_SaleBill" sourceColumn="Special2_SaleBill" />
  1272. </Params>
  1273. </New>
  1274. <Update CmdType="Text" CmdText=" UPDATE SaleBill SET Date_SaleBill = @Date_SaleBill
  1275. ,ID_Location = @ID_Location
  1276. ,ID_Customer = @ID_Customer
  1277. ,No_OrderBill = @No_OrderBill
  1278. ,GetMethod_SaleBill = @GetMethod_SaleBill
  1279. ,ToGet_SaleBill = @ToGet_SaleBill
  1280. ,Name_Linkman = @Name_Linkman
  1281. ,Tel_SaleBill = @Tel_SaleBill
  1282. ,Fax_SaleBill = @Fax_SaleBill
  1283. ,SendAddr_SaleBill = @SendAddr_SaleBill
  1284. ,InvoiceAddress_Company = @InvoiceAddress_Company
  1285. ,InvoiceTitle_Company = @InvoiceTitle_Company
  1286. ,TaxCurrency_SaleBill = @TaxCurrency_SaleBill
  1287. ,Currency_SaleBill = @Currency_SaleBill
  1288. ,ID_Principal = @ID_Principal
  1289. ,Amount_SaleBill = @Amount_SaleBill
  1290. ,LastModUser_SaleBill = @LastModUser_SaleBill
  1291. ,LastModDate_SaleBill = @LastModDate_SaleBill
  1292. ,Discount_SaleBill=@Discount_SaleBill
  1293. ,GoodsAmount_SaleBill=@GoodsAmount_SaleBill
  1294. ,TaxAmount_SaleBill=@TaxAmount_SaleBill
  1295. ,Assess_SaleBill = @Assess_SaleBill
  1296. ,OutStatus_SaleBill=@OutStatus_SaleBill
  1297. ,Special_SaleBill=@Special_SaleBill
  1298. ,Special2_SaleBill=@Special2_SaleBill
  1299. WHERE ID_SaleBill = @ID_SaleBill
  1300. UPDATE Customer SET Customer.LastPrincipal_Customer=@ID_Principal
  1301. ,Customer.LastDiscount_Customer = @Discount_SaleBill
  1302. ,Customer.LastTax_Customer = @TaxCurrency_SaleBill
  1303. WHERE Customer.ID_Customer = @ID_Customer
  1304. ">
  1305. <Params>
  1306. <Param name="@ID_SaleBill" type="SaleBill.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1307. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" sourceColumn="No_SaleBill" />
  1308. <Param name="@Date_SaleBill" type="SaleBill.Date_SaleBill" sourceColumn="Date_SaleBill" />
  1309. <Param name="@ID_Location" type="SaleBill.ID_Location" sourceColumn="ID_Location" />
  1310. <Param name="@ID_Customer" type="SaleBill.ID_Customer" sourceColumn="ID_Customer" />
  1311. <Param name="@No_OrderBill" type="SaleBill.No_OrderBill" sourceColumn="No_OrderBill" />
  1312. <Param name="@GetMethod_SaleBill" type="SaleBill.GetMethod_SaleBill" sourceColumn="GetMethod_SaleBill" />
  1313. <Param name="@ToGet_SaleBill" type="SaleBill.ToGet_SaleBill" sourceColumn="ToGet_SaleBill" />
  1314. <Param name="@Name_Linkman" type="SaleBill.Name_Linkman" sourceColumn="Name_Linkman" />
  1315. <Param name="@Tel_SaleBill" type="SaleBill.Tel_SaleBill" sourceColumn="Tel_SaleBill" />
  1316. <Param name="@Fax_SaleBill" type="SaleBill.Fax_SaleBill" sourceColumn="Fax_SaleBill" />
  1317. <Param name="@SendAddr_SaleBill" type="SaleBill.SendAddr_SaleBill" sourceColumn="SendAddr_SaleBill" />
  1318. <Param name="@InvoiceAddress_Company" type="SaleBill.InvoiceAddress_Company" sourceColumn="InvoiceAddress_Company" />
  1319. <Param name="@InvoiceTitle_Company" type="SaleBill.InvoiceTitle_Company" sourceColumn="InvoiceTitle_Company" />
  1320. <Param name="@TaxCurrency_SaleBill" type="SaleBill.TaxCurrency_SaleBill" sourceColumn="TaxCurrency_SaleBill" />
  1321. <Param name="@Currency_SaleBill" type="SaleBill.Currency_SaleBill" sourceColumn="Currency_SaleBill" />
  1322. <Param name="@ID_Principal" type="SaleBill.ID_Principal" sourceColumn="ID_Principal" />
  1323. <Param name="@LastModUser_SaleBill" type="SaleBill.LastModUser_SaleBill" sourceColumn="LastModUser_SaleBill" />
  1324. <Param name="@LastModDate_SaleBill" type="SaleBill.LastModDate_SaleBill" sourceColumn="LastModDate_SaleBill" />
  1325. <Param name="@Amount_SaleBill" type="SaleBill.Amount_SaleBill" sourceColumn="Amount_SaleBill" />
  1326. <Param name="@Discount_SaleBill" type="SaleBill.Discount_SaleBill" sourceColumn="Discount_SaleBill" />
  1327. <Param name="@GoodsAmount_SaleBill" type="SaleBill.GoodsAmount_SaleBill" sourceColumn="GoodsAmount_SaleBill" />
  1328. <Param name="@TaxAmount_SaleBill" type="SaleBill.TaxAmount_SaleBill" sourceColumn="TaxAmount_SaleBill" />
  1329. <Param name="@Assess_SaleBill" type="SaleBill.Assess_SaleBill" sourceColumn="Assess_SaleBill" />
  1330. <Param name="@OutStatus_SaleBill" type="SaleBill.OutStatus_SaleBill" sourceColumn="OutStatus_SaleBill" />
  1331. <Param name="@Special_SaleBill" type="SaleBill.Special_SaleBill" sourceColumn="Special_SaleBill" />
  1332. <Param name="@Special2_SaleBill" type="SaleBill.Special2_SaleBill" sourceColumn="Special2_SaleBill" />
  1333. </Params>
  1334. </Update>
  1335. <Audit CmdType="Text" CmdText=" DECLARE @ID_SaleBillProduct uniqueidentifier
  1336. DECLARE @No_SaleBillProduct nvarchar(64)
  1337. DECLARE @ID_Product uniqueidentifier
  1338. DECLARE @Quantity decimal(14,4)
  1339. DECLARE @ID_SaleSourceBillProduct uniqueidentifier
  1340. DECLARE @Quantity_Sale decimal(14,4)
  1341. DECLARE @UnitPrice_SaleBillProduct decimal(14,4)
  1342. DECLARE @Quantity_OutDepot decimal(14,4)
  1343. DECLARE @AvailableQty decimal(14,4)
  1344. DECLARE @Assess_SaleBill bit
  1345. DECLARE @SaleAndOutDepot bit
  1346. DECLARE @error nvarchar(64)
  1347. DECLARE @ID_IndentBill uniqueidentifier
  1348. DECLARE @No_FromBill nvarchar(64)
  1349. DECLARE @UnitPrice_PriceReference decimal(14,4)
  1350. DECLARE @UnitPriceWithTax_PriceReference decimal(14,4)
  1351. DECLARE @CessOut decimal(14,4)
  1352. Declare @No_FromBillProduct nvarchar(64)
  1353. DECLARE CUR CURSOR FOR SELECT SaleBillProduct.ID_SaleBillProduct
  1354. ,SaleBillProduct.No_SaleBillProduct
  1355. ,SaleBillProduct.ID_Product
  1356. ,SaleBillProduct.Quantity_SaleBillProduct
  1357. ,SaleBillProduct.ID_SaleSourceBillProduct
  1358. ,UnitPrice_SaleBillProduct
  1359. ,No_FromBill
  1360. ,No_FromBillProduct
  1361. FROM SaleBillProduct
  1362. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  1363. SELECT @SaleAndOutDepot = SystemSetting.SaleAndOutDepot_SystemSetting,@CessOut=CessOut_SystemSetting/100 FROM SystemSetting
  1364. IF (@ID_Assessor IS NULL)
  1365. BEGIN
  1366. SELECT @Assess_SaleBill = SaleBill.Assess_SaleBill FROM SaleBill WHERE SaleBill.ID_SaleBill = @ID_SaleBill
  1367. IF (@Assess_SaleBill = 1)
  1368. BEGIN
  1369. RAISERROR('该单据已经财务复核,请先取消财务复核!',16,1)
  1370. RETURN
  1371. END
  1372. IF (@SaleAndOutDepot = 1 and @Disable_SaleBill=0)
  1373. BEGIN
  1374. SELECT @Quantity_Sale = SUM(SaleSourceBillProduct.Quantity_Sale), @Quantity_OutDepot = SUM(SaleSourceBillProduct.Quantity_OutDepot) FROM SaleSourceBillProduct
  1375. INNER JOIN SaleBillProduct ON SaleBillProduct.ID_SaleSourceBillProduct = SaleSourceBillProduct.ID_SaleSourceBillProduct WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  1376. IF (@Quantity_Sale = @Quantity_OutDepot) AND (@Quantity_Sale &gt; 0) AND (@Quantity_OutDepot &gt; 0)
  1377. BEGIN
  1378. RAISERROR('该单据产品已经全部出库,取消审核失败!',16,1)
  1379. RETURN
  1380. END
  1381. END
  1382. END
  1383. OPEN CUR
  1384. FETCH NEXT FROM CUR INTO @ID_SaleBillProduct, @No_SaleBillProduct, @ID_Product, @Quantity, @ID_SaleSourceBillProduct,@UnitPrice_SaleBillProduct,@No_FromBill,@No_FromBillProduct
  1385. WHILE @@FETCH_STATUS = 0
  1386. BEGIN
  1387. IF (@ID_Assessor IS NOT NULL)
  1388. BEGIN
  1389. IF(@TaxCurrency_SaleBill='内含')
  1390. BEGIN
  1391. SET @UnitPrice_PriceReference=@UnitPrice_SaleBillProduct/(1+@CessOut)
  1392. SET @UnitPriceWithTax_PriceReference=@UnitPrice_SaleBillProduct
  1393. END
  1394. ELSE
  1395. BEGIN
  1396. SET @UnitPrice_PriceReference=@UnitPrice_SaleBillProduct
  1397. SET @UnitPriceWithTax_PriceReference=@UnitPrice_SaleBillProduct*(1+@CessOut)
  1398. END
  1399. IF Exists (Select * From PriceReference Where ID_Customer=@ID_Customer AND ID_Product=@ID_Product)
  1400. Update PriceReference Set UnitPrice_PriceReference=Convert(decimal(18,2),@UnitPrice_PriceReference),UnitPriceWithTax_PriceReference=Convert(decimal(18,2),@UnitPriceWithTax_PriceReference) Where ID_Customer=@ID_Customer ANd ID_Product=@ID_Product
  1401. Else
  1402. Insert Into PriceReference(ID_PriceReference,ID_Customer,ID_Product,UnitPrice_PriceReference,UnitPriceWithTax_PriceReference) Values(newID(),@ID_Customer,@ID_Product,Convert(decimal(18,2),@UnitPrice_PriceReference),Convert(decimal(18,2),@UnitPriceWithTax_PriceReference))
  1403. IF (@SaleAndOutDepot = 1)
  1404. BEGIN
  1405. IF (@ID_SaleSourceBillProduct IS NULL)
  1406. BEGIN
  1407. SET @ID_SaleSourceBillProduct = @ID_SaleBillProduct
  1408. INSERT INTO SaleSourceBillProduct (ID_SaleSourceBillProduct, Quantity_Sale) VALUES (@ID_SaleSourceBillProduct, @Quantity)
  1409. UPDATE SaleBillProduct SET SaleBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct WHERE SaleBillProduct.ID_SaleBillProduct = @ID_SaleBillProduct
  1410. END
  1411. ELSE
  1412. BEGIN
  1413. SELECT @Quantity_OutDepot = SaleSourceBillProduct.Quantity_OutDepot FROM SaleSourceBillProduct WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1414. IF (@Quantity &lt; @Quantity_OutDepot)
  1415. BEGIN
  1416. SET @error = N'序号为'+@No_SaleBillProduct+N'的销售数量小于已出库数量,审核失败!请于关联单据处查询。'
  1417. RAISERROR(@error,16,1)
  1418. RETURN
  1419. END
  1420. ELSE
  1421. BEGIN
  1422. UPDATE SaleSourceBillProduct SET SaleSourceBillProduct.Quantity_Sale = @Quantity WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1423. END
  1424. END
  1425. END
  1426. SELECT @AvailableQty = ProductStocks.AvailableQty_ProductStocks FROM ProductStocks WHERE ProductStocks.ID_Product = @ID_Product AND ProductStocks.ID_Location = @ID_Location
  1427. -- IF (@AvailableQty &lt; @Quantity)
  1428. -- BEGIN
  1429. -- SET @error = N'产品编号为'+@No_SaleBillProduct+N'的产品目前可用数量为'+ convert(nvarchar(64),@AvailableQty) +',不能通过审核,请修改销货单!'
  1430. -- RAISERROR(@error,16,1)
  1431. -- RETURN
  1432. -- END
  1433. IF @AvailableQty IS NULL
  1434. BEGIN
  1435. SET @error = N'对应库位中不存在序号为'+@No_SaleBillProduct+N'的产品,审核失败!'
  1436. RAISERROR(@error,16,1)
  1437. RETURN
  1438. END
  1439. ELSE
  1440. BEGIN
  1441. SET @AvailableQty = NULL
  1442. UPDATE ProductStocks SET ProductStocks.AvailableQty_ProductStocks = ProductStocks.AvailableQty_ProductStocks - @Quantity WHERE ProductStocks.ID_Product = @ID_Product AND ProductStocks.ID_Location = @ID_Location
  1443. END
  1444. Select @ID_IndentBill = ID_IndentBill From IndentBill WHERE No_IndentBill = @No_FromBill
  1445. UPDATE IndentBillProduct SET Quantity_Sale = Quantity_Sale + @Quantity WHERE ID_IndentBill = @ID_IndentBill and No_IndentBillProduct = @No_FromBillProduct
  1446. END
  1447. ELSE
  1448. BEGIN
  1449. IF (@SaleAndOutDepot = 1)
  1450. BEGIN
  1451. UPDATE SaleSourceBillProduct SET SaleSourceBillProduct.Quantity_Sale = 0 WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1452. END
  1453. UPDATE ProductStocks SET ProductStocks.AvailableQty_ProductStocks = ProductStocks.AvailableQty_ProductStocks + @Quantity WHERE ProductStocks.ID_Product = @ID_Product AND ProductStocks.ID_Location = @ID_Location
  1454. Select @ID_IndentBill = ID_IndentBill From IndentBill WHERE No_IndentBill = @No_FromBill
  1455. UPDATE IndentBillProduct SET Quantity_Sale = Quantity_Sale - @Quantity WHERE ID_IndentBill = @ID_IndentBill and No_IndentBillProduct = @No_FromBillProduct
  1456. END
  1457. FETCH NEXT FROM CUR INTO @ID_SaleBillProduct, @No_SaleBillProduct, @ID_Product, @Quantity, @ID_SaleSourceBillProduct,@UnitPrice_SaleBillProduct,@No_FromBill,@No_FromBillProduct
  1458. END
  1459. CLOSE CUR
  1460. DEALLOCATE CUR
  1461. UPDATE SaleBill SET ID_Assessor = @ID_Assessor
  1462. ,AssessDate_SaleBill = @AssessDate_SaleBill
  1463. ,Disable_SaleBill=@Disable_SaleBill
  1464. ,OutStatus_SaleBill=@OutStatus_SaleBill
  1465. WHERE ID_SaleBill = @ID_SaleBill
  1466. ">
  1467. <Params>
  1468. <Param name="@ID_SaleBill" type="SaleBill.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1469. <Param name="@ID_Location" type="SaleBill.ID_Location" sourceColumn="ID_Location" />
  1470. <Param name="@ID_Assessor" type="SaleBill.ID_Assessor" sourceColumn="ID_Assessor" />
  1471. <Param name="@AssessDate_SaleBill" type="SaleBill.AssessDate_SaleBill" sourceColumn="AssessDate_SaleBill" />
  1472. <Param name="@ID_Customer" type="SaleBill.ID_Customer" sourceColumn="ID_Customer" />
  1473. <Param name="@Disable_SaleBill" type="SaleBill.Disable_SaleBill" sourceColumn="Disable_SaleBill" />
  1474. <Param name="@OutStatus_SaleBill" type="SaleBill.OutStatus_SaleBill" sourceColumn="OutStatus_SaleBill" />
  1475. <Param name="@TaxCurrency_SaleBill" type="SaleBill.TaxCurrency_SaleBill" sourceColumn="TaxCurrency_SaleBill" />
  1476. </Params>
  1477. </Audit>
  1478. <Delete CmdType="Text" CmdText=" DECLARE @SaleAndOutDepot bit
  1479. DECLARE @Quantity_OutDepot decimal(14,4)
  1480. DECLARE @Quantity_SaleRtn decimal(14,4)
  1481. DECLARE @Quantity_InDepot decimal(14,4)
  1482. SELECT @SaleAndOutDepot = SystemSetting.SaleAndOutDepot_SystemSetting FROM SystemSetting
  1483. IF (@SaleAndOutDepot = 1)
  1484. BEGIN
  1485. SELECT @Quantity_OutDepot = SUM(SaleSourceBillProduct.Quantity_OutDepot), @Quantity_SaleRtn = SUM(SaleSourceBillProduct.Quantity_SaleRtn), @Quantity_InDepot = SUM(SaleSourceBillProduct.Quantity_InDepot)
  1486. FROM SaleSourceBillProduct
  1487. INNER JOIN SaleBillProduct ON SaleBillProduct.ID_SaleSourceBillProduct = SaleSourceBillProduct.ID_SaleSourceBillProduct
  1488. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  1489. IF (@Quantity_OutDepot &gt; 0)
  1490. BEGIN
  1491. RAISERROR('该单据已有相应的销售出库记录,删除失败!',16,1)
  1492. RETURN
  1493. END
  1494. IF (@Quantity_SaleRtn &gt; 0)
  1495. BEGIN
  1496. RAISERROR('该单据已有相应的销售退货记录,删除失败!',16,1)
  1497. RETURN
  1498. END
  1499. IF (@Quantity_InDepot &gt; 0)
  1500. BEGIN
  1501. RAISERROR('该单据已有相应的销售退货入库记录,删除失败!',16,1)
  1502. RETURN
  1503. END
  1504. DELETE SaleSourceBillProduct WHERE ID_SaleSourceBillProduct IN (SELECT SaleBillProduct.ID_SaleSourceBillProduct FROM SaleBillProduct WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill)
  1505. END
  1506. DELETE SaleBillProduct WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  1507. DELETE BillComment WHERE BillComment.ID_Bill = @ID_SaleBill
  1508. DELETE ReportComment WHERE ReportComment.ID_Bill = @ID_SaleBill
  1509. IF (@SaleAndOutDepot = 1)
  1510. BEGIN
  1511. DELETE SaleBill WHERE SaleBill.ID_SaleBill = @ID_SaleBill
  1512. END
  1513. ELSE
  1514. BEGIN
  1515. UPDATE SaleBill SET SaleBill.Disable_SaleBill = 1 WHERE SaleBill.ID_SaleBill = @ID_SaleBill
  1516. END">
  1517. <Params>
  1518. <Param name="@ID_SaleBill" type="SaleBill.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1519. </Params>
  1520. </Delete>
  1521. <FKErrorReport ErrorMessage="该单据已被其他单据引用,删除失败!" />
  1522. <UNIQUEErrorReport ErrorMessage="该销货单号已存在,提交失败!" />
  1523. </Table>
  1524. <Table name="SaleBillProduct" Type="Child">
  1525. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 SaleBillProduct.*
  1526. ,Product.No_Product
  1527. ,Product.Name_Product
  1528. ,Product.Unit_Product
  1529. ,Product.LowSalePrice_Product
  1530. ,CONVERT(decimal(18,6), 0) AS Amount_SaleBillProduct
  1531. ,BillType.Name_BillType
  1532. ,Convert(nvarchar(64),'') as No_SaleBill
  1533. FROM SaleBillProduct
  1534. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  1535. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  1536. "/>
  1537. <New CmdType="Text" CmdText=" SET @ID_SaleSourceBillProduct = NULL
  1538. if(@ID_IndentBillOnNetProduct='00000000-0000-0000-0000-000000000000') Set @ID_IndentBillOnNetProduct=Null
  1539. INSERT INTO SaleBillProduct (ID_SaleBillProduct
  1540. ,No_SaleBillProduct
  1541. ,ID_SaleBill
  1542. ,Type_FromBill
  1543. ,No_FromBill
  1544. ,No_FromBillProduct
  1545. ,ID_SaleSourceBillProduct
  1546. ,ID_Product
  1547. ,Quantity_SaleBillProduct
  1548. ,UnitPrice_SaleBillProduct
  1549. ,Discount_SaleBillProduct
  1550. ,Comment_SaleBillProduct
  1551. ,OrderPrice_SaleBillProduct
  1552. ,ID_IndentBillOnNetProduct)
  1553. VALUES (@ID_SaleBillProduct
  1554. ,@No_SaleBillProduct
  1555. ,@ID_SaleBill
  1556. ,@Type_FromBill
  1557. ,@No_FromBill
  1558. ,@No_FromBillProduct
  1559. ,@ID_SaleSourceBillProduct
  1560. ,@ID_Product
  1561. ,@Quantity_SaleBillProduct
  1562. ,@UnitPrice_SaleBillProduct
  1563. ,@Discount_SaleBillProduct
  1564. ,@Comment_SaleBillProduct
  1565. ,@OrderPrice_SaleBillProduct
  1566. ,@ID_IndentBillOnNetProduct)
  1567. ">
  1568. <Params>
  1569. <Param name="@ID_SaleBillProduct" type="SaleBillProduct.ID_SaleBillProduct" sourceColumn="ID_SaleBillProduct" />
  1570. <Param name="@No_SaleBillProduct" type="SaleBillProduct.No_SaleBillProduct" sourceColumn="No_SaleBillProduct" />
  1571. <Param name="@ID_SaleBill" type="SaleBillProduct.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1572. <Param name="@Type_FromBill" type="SaleBillProduct.Type_FromBill" sourceColumn="Type_FromBill" />
  1573. <Param name="@No_FromBill" type="SaleBillProduct.No_FromBill" sourceColumn="No_FromBill" />
  1574. <Param name="@No_FromBillProduct" type="SaleBillProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct" />
  1575. <Param name="@ID_SaleSourceBillProduct" type="SaleBillProduct.ID_SaleSourceBillProduct" sourceColumn="ID_SaleSourceBillProduct" />
  1576. <Param name="@ID_Product" type="SaleBillProduct.ID_Product" sourceColumn="ID_Product" />
  1577. <Param name="@Quantity_SaleBillProduct" type="SaleBillProduct.Quantity_SaleBillProduct" sourceColumn="Quantity_SaleBillProduct" />
  1578. <Param name="@UnitPrice_SaleBillProduct" type="SaleBillProduct.UnitPrice_SaleBillProduct" sourceColumn="UnitPrice_SaleBillProduct" />
  1579. <Param name="@Discount_SaleBillProduct" type="SaleBillProduct.Discount_SaleBillProduct" sourceColumn="Discount_SaleBillProduct" />
  1580. <Param name="@Comment_SaleBillProduct" type="SaleBillProduct.Comment_SaleBillProduct" sourceColumn="Comment_SaleBillProduct" />
  1581. <Param name="@OrderPrice_SaleBillProduct" type="SaleBillProduct.OrderPrice_SaleBillProduct" sourceColumn="OrderPrice_SaleBillProduct" />
  1582. <Param name="@ID_IndentBillOnNetProduct" type="SaleBillProduct.ID_IndentBillOnNetProduct" sourceColumn="ID_IndentBillOnNetProduct" />
  1583. </Params>
  1584. </New>
  1585. <Update CmdType="Text" CmdText=" DECLARE @SaleAndOutDepot bit
  1586. DECLARE @Quantity_OutDepot decimal(14,4)
  1587. DECLARE @error nvarchar(64)
  1588. DECLARE @IsGeneric_Customer BIT
  1589. SELECT @IsGeneric_Customer=Customer.IsGeneric_Customer FROM Customer
  1590. JOIN SaleBill ON Customer.ID_Customer=SaleBill.ID_Customer
  1591. WHERE SaleBill.ID_SaleBill = @ID_SaleBill
  1592. SELECT @SaleAndOutDepot = SystemSetting.SaleAndOutDepot_SystemSetting FROM SystemSetting
  1593. IF (@SaleAndOutDepot = 1 AND @ID_SaleSourceBillProduct IS NOT NULL)
  1594. BEGIN
  1595. SELECT @Quantity_OutDepot = SaleSourceBillProduct.Quantity_OutDepot FROM SaleSourceBillProduct WHERE SaleSourceBillProduct.ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1596. IF @Quantity_SaleBillProduct &lt; @Quantity_OutDepot
  1597. BEGIN
  1598. SET @error = N'序号为'+@No_SaleBillProduct+N'的销售数量小于已出库数量,提交失败!请于关联单据处查询。'
  1599. RAISERROR (@error,16,1)
  1600. RETURN
  1601. END
  1602. END
  1603. UPDATE SaleBillProduct SET ID_SaleBill = @ID_SaleBill
  1604. ,Type_FromBill = @Type_FromBill
  1605. ,No_FromBill = @No_FromBill
  1606. ,No_FromBillProduct = @No_FromBillProduct
  1607. ,ID_SaleSourceBillProduct = @ID_SaleSourceBillProduct
  1608. ,ID_Product = @ID_Product
  1609. ,Quantity_SaleBillProduct = @Quantity_SaleBillProduct
  1610. ,UnitPrice_SaleBillProduct = @UnitPrice_SaleBillProduct
  1611. ,Discount_SaleBillProduct = @Discount_SaleBillProduct
  1612. ,Comment_SaleBillProduct = @Comment_SaleBillProduct
  1613. ,OrderPrice_SaleBillProduct=@OrderPrice_SaleBillProduct
  1614. ,ID_IndentBillOnNetProduct=@ID_IndentBillOnNetProduct
  1615. WHERE ID_SaleBillProduct = @ID_SaleBillProduct
  1616. ">
  1617. <Params>
  1618. <Param name="@ID_SaleBillProduct" type="SaleBillProduct.ID_SaleBillProduct" sourceColumn="ID_SaleBillProduct" />
  1619. <Param name="@No_SaleBillProduct" type="SaleBillProduct.No_SaleBillProduct" sourceColumn="No_SaleBillProduct" />
  1620. <Param name="@ID_SaleBill" type="SaleBillProduct.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1621. <Param name="@Type_FromBill" type="SaleBillProduct.Type_FromBill" sourceColumn="Type_FromBill" />
  1622. <Param name="@No_FromBill" type="SaleBillProduct.No_FromBill" sourceColumn="No_FromBill" />
  1623. <Param name="@No_FromBillProduct" type="SaleBillProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct" />
  1624. <Param name="@ID_SaleSourceBillProduct" type="SaleBillProduct.ID_SaleSourceBillProduct" sourceColumn="ID_SaleSourceBillProduct" />
  1625. <Param name="@ID_Product" type="SaleBillProduct.ID_Product" sourceColumn="ID_Product" />
  1626. <Param name="@Quantity_SaleBillProduct" type="SaleBillProduct.Quantity_SaleBillProduct" sourceColumn="Quantity_SaleBillProduct" />
  1627. <Param name="@UnitPrice_SaleBillProduct" type="SaleBillProduct.UnitPrice_SaleBillProduct" sourceColumn="UnitPrice_SaleBillProduct" />
  1628. <Param name="@Discount_SaleBillProduct" type="SaleBillProduct.Discount_SaleBillProduct" sourceColumn="Discount_SaleBillProduct" />
  1629. <Param name="@Comment_SaleBillProduct" type="SaleBillProduct.Comment_SaleBillProduct" sourceColumn="Comment_SaleBillProduct" />
  1630. <Param name="@OrderPrice_SaleBillProduct" type="SaleBillProduct.OrderPrice_SaleBillProduct" sourceColumn="OrderPrice_SaleBillProduct" />
  1631. <Param name="@ID_IndentBillOnNetProduct" type="SaleBillProduct.ID_IndentBillOnNetProduct" sourceColumn="ID_IndentBillOnNetProduct" />
  1632. </Params>
  1633. </Update>
  1634. <Delete CmdType="Text" CmdText=" DELETE SaleBillProduct WHERE ID_SaleBillProduct = @ID_SaleBillProduct">
  1635. <Params>
  1636. <Param name="@ID_SaleBillProduct" type="SaleBillProduct.ID_SaleBillProduct" sourceColumn="ID_SaleBillProduct" />
  1637. <Param name="@No_SaleBillProduct" type="SaleBillProduct.No_SaleBillProduct" sourceColumn="No_SaleBillProduct" />
  1638. <Param name="@ID_SaleBill" type="SaleBillProduct.ID_SaleBill" sourceColumn="ID_SaleBill" />
  1639. <Param name="@Type_FromBill" type="SaleBillProduct.Type_FromBill" sourceColumn="Type_FromBill" />
  1640. <Param name="@No_FromBill" type="SaleBillProduct.No_FromBill" sourceColumn="No_FromBill" />
  1641. <Param name="@No_FromBillProduct" type="SaleBillProduct.No_FromBillProduct" sourceColumn="No_FromBillProduct" />
  1642. <Param name="@ID_SaleSourceBillProduct" type="SaleBillProduct.ID_SaleSourceBillProduct" sourceColumn="ID_SaleSourceBillProduct" />
  1643. <Param name="@ID_Product" type="SaleBillProduct.ID_Product" sourceColumn="ID_Product" />
  1644. <Param name="@Quantity_SaleBillProduct" type="SaleBillProduct.Quantity_SaleBillProduct" sourceColumn="Quantity_SaleBillProduct" />
  1645. <Param name="@UnitPrice_SaleBillProduct" type="SaleBillProduct.UnitPrice_SaleBillProduct" sourceColumn="UnitPrice_SaleBillProduct" />
  1646. <Param name="@Discount_SaleBillProduct" type="SaleBillProduct.Discount_SaleBillProduct" sourceColumn="Discount_SaleBillProduct" />
  1647. <Param name="@Comment_SaleBillProduct" type="SaleBillProduct.Comment_SaleBillProduct" sourceColumn="Comment_SaleBillProduct" />
  1648. </Params>
  1649. </Delete>
  1650. </Table>
  1651. <Table name="BillComment" Type="Child">
  1652. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 BillComment.* FROM BillComment"/>
  1653. <New CmdType="Text" CmdText=" INSERT INTO BillComment (ID_BillComment
  1654. ,ID_Bill
  1655. ,Comment_BillComment)
  1656. VALUES (@ID_BillComment
  1657. ,@ID_Bill
  1658. ,@Comment_BillComment)
  1659. ">
  1660. <Params>
  1661. <Param name="@ID_BillComment" type="BillComment.ID_BillComment" sourceColumn="ID_BillComment" />
  1662. <Param name="@ID_Bill" type="BillComment.ID_Bill" sourceColumn="ID_Bill" />
  1663. <Param name="@Comment_BillComment" type="BillComment.Comment_BillComment" sourceColumn="Comment_BillComment" />
  1664. </Params>
  1665. </New>
  1666. <Update CmdType="Text" CmdText=" UPDATE BillComment SET ID_Bill = @ID_Bill
  1667. ,Comment_BillComment = @Comment_BillComment
  1668. WHERE ID_BillComment = @ID_BillComment
  1669. ">
  1670. <Params>
  1671. <Param name="@ID_BillComment" type="BillComment.ID_BillComment" sourceColumn="ID_BillComment" />
  1672. <Param name="@ID_Bill" type="BillComment.ID_Bill" sourceColumn="ID_Bill" />
  1673. <Param name="@Comment_BillComment" type="BillComment.Comment_BillComment" sourceColumn="Comment_BillComment" />
  1674. </Params>
  1675. </Update>
  1676. <Delete CmdType="Text" CmdText=" DELETE BillComment WHERE ID_BillComment = @ID_BillComment">
  1677. <Params>
  1678. <Param name="@ID_BillComment" type="BillComment.ID_BillComment" sourceColumn="ID_BillComment" />
  1679. </Params>
  1680. </Delete>
  1681. </Table>
  1682. <Table name="ReportComment" Type="Child">
  1683. <GetSchema CmdType="Text" CmdText=" SELECT TOP 0 ReportComment.*,Convert(nvarchar(64),'') as No_SaleBill FROM ReportComment"/>
  1684. <New CmdType="Text" CmdText=" INSERT INTO ReportComment (ID_ReportComment, ID_Bill, Comment_ReportComment)
  1685. VALUES (@ID_ReportComment, @ID_Bill, @Comment_ReportComment)">
  1686. <Params>
  1687. <Param name="@ID_ReportComment" type="ReportComment.ID_ReportComment" sourceColumn="ID_ReportComment" />
  1688. <Param name="@ID_Bill" type="ReportComment.ID_Bill" sourceColumn="ID_Bill" />
  1689. <Param name="@Comment_ReportComment" type="ReportComment.Comment_ReportComment" sourceColumn="Comment_ReportComment" />
  1690. </Params>
  1691. </New>
  1692. <Update CmdType="Text" CmdText=" UPDATE ReportComment SET ID_Bill = @ID_Bill, Comment_ReportComment = @Comment_ReportComment
  1693. WHERE ID_ReportComment = @ID_ReportComment">
  1694. <Params>
  1695. <Param name="@ID_ReportComment" type="ReportComment.ID_ReportComment" sourceColumn="ID_ReportComment" />
  1696. <Param name="@ID_Bill" type="ReportComment.ID_Bill" sourceColumn="ID_Bill" />
  1697. <Param name="@Comment_ReportComment" type="ReportComment.Comment_ReportComment" sourceColumn="Comment_ReportComment" />
  1698. </Params>
  1699. </Update>
  1700. <Delete CmdType="Text" CmdText=" DELETE ReportComment WHERE ID_ReportComment = @ID_ReportComment">
  1701. <Params>
  1702. <Param name="@ID_ReportComment" type="ReportComment.ID_ReportComment" sourceColumn="ID_ReportComment" />
  1703. </Params>
  1704. </Delete>
  1705. </Table>
  1706. </Tables>
  1707. <Search>
  1708. <SearchAllBill CmdType="Text" CmdText=" SELECT SaleBill.*
  1709. ,Customer.No_Customer
  1710. ,Customer.Name_Customer
  1711. ,Customer.ShortName_Customer
  1712. ,Customer.Type_Customer
  1713. ,Customer.LastDiscount_Customer
  1714. ,Customer.PostalCode_Customer
  1715. ,a.Name_User AS Name_Creator
  1716. ,b.Name_User AS Name_Assessor
  1717. ,c.Name_User AS LastModUserName
  1718. ,Location.No_Location
  1719. ,Location.Name_Location
  1720. ,CONVERT(decimal(18,6), 0) AS NumSum
  1721. ,CONVERT(decimal(18,6), 0) AS MoneySum
  1722. ,CONVERT(decimal(18,6), 0) AS TaxSum
  1723. ,Employee.No_Employee AS No_Principal
  1724. ,Employee.Name_Employee AS Principal_SaleBill
  1725. ,statu= Case isnull(DataLength(SaleBill.ID_Assessor),0) WHEN 0 THEN CASE Disable_SaleBill WHEN 1 THEN '作废' ELSE '未审核' END ELSE '已审核' END
  1726. FROM SaleBill
  1727. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  1728. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  1729. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  1730. LEFT JOIN AppUser c ON c.ID_User= SaleBill.LastModUser_SaleBill
  1731. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  1732. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  1733. ">
  1734. <Tables>
  1735. <Table name="AllBill" />
  1736. </Tables>
  1737. </SearchAllBill>
  1738. <SearchAllIndentBillOnNet CmdType="Text" CmdText="Select IndentBillOnNet.ID_IndentBillOnNet
  1739. ,IndentBillOnNet.No_IndentBillOnNet
  1740. ,IndentBillOnNet.TaxCurrency_IndentBillOnNet
  1741. ,IndentBillOnNet.Date_IndentBillOnNet
  1742. ,Customer.No_Customer
  1743. ,Customer.ShortName_Customer
  1744. ,Case When IndentBillOnNet.ID_Assessor is null Then '未审核' Else '已审核' End As State_IndentBillOnNet
  1745. From IndentBillOnNet
  1746. Inner Join Customer On IndentBillOnNet.ID_Customer = Customer.ID_Customer
  1747. " >
  1748. <Tables>
  1749. <Table name="AllIndentBillOnNet" />
  1750. </Tables>
  1751. </SearchAllIndentBillOnNet>
  1752. <SearchAllIndentBillOnNetProduct CmdType="Text" CmdText=" Select Product.No_Product
  1753. ,IndentBillOnNetProduct.No_IndentBillOnNetProduct
  1754. ,Product.Name_Product
  1755. ,IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct
  1756. ,UnitPrice_IndentBillOnNetProduct As OrderPrice_IndentBillOnNetProduct
  1757. From IndentBillOnNetProduct
  1758. Inner Join Product On Product.ID_Product = IndentBillOnNetProduct.ID_Product
  1759. Inner Join IndentBillOnNet On IndentBillOnNet.ID_IndentBillOnNet = IndentBillOnNetProduct.ID_IndentBillOnNet
  1760. " >
  1761. <Tables>
  1762. <Table name="AllIndentBillOnNetProduct" />
  1763. </Tables>
  1764. </SearchAllIndentBillOnNetProduct>
  1765. <SearchCessOut CmdType="Text" CmdText=" SELECT SystemSetting.CessOut_SystemSetting
  1766. ,SysCurrency_SystemSetting,SAudit_FunctionSetting
  1767. FROM SystemSetting, FunctionSetting
  1768. ">
  1769. <Tables>
  1770. <Table name="System" />
  1771. </Tables>
  1772. </SearchCessOut>
  1773. <SearchContr CmdType="Text" CmdText=" SELECT SaleAndOutDepot_SystemSetting
  1774. ,OutDepotAndSaleBack_SystemSetting
  1775. ,SaleRtnSourceBill_SystemSetting,PriceDecimal_SystemSetting
  1776. FROM SystemSetting
  1777. ">
  1778. <Tables>
  1779. <Table name="SystemSetting" />
  1780. </Tables>
  1781. </SearchContr>
  1782. <SearchSaleBillWithNo CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  1783. SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  1784. Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
  1785. a.Name_User AS Name_Creator, ISNULL(b.Name_User, '') AS Name_Assessor, ISNULL(c.Name_User, '') AS LastModUserName,
  1786. Location.No_Location, Location.Name_Location, Employee.No_Employee AS No_Principal
  1787. ,Employee.Name_Employee AS Principal_SaleBill,Customer.ID_Creator As CustomerCreator
  1788. FROM SaleBill
  1789. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  1790. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  1791. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  1792. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  1793. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  1794. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  1795. WHERE SaleBill.No_SaleBill = @No_SaleBill
  1796. SELECT @ID_SaleBill = SaleBill.ID_SaleBill
  1797. FROM SaleBill
  1798. WHERE SaleBill.No_SaleBill = @No_SaleBill
  1799. SELECT SaleBillProduct.*, Product.No_Product, Product.Name_Product, Product.Unit_Product,
  1800. Product.LowSalePrice_Product, BillType.Name_BillType,
  1801. (SaleBillProduct.Quantity_SaleBillProduct * SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct
  1802. ,@No_SaleBill as No_SaleBill
  1803. FROM SaleBillProduct
  1804. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  1805. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  1806. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  1807. ORDER BY CAST(SaleBillProduct.No_SaleBillProduct AS INT)
  1808. SELECT BillComment.*
  1809. FROM BillComment
  1810. WHERE BillComment.ID_Bill = @ID_SaleBill
  1811. order by BillComment.No_BillComment
  1812. SELECT ReportComment.*
  1813. FROM ReportComment
  1814. WHERE ReportComment.ID_Bill = @ID_SaleBill
  1815. order by ReportComment.No_ReportComment
  1816. ">
  1817. <Params>
  1818. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  1819. </Params>
  1820. <Tables>
  1821. <Table name="SaleBill" />
  1822. <Table name="SaleBillProduct" />
  1823. <Table name="BillComment" />
  1824. <Table name="ReportComment" />
  1825. </Tables>
  1826. </SearchSaleBillWithNo>
  1827. <SearchLocation CmdType="Text" CmdText=" SELECT Location.ID_Location
  1828. ,Location.No_Location
  1829. ,Location.Name_Location
  1830. FROM Location
  1831. WHERE Location.Level_Location = 0
  1832. ORDER BY Location.No_Location
  1833. ">
  1834. <Tables>
  1835. <Table name="Location" />
  1836. </Tables>
  1837. </SearchLocation>
  1838. <SearchCustomerWithNo CmdType="Text" CmdText="
  1839. declare @LastTax_Customer1 nvarchar(64)
  1840. declare @LastTax_Customer2 nvarchar(64)
  1841. declare @LastTax_Customer3 nvarchar(64)
  1842. declare @STaxDefault1_FunctionSetting int
  1843. declare @STaxDefault2_FunctionSetting int
  1844. declare @STaxDefault3_FunctionSetting int
  1845. Select @STaxDefault1_FunctionSetting = STaxDefault1_FunctionSetting
  1846. ,@STaxDefault2_FunctionSetting = STaxDefault2_FunctionSetting
  1847. ,@STaxDefault3_FunctionSetting = STaxDefault3_FunctionSetting
  1848. From FunctionSetting
  1849. if @STaxDefault1_FunctionSetting=0
  1850. Begin
  1851. Select @LastTax_Customer1 = Customer.LastTax_Customer
  1852. From Customer
  1853. WHERE Customer.No_Customer = @No_Customer
  1854. End
  1855. else if @STaxDefault1_FunctionSetting = 1
  1856. Begin
  1857. Select top 1 @LastTax_Customer1 = TaxCurrency_SaleBill
  1858. From SaleBill
  1859. order by Date_SaleBill desc
  1860. End
  1861. else
  1862. Begin
  1863. set @LastTax_Customer1 = '外加'
  1864. End
  1865. if @STaxDefault2_FunctionSetting=0
  1866. Begin
  1867. select @LastTax_Customer2 = Customer.LastTax_Customer
  1868. from Customer
  1869. WHERE Customer.No_Customer = @No_Customer
  1870. End
  1871. else if @STaxDefault2_FunctionSetting = 1
  1872. Begin
  1873. select top 1 @LastTax_Customer2 = TaxCurrency_SaleBill
  1874. from SaleBill
  1875. order by Date_SaleBill desc
  1876. End
  1877. else
  1878. Begin
  1879. set @LastTax_Customer2 = '外加'
  1880. End
  1881. if @STaxDefault3_FunctionSetting=0
  1882. Begin
  1883. select @LastTax_Customer3 = Customer.LastTax_Customer
  1884. from Customer
  1885. WHERE Customer.No_Customer = @No_Customer
  1886. End
  1887. else if @STaxDefault3_FunctionSetting = 1
  1888. Begin
  1889. select top 1 @LastTax_Customer3 = TaxCurrency_SaleBill
  1890. from SaleBill
  1891. order by Date_SaleBill desc
  1892. End
  1893. else
  1894. Begin
  1895. set @LastTax_Customer3 = '外加'
  1896. End
  1897. if @LastTax_Customer1 is null
  1898. set @LastTax_Customer1 = isnull(@LastTax_Customer2, @LastTax_Customer3)
  1899. DECLARE @ID_Customer uniqueidentifier
  1900. DECLARE @CustoemrNo nvarchar(64)
  1901. ,@CustomerID Uniqueidentifier
  1902. ,@HighCustomerID Uniqueidentifier
  1903. ,@Amount decimal(14,6)
  1904. ,@Amount1 decimal(14,6)
  1905. ,@IsCustomer int
  1906. select @CustomerID=ID_Customer,@HighCustomerID=CustomerID_Customer
  1907. ,@IsCustomer =IsCustomersCustomer_Customer
  1908. From Customer
  1909. Where No_Customer = @No_Customer
  1910. IF (@IsCustomer=1)
  1911. Begin
  1912. select @Amount1=a.Amount
  1913. from
  1914. (
  1915. SELECT ID_Customer,sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  1916. FROM CUSTOMER
  1917. --WHERE SuspendDate_Customer is null
  1918. WHERE ID_Customer = @HighCustomerID
  1919. Group By ID_Customer
  1920. ) a
  1921. select @Amount = b.Amount
  1922. From
  1923. (
  1924. SELECT (IsNull(@Amount1,0)+Sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0))) As Amount
  1925. FROM CUSTOMER
  1926. -- WHERE SuspendDate_Customer is null
  1927. WHERE CustomerID_Customer = @HighCustomerID
  1928. And IsCustomersCustomer_Customer = 1
  1929. Group By CustomerID_Customer
  1930. )b
  1931. End
  1932. else
  1933. Begin
  1934. select @Amount = c.Amount
  1935. from
  1936. (
  1937. select (IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(A.Amount,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  1938. from customer
  1939. left join (SELECT CustomerID_Customer,sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  1940. FROM CUSTOMER
  1941. --WHERE SuspendDate_Customer is null
  1942. WHERE IsCustomersCustomer_Customer = 1
  1943. Group By CustomerID_Customer)A On A.CustomerID_Customer =Customer.ID_Customer
  1944. Where ID_Customer = @CustomerID
  1945. )c
  1946. End
  1947. SELECT Customer.ID_Customer,Customer.IsGeneric_Customer, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer, Customer.GetMethod_Customer, Customer.PostalCode_Customer, ISNULL(Customer.LastDiscount_Customer, 100) AS LastDiscount_Customer, Customer.SendAddr_Customer, Customer.SuspendDate_Customer
  1948. , ISNULL(@LastTax_Customer1, '外加') AS LastTax_Customer ,
  1949. (IsNull(@Amount,0)) as ToGetBalance_Customer,Employee.Name_Employee,Employee.No_Employee,Employee.ID_Employee As LastPrincipal_Customer,IsCustomersCustomer_Customer
  1950. FROM Customer
  1951. Left Join Principal On Principal.ID_Person = Customer.ID_Customer and IsMain_Principal = 1
  1952. Left join Employee On Employee.ID_Employee = Principal.ID_Employee
  1953. WHERE Customer.No_Customer = @No_Customer
  1954. SELECT @ID_Customer = Customer.ID_Customer FROM Customer WHERE Customer.No_Customer = @No_Customer
  1955. SELECT Telephone.No_Telephone FROM Telephone WHERE Telephone.ID_Person = @ID_Customer
  1956. SELECT Fax.No_Fax FROM Fax WHERE Fax.ID_Person = @ID_Customer
  1957. SELECT Linkman.Name_Linkman FROM Linkman WHERE Linkman.ID_Person = @ID_Customer And IsMain_Linkman=1
  1958. SELECT Invoice.Title_Invoice, Invoice.Address_Invoice FROM Invoice WHERE Invoice.ID_Customer = @ID_Customer AND Invoice.Common_Invoice = 1
  1959. ">
  1960. <Params>
  1961. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  1962. </Params>
  1963. <Tables>
  1964. <Table name="Customer" />
  1965. <Table name="Telephone" />
  1966. <Table name="Fax" />
  1967. <Table name="Linkman" />
  1968. <Table name="Invoice" />
  1969. </Tables>
  1970. </SearchCustomerWithNo>
  1971. <SearchAllCustomer CmdType="Text" CmdText="SELECT Customer.*,Linkman.Name_Linkman,Linkman.Tel_Linkman
  1972. ,No_Telephone,No_Fax,RegionalLeader.No_RegionalLeader
  1973. FROM
  1974. (
  1975. SELECT Customer.ID_Customer,Customer.No_Customer
  1976. ,Customer.ShortName_Customer,Customer.Zone_Customer
  1977. ,Customer.SendAddr_Customer,RegistedAddress_Customer
  1978. ,SuspendDate_Customer,Customer.Type_Customer
  1979. ,Customer.Level_Customer,Customer.IsGeneric_Customer
  1980. ,ID_Linkman=(Select Top 1 ID_Linkman
  1981. From Linkman
  1982. Where ID_Person=Customer.ID_Customer
  1983. And IsMain_Linkman=1 order by name_linkman)
  1984. ,ID_RegionalLeader= (Select TOP 1 ID_RegionalLeader
  1985. FROM RegionalLeader
  1986. WHERE ID_RegionalLeader = Customer.ID_RegionalLeader)
  1987. From Customer
  1988. )Customer
  1989. Left Join Linkman On Customer.ID_Linkman=Linkman.ID_Linkman
  1990. LEFT JOIN RegionalLeader ON RegionalLeader.ID_RegionalLeader = Customer.ID_RegionalLeader
  1991. LEFT JOIN Telephone ON Telephone.ID_Person = Customer.ID_Customer and Focus_Telephone = 1
  1992. left join Fax ON Fax.ID_Person = Customer.ID_Customer and Focus_Fax = 1">
  1993. <Tables>
  1994. <Table name="AllCustomer" />
  1995. </Tables>
  1996. </SearchAllCustomer>
  1997. <SearchAllProduct CmdType="Text" CmdText="SELECT Product.No_Product,Product.Name_Product ,Type_Product, Price_Product, LowSalePrice_Product, SafetyQty_Product FROM Product ">
  1998. <Tables>
  1999. <Table name="AllProduct" />
  2000. </Tables>
  2001. </SearchAllProduct>
  2002. <SearchAllPriceQueryBill CmdType="Text" CmdText=" Select PriceQueryBill.ID_PriceQueryBill,PriceQueryBill.No_PriceQueryBill,PriceQueryBill.TaxCurrency_PriceQueryBill,PriceQueryBill.Date_PriceQueryBill,Customer.No_Customer,Customer.ShortName_Customer,Case When PriceQueryBill.ID_Assessor is null Then '未审核' Else '已审核' End As State_PriceQueryBill ,Case When DateDiff(Day,GETDATE ( ),ValidDate_PriceQueryBill) &gt; 0 Or DateDiff(Day,GETDATE ( ),ValidDate_PriceQueryBill) = 0 Then '有效' Else '无效' End As StateDay_PriceQueryBill From PriceQueryBill
  2003. Inner Join Customer On PriceQueryBill.ID_Customer = Customer.ID_Customer " >
  2004. <Tables>
  2005. <Table name="AllPriceQueryBill" />
  2006. </Tables>
  2007. </SearchAllPriceQueryBill>
  2008. <SearchAllPriceQueryBillProduct CmdType="Text" CmdText="Select Product.No_Product,PriceQueryBillProduct.No_PriceQueryBillProduct,Product.Name_Product,PriceQueryBillProduct.Quantity_PriceQueryBillProduct,PriceQueryBillProduct.UnitPrice_PriceQueryBillProduct,PriceQueryBillProduct.Discount_PriceQueryBillProduct From PriceQueryBillProduct
  2009. Inner Join Product On Product.ID_Product = PriceQueryBillProduct.ID_Product
  2010. Inner Join PriceQueryBill On PriceQueryBill.ID_PriceQueryBill = PriceQueryBillProduct.ID_PriceQueryBill" >
  2011. <Tables>
  2012. <Table name="AllPriceQueryBillProduct" />
  2013. </Tables>
  2014. </SearchAllPriceQueryBillProduct>
  2015. <SearchGetMethod CmdType="Text" CmdText=" CREATE TABLE GetMethod
  2016. (
  2017. [Type] nvarchar(64)
  2018. )
  2019. INSERT INTO GetMethod VALUES ('先款后货')
  2020. INSERT INTO GetMethod VALUES ('票到当月结')
  2021. INSERT INTO GetMethod VALUES ('两月结')
  2022. INSERT INTO GetMethod VALUES ('三月结')
  2023. INSERT INTO GetMethod VALUES ('四月结')
  2024. INSERT INTO GetMethod VALUES ('票到付款')
  2025. SELECT Type AS Result FROM GetMethod
  2026. DROP TABLE GetMethod
  2027. ">
  2028. <Tables>
  2029. <Table name="GetMethod" />
  2030. </Tables>
  2031. </SearchGetMethod>
  2032. <SearchAllPrincipal CmdType="Text" CmdText="SELECT Employee.ID_Employee,Employee.No_Employee AS No_Principal, Employee.Name_Employee AS Principal_SaleBill
  2033. FROM Employee
  2034. order by Employee.No_Employee
  2035. ">
  2036. <Tables>
  2037. <Table name="Principal" />
  2038. </Tables>
  2039. </SearchAllPrincipal>
  2040. <SearchLinkman CmdType="Text" CmdText=" SELECT Linkman.Name_Linkman
  2041. FROM Linkman
  2042. INNER JOIN Customer ON Customer.ID_Customer = Linkman.ID_Person
  2043. WHERE Customer.No_Customer = @No_Customer
  2044. ">
  2045. <Params>
  2046. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2047. </Params>
  2048. <Tables>
  2049. <Table name="Linkman" />
  2050. </Tables>
  2051. </SearchLinkman>
  2052. <SearchTele CmdType="Text" CmdText=" SELECT Telephone.No_Telephone
  2053. FROM Telephone
  2054. INNER JOIN Customer ON Customer.ID_Customer = Telephone.ID_Person
  2055. WHERE Customer.No_Customer = @No_Customer
  2056. ">
  2057. <Params>
  2058. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2059. </Params>
  2060. <Tables>
  2061. <Table name="Telephone" />
  2062. </Tables>
  2063. </SearchTele>
  2064. <SearchFax CmdType="Text" CmdText=" SELECT Fax.No_Fax
  2065. FROM Fax
  2066. INNER JOIN Customer ON Customer.ID_Customer = Fax.ID_Person
  2067. WHERE Customer.No_Customer = @No_Customer
  2068. ">
  2069. <Params>
  2070. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2071. </Params>
  2072. <Tables>
  2073. <Table name="Fax" />
  2074. </Tables>
  2075. </SearchFax>
  2076. <SearchInvoice CmdType="Text" CmdText=" SELECT Invoice.Title_Invoice, Invoice.Address_Invoice
  2077. FROM Invoice
  2078. INNER JOIN Customer ON Customer.ID_Customer = Invoice.ID_Customer
  2079. WHERE Customer.No_Customer = @No_Customer
  2080. ">
  2081. <Params>
  2082. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2083. </Params>
  2084. <Tables>
  2085. <Table name="Invoice" />
  2086. </Tables>
  2087. </SearchInvoice>
  2088. <SearchBillType CmdType="Text" CmdText=" SELECT * FROM BillType WHERE Value_BillType = 23 OR Value_BillType = 0 OR Value_BillType = 24 OR Value_BillType = 25 ORDER BY Value_BillType">
  2089. <Tables>
  2090. <Table name="BillType" />
  2091. </Tables>
  2092. </SearchBillType>
  2093. <SearchFromBillWithNo CmdType="Text" CmdText=" SELECT * FROM PriceQueryBill WHERE PriceQueryBill.No_PriceQueryBill = @No_PriceQueryBill">
  2094. <Params>
  2095. <Param name="@No_PriceQueryBill" type="PriceQueryBill.No_PriceQueryBill" Index="0" />
  2096. </Params>
  2097. <Tables>
  2098. <Table name="FromBill" />
  2099. </Tables>
  2100. </SearchFromBillWithNo>
  2101. <SearchIndentBillWithNo CmdType="Text" CmdText="SELECT * FROM IndentBill WHERE IndentBill.No_IndentBill = @No_IndentBill">
  2102. <Params>
  2103. <Param name="@No_IndentBill" type="IndentBill.No_IndentBill" Index="0" />
  2104. </Params>
  2105. <Tables>
  2106. <Table name="IndentBill" />
  2107. </Tables>
  2108. </SearchIndentBillWithNo>
  2109. <SearchIndentBillOnNetProductWithNoID CmdType="Text" CmdText="declare @ID_IndentBillOnNet Uniqueidentifier
  2110. Select @ID_IndentBillOnNet = ID_IndentBillOnNet
  2111. From IndentBillOnNet
  2112. Where No_IndentBillOnNet = @No_IndentBillOnNet
  2113. Select Quantity_IndentBillOnNetProduct,Amount_SaleBill
  2114. From IndentBillOnNetProduct
  2115. Where ID_IndentBillOnNet = @ID_IndentBillOnNet
  2116. And ID_Product = @ID_Product
  2117. ">
  2118. <Params>
  2119. <Param name="@No_IndentBillOnNet" type="IndentBillOnNet.No_IndentBillOnNet" Index="0" />
  2120. <Param name="@ID_Product" type="Product.ID_Product" Index="1" />
  2121. </Params>
  2122. <Tables>
  2123. <Table name="IndentBillOnNetProductAmount" />
  2124. </Tables>
  2125. </SearchIndentBillOnNetProductWithNoID>
  2126. <SearchFromBillProductWithNo CmdType="Text" CmdText=" SELECT PriceQueryBillProduct.ID_Product, PriceQueryBillProduct.Quantity_PriceQueryBillProduct,
  2127. PriceQueryBillProduct.UnitPrice_PriceQueryBillProduct, PriceQueryBillProduct.Discount_PriceQueryBillProduct, PriceQueryBillProduct.OrderPrice_PriceQueryBillProduct,
  2128. Product.No_Product, Product.Name_Product, Product.Unit_Product, Product.SuspendDate_Product, Product.LowSalePrice_Product,PriceQueryBill.TaxCurrency_PriceQueryBill
  2129. FROM PriceQueryBillProduct
  2130. INNER JOIN PriceQueryBill ON PriceQueryBill.ID_PriceQueryBill = PriceQueryBillProduct.ID_PriceQueryBill
  2131. INNER JOIN Product ON Product.ID_Product = PriceQueryBillProduct.ID_Product
  2132. WHERE PriceQueryBill.No_PriceQueryBill = @No_PriceQueryBill AND PriceQueryBillProduct.No_PriceQueryBillProduct = @No_PriceQueryBillProduct">
  2133. <Params>
  2134. <Param name="@No_PriceQueryBill" type="PriceQueryBill.No_PriceQueryBill" Index="0" />
  2135. <Param name="@No_PriceQueryBillProduct" type="PriceQueryBillProduct.No_PriceQueryBillProduct" Index="1" />
  2136. </Params>
  2137. <Tables>
  2138. <Table name="FromBillProduct" />
  2139. </Tables>
  2140. </SearchFromBillProductWithNo>
  2141. <SearchIndentBillProductWithNo CmdType="Text" CmdText=" SELECT IndentBillProduct.ID_Product, IndentBillProduct.Quantity_IndentBillProduct,
  2142. IndentBillProduct.UnitPrice_IndentBillProduct, IndentBillProduct.Discount_IndentBillProduct, IndentBillProduct.OrderPrice_IndentBillProduct,
  2143. Product.No_Product, Product.Name_Product, Product.Unit_Product, Product.SuspendDate_Product, Product.LowSalePrice_Product,IndentBill.TaxCurrency_IndentBill
  2144. FROM IndentBillProduct
  2145. INNER JOIN IndentBill ON IndentBill.ID_IndentBill = IndentBillProduct.ID_IndentBill
  2146. INNER JOIN Product ON Product.ID_Product = IndentBillProduct.ID_Product
  2147. WHERE IndentBill.No_IndentBill = @No_IndentBill AND IndentBillProduct.No_IndentBillProduct = @No_IndentBillProduct
  2148. ">
  2149. <Params>
  2150. <Param name="@No_IndentBill" type="IndentBill.No_IndentBill" Index="0" />
  2151. <Param name="@No_IndentBillProduct" type="IndentBillProduct.No_IndentBillProduct" Index="1" />
  2152. </Params>
  2153. <Tables>
  2154. <Table name="IndentBillProduct" />
  2155. </Tables>
  2156. </SearchIndentBillProductWithNo>
  2157. <SearchIndentBillOnNetProductWithNo CmdType="Text" CmdText="SELECT IndentBillOnNetProduct.ID_Product, IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct,
  2158. IndentBillOnNetProduct.UnitPrice_IndentBillOnNetProduct,IndentBillOnNetProduct.ID_IndentBillOnNetProduct,
  2159. Product.No_Product, Product.Name_Product, Product.Unit_Product, Product.SuspendDate_Product, Product.LowSalePrice_Product,IndentBillOnNet.TaxCurrency_IndentBillOnNet
  2160. FROM IndentBillOnNetProduct
  2161. INNER JOIN IndentBillOnNet ON IndentBillOnNet.ID_IndentBillOnNet = IndentBillOnNetProduct.ID_IndentBillOnNet
  2162. INNER JOIN Product ON Product.ID_Product = IndentBillOnNetProduct.ID_Product
  2163. WHERE IndentBillOnNet.No_IndentBillOnNet = @No_IndentBillOnNet AND IndentBillOnNetProduct.No_IndentBillOnNetProduct = @No_IndentBillOnNetProduct
  2164. ">
  2165. <Params>
  2166. <Param name="@No_IndentBillOnNet" type="IndentBillOnNet.No_IndentBillOnNet" Index="0" />
  2167. <Param name="@No_IndentBillOnNetProduct" type="IndentBillOnNetProduct.No_IndentBillOnNetProduct" Index="1" />
  2168. </Params>
  2169. <Tables>
  2170. <Table name="IndentBillOnNetProduct" />
  2171. </Tables>
  2172. </SearchIndentBillOnNetProductWithNo>
  2173. <SearchProductStocks CmdType="Text" CmdText=" SELECT AvailableQty_ProductStocks FROM ProductStocks WHERE ID_Product=@ID_Product AND ID_Location=@ID_Location">
  2174. <Params>
  2175. <Param name="@ID_Product" type="ProductStocks.ID_Product" Index="0" />
  2176. <Param name="@ID_Location" type="ProductStocks.ID_Location" Index="1" />
  2177. </Params>
  2178. <Tables>
  2179. <Table name="ProductStocks" />
  2180. </Tables>
  2181. </SearchProductStocks>
  2182. <SearchProductWithNo CmdType="Text" CmdText=" SELECT ID_Product, Name_Product, Unit_Product, Price_Product, SuspendDate_Product, LowSalePrice_Product
  2183. FROM Product
  2184. WHERE No_Product = @No_Product
  2185. ">
  2186. <Params>
  2187. <Param name="@No_Product" type="Product.No_Product" Index="0" />
  2188. </Params>
  2189. <Tables>
  2190. <Table name="Product" />
  2191. </Tables>
  2192. </SearchProductWithNo>
  2193. <SearchRelation CmdType="Text" CmdText=" Select UnitPrice_PriceReference,UnitPriceWithTax_PriceReference From PriceReference
  2194. Left Join Product On Product.ID_Product = PriceReference.ID_Product
  2195. Left Join Customer On Customer.ID_Customer = PriceReference.ID_Customer
  2196. Where No_Product = @No_Product And No_Customer = @No_Customer
  2197. ">
  2198. <Params>
  2199. <Param name="@No_Product" type="Product.No_Product" Index="0" />
  2200. <Param name="@No_Customer" type="Customer.No_Customer" Index="1" />
  2201. </Params>
  2202. <Tables>
  2203. <Table name="PriceReference" />
  2204. </Tables>
  2205. </SearchRelation>
  2206. <SearchSaleBillFirst CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  2207. DECLARE @SaleBillNo nvarchar(64)
  2208. SELECT TOP 1 @SaleBillNo = SaleBill.No_SaleBill
  2209. FROM SaleBill
  2210. Join Customer On Customer.ID_Customer=SaleBill.ID_Customer
  2211. WHERE Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  2212. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End --added for Special
  2213. and Special2_SaleBill=case @Special2 when 1 then Special2_SaleBill else 0 End
  2214. --and Customer.ID_RegionalLeader in
  2215. --(Select ID_RegionalLeader From Principal
  2216. --Where ID_Employee in(select ID_Employee from Employee where Name_Employee=@Name_Employee)
  2217. --)
  2218. ORDER BY SaleBill.No_SaleBill
  2219. SELECT SaleBill.*, Customer.No_Customer
  2220. ,Customer.Name_Customer, Customer.ShortName_Customer
  2221. ,Customer.Type_Customer,Customer.LastDiscount_Customer
  2222. ,Customer.PostalCode_Customer
  2223. ,a.Name_User AS Name_Creator
  2224. ,ISNULL(b.Name_User, '') AS Name_Assessor
  2225. ,ISNULL(c.Name_User, '') AS LastModUserName
  2226. ,Location.No_Location, Location.Name_Location
  2227. ,Employee.No_Employee AS No_Principal
  2228. ,Employee.Name_Employee AS Principal_SaleBill
  2229. FROM SaleBill
  2230. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  2231. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  2232. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  2233. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  2234. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  2235. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  2236. WHERE SaleBill.No_SaleBill = @SaleBillNo
  2237. SELECT @ID_SaleBill = SaleBill.ID_SaleBill
  2238. FROM SaleBill
  2239. WHERE SaleBill.No_SaleBill = @SaleBillNo
  2240. SELECT SaleBillProduct.*, Product.No_Product
  2241. ,Product.Name_Product,Product.Unit_Product
  2242. ,Product.LowSalePrice_Product,BillType.Name_BillType
  2243. ,(SaleBillProduct.Quantity_SaleBillProduct * SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct
  2244. ,@SaleBillNo as No_SaleBill
  2245. FROM SaleBillProduct
  2246. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  2247. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  2248. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill ORDER BY CAST(SaleBillProduct.No_SaleBillProduct AS INT)
  2249. SELECT BillComment.*
  2250. FROM BillComment
  2251. WHERE BillComment.ID_Bill = @ID_SaleBill
  2252. order by BillComment.No_BillComment
  2253. SELECT ReportComment.*,@SaleBillNo as No_SaleBill
  2254. FROM ReportComment
  2255. WHERE ReportComment.ID_Bill = @ID_SaleBill
  2256. order by ReportComment.No_ReportComment
  2257. ">
  2258. <Params>
  2259. <Param name="@Right" type="SaleBill.ID_Customer" Index="0" />
  2260. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="1" />
  2261. <Param name="@Name_Employee" type="Employee.Name_Employee" Index="2" />
  2262. <Param name="@Special2" type="SaleBill.Special_SaleBill" Index="3" />
  2263. </Params>
  2264. <Tables>
  2265. <Table name="SaleBill" />
  2266. <Table name="SaleBillProduct" />
  2267. <Table name="BillComment" />
  2268. <Table name="ReportComment" />
  2269. </Tables>
  2270. </SearchSaleBillFirst>
  2271. <SearchSaleBillPrevious CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  2272. DECLARE @SaleBillNo nvarchar(64)
  2273. SELECT TOP 1 @SaleBillNo = SaleBill.No_SaleBill FROM SaleBill
  2274. Join Customer On Customer.ID_Customer=SaleBill.ID_Customer
  2275. WHERE SaleBill.No_SaleBill &lt; @No_SaleBill
  2276. And Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  2277. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End --added for Special
  2278. and Special2_SaleBill=case @Special2 when 1 then Special2_SaleBill else 0 end
  2279. --and Customer.ID_RegionalLeader in
  2280. --(Select ID_RegionalLeader From Principal
  2281. --Where ID_Employee in(select ID_Employee from Employee where Name_Employee=@Name_Employee)
  2282. -- )
  2283. ORDER BY SaleBill.No_SaleBill DESC
  2284. SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  2285. Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
  2286. a.Name_User AS Name_Creator, ISNULL(b.Name_User, '') AS Name_Assessor, ISNULL(c.Name_User, '') AS LastModUserName,
  2287. Location.No_Location, Location.Name_Location, Employee.No_Employee AS No_Principal ,Employee.Name_Employee AS Principal_SaleBill
  2288. FROM SaleBill
  2289. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  2290. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  2291. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  2292. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  2293. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  2294. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  2295. WHERE SaleBill.No_SaleBill = @SaleBillNo
  2296. SELECT @ID_SaleBill = SaleBill.ID_SaleBill FROM SaleBill WHERE SaleBill.No_SaleBill = @SaleBillNo
  2297. SELECT SaleBillProduct.*, Product.No_Product, Product.Name_Product, Product.Unit_Product,
  2298. Product.LowSalePrice_Product, BillType.Name_BillType,
  2299. (SaleBillProduct.Quantity_SaleBillProduct * SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct,@SaleBillNo as No_SaleBill
  2300. FROM SaleBillProduct
  2301. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  2302. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  2303. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill ORDER BY CAST(SaleBillProduct.No_SaleBillProduct AS INT)
  2304. SELECT BillComment.* FROM BillComment WHERE BillComment.ID_Bill = @ID_SaleBill order by BillComment.No_BillComment
  2305. SELECT ReportComment.*,@SaleBillNo as No_SaleBill FROM ReportComment WHERE ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment">
  2306. <Params>
  2307. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  2308. <Param name="@Right" type="SaleBill.ID_Customer" Index="1" />
  2309. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="2" />
  2310. <Param name="@Name_Employee" type="Employee.Name_Employee" Index="3" />
  2311. <Param name="@Special2" type="SaleBill.Special_SaleBill" Index="4" />
  2312. </Params>
  2313. <Tables>
  2314. <Table name="SaleBill" />
  2315. <Table name="SaleBillProduct" />
  2316. <Table name="BillComment" />
  2317. <Table name="ReportComment" />
  2318. </Tables>
  2319. </SearchSaleBillPrevious>
  2320. <SearchSaleBillNext CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  2321. DECLARE @SaleBillNo nvarchar(64)
  2322. SELECT TOP 1 @SaleBillNo = SaleBill.No_SaleBill FROM SaleBill
  2323. Join Customer On Customer.ID_Customer=SaleBill.ID_Customer
  2324. WHERE SaleBill.No_SaleBill &gt; @No_SaleBill
  2325. And Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  2326. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End --added for Special
  2327. and Special2_SaleBill=case @Special2 when 1 then Special2_SaleBill else 0 end
  2328. --and Customer.ID_RegionalLeader in
  2329. --(Select ID_RegionalLeader From Principal
  2330. --Where ID_Employee in(select ID_Employee from Employee where Name_Employee=@Name_Employee)
  2331. --)
  2332. ORDER BY SaleBill.No_SaleBill
  2333. SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  2334. Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
  2335. a.Name_User AS Name_Creator, ISNULL(b.Name_User, '') AS Name_Assessor, ISNULL(c.Name_User, '') AS LastModUserName,
  2336. Location.No_Location, Location.Name_Location, Employee.No_Employee AS No_Principal ,Employee.Name_Employee AS Principal_SaleBill
  2337. FROM SaleBill
  2338. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  2339. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  2340. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  2341. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  2342. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  2343. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  2344. WHERE SaleBill.No_SaleBill = @SaleBillNo
  2345. SELECT @ID_SaleBill = SaleBill.ID_SaleBill FROM SaleBill WHERE SaleBill.No_SaleBill = @SaleBillNo
  2346. SELECT SaleBillProduct.*, Product.No_Product, Product.Name_Product, Product.Unit_Product,
  2347. Product.LowSalePrice_Product, BillType.Name_BillType,
  2348. (SaleBillProduct.Quantity_SaleBillProduct * SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct,@SaleBillNo as No_SaleBill
  2349. FROM SaleBillProduct
  2350. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  2351. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  2352. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill ORDER BY CAST(SaleBillProduct.No_SaleBillProduct AS INT)
  2353. SELECT BillComment.* FROM BillComment WHERE BillComment.ID_Bill = @ID_SaleBill order by BillComment.No_BillComment
  2354. SELECT ReportComment.*,@SaleBillNo as No_SaleBill FROM ReportComment WHERE ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment">
  2355. <Params>
  2356. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  2357. <Param name="@Right" type="SaleBill.ID_Customer" Index="1" />
  2358. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="2" />
  2359. <Param name="@Name_Employee" type="Employee.Name_Employee" Index="3" />
  2360. <Param name="@Special2" type="SaleBill.Special_SaleBill" Index="4" />
  2361. </Params>
  2362. <Tables>
  2363. <Table name="SaleBill" />
  2364. <Table name="SaleBillProduct" />
  2365. <Table name="BillComment" />
  2366. <Table name="ReportComment" />
  2367. </Tables>
  2368. </SearchSaleBillNext>
  2369. <SearchSaleBillLast CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  2370. DECLARE @SaleBillNo nvarchar(64)
  2371. SELECT TOP 1 @SaleBillNo = SaleBill.No_SaleBill FROM SaleBill
  2372. Join Customer On Customer.ID_Customer=SaleBill.ID_Customer
  2373. WHERE Customer.ID_Creator=case IsNull(DataLength(@Right),0) When 0 Then Customer.ID_Creator Else @Right End --added for validating right
  2374. and Special_SaleBill=case @Special when 1 then Special_SaleBill else 0 End --added for Special
  2375. and Special2_SaleBill=case @Special2 when 1 then Special2_SaleBill else 0 end
  2376. --and Customer.ID_RegionalLeader in
  2377. --(Select ID_RegionalLeader From Principal
  2378. --Where ID_Employee in(select ID_Employee from Employee where Name_Employee=@Name_Employee)
  2379. -- )
  2380. ORDER BY SaleBill.No_SaleBill DESC
  2381. SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  2382. Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
  2383. a.Name_User AS Name_Creator, ISNULL(b.Name_User, '') AS Name_Assessor, ISNULL(c.Name_User, '') AS LastModUserName,
  2384. Location.No_Location, Location.Name_Location, Employee.No_Employee AS No_Principal ,Employee.Name_Employee AS Principal_SaleBill
  2385. FROM SaleBill LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  2386. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  2387. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  2388. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  2389. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  2390. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  2391. WHERE SaleBill.No_SaleBill = @SaleBillNo
  2392. SELECT @ID_SaleBill = SaleBill.ID_SaleBill FROM SaleBill WHERE SaleBill.No_SaleBill = @SaleBillNo
  2393. SELECT SaleBillProduct.*, Product.No_Product, Product.Name_Product, Product.Unit_Product,
  2394. Product.LowSalePrice_Product, BillType.Name_BillType,
  2395. (SaleBillProduct.Quantity_SaleBillProduct * SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct,@SaleBillNo as No_SaleBill
  2396. FROM SaleBillProduct
  2397. LEFT JOIN Product ON Product.ID_Product = SaleBillProduct.ID_Product
  2398. LEFT JOIN BillType ON BillType.Value_BillType = SaleBillProduct.Type_FromBill
  2399. WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill ORDER BY CAST(SaleBillProduct.No_SaleBillProduct AS INT)
  2400. SELECT BillComment.* FROM BillComment WHERE BillComment.ID_Bill = @ID_SaleBill order by BillComment.No_BillComment
  2401. SELECT ReportComment.*,@SaleBillNo as No_SaleBill FROM ReportComment WHERE ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment">
  2402. <Params>
  2403. <Param name="@Right" type="SaleBill.ID_Customer" Index="0" />
  2404. <Param name="@Special" type="SaleBill.Special_SaleBill" Index="1" />
  2405. <Param name="@Name_Employee" type="Employee.Name_Employee" Index="2" />
  2406. <Param name="@Special2" type="SaleBill.Special_SaleBill" Index="3" />
  2407. </Params>
  2408. <Tables>
  2409. <Table name="SaleBill" />
  2410. <Table name="SaleBillProduct" />
  2411. <Table name="BillComment" />
  2412. <Table name="ReportComment" />
  2413. </Tables>
  2414. </SearchSaleBillLast>
  2415. <SearchContrSOB CmdType="Text" CmdText=" SELECT SystemSetting.SaleAndOutDepot_SystemSetting,SystemSetting.OutDepotAndSaleBack_SystemSetting FROM SystemSetting WHERE SystemSetting.OutDepotAndSaleBack_SystemSetting = 1 and SystemSetting.SaleAndOutDepot_SystemSetting=1">
  2416. <Tables>
  2417. <Table name="SystemOutIn" />
  2418. </Tables>
  2419. </SearchContrSOB>
  2420. <SearchTypeComment CmdType="Text" CmdText=" declare @SRemark1_FunctionSetting int
  2421. declare @SRemark2_FunctionSetting int
  2422. Select @SRemark1_FunctionSetting = SRemark1_FunctionSetting, @SRemark2_FunctionSetting = SRemark2_FunctionSetting
  2423. from FunctionSetting
  2424. declare @ID_SaleBill uniqueidentifier
  2425. declare @flag int
  2426. set @flag = 0
  2427. if @SRemark1_FunctionSetting = 0
  2428. begin
  2429. select top 1 @ID_SaleBill = SaleBill.ID_SaleBill
  2430. from SaleBill
  2431. where ID_Customer = @ID_Customer
  2432. order by SaleBill.Date_SaleBill desc
  2433. if exists( select ReportComment.* from ReportComment where ReportComment.ID_Bill = @ID_SaleBill)
  2434. begin
  2435. select ReportComment.Comment_ReportComment from ReportComment where ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment
  2436. set @flag = 1
  2437. end
  2438. end
  2439. else
  2440. begin
  2441. if exists(SELECT Name_TypeDef FROM TypeDef WHERE Type_TypeDef=26 )
  2442. begin
  2443. SELECT Name_TypeDef as Comment_ReportComment FROM TypeDef WHERE Type_TypeDef=26
  2444. set @flag = 1
  2445. end
  2446. end
  2447. if @flag = 0
  2448. begin
  2449. if @SRemark2_FunctionSetting = 0
  2450. begin
  2451. select top 1 @ID_SaleBill = SaleBill.ID_SaleBill
  2452. from SaleBill
  2453. where ID_Customer = @ID_Customer
  2454. order by SaleBill.Date_SaleBill desc
  2455. select ReportComment.Comment_ReportComment from ReportComment where ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment
  2456. end
  2457. else
  2458. begin
  2459. SELECT Name_TypeDef as Comment_ReportComment FROM TypeDef WHERE Type_TypeDef=26
  2460. end
  2461. end
  2462. ">
  2463. <Params>
  2464. <Param name="@ID_Customer" type="SaleBill.ID_Customer" Index="0" />
  2465. </Params>
  2466. <Tables>
  2467. <Table name="TypeComment" />
  2468. </Tables>
  2469. </SearchTypeComment>
  2470. <SearchRespiteForSaleBill CmdType="Text" CmdText="
  2471. SELECT Name_TypeDef as Result FROM TypeDef WHERE Type_TypeDef=0
  2472. ">
  2473. <Tables>
  2474. <Table name="RespiteForSaleBill" />
  2475. </Tables>
  2476. </SearchRespiteForSaleBill>
  2477. <SearchOutDepot CmdType="Text" CmdText="
  2478. SELECT SUM(SaleSourceBillProduct.Quantity_OutDepot) As Quantity_OutDepot, SUM(SaleSourceBillProduct.Quantity_SaleRtn) As Quantity_SaleRtn, SUM(SaleSourceBillProduct.Quantity_InDepot) As Quantity_InDepot
  2479. FROM SaleSourceBillProduct INNER JOIN SaleBillProduct ON SaleBillProduct.ID_SaleSourceBillProduct = SaleSourceBillProduct.ID_SaleSourceBillProduct WHERE SaleBillProduct.ID_SaleBill = @ID_SaleBill
  2480. ">
  2481. <Params>
  2482. <Param name="@ID_SaleBill" type="SaleBill.ID_SaleBill" Index="0" />
  2483. </Params>
  2484. <Tables>
  2485. <Table name="OutDepot" />
  2486. </Tables>
  2487. </SearchOutDepot>
  2488. <SearchStockSettle CmdType="Text" CmdText="
  2489. Select * From StockSettleAccounts
  2490. Where DateDiff(Day,@Date_SaleOutDepotBill,FromDate_StockSettleAccounts) &lt;=0
  2491. And DateDiff(Day,@Date_SaleOutDepotBill,EndDate_StockSettleAccounts) &gt;=0
  2492. And Status_StockSettleAccounts=0
  2493. ">
  2494. <Params>
  2495. <Param name="@Date_SaleOutDepotBill" type="PurchaseInDepotBill.Date_SaleOutDepotBill" Index="0" />
  2496. </Params>
  2497. <Tables>
  2498. <Table name="StockSettle" />
  2499. </Tables>
  2500. </SearchStockSettle>
  2501. <SearchSaleBillWithNo1 CmdType="Text" CmdText=" DECLARE @ID_SaleBill uniqueidentifier
  2502. SELECT SaleBill.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  2503. Customer.LastDiscount_Customer, Customer.PostalCode_Customer,
  2504. a.Name_User AS Name_Creator, ISNULL(b.Name_User, '') AS Name_Assessor, ISNULL(c.Name_User, '') AS LastModUserName,
  2505. Location.No_Location, Location.Name_Location, Employee.No_Employee AS No_Principal,Employee.Name_Employee AS Principal_SaleBill,Customer.ID_Creator As CustomerCreator
  2506. FROM SaleBill
  2507. LEFT JOIN Customer ON Customer.ID_Customer = SaleBill.ID_Customer
  2508. LEFT JOIN AppUser a ON a.ID_User = SaleBill.ID_Creator
  2509. LEFT JOIN AppUser b ON b.ID_User = SaleBill.ID_Assessor
  2510. LEFT JOIN AppUser c ON c.ID_User = SaleBill.LastModUser_SaleBill
  2511. LEFT JOIN Location ON Location.ID_Location = SaleBill.ID_Location
  2512. LEFT JOIN Employee ON Employee.ID_Employee = SaleBill.ID_Principal
  2513. WHERE SaleBill.No_SaleBill = @No_SaleBill
  2514. SELECT @ID_SaleBill = SaleBill.ID_SaleBill FROM SaleBill WHERE SaleBill.No_SaleBill = @No_SaleBill
  2515. Select identity(int,1,1) as No_SaleBillProduct,ID_SaleBillProduct,ID_SaleBill,ID_SaleSourceBillProduct,Type_FromBill,No_FromBill,No_FromBillProduct,
  2516. ID_Product,Quantity_SaleBillProduct,OrderPrice_SaleBillProduct,Discount_SaleBillProduct,UnitPrice_SaleBillProduct,Comment_SaleBillProduct Into #SaleBillProduct From SaleBillProduct
  2517. Where ID_SaleBill = @ID_SaleBill
  2518. SELECT (@Count+No_SaleBillProduct) as No_SaleBillProduct,ID_SaleBillProduct,ID_SaleBill,ID_SaleSourceBillProduct,Type_FromBill,No_FromBill,No_FromBillProduct,
  2519. #SaleBillProduct.ID_Product,Quantity_SaleBillProduct,OrderPrice_SaleBillProduct,Discount_SaleBillProduct,UnitPrice_SaleBillProduct,Comment_SaleBillProduct, Product.No_Product, Product.Name_Product, Product.Unit_Product,
  2520. Product.LowSalePrice_Product, BillType.Name_BillType,
  2521. (#SaleBillProduct.Quantity_SaleBillProduct * #SaleBillProduct.UnitPrice_SaleBillProduct) AS Amount_SaleBillProduct ,@No_SaleBill as No_SaleBill
  2522. FROM #SaleBillProduct
  2523. LEFT JOIN Product ON Product.ID_Product = #SaleBillProduct.ID_Product
  2524. LEFT JOIN BillType ON BillType.Value_BillType = #SaleBillProduct.Type_FromBill
  2525. WHERE #SaleBillProduct.ID_SaleBill = @ID_SaleBill ORDER BY CAST(#SaleBillProduct.No_SaleBillProduct AS INT)
  2526. Drop Table #SaleBillProduct
  2527. SELECT BillComment.* FROM BillComment WHERE BillComment.ID_Bill = @ID_SaleBill order by BillComment.No_BillComment
  2528. SELECT ReportComment.* FROM ReportComment WHERE ReportComment.ID_Bill = @ID_SaleBill order by ReportComment.No_ReportComment">
  2529. <Params>
  2530. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" Index="0" />
  2531. <Param name="@Count" type="SaleBillProduct.Type_FromBill" Index="1" />
  2532. </Params>
  2533. <Tables>
  2534. <Table name="SaleBill" />
  2535. <Table name="SaleBillProduct" />
  2536. <Table name="BillComment" />
  2537. <Table name="ReportComment" />
  2538. </Tables>
  2539. </SearchSaleBillWithNo1>
  2540. <SearchLowSalePrice CmdType="Text" CmdText="Select * From Product Where ID_Product = @ID_Product">
  2541. <Params>
  2542. <Param name="@ID_Product" type="Product.ID_Product" Index="0" />
  2543. </Params>
  2544. <Tables>
  2545. <Table name="LowSalePrice" />
  2546. </Tables>
  2547. </SearchLowSalePrice>
  2548. <AddIndentBillOnNetProduct CmdType="Text" CmdText="Declare @ID_IndentBillOnNet Uniqueidentifier
  2549. Select @ID_IndentBillOnNet = ID_IndentBillOnNet
  2550. From IndentBillOnNet
  2551. Where No_IndentBillOnNet = @No_IndentBillOnNet
  2552. Update IndentBillOnNetProduct
  2553. Set Amount_SaleBill = Amount_SaleBill + @Quantity_SaleBillProduct
  2554. Where ID_IndentBillOnNet = @ID_IndentBillOnNet
  2555. And ID_Product = @ID_Product
  2556. Select 1
  2557. ">
  2558. <Params>
  2559. <Param name="@No_IndentBillOnNet" type="SaleBill.No_SaleBill" Index="0" />
  2560. <Param name="@ID_Product" type="Product.ID_Product" Index="1" />
  2561. <Param name="@Quantity_SaleBillProduct" type="SaleBillProduct.Quantity_SaleBillProduct" Index="2" />
  2562. </Params>
  2563. <Tables>
  2564. <Table name="add" />
  2565. </Tables>
  2566. </AddIndentBillOnNetProduct>
  2567. <ReduceIndentBillOnNetProduct CmdType="Text" CmdText="Declare @ID_IndentBillOnNet Uniqueidentifier
  2568. Select @ID_IndentBillOnNet = ID_IndentBillOnNet
  2569. From IndentBillOnNet
  2570. Where No_IndentBillOnNet = @No_IndentBillOnNet
  2571. Update IndentBillOnNetProduct
  2572. Set Amount_SaleBill = Amount_SaleBill - @Quantity_SaleBillProduct
  2573. Where ID_IndentBillOnNet = @ID_IndentBillOnNet
  2574. And ID_Product = @ID_Product
  2575. Select 0">
  2576. <Params>
  2577. <Param name="@No_IndentBillOnNet" type="SaleBill.No_SaleBill" Index="0" />
  2578. <Param name="@ID_Product" type="Product.ID_Product" Index="1" />
  2579. <Param name="@Quantity_SaleBillProduct" type="SaleBillProduct.Quantity_SaleBillProduct" Index="2" />
  2580. </Params>
  2581. <Tables>
  2582. <Table name="Reduce" />
  2583. </Tables>
  2584. </ReduceIndentBillOnNetProduct>
  2585. <SearchPrincipalByNo CmdType="Text" CmdText="Select top 1 ID_Employee From Employee where no_employee = @No_Employee">
  2586. <Params>
  2587. <Param name="@No_Employee" type="Employee.No_Employee" Index="0" />
  2588. </Params>
  2589. <Tables>
  2590. <Table name="Principal1" />
  2591. </Tables>
  2592. </SearchPrincipalByNo>
  2593. <UpdateCustomer CmdType="Text" CmdText="if (@IsAudit = '1')
  2594. Begin
  2595. Update Customer Set Saleroom_Customer = Saleroom_Customer + @Amount_SaleBill
  2596. Where Customer.ID_Customer = @ID_Customer
  2597. End
  2598. if (@IsAudit = '0')
  2599. Begin
  2600. Update Customer Set Saleroom_Customer = Saleroom_Customer - @Amount_SaleBill
  2601. Where Customer.ID_Customer = @ID_Customer
  2602. End
  2603. Select 1">
  2604. <Params>
  2605. <Param name="@ID_Customer" type="Customer.ID_Customer" Index="0" />
  2606. <Param name="Amount_SaleBill" type="SaleBill.Amount_SaleBill" Index="1" />
  2607. <Param name="IsAudit" type="SaleBill.No_SaleBill" Index="2" />
  2608. </Params>
  2609. <Tables>
  2610. <Table name="Audit" />
  2611. </Tables>
  2612. </UpdateCustomer>
  2613. <SearchCustomerPayLimitAll CmdType="Text" CmdText=" DECLARE @CustoemrNo nvarchar(64)
  2614. ,@CustomerID Uniqueidentifier
  2615. ,@HighCustomerID Uniqueidentifier
  2616. ,@PayLimit decimal(14,2)
  2617. ,@IsCustomer int
  2618. select @CustomerID=ID_Customer,@HighCustomerID=CustomerID_Customer
  2619. ,@IsCustomer =IsCustomersCustomer_Customer
  2620. From Customer
  2621. Where ID_Customer = @ID_Customer
  2622. IF (@IsCustomer = 1)
  2623. begin
  2624. select @PayLimit=IsNull(a.PayLimit_Customer,0)
  2625. from
  2626. (
  2627. SELECT ID_Customer,Convert(decimal(14,2),sum(IsNull(PayLimit_Customer,0))) As PayLimit_Customer
  2628. FROM CUSTOMER
  2629. WHERE SuspendDate_Customer is null
  2630. and ID_Customer = @HighCustomerID
  2631. Group By ID_Customer
  2632. ) a
  2633. SELECT (IsNull(@PayLimit,0)+Convert(decimal(14,2),sum(IsNull(PayLimit_Customer,0)))) As PayLimit_Customer
  2634. FROM CUSTOMER
  2635. WHERE SuspendDate_Customer is null
  2636. and CustomerID_Customer = @HighCustomerID
  2637. And IsCustomersCustomer_Customer = 1
  2638. Group By CustomerID_Customer
  2639. end
  2640. else
  2641. begin
  2642. select customer.ID_Customer
  2643. ,(Convert(decimal(14,2),IsNull(PayLimit_Customer,0)) + IsNull(A.LowPayLimit_Customer,0)) As PayLimit_Customer
  2644. from customer
  2645. left join (SELECT CustomerID_Customer,Convert(decimal(14,2),sum(IsNull(PayLimit_Customer,0))) As LowPayLimit_Customer
  2646. FROM CUSTOMER
  2647. WHERE SuspendDate_Customer is null
  2648. and IsCustomersCustomer_Customer = 1
  2649. Group By CustomerID_Customer)A On A.CustomerID_Customer =Customer.ID_Customer
  2650. Where ID_Customer = @CustomerID
  2651. end
  2652. ">
  2653. <Params>
  2654. <Param name="@ID_Customer" type="Customer.ID_Customer" Index="0" />
  2655. </Params>
  2656. <Tables>
  2657. <Table name="PayLimit" />
  2658. </Tables>
  2659. </SearchCustomerPayLimitAll>
  2660. <SearchSaleInvoice CmdType="Text" CmdText="
  2661. declare @CustomerID uniqueidentifier
  2662. declare @TMPID uniqueidentifier
  2663. select @CustomerID = ID_Customer from Customer where No_Customer = @No_Customer
  2664. select @TMPID = CustomerID_Customer from Customer where ID_Customer = @CustomerID and (CustomerID_Customer is not null and CustomerID_Customer != '00000000-0000-0000-0000-000000000000')
  2665. if @TMPID is not null
  2666. select @CustomerID = @TMPID
  2667. Select No_SaleInvoice,Amount_SaleInvoice-StrikedAmount_SaleInvoice as Amount_SaleInvoice
  2668. From SaleInvoice
  2669. Where ID_Customer = @CustomerID
  2670. And ID_Assessor is not null
  2671. And Amount_saleinvoice &gt; StrikedAmount_SaleInvoice + DisCountAmount_SaleInvoice
  2672. And PayDate_SaleInvoice &lt; CONVERT(VARCHAR(100),@AssessDate_SaleBill,23)
  2673. And Disable_SaleInvoice = 0
  2674. --Declare @ID_Customer uniqueidentifier
  2675. --Select @ID_Customer =ID_customer From Customer
  2676. --Where No_Customer=@No_Customer
  2677. --
  2678. --Declare @Customer Table(ID_Customer Uniqueidentifier)
  2679. --Insert Into @Customer Values(@ID_Customer)
  2680. --Insert Into @Customer
  2681. --Select ID_Customer
  2682. --From Customer
  2683. --Where CustomerID_Customer = @ID_Customer
  2684. --
  2685. --Select No_SaleInvoice,Amount_SaleInvoice-StrikedAmount_SaleInvoice as Amount_SaleInvoice
  2686. --From SaleInvoice
  2687. --Where ID_Customer in (Select ID_Customer From @Customer)
  2688. --And ID_Assessor is not null
  2689. --And Amount_saleinvoice &gt; StrikedAmount_SaleInvoice + DisCountAmount_SaleInvoice
  2690. --And PayDate_SaleInvoice &lt; CONVERT(VARCHAR(100),@AssessDate_SaleBill,23)
  2691. --And Disable_SaleInvoice = 0
  2692. ">
  2693. <Params>
  2694. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2695. <Param name="@AssessDate_SaleBill" type="SaleBill.AssessDate_SaleBill" Index="1" />
  2696. </Params>
  2697. <Tables>
  2698. <Table name="SearchSaleInvoice" />
  2699. </Tables>
  2700. </SearchSaleInvoice>
  2701. <UpdateToGet CmdType="Text" CmdText=" update SaleBill set ToGet_SaleBill=@ToGet_SaleBill
  2702. where No_SaleBill=@No_SaleBill
  2703. Select 1
  2704. ">
  2705. <Params>
  2706. <Param name="@ToGet_SaleBill" type="SaleBill.ToGet_SaleBill" />
  2707. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" />
  2708. </Params>
  2709. <Tables>
  2710. <Table name="UpdateToGet" />
  2711. </Tables>
  2712. </UpdateToGet>
  2713. <SearchToGet CmdType="Text" CmdText=" select ToGet_SaleBill from SaleBill where No_SaleBill=@No_SaleBill">
  2714. <Params>
  2715. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" />
  2716. </Params>
  2717. <Tables>
  2718. <Table name="SearchToGet" />
  2719. </Tables>
  2720. </SearchToGet>
  2721. <UpdatentbToGet CmdType="Text" CmdText=" DECLARE @CustoemrNo nvarchar(64)
  2722. ,@CustomerID Uniqueidentifier
  2723. ,@HighCustomerID Uniqueidentifier
  2724. ,@Amount decimal(14,6)
  2725. ,@IsCustomer int
  2726. select @CustomerID=ID_Customer,@HighCustomerID=CustomerID_Customer
  2727. ,@IsCustomer =IsCustomersCustomer_Customer
  2728. From Customer
  2729. Where No_Customer = @No_Customer
  2730. IF (@IsCustomer = 1)
  2731. begin
  2732. select @Amount=a.Amount
  2733. from
  2734. (
  2735. SELECT ID_Customer,sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  2736. FROM CUSTOMER
  2737. --WHERE SuspendDate_Customer is null
  2738. where ID_Customer = @HighCustomerID
  2739. Group By ID_Customer
  2740. ) a
  2741. SELECT (@Amount+Sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0))) As Amount
  2742. FROM CUSTOMER
  2743. --WHERE SuspendDate_Customer is null
  2744. WHERE CustomerID_Customer = @HighCustomerID
  2745. And IsCustomersCustomer_Customer = 1
  2746. Group By CustomerID_Customer
  2747. end
  2748. else
  2749. begin
  2750. select customer.ID_Customer
  2751. ,(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(A.Amount,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  2752. from customer
  2753. left join (SELECT CustomerID_Customer,sum(IsNull(OpeningToGetBalance_Customer,0)+IsNull(Saleroom_Customer,0)-IsNull(PerValue_Customer,0)+IsNull(OpeningBalanceAdjust_Customer,0)) As Amount
  2754. FROM CUSTOMER
  2755. --WHERE SuspendDate_Customer is null
  2756. WHERE IsCustomersCustomer_Customer = 1
  2757. Group By CustomerID_Customer)A On A.CustomerID_Customer =Customer.ID_Customer
  2758. Where ID_Customer = @CustomerID
  2759. end ">
  2760. <Params>
  2761. <Param name="@No_Customer" type="Customer.No_Customer" Index="0" />
  2762. </Params>
  2763. <Tables>
  2764. <Table name="tbToGet" />
  2765. </Tables>
  2766. </UpdatentbToGet>
  2767. <SearchCustomersIsInRegionalLeader CmdType="Text" CmdText=" select * from Employee
  2768. where ID_Employee
  2769. in
  2770. (
  2771. Select ID_Employee from Principal
  2772. where ID_RegionalLeader
  2773. in
  2774. (
  2775. select ID_RegionalLeader from Customer
  2776. where No_Customer = @No_Customer
  2777. )
  2778. )
  2779. and Employee.Name_Employee = @Name_Employee
  2780. ">
  2781. <Params>
  2782. <Param name="@No_Customer" type="Customer.No_Customer" />
  2783. <Param name="@Name_Employee" type="Employee.Name_Employee" />
  2784. </Params>
  2785. <Tables>
  2786. <Table name="IsInRegionalLeader" />
  2787. </Tables>
  2788. </SearchCustomersIsInRegionalLeader>
  2789. <SearchTime CmdType="Text" CmdText=" Select Convert(varchar,Date_SaleBill,23) as Date_SaleBill
  2790. From SaleBill
  2791. Where Convert(varchar,@Date_SaleBill,23) = Convert(varchar,getdate(),23)
  2792. ">
  2793. <Params>
  2794. <Param name="@Date_SaleBill" type="SaleBill.Date_SaleBill" />
  2795. </Params>
  2796. <Tables>
  2797. <Table name="Time" />
  2798. </Tables>
  2799. </SearchTime>
  2800. <UpdatePrice CmdType ="Text" CmdText=" Select SaleBill.ID_SaleBill
  2801. ,SUM(Case SaleBill.TaxCurrency_SaleBill When '外加' then UnitPrice_SaleBillProduct*Quantity_SaleBillProduct
  2802. else UnitPrice_SaleBillProduct*Quantity_SaleBillProduct/1.17 end) As GoodsAmount_SaleBill
  2803. ,SUM(Case SaleBill.TaxCurrency_SaleBill When '外加' then UnitPrice_SaleBillProduct*Quantity_SaleBillProduct*0.17
  2804. else (UnitPrice_SaleBillProduct*Quantity_SaleBillProduct-UnitPrice_SaleBillProduct*Quantity_SaleBillProduct/1.17) end) As TaxAmount_SaleBill
  2805. ,SUM(Case SaleBill.TaxCurrency_SaleBill When '外加' then UnitPrice_SaleBillProduct*Quantity_SaleBillProduct*1.17
  2806. else (UnitPrice_SaleBillProduct*Quantity_SaleBillProduct) end) As Amount_SaleBill
  2807. from SaleBillProduct
  2808. left join SaleBill on SaleBill.ID_SaleBill = SaleBillProduct.ID_SaleBill
  2809. group by SaleBill.ID_SaleBill
  2810. update SaleBill set GoodsAmount_SaleBill =@GoodsAmount_SaleBill
  2811. ,TaxAmount_SaleBill = @TaxAmount_SaleBill
  2812. ,Amount_SaleBill = @Amount_SaleBill
  2813. where No_SaleBill=@No_SaleBill
  2814. ">
  2815. <Params>
  2816. <Param name="@GoodsAmount_SaleBill" type="SaleBill.GoodsAmount_SaleBill" />
  2817. <Param name="@TaxAmount_SaleBill" type="SaleBill.TaxAmount_SaleBill" />
  2818. <Param name="@Amount_SaleBill" type="SaleBill.Amount_SaleBill" />
  2819. <Param name="@No_SaleBill" type="SaleBill.No_SaleBill" />
  2820. </Params>
  2821. <Tables>
  2822. <Table name="updatePrice" />
  2823. </Tables>
  2824. </UpdatePrice>
  2825. </Search>
  2826. </Server>
  2827. <Lables>
  2828. <Search>
  2829. Empty();
  2830. NewInstance();
  2831. dtpDate.Enabled = false;
  2832. tbNo.ReadOnly = false;
  2833. cbLocation.Enabled = false;
  2834. tbCustomerNo.ReadOnly = true;
  2835. txtOrderBillNo.ReadOnly = true;
  2836. cbGetMethod.Enabled = false;
  2837. ntbDiscount.ReadOnly = true;
  2838. cbTaxCurrency.Enabled = false;
  2839. cbPrincipal.Enabled = false;
  2840. cbLinkman.Enabled = false;
  2841. cbTele.Enabled = false;
  2842. cbOutStatus.Enabled = false;
  2843. ckSpecial.Enabled=false;
  2844. ckSpecial1.Enabled=false;
  2845. cbFax.Enabled = false;
  2846. txtSendAddr.ReadOnly = true;
  2847. cbInvoiceTitle.Enabled = false;
  2848. txtAdress.ReadOnly = true;
  2849. dgProduct.ReadOnly = true;
  2850. dgRemark.ReadOnly = true;
  2851. dgReportComment.ReadOnly = true;
  2852. toolBar.EnableNew = GetRight(@Title,"新增");
  2853. toolBar.EnableSubmit = false;
  2854. toolBar.EnableModify = false;
  2855. toolBar.EnableDelete = false;
  2856. toolBar.EnableAudit = false;
  2857. toolBar.EnableUnAudit = false;
  2858. toolBar.EnablePrint = false;
  2859. toolBar.EnableExport = false;
  2860. toolBar.EnableImport = false;
  2861. toolBar.EnableAssess = false;
  2862. toolBar.EnableUnAssess = false;
  2863. btnDelelte.Enabled = false;
  2864. #SaleBill.ID_Location = DBNull();
  2865. #SaleBill.ToGet_SaleBill = 0;
  2866. #SaleBill.Discount_SaleBill = 0;
  2867. #SaleBill.TaxCurrency_SaleBill = "";
  2868. #SaleBill.Currency_SaleBill = "";
  2869. #SaleBill.AssessDate_SaleBill = DBNull();
  2870. #SaleBill.LastModUser_SaleBill = DBNull();
  2871. #SaleBill.LastModDate_SaleBill = DBNull();
  2872. #SaleBill.NumSum = 0;
  2873. #SaleBill.MoneySum = 0;
  2874. #SaleBill.TaxSum = 0;
  2875. #SaleBill.Amount_SaleBill = 0;
  2876. UpdateForm(true, "");
  2877. tbNo.Focus();
  2878. @Status = 0;
  2879. </Search>
  2880. <New>
  2881. Empty();
  2882. NewInstance();
  2883. @viewMode = false;
  2884. dtpDate.Enabled = true;
  2885. tbNo.ReadOnly = true;
  2886. cbLocation.Enabled = true;
  2887. tbCustomerNo.ReadOnly = false;
  2888. txtOrderBillNo.ReadOnly = false;
  2889. cbGetMethod.Enabled = true;
  2890. ntbDiscount.ReadOnly = false;
  2891. cbTaxCurrency.Enabled = true;
  2892. cbPrincipal.Enabled = true;
  2893. cbLinkman.Enabled = true;
  2894. cbTele.Enabled = true;
  2895. cbFax.Enabled = true;
  2896. ckSpecial.Enabled=GetFieldRight(@Title,"特价单","修改");
  2897. ckSpecial1.Enabled=GetFieldRight(@Title,"特批单","修改");
  2898. cbOutStatus.Enabled = true;
  2899. txtSendAddr.ReadOnly = false;
  2900. cbInvoiceTitle.Enabled = true;
  2901. txtAdress.ReadOnly = false;
  2902. dgProduct.ReadOnly = false;
  2903. dgRemark.ReadOnly = false;
  2904. dgReportComment.ReadOnly = false;
  2905. toolBar.EnableNew = false;
  2906. toolBar.EnableSubmit = GetRight(@Title,"新增");
  2907. toolBar.EnableModify = false;
  2908. toolBar.EnableDelete = false;
  2909. toolBar.EnableAudit = false;
  2910. toolBar.EnableUnAudit = false;
  2911. toolBar.EnablePrint = false;
  2912. toolBar.EnableExport = false;
  2913. toolBar.EnableImport = true;
  2914. toolBar.EnableAssess = false;
  2915. toolBar.EnableUnAssess = false;
  2916. btnDelelte.Enabled = false;
  2917. #SaleBill.ID_SaleBill = NewGuid();
  2918. #SaleBill.ID_Location = DBNull();
  2919. #SaleBill.ToGet_SaleBill = 0;
  2920. #SaleBill.Discount_SaleBill = 100;
  2921. #SaleBill.TaxCurrency_SaleBill = "外加";
  2922. #SaleBill.Currency_SaleBill = @SysCurrency;
  2923. #SaleBill.ID_Creator = GetLoginUserID();
  2924. #SaleBill.Name_Creator = GetCurrentUser();
  2925. #SaleBill.ID_Assessor = DBNull();
  2926. #SaleBill.AssessDate_SaleBill = DBNull();
  2927. #SaleBill.LastModUser_SaleBill = DBNull();
  2928. #SaleBill.LastModDate_SaleBill = DBNull();
  2929. #SaleBill.NumSum = 0;
  2930. #SaleBill.MoneySum = 0;
  2931. #SaleBill.TaxSum = 0;
  2932. #SaleBill.Amount_SaleBill = 0;
  2933. #SaleBill.ID_Location = GetCurrentDepotID();
  2934. #SaleBill.Name_Location = GetCurrentDepot();
  2935. #SaleBill.No_Location = GetCurrentDepotNo();
  2936. #SaleBill.Date_SaleBill = GetCurrentTime();
  2937. dgProduct.SetColumnReadOnly(1, false);
  2938. dgProduct.SetColumnReadOnly(9, false);
  2939. dgProduct.SetColumnReadOnly(10, false);
  2940. dgProduct.SetColumnReadOnly(11, false);
  2941. dgProduct.RowHeaderCheck=true;
  2942. dgProduct.AllowNew(true);
  2943. dgProduct.AllowDelete(true);
  2944. SetColumnDefaultValue("SaleBillProduct", "Discount_SaleBillProduct", #SaleBill.Discount_SaleBill);
  2945. SetColumnDefaultValue("SaleBillProduct", "Quantity_SaleBillProduct", 1);
  2946. UpdateForm(true, "");
  2947. dtpDate.Focus();
  2948. @Status = 1;
  2949. </New>
  2950. <View>
  2951. @viewMode = true;
  2952. dtpDate.Enabled = false;
  2953. tbNo.ReadOnly = false;
  2954. cbLocation.Enabled = false;
  2955. tbCustomerNo.ReadOnly = true;
  2956. txtOrderBillNo.ReadOnly = true;
  2957. cbGetMethod.Enabled = false;
  2958. ntbDiscount.ReadOnly = true;
  2959. cbTaxCurrency.Enabled = false;
  2960. cbPrincipal.Enabled = false;
  2961. cbLinkman.Enabled = false;
  2962. cbTele.Enabled = false;
  2963. ckSpecial.Enabled=false;
  2964. ckSpecial1.Enabled=false;
  2965. cbFax.Enabled = false;
  2966. cbOutStatus.Enabled = false;
  2967. txtSendAddr.ReadOnly = true;
  2968. cbInvoiceTitle.Enabled = false;
  2969. txtAdress.ReadOnly = true;
  2970. dgProduct.ReadOnly = true;
  2971. dgRemark.ReadOnly = true;
  2972. dgReportComment.ReadOnly = true;
  2973. toolBar.EnableNew = GetRight(@Title,"新增");
  2974. toolBar.EnableSubmit = false;
  2975. if(Search("SearchStockSettle",#SaleBill.Date_SaleBill))
  2976. {
  2977. if(Equals(#SaleBill.ID_Assessor, DBNull()))
  2978. {
  2979. if(#SaleBill.Disable_SaleBill==false)
  2980. {
  2981. toolBar.EnableModify = GetRight(@Title,"修改");
  2982. toolBar.EnableDelete = GetRight(@Title,"删除");
  2983. toolBar.EnableAudit = GetRight(@Title,"审核");
  2984. }
  2985. else
  2986. {
  2987. toolBar.EnableAudit = false;
  2988. toolBar.EnableModify = false;
  2989. toolBar.EnableDelete = false;
  2990. }
  2991. toolBar.EnableUnAudit = false;
  2992. toolBar.EnableAssess = false;
  2993. btnDelelte.Enabled = false;
  2994. toolBar.EnableUnAssess = false;
  2995. }
  2996. else
  2997. {
  2998. toolBar.EnableModify = false;
  2999. toolBar.EnableDelete = false;
  3000. toolBar.EnableAudit = false;
  3001. toolBar.EnableUnAudit = GetRight(@Title,"取消审核");
  3002. btnDelelte.Enabled = GetRight(@Title,"取消审核")&amp;&amp;GetRight(@Title,"删除");
  3003. if(#SaleBill.Assess_SaleBill == 0)
  3004. {
  3005. toolBar.EnableAssess = GetRight(@Title,"审核");
  3006. toolBar.EnableUnAssess = false;
  3007. }
  3008. else
  3009. {
  3010. toolBar.EnableUnAssess = GetRight(@Title,"取消审核");
  3011. toolBar.EnableAssess = false;
  3012. }
  3013. }
  3014. }
  3015. else
  3016. {
  3017. toolBar.EnablePrint=false;
  3018. toolBar.EnableAudit=false;
  3019. toolBar.EnableUnAudit=false;
  3020. toolBar.EnableModify=false;
  3021. toolBar.EnableDelete=false;
  3022. btnDelelte.Enabled = false;
  3023. }
  3024. toolBar.EnablePrint = GetRight(@Title,"打印");
  3025. toolBar.EnableExport = true;
  3026. toolBar.EnableImport = false;
  3027. UpdateForm(true, "");
  3028. @Status = 2;
  3029. tbNo.Focus();
  3030. <!--if (!Search("SearchCustomersIsInRegionalLeader",tbCustomerNo.CValue, GetCurrentUser()))
  3031. {
  3032. MessageBox("你与客户不在同一个区域,不能填单!");
  3033. tbCustomerNo.Text = "";
  3034. return;
  3035. }-->
  3036. </View>
  3037. <Modify>
  3038. @viewMode = false;
  3039. dtpDate.Enabled = false;
  3040. tbNo.ReadOnly = true;
  3041. cbLocation.Enabled = true;
  3042. tbCustomerNo.ReadOnly = false;
  3043. txtOrderBillNo.ReadOnly = false;
  3044. cbGetMethod.Enabled = true;
  3045. ntbDiscount.ReadOnly = false;
  3046. ckSpecial.Enabled=GetFieldRight(@Title,"特价单","修改");
  3047. ckSpecial1.Enabled=GetFieldRight(@Title,"特批单","修改");
  3048. cbPrincipal.Enabled = true;
  3049. cbLinkman.Enabled = true;
  3050. cbTele.Enabled = true;
  3051. cbFax.Enabled = true;
  3052. cbOutStatus.Enabled = true;
  3053. txtSendAddr.ReadOnly = false;
  3054. cbInvoiceTitle.Enabled = true;
  3055. txtAdress.ReadOnly = false;
  3056. dgProduct.ReadOnly = false;
  3057. dgRemark.ReadOnly = false;
  3058. dgReportComment.ReadOnly = false;
  3059. toolBar.EnableNew = false;
  3060. toolBar.EnableSubmit = GetRight(@Title,"修改");
  3061. toolBar.EnableModify = false;
  3062. toolBar.EnableDelete = false;
  3063. toolBar.EnableAudit = false;
  3064. toolBar.EnableUnAudit = false;
  3065. toolBar.EnablePrint = false;
  3066. toolBar.EnableExport = false;
  3067. toolBar.EnableImport = false;
  3068. toolBar.EnableAssess = false;
  3069. toolBar.EnableUnAssess = false;
  3070. btnDelelte.Enabled = false;
  3071. #SaleBill.LastModUser_SaleBill = GetLoginUserID();
  3072. #SaleBill.LastModUserName = GetCurrentUser();
  3073. #SaleBill.LastModDate_SaleBill = DateTimeNow();
  3074. @HaveAccessed = !Equals(#SaleBill.AssessDate_SaleBill,DBNull());
  3075. if(@HaveAccessed)
  3076. cbTaxCurrency.Enabled = false;
  3077. else
  3078. cbTaxCurrency.Enabled = true;
  3079. dgProduct.SetColumnReadOnly(1, @HaveAccessed);
  3080. <!--dgProduct.SetColumnReadOnly(2, !Equal(#SaleBill.ID_AssessDate,DBNull()));wja-->
  3081. dgProduct.SetColumnReadOnly(10, @HaveAccessed);
  3082. dgProduct.SetColumnReadOnly(11, @HaveAccessed);
  3083. dgProduct.SetColumnReadOnly(12, @HaveAccessed);
  3084. dgProduct.AllowNew(!@HaveAccessed);
  3085. dgProduct.AllowDelete(!@HaveAccessed);
  3086. dgProduct.RowHeaderCheck=!@HaveAccessed;
  3087. SetColumnDefaultValue("SaleBillProduct", "Discount_SaleBillProduct", #SaleBill.Discount_SaleBill);
  3088. SetColumnDefaultValue("SaleBillProduct", "Quantity_SaleBillProduct", 1);
  3089. UpdateForm(true, "");
  3090. @Status = 3;
  3091. </Modify>
  3092. <SubmitButtonClick>
  3093. <![CDATA[
  3094. @sellprice=0;
  3095. if(!Search("SearchStockSettle",dtpDate.Value))
  3096. {
  3097. MessageBox("制单日期不在开帐区间内,提交失败!");
  3098. return;
  3099. }
  3100. if (!Search("SearchCustomerWithNo", tbCustomerNo.CValue) || !Equals(#SaleBill.ID_Customer,#Customer.ID_Customer))
  3101. {
  3102. MessageBox("请输入有效的客户编号,并按回车确认!",@Title);
  3103. tbCustomerNo.Focus();
  3104. return;
  3105. }
  3106. if (!cbLocation.CheckSelectedItem())
  3107. {
  3108. MessageBox("请选择有效的出货仓库!",@Title);
  3109. tbDetail.SelectedIndex = 0;
  3110. cbLocation.Focus();
  3111. return;
  3112. }
  3113. if (!cbGetMethod.CheckSelectedItem())
  3114. {
  3115. MessageBox("请选择有效的收款方式!",@Title);
  3116. tbDetail.SelectedIndex = 0;
  3117. cbGetMethod.Focus();
  3118. return;
  3119. }
  3120. if (!cbTaxCurrency.CheckSelectedItem())
  3121. {
  3122. MessageBox("请选择有效的税别!",@Title);
  3123. tbDetail.SelectedIndex = 0;
  3124. cbTaxCurrency.Focus();
  3125. return;
  3126. }
  3127. if (!cbPrincipal.CheckSelectedItem())
  3128. {
  3129. MessageBox("请选择有效的负责业务!",@Title);
  3130. tbDetail.SelectedIndex = 0;
  3131. cbPrincipal.Focus();
  3132. return;
  3133. }
  3134. if (RowCount("#SaleBillProduct") == 0)
  3135. {
  3136. MessageBox("请输入销售产品!",@Title);
  3137. tbDetail.SelectedIndex = 1;
  3138. dgProduct.Focus();
  3139. return;
  3140. }
  3141. @Money=0;
  3142. @Tax=0;
  3143. @Total=0;
  3144. switch (cbTaxCurrency.SelectedName)
  3145. {
  3146. case "外加":
  3147. case "零税":
  3148. case "免税":
  3149. @Money = SumOfCol("#SaleBillProduct.Amount_SaleBillProduct");
  3150. break;
  3151. case "内含":
  3152. @Total= SumOfCol("#SaleBillProduct.Amount_SaleBillProduct");
  3153. SuspendLayout();
  3154. for(@i=0;@i < RowCount("#SaleBillProduct");@i++)
  3155. {
  3156. SetPosition("#SaleBillProduct",@i);
  3157. @Tax +=FormatNumber(#SaleBillProduct.Amount_SaleBillProduct * @CessOut / (1 + @CessOut), #SystemSetting.PriceDecimal_SystemSetting);
  3158. }
  3159. ResumeLayout();
  3160. @Money = @Total - @Tax;
  3161. break;
  3162. }
  3163. if(@Money!=ntbMoneySum.CValue)
  3164. {
  3165. MessageBox("发生操作错误,请联系上海韶光有限公司,电话54590333-675!",@Title);
  3166. return;
  3167. }
  3168. UpdateForm(false, "");
  3169. SuspendLayout();
  3170. for (@i=0;@i<RowCount("#SaleBillProduct");@i=@i+1)
  3171. {
  3172. SetPosition("#SaleBillProduct", @i);
  3173. if (#SaleBillProduct.Type_FromBill == 23 && #SaleBillProduct.No_FromBill != "" && Search("SearchFromBillWithNo",#SaleBillProduct.No_FromBill))
  3174. {
  3175. if (Equals(#FromBill.ID_Assessor,DBNull()))
  3176. {
  3177. tbDetail.SelectedIndex = 1;
  3178. dgProduct.CurrentRowIndex = @i;
  3179. @ClickResult = MessageBox("该来源单据未经审核,确定要保留来源单据资料吗?",@Title,MB_YESNOCANCEL);
  3180. if (@ClickResult == DialogResult("CANCEL"))
  3181. {
  3182. dgProduct.Focus();
  3183. ResumeLayout();
  3184. return;
  3185. }
  3186. else if (@ClickResult == DialogResult("NO"))
  3187. {
  3188. #SaleBillProduct.Name_BillType = "";
  3189. #SaleBillProduct.Type_FromBill = 0;
  3190. #SaleBillProduct.No_FromBill = "";
  3191. #SaleBillProduct.No_FromBillProduct = "";
  3192. }
  3193. }
  3194. }
  3195. if (#SaleBillProduct.Type_FromBill == 24 && #SaleBillProduct.No_FromBill != "" && Search("SearchIndentBillWithNo",#SaleBillProduct.No_FromBill))
  3196. {
  3197. if (Equals(#IndentBill.ID_Assessor,DBNull()))
  3198. {
  3199. tbDetail.SelectedIndex = 1;
  3200. dgProduct.CurrentRowIndex = @i;
  3201. @ClickResult = MessageBox("该来源单据未经审核,确定要保留来源单据资料吗?",@Title,MB_YESNOCANCEL);
  3202. if (@ClickResult == DialogResult("CANCEL"))
  3203. {
  3204. dgProduct.Focus();
  3205. ResumeLayout();
  3206. return;
  3207. }
  3208. else if (@ClickResult == DialogResult("NO"))
  3209. {
  3210. #SaleBillProduct.Name_BillType = "";
  3211. #SaleBillProduct.Type_FromBill = 0;
  3212. #SaleBillProduct.No_FromBill = "";
  3213. #SaleBillProduct.No_FromBillProduct = "";
  3214. }
  3215. }
  3216. }
  3217. if (#SaleBillProduct.Type_FromBill == 25 && #SaleBillProduct.No_FromBill != "" && Search("SearchIndentBillOnNetProductWithNoID",#SaleBillProduct.No_FromBill,#SaleBillProduct.ID_Product))
  3218. {
  3219. if (#SaleBillProduct.Quantity_SaleBillProduct > (#IndentBillOnNetProductAmount.Quantity_IndentBillOnNetProduct-#IndentBillOnNetProductAmount.Amount_SaleBill))
  3220. {
  3221. dgProduct.CurrentRowIndex = @i;
  3222. tbDetail.SelectedIndex = 1;
  3223. dgProduct.Focus();
  3224. MessageBox("销货数量大于网上订货数量,提交失败!",@Title);
  3225. ResumeLayout();
  3226. return;
  3227. }
  3228. }
  3229. if(Equals(#SaleBillProduct.No_Product,""))
  3230. {
  3231. tbDetail.SelectedIndex = 1;
  3232. dgProduct.CurrentRowIndex = @i;
  3233. MessageBox("请填入产品编号!",@Title);
  3234. dgProduct.Focus();
  3235. ResumeLayout();
  3236. return;
  3237. }
  3238. if(Equals(#SaleBillProduct.ID_Product,GuidEmpty()))
  3239. {
  3240. tbDetail.SelectedIndex = 1;
  3241. dgProduct.CurrentRowIndex = @i;
  3242. MessageBox("该产品不存在!",@Title);
  3243. dgProduct.Focus();
  3244. ResumeLayout();
  3245. return;
  3246. }
  3247. if (#SaleBillProduct.Quantity_SaleBillProduct <= 0 || #SaleBillProduct.UnitPrice_SaleBillProduct <= 0 || #SaleBillProduct.Discount_SaleBillProduct < 0)
  3248. {
  3249. tbDetail.SelectedIndex = 1;
  3250. dgProduct.CurrentRowIndex = @i;
  3251. if(#SaleBillProduct.Quantity_SaleBillProduct <= 0)
  3252. {
  3253. MessageBox("数量不得小于0!",@Title);
  3254. }
  3255. else if(#SaleBillProduct.UnitPrice_SaleBillProduct <= 0)
  3256. {
  3257. MessageBox("单价不得小于0!",@Title);
  3258. }
  3259. else
  3260. {
  3261. MessageBox("折扣不得小于0!",@Title);
  3262. }
  3263. dgProduct.Focus();
  3264. ResumeLayout();
  3265. return;
  3266. }
  3267. Search("SearchLowSalePrice",#SaleBillProduct.ID_Product);
  3268. if (ckSpecial.Checked == false)
  3269. {
  3270. if(cbTaxCurrency.SelectedName=="内含")
  3271. {
  3272. if (#SaleBillProduct.UnitPrice_SaleBillProduct/1.17 < #LowSalePrice.LowSalePrice_Product)
  3273. {
  3274. tbDetail.SelectedIndex = 1;
  3275. dgProduct.CurrentRowIndex = @i;
  3276. MessageBox("产品单价低于最低售价,提交失败!\r\n产品序号 : " + #SaleBillProduct.No_SaleBillProduct ,@Title);
  3277. dgProduct.Focus();
  3278. ResumeLayout();
  3279. return;
  3280. }
  3281. }
  3282. else
  3283. {
  3284. if (#SaleBillProduct.UnitPrice_SaleBillProduct < #LowSalePrice.LowSalePrice_Product)
  3285. {
  3286. tbDetail.SelectedIndex = 1;
  3287. dgProduct.CurrentRowIndex = @i;
  3288. MessageBox("产品单价低于最低售价,提交失败!\r\n产品序号 : " + #SaleBillProduct.No_SaleBillProduct,@Title);
  3289. dgProduct.Focus();
  3290. ResumeLayout();
  3291. return;
  3292. }
  3293. }
  3294. }
  3295. @AvaQuantity = AvailableQty(#SaleBillProduct.ID_Product,#SaleBill.ID_Location);
  3296. if (#SaleBillProduct.Quantity_SaleBillProduct > @AvaQuantity)
  3297. {
  3298. @strMessage = #SaleBillProduct.No_Product +" 目前可用数量为" + (string)@AvaQuantity + ",不能满足此次销货需求,继续提交吗!";
  3299. @ClickResult = MessageBox(@strMessage,@Title,MB_OKCANCEL);
  3300. if (@ClickResult == DialogResult("CANCEL"))
  3301. {
  3302. ResumeLayout();
  3303. return;
  3304. }
  3305. }
  3306. if (Equals(#SaleBillProduct.ID_SaleBillProduct,GuidEmpty()))
  3307. #SaleBillProduct.ID_SaleBillProduct = NewGuid();
  3308. #SaleBillProduct.ID_SaleBill =#SaleBill.ID_SaleBill;
  3309. }
  3310. for (@j=0;@j<RowCount("#BillComment");@j=@j+1)
  3311. {
  3312. SetPosition("#BillComment", @j);
  3313. if (Equals(#BillComment.ID_BillComment,GuidEmpty()))
  3314. #BillComment.ID_BillComment = NewGuid();
  3315. #BillComment.ID_Bill = #SaleBill.ID_SaleBill;
  3316. }
  3317. for (@k=0;@k<RowCount("#ReportComment");@k=@k+1)
  3318. {
  3319. SetPosition("#ReportComment", @k);
  3320. if (Equals(#ReportComment.ID_ReportComment,GuidEmpty()))
  3321. #ReportComment.ID_ReportComment = NewGuid();
  3322. #ReportComment.ID_Bill = #SaleBill.ID_SaleBill;
  3323. }
  3324. for(@r = 0;@r<RowCount("#SaleBillProduct");@r = @r+1)
  3325. {
  3326. SetPosition("#SaleBillProduct", @r);
  3327. @sellprice=#SaleBillProduct.UnitPrice_SaleBillProduct;
  3328. }
  3329. @SumGoodsMoney=0;
  3330. @SumTax=0;
  3331. @SumTotal=0;
  3332. for(@m = 0;@m<RowCount("#SaleBillProduct");@m = @m+1)
  3333. {
  3334. SetPosition("#SaleBillProduct", @m);
  3335. @sellprice=#SaleBillProduct.UnitPrice_SaleBillProduct;
  3336. if(#SaleBillProduct.OrderPrice_SaleBillProduct == 0)
  3337. {
  3338. #SaleBillProduct.Discount_SaleBillProduct = 100;
  3339. }
  3340. else
  3341. {
  3342. #SaleBillProduct.Discount_SaleBillProduct = @sellprice/#SaleBillProduct.OrderPrice_SaleBillProduct*100;
  3343. }
  3344. if(#SaleBill.TaxCurrency_SaleBill=="外加")
  3345. {
  3346. @SumGoodsMoney += FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct,@PriceDecimal);
  3347. @SumTax += FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct*0.17,@PriceDecimal);
  3348. @SumTotal += FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct*1.17,@PriceDecimal);
  3349. }
  3350. else
  3351. {
  3352. if(#SaleBill.TaxCurrency_SaleBill=="内含")
  3353. {
  3354. @SumGoodsMoney+= FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct/1.17,@PriceDecimal);
  3355. @SumTax += FormatNumber((@sellprice*#SaleBillProduct.Quantity_SaleBillProduct)-(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct/1.17),@PriceDecimal);
  3356. }
  3357. else
  3358. {
  3359. @SumGoodsMoney+= FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct,@PriceDecimal);
  3360. }
  3361. @SumTotal +=FormatNumber(@sellprice*#SaleBillProduct.Quantity_SaleBillProduct,@PriceDecimal);
  3362. }
  3363. #SaleBillProduct.UnitPrice_SaleBillProduct=@sellprice;
  3364. }
  3365. #SaleBill.GoodsAmount_SaleBill = @SumGoodsMoney;
  3366. #SaleBill.TaxAmount_SaleBill = @SumTax;
  3367. #SaleBill.Amount_SaleBill = @SumTotal;
  3368. ResumeLayout();
  3369. UpdateForm(true, "");
  3370. if(@Status == 1)
  3371. {
  3372. #SaleBill.CreateDate_SaleBill = DateTimeNow();
  3373. #SaleBill.No_SaleBill = New("#SaleBill.No_SaleBill", dtpDate.CValue);
  3374. }
  3375. else if(@Status == 3)
  3376. {
  3377. #SaleBill.LastModDate_SaleBill = DateTimeNow();
  3378. Update();
  3379. }
  3380. ChangeMode("View");
  3381. ]]>
  3382. </SubmitButtonClick>
  3383. <CountSum>
  3384. <![CDATA[
  3385. if (RowCount("#SaleBillProduct") == 0)
  3386. {
  3387. #SaleBill.NumSum = 0;
  3388. #SaleBill.GoodsAmount_SaleBill = 0;
  3389. #SaleBill.TaxAmount_SaleBill = 0;
  3390. #SaleBill.Amount_SaleBill = 0;
  3391. }
  3392. else
  3393. {
  3394. #SaleBill.NumSum = SumOfCol("#SaleBillProduct.Quantity_SaleBillProduct");
  3395. switch (cbTaxCurrency.SelectedName)
  3396. {
  3397. case "外加":
  3398. #SaleBill.GoodsAmount_SaleBill = SumOfCol("#SaleBillProduct.Amount_SaleBillProduct");
  3399. #SaleBill.TaxAmount_SaleBill=0;
  3400. SuspendLayout();
  3401. for(@i=0;@i < RowCount("#SaleBillProduct");@i++)
  3402. {
  3403. SetPosition("#SaleBillProduct",@i);
  3404. #SaleBill.TaxAmount_SaleBill += FormatNumber(#SaleBillProduct.Amount_SaleBillProduct * @CessOut,#SystemSetting.PriceDecimal_SystemSetting);
  3405. }
  3406. ResumeLayout();
  3407. #SaleBill.Amount_SaleBill = FormatNumber(#SaleBill.GoodsAmount_SaleBill + #SaleBill.TaxAmount_SaleBill,#SystemSetting.PriceDecimal_SystemSetting);
  3408. break;
  3409. case "内含":
  3410. #SaleBill.Amount_SaleBill = SumOfCol("#SaleBillProduct.Amount_SaleBillProduct");
  3411. #SaleBill.TaxAmount_SaleBill = 0;
  3412. SuspendLayout();
  3413. for(@i=0;@i < RowCount("#SaleBillProduct");@i++)
  3414. {
  3415. SetPosition("#SaleBillProduct",@i);
  3416. #SaleBill.TaxAmount_SaleBill +=FormatNumber(#SaleBillProduct.Amount_SaleBillProduct * @CessOut / (1 + @CessOut), #SystemSetting.PriceDecimal_SystemSetting);
  3417. }
  3418. ResumeLayout();
  3419. #SaleBill.GoodsAmount_SaleBill = FormatNumber(#SaleBill.Amount_SaleBill - #SaleBill.TaxAmount_SaleBill,#SystemSetting.PriceDecimal_SystemSetting);
  3420. break;
  3421. case "零税":
  3422. case "免税":
  3423. #SaleBill.GoodsAmount_SaleBill = SumOfCol("#SaleBillProduct.Amount_SaleBillProduct");
  3424. #SaleBill.TaxAmount_SaleBill = 0;
  3425. #SaleBill.Amount_SaleBill = #SaleBill.GoodsAmount_SaleBill;
  3426. break;
  3427. }
  3428. }
  3429. UpdateForm(true, "ntbNumSum");
  3430. UpdateForm(true, "ntbMoneySum");
  3431. UpdateForm(true, "ntbTaxSum");
  3432. UpdateForm(true, "ntbSum");
  3433. ]]>
  3434. </CountSum>
  3435. <CountPrice>
  3436. <![CDATA[
  3437. if (RowCount("#SaleBillProduct") != 0)
  3438. {
  3439. switch (cbTaxCurrency.SelectedName)
  3440. {
  3441. case "内含":
  3442. SuspendLayout();
  3443. for(@j=0;@j<RowCount("#SaleBillProduct");@j=@j+1)
  3444. {
  3445. SetPosition("#SaleBillProduct", @j);
  3446. if(Search("SearchProductWithNo",#SaleBillProduct.No_Product))
  3447. {
  3448. @Price=#Product.Price_Product;
  3449. #SaleBillProduct.OrderPrice_SaleBillProduct=FormatNumber(@Price*(1 + @CessOut),@PriceDecimal);
  3450. #SaleBillProduct.UnitPrice_SaleBillProduct = FormatNumber(#SaleBillProduct.OrderPrice_SaleBillProduct*#SaleBillProduct.Discount_SaleBillProduct/100,@PriceDecimal);
  3451. }
  3452. }
  3453. ResumeLayout();
  3454. break;
  3455. case "外加":
  3456. case "零税":
  3457. case "免税":
  3458. SuspendLayout();
  3459. for(@j=0;@j<RowCount("#SaleBillProduct");@j=@j+1)
  3460. {
  3461. SetPosition("#SaleBillProduct", @j);
  3462. if(Search("SearchProductWithNo",#SaleBillProduct.No_Product))
  3463. {
  3464. @Price=#Product.Price_Product;
  3465. #SaleBillProduct.OrderPrice_SaleBillProduct=@Price;
  3466. #SaleBillProduct.UnitPrice_SaleBillProduct =FormatNumber( #SaleBillProduct.OrderPrice_SaleBillProduct*#SaleBillProduct.Discount_SaleBillProduct/100,@PriceDecimal);
  3467. }
  3468. }
  3469. ResumeLayout();
  3470. break;
  3471. }
  3472. }
  3473. ]]>
  3474. </CountPrice>
  3475. <ChangeDiscount>
  3476. <![CDATA[
  3477. if (RowCount("#SaleBillProduct") > 0)
  3478. {
  3479. SuspendLayout();
  3480. for (@a=0;@a<RowCount("#SaleBillProduct");@a=@a+1)
  3481. {
  3482. SetPosition("#SaleBillProduct", @a);
  3483. #SaleBillProduct.Discount_SaleBillProduct = #SaleBill.Discount_SaleBill;
  3484. }
  3485. ResumeLayout();
  3486. }
  3487. SetColumnDefaultValue("SaleBillProduct", "Discount_SaleBillProduct", #SaleBill.Discount_SaleBill);
  3488. ]]>
  3489. </ChangeDiscount>
  3490. <AssessClick>
  3491. Update();
  3492. </AssessClick>
  3493. <AuditLable>
  3494. <![CDATA[
  3495. if(!ckSpecial1.Checked)
  3496. {
  3497. SuspendLayout();
  3498. Search("SearchCustomerPayLimitAll",#SaleBill.ID_Customer);
  3499. Search("SearchCustomerWithNo", tbCustomerNo.CValue);
  3500. @temptogetvalue= #Customer.ToGetBalance_Customer;
  3501. Search("UpdateToGet",@temptogetvalue,tbNo.CValue);
  3502. ntbToGet.CValue=@temptogetvalue;
  3503. if ((ntbToGet.CValue + ntbSum.CValue) > #PayLimit.PayLimit_Customer)
  3504. {
  3505. MessageBox("本次销售已大于客户信用额度,审核失败!",@Title);
  3506. ResumeLayout();
  3507. return;
  3508. }
  3509. if(Search("SearchSaleInvoice",tbCustomerNo.CValue,DateTimeNow()))
  3510. {
  3511. string str = "";
  3512. string tem = "";
  3513. for( @o = 0 ; @o < RowCount("#SearchSaleInvoice") ; @o=@o+1)
  3514. {
  3515. SetPosition("#SearchSaleInvoice", @o);
  3516. tem =#SearchSaleInvoice.Amount_SaleInvoice;
  3517. str += #SearchSaleInvoice.No_SaleInvoice +","+"未付款金额:"+tem+"\n\n";
  3518. }
  3519. MessageBox("该客户有销项发票到期未付款,审核失败!\n\n "+str,@Title);
  3520. ResumeLayout();
  3521. return;
  3522. }
  3523. for (@i=0;@i<RowCount("#SaleBillProduct");@i=@i+1)
  3524. {
  3525. SetPosition("#SaleBillProduct", @i);
  3526. if (#SaleBillProduct.Type_FromBill == 23 && #SaleBillProduct.No_FromBill != "" && Search("SearchFromBillWithNo",#SaleBillProduct.No_FromBill))
  3527. {
  3528. if (Equals(#FromBill.ID_Assessor,DBNull()))
  3529. {
  3530. tbDetail.SelectedIndex = 1;
  3531. dgProduct.CurrentRowIndex = @i;
  3532. if (MessageBox("该来源单据未经审核,确定要审核吗?",@Title,MB_OKCANCEL) == DialogResult("CANCEL"))
  3533. {
  3534. dgProduct.Focus();
  3535. ResumeLayout();
  3536. return;
  3537. }
  3538. }
  3539. }
  3540. if (#SaleBillProduct.Type_FromBill == 24 && #SaleBillProduct.No_FromBill != "" && Search("SearchIndentBillWithNo",#SaleBillProduct.No_FromBill))
  3541. {
  3542. if (Equals(#IndentBill.ID_Assessor,DBNull()))
  3543. {
  3544. tbDetail.SelectedIndex = 1;
  3545. dgProduct.CurrentRowIndex = @i;
  3546. if (MessageBox("该来源单据未经审核,确定要审核吗?",@Title,MB_OKCANCEL) == DialogResult("CANCEL"))
  3547. {
  3548. dgProduct.Focus();
  3549. ResumeLayout();
  3550. return;
  3551. }
  3552. }
  3553. }
  3554. }
  3555. ResumeLayout();
  3556. }
  3557. else
  3558. {
  3559. SuspendLayout();
  3560. if(ckSpecial.Checked && ckSpecial1.Checked)
  3561. ResumeLayout();
  3562. }
  3563. ]]>
  3564. BeginAudit();
  3565. #SaleBill.ID_Assessor = GetLoginUserID();
  3566. #SaleBill.Name_Assessor = GetCurrentUser();
  3567. #SaleBill.AssessDate_SaleBill = DateTimeNow();
  3568. Audit();
  3569. ChangeMode("View");
  3570. EndAudit();
  3571. </AuditLable>
  3572. </Lables>
  3573. </Form>
  3574. </Forms>