中文字幕亚洲国产_欧美中文字幕精在线不卡_韩国精品久久久999_在线欧美三区

首頁 > CRM服務(wù) > 公司介紹

如何在CRM系統(tǒng)中實(shí)現(xiàn)單據(jù)格式的自動編號

2024-6-10 官網(wǎng) 閱讀 13985

CRM系統(tǒng)的使用及實(shí)施過程中,經(jīng)常會用到報(bào)價(jià)單,合同,銷售單,采購單等單據(jù),這些單據(jù)有一個(gè)共同點(diǎn)是都會有一個(gè)單據(jù)編號的字段,如下圖所示的合同編號:

如圖,合同編號的初始化規(guī)則是:“C-” + “年月日-” + 順序號,該表信息為:

英文表名

db_contractinfo

中文表名

合同信息表

物理表名

db_contractinfo_init

表編號

29

主鍵

ci_pkid

合同編號

ci_contractid

我們在表單設(shè)置中,模塊編程里建立一段功能程序

作用表名

db_contractinfo

Script說明

模塊啟動時(shí)初始化合同編號

Script代碼

以上代碼實(shí)現(xiàn):"C-" + "年月日-",下面代碼實(shí)現(xiàn)順序號:
到服務(wù)器打開Microsoft SQL Server Management Studio,然后找到需要找的物理表。這里,我們的物理表名是:db_contractinfo_init,故找到:dbo. db_contractinfo_init。

如果是其它表的此類功能,只需把下表中的紅色部分字段做相應(yīng)替換即可,同時(shí),在JS里的字段是11位,也是取其11位,如是其它位數(shù),在下面程序中相應(yīng)把11替換成其它位數(shù)。

英文表名

db_contractinfo

中文表名

合同信息表

物理表名

db_contractinfo_init

表編號

29

主鍵

ci_pkid

合同編號

ci_contractid

ALTER TRIGGER [ht_tg_db_contractinsert] ON [dbo].[db_contractinfo_init]

FOR INSERT    /* ht_tg_db_contractinsert是當(dāng)前觸發(fā)器名字,只要不跟之前名字一樣,可以隨便取,它有中括號是因?yàn)?/SPAN> 系統(tǒng)自動生成的方便好看 */

 

AS

begin

    declare @contractid varchar(20) /*首先要定義一個(gè)變量來存他插入的編號信息 */

   

    select @contractid=ci_contractid from inserted  /*這個(gè)就是獲取當(dāng)前插入的編號,存到變量 */

             declare @contractcount numeric(10)

             declare @flow varchar(20)

    --select @contractcount=count(*) from db_contractinfo_init where left(ci_contractid,11)= @contractid

    select @contractid=left(@contractid,11)   /*獲取插入編號的前11位。在這里,js生成的就是11 */

    select top 1 @flow=ci_contractid from db_contractinfo_init where left(ci_contractid,11)=@contractid and ci_contractid<>@contractid order by ci_contractid desc   /* 這一句 就是查詢當(dāng)前11位編號相同的編號在數(shù)據(jù)庫中有多少個(gè),如我這個(gè)編號是 C20141028-,則查詢有多少個(gè)同樣編號的,如果有3個(gè)這樣的,最新這個(gè)就是004  */

    if (@flow is not null )  /*if語句查詢存在多少個(gè)是保存在變量@flow里面的*/

       select @contractcount=convert(int,right(@flow,3))+1

    else

       select @contractcount='1'

 

/*下面幾句用來判斷編號的位數(shù),如為一位,就要在前面加002位就加0  三位就直接加上那個(gè)數(shù)字。

             if (len(@contractcount)=1 )

             begin

       select @flow='00'+convert(varchar(1),@contractcount)

             end

             if (len(@contractcount)=2 )

             begin

       select @flow='0'+convert(varchar(2),@contractcount)

             end

             if (len(@contractcount)=3 )

             begin

       select @flow=convert(varchar(3),@contractcount)

             end 

 

    update db_contractinfo_init set ci_contractid=ci_contractid+@flow where ci_pkid=@@identity

 

 

/*  select @contractmoney=ci_money from inserted

    update db_custominfo set ci_purchaseamount=ci_purchaseamount+ @contractmoney,ci_customkind=3 where ci_pkid=(select ci_customid from inserted)

*/

end

 

資訊中心

為您的企業(yè)績效提升竭盡全力!

聯(lián)
咨詢熱線:
020-82352035
137-2801-2172
在線客服:
APP下載:
在線免費(fèi)試用: http://pro.supercrm.com
主站蜘蛛池模板: 临高县| 汉川市| 纳雍县| 新建县| 云南省| 尉氏县| 桑植县| 平谷区| 瓦房店市| 启东市| 上高县| 夏津县| 屯昌县| 东源县| 长垣县| 辽宁省| 阿荣旗| 宜宾市| 渝北区| 松原市| 容城县| 通城县| 和顺县| 永善县| 靖江市| 牟定县| 同江市| 萨嘎县| 鸡泽县| 卢氏县| 恩施市| 北川| 五原县| 平武县| 颍上县| 大连市| 鹤庆县| 伊川县| 富平县| 汝阳县| 绩溪县|