{"id":179,"date":"2008-12-02T09:44:17","date_gmt":"2008-12-02T01:44:17","guid":{"rendered":""},"modified":"2014-02-27T22:58:59","modified_gmt":"2014-02-27T14:58:59","slug":"%e7%94%a8%e6%95%b0%e6%8d%ae%e5%ba%93%e7%94%9f%e6%88%90%e4%b8%8d%e9%87%8d%e5%a4%8d%e7%9a%84%e6%b5%81%e6%b0%b4%e5%8f%b7","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2008\/12\/02\/179.htm","title":{"rendered":"\u7528\u6570\u636e\u5e93\u751f\u6210\u4e0d\u91cd\u590d\u7684\u6d41\u6c34\u53f7"},"content":{"rendered":"<p>&#8216;\u51fd\u6570\u540d\uff1agetMaxOrder<br \/>\n&#8216;\u4f5c&nbsp; \u7528\uff1a\u5f97\u5230\u6700\u5927\u5e8f\u5217\u53f7<br \/>\n&#8216;\u53c2&nbsp; \u6570\uff1afieldName&nbsp;&nbsp; &#8212;-\u5728\u5e8f\u5217\u53f7\u8868\u4e2d\u7684\u5b57\u6bb5\u540d<br \/>\n&#8216;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tableName&nbsp;&nbsp; &#8212;-\u5e8f\u5217\u53f7\u6240\u5728\u8868\u540d<br \/>\n&#8216;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fieldName&nbsp;&nbsp; &#8212;-\u5728\u8868\u4e2d\u7684\u5b57\u6bb5\u540d<br \/>\n&#8216;\u8fd4\u56de\u503c\uff1a\u5b57\u6bb5\u7684\u6700\u5927\u503c<br \/>\n&#8216;\u8c03\u7528\u51fd\u6570\uff1aidAdd\uff1a\u4f5c\u7528\u89c1\u4e0a<br \/>\n&#8216;*************************************************<br \/>\nfunction getMaxOrder(fieldName,tableName,tableFileName)<br \/>\n&nbsp;dim orderNO,orderRS,testRS<br \/>\n&nbsp;set testRS=Server.CreateObject(&quot;ADODB.recordset&quot;)<br \/>\n&nbsp;set orderRS=Server.CreateObject(&quot;ADODB.recordset&quot;)<br \/>\n&nbsp;firstNO=year(date)&amp;right((&quot;0&quot;&amp;month(date)),2)<br \/>\n&nbsp;orderSQL=&quot;select * from fieldMaxValue where fieldName=&#8217;&quot;&amp;fieldName&amp;&quot;&#8217;&quot;<br \/>\n&nbsp;orderRS.open orderSQL,conn,3,2<br \/>\n&nbsp;if not orderRS.eof then<br \/>\n&nbsp;&nbsp;orderRS(&quot;fieldMaxValue&quot;)=orderRS(&quot;fieldMaxValue&quot;)<br \/>\n&nbsp;&nbsp;orderNO=orderRS(&quot;fieldMaxValue&quot;)<br \/>\n&nbsp;&nbsp;if left(orderNO,6)=firstNO then<br \/>\n&nbsp;&nbsp;&nbsp;orderNO=idAdd(orderNO)<br \/>\n&nbsp;&nbsp;else<br \/>\n&nbsp;&nbsp;&nbsp;orderNO=firstNO&amp;&quot;00001&quot;<br \/>\n&nbsp;&nbsp;end if<br \/>\n&nbsp;else<br \/>\n&nbsp;&nbsp;orderRS.addnew<br \/>\n&nbsp;&nbsp;orderRS(&quot;fieldName&quot;)=fieldName<br \/>\n&nbsp;&nbsp;orderNO=firstNO&amp;&quot;00001&quot;<br \/>\n&nbsp;end if<br \/>\n&nbsp;testRS.open &quot;select max(&quot;&amp;tableFileName&amp;&quot;) from &quot;&amp;tableName&amp;&quot; where &quot;&amp;tableFileName&amp;&quot; like &#8216;&quot;&amp;firstNO&amp;&quot;%&#8217;&quot;,conn,1,2<br \/>\n&nbsp;if (not testRS.eof) and testRS(0).value&gt;orderNO then<br \/>\n&nbsp;&nbsp;orderNO=idAdd(testRS(0).value)<br \/>\n&nbsp;end if<br \/>\n&nbsp;testRS.close<br \/>\n&nbsp;set testRS=nothing<br \/>\n&nbsp;orderRS(&quot;fieldMaxValue&quot;)=orderNO<br \/>\n&nbsp;orderRS.update<br \/>\n&nbsp;orderRS.close<br \/>\n&nbsp;set orderRS=nothing<br \/>\n&nbsp;getMaxOrder=orderNO<br \/>\nend function<\/p>\n<p>\n&#8216;*************************************************<br \/>\n&#8216;\u51fd\u6570\u540d\uff1aidAdd<br \/>\n&#8216;\u4f5c&nbsp; \u7528\uff1a\u7528\u6765\u589e\u52a0\u4e00\uff1a\u6bd4\u5982idAdd(&quot;5&quot;)=&quot;6&quot;,idAdd(&quot;L99&quot;)=&quot;M00&quot;\uff0cidAdd(&quot;!&quot;)=&quot;!1&quot;<br \/>\n&#8216;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5982\u679c\u662f\u6570\u5b57\u5c31\u52309\u540e\u8fdb\u4f4d,\u5982\u679c\u662f\u5c0f\u5199\u5b57\u6bcd\u5230\u671fz\u540e\u8fdb\u4f4d<br \/>\n&#8216;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5982\u679c\u662f\u5927\u5199\u5b57\u6bcd\u5230Z\u540e\u8fdb\u4f4d\uff0c\u5176\u5b83\u5728\u540e\u9762\u52a0\u4e00\u4e2a1 <br \/>\n&#8216;\u53c2&nbsp; \u6570\uff1aid&nbsp;&nbsp; &#8212;-\u9700\u6765\u589e\u52a0\u7684\u6570<br \/>\n&#8216;\u8fd4\u56de\u503c\uff1a\u589e\u52a0\u540e\u7684\u6570<br \/>\n&#8216;\u8c03\u7528\u51fd\u6570\uff1aaddOne \u4e00\u4e2a\u6570\u589e\u52a0\u4e00 AddOne(&quot;5&quot;)=&quot;6&quot;,Add(9)=&quot;0&quot;,AddOne(&quot;a&quot;)=&quot;b&quot;,<br \/>\n&#8216;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddOne(&quot;z&quot;)=&quot;a&quot;,AddOne(&quot;A&quot;)=&quot;B&quot;,AddOne(&quot;Z&quot;)=&quot;A&quot;<br \/>\n&#8216;*************************************************<br \/>\nFunction AddOne(first)<br \/>\nDim tempfirst<br \/>\nAddOne = first<br \/>\nintfirst = Asc(first)<br \/>\nIf (intfirst &gt;= 48 And intfirst &lt; 57) Or (intfirst &gt;= 65 And intfirst &lt; 90) Or (intfirst &gt;= 97 And intfirst &lt; 122) Then<br \/>\n&nbsp;&nbsp;&nbsp; AddOne = Chr(intfirst + 1)<br \/>\n&nbsp;&nbsp;&nbsp; Exit Function<br \/>\nEnd If<br \/>\nIf (intfirst = 57) Then<br \/>\n&nbsp;&nbsp;&nbsp; AddOne = &quot;0&quot;<br \/>\n&nbsp;&nbsp;&nbsp; Exit Function<br \/>\nEnd If<br \/>\nIf (intfirst = 90) Then<br \/>\n&nbsp;&nbsp;&nbsp; AddOne = &quot;A&quot;<br \/>\n&nbsp;&nbsp;&nbsp; Exit Function<br \/>\nEnd If<br \/>\nIf (intfirst = 122) Then<br \/>\n&nbsp;&nbsp;&nbsp; AddOne = &quot;a&quot;<br \/>\n&nbsp;&nbsp;&nbsp; Exit Function<br \/>\nEnd If<br \/>\nEnd Function<\/p>\n<p>Function idAdd(id)<br \/>\nDim fornt, back, strFind, strBackFind, idLen, tempid<br \/>\nif id=&quot;&quot; or isNull(id) then<br \/>\n&nbsp;iddAdd=1<br \/>\n&nbsp;exit Function<br \/>\nend if<br \/>\ntempid = id<br \/>\nidLen = Len(id)<br \/>\nFor i = 1 To idLen<br \/>\n&nbsp;&nbsp;&nbsp; fornt = Left(id, idLen &#8211; i)<br \/>\n&nbsp;&nbsp;&nbsp; back = Right(id, i &#8211; 1)<br \/>\n&nbsp;&nbsp;&nbsp; strFind = Mid(id, idLen + 1 &#8211; i, 1)<br \/>\n&nbsp;&nbsp;&nbsp; strBackFind = AddOne(strFind)<br \/>\n&nbsp;&nbsp;&nbsp; id = fornt &amp; strBackFind &amp; back<br \/>\n&nbsp;&nbsp;&nbsp; If strFind &lt; strBackFind Then<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit For<br \/>\n&nbsp;&nbsp;&nbsp; End If<br \/>\n&nbsp;&nbsp;&nbsp; If strFind &gt; strBackFind Then<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If i = idLen Then<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id = id &amp; &quot;1&quot;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Mid(id, idLen &#8211; i, 1) = AddOne(Mid(id, idLen &#8211; i, 1)) Then<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id = fornt &amp; strBackFind &amp; back &amp; &quot;1&quot;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit For<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br \/>\n&nbsp;&nbsp;&nbsp; End If<br \/>\nNext<br \/>\nIf id = tempid Then<br \/>\n&nbsp;&nbsp;&nbsp; id = id &amp; &quot;1&quot;<br \/>\nEnd If<br \/>\nidAdd = id<br \/>\nEnd Function<\/p>\n<p>\n&#8216;\u8c03\u7528\u793a\u4f8b<br \/>\nserviceNO=getMaxOrder(&quot;serviceNO&quot;,&quot;service&quot;,&quot;serviceNO&quot;)<\/p>\n<p>\n&#8216;\u5176\u4e2d\u4fdd\u5b58\u6240\u6709\u5b57\u6bb5\u6d41\u6c34\u53f7\u6700\u5927\u503c\u7684\u8868\u7684\u7ed3\u6784\u4e3a:<br \/>\n\u8868\u540d:fieldMaxValue<br \/>\n\u5b57\u6bb5<br \/>\nid&nbsp;&nbsp;&nbsp; fieldName&nbsp;&nbsp;&nbsp;&nbsp; fieldMaxValue<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;\u51fd\u6570\u540d\uff1agetMaxOrder &#8216;\u4f5c&nbsp; \u7528\uff1a\u5f97\u5230\u6700\u5927\u5e8f\u5217\u53f7 &#8216;\u53c2&nbsp; \u6570\uff1afieldName&nbsp;&nbsp; &#8212;-\u5728\u5e8f\u5217\u53f7\u8868\u4e2d\u7684\u5b57\u6bb5\u540d &#8216;&nbsp;&#038;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":66044,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/179\/revisions\/66044"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=179"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}