c#中的有用的方法

 
using  System;
using  System.Data;

using  EBiz.Security.API;
using  System.IO;
using  System.Reflection;
using  System.Text;
using  System.Text.RegularExpressions;
using  System.Xml;
using  System.Xml.Serialization;
using  System.Globalization;
using  System.Web;
using  System.Web.Security;
using  System.Configuration;

using  EBiz.DBM.Common.Types;

namespace  EBiz.DBM.API
{
 
///   <summary>
 
///  这是收集一些常用的函数
 
///   </summary>
  public   class  Utility
 {
  
public   const    string   numerousString  =   " 啊阿埃挨哎唉哀皚癌藹矮艾礙愛隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翺襖傲奧懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙壩霸罷爸白柏百擺佰敗拜稗斑班搬扳般頒板版扮拌伴瓣半辦絆邦幫梆榜膀綁棒磅蚌鎊傍謗苞胞包褒剝薄雹保堡飽寶抱報暴豹鮑爆杯碑悲卑北輩背貝鋇倍狽備憊焙被奔苯本笨崩繃甭泵蹦迸逼鼻比鄙筆彼碧蓖蔽畢斃毖幣庇痹閉敝弊必辟壁臂避陛鞭邊編貶扁便變卞辨辯辮遍標彪膘表鼈憋別癟彬斌瀕濱賓擯兵冰柄丙秉餅炳病並玻菠播撥缽波博勃搏鉑箔伯帛舶脖膊渤泊駁捕蔔哺補埠不布步簿部怖擦猜裁材才財睬踩采彩菜蔡餐參蠶殘慚慘燦蒼艙倉滄藏操糙槽曹草廁策側冊測層蹭插叉茬茶查碴搽察岔差詫拆柴豺攙摻蟬饞讒纏鏟産闡顫昌猖場嘗常長償腸廠敞暢唱倡超抄鈔朝嘲潮巢吵炒車扯撤掣徹澈郴臣辰塵晨忱沈陳趁襯撐稱城橙成呈乘程懲澄誠承逞騁秤吃癡持匙池遲弛馳恥齒侈尺赤翅斥熾充沖蟲崇寵抽酬疇躊稠愁籌仇綢瞅醜臭初出櫥廚躇鋤雛滁除楚礎儲矗搐觸處揣川穿椽傳船喘串瘡窗幢床闖創吹炊捶錘垂春椿醇唇淳純蠢戳綽疵茨磁雌辭慈瓷詞此刺賜次聰蔥囪匆從叢湊粗醋簇促躥篡竄摧崔催脆瘁粹淬翠村存寸磋撮搓措挫錯搭達答瘩打大呆歹傣戴帶殆代貸袋待逮怠耽擔丹單鄲撣膽旦氮但憚淡誕彈蛋當擋黨蕩檔刀搗蹈倒島禱導到稻悼道盜德得的蹬燈登等瞪凳鄧堤低滴迪敵笛狄滌翟嫡抵底地蒂第帝弟 "
   
+   " 遞締顛掂滇碘點典靛墊電佃甸店惦奠澱殿碉叼雕凋刁掉吊釣調跌爹碟蝶叠諜疊丁盯叮釘頂鼎錠定訂丟東冬董懂動棟侗恫凍洞兜抖鬥陡豆逗痘都督毒犢獨讀堵睹賭杜鍍肚度渡妒端短鍛段斷緞堆兌隊對墩噸蹲敦頓囤鈍盾遁掇哆多奪垛躲朵跺舵剁惰墮蛾峨鵝俄額訛娥惡厄扼遏鄂餓恩而兒耳爾餌洱二貳發罰筏伐乏閥法琺藩帆番翻樊礬釩繁凡煩反返範販犯飯泛坊芳方肪房防妨仿訪紡放菲非啡飛肥匪誹吠肺廢沸費芬酚吩氛分紛墳焚汾粉奮份忿憤糞豐封楓蜂峰鋒風瘋烽逢馮縫諷奉鳳佛否夫敷膚孵扶拂輻幅氟符伏俘服浮涪福袱弗甫撫輔俯釜斧脯腑府腐赴副覆賦複傅付阜父腹負富訃附婦縛咐噶嘎該改概鈣蓋溉幹甘杆柑竿肝趕感稈敢贛岡剛鋼缸肛綱崗港杠篙臯高膏羔糕搞鎬稿告哥歌擱戈鴿胳疙割革葛格蛤閣隔鉻個各給根跟耕更庚羹埂耿梗工攻功恭龔供躬公宮弓鞏汞拱貢共鈎勾溝苟狗垢構購夠辜菇咕箍估沽孤姑鼓古蠱骨谷股故顧固雇刮瓜剮寡挂褂乖拐怪棺關官冠觀管館罐慣灌貫光廣逛瑰規圭矽歸龜閨軌鬼詭癸桂櫃跪貴劊輥滾棍鍋郭國果裹過哈骸孩海氦亥害駭酣憨邯韓含涵寒函喊罕翰撼捍旱憾悍焊汗漢夯杭航壕嚎豪毫郝好耗號浩呵喝荷菏核禾和何合盒貉閡河涸赫褐鶴賀嘿黑痕很狠恨哼亨橫衡恒轟哄烘虹鴻洪宏弘紅喉侯猴吼厚候後呼乎忽瑚壺葫胡蝴狐糊湖弧虎唬護互滬戶花嘩華猾滑畫劃化話槐徊懷淮壞歡環桓還緩 "
   
+   " 換患喚瘓豢煥渙宦幻荒慌黃磺蝗簧皇凰惶煌晃幌恍謊灰揮輝徽恢蛔回毀悔慧卉惠晦賄穢會燴彙諱誨繪葷昏婚魂渾混豁活夥火獲或惑霍貨禍擊圾基機畸稽積箕肌饑迹激譏雞姬績緝吉極棘輯籍集及急疾汲即嫉級擠幾脊己薊技冀季伎祭劑悸濟寄寂計記既忌際妓繼紀嘉枷夾佳家加莢頰賈甲鉀假稼價架駕嫁殲監堅尖箋間煎兼肩艱奸緘繭檢柬堿鹼揀撿簡儉剪減薦檻鑒踐賤見鍵箭件健艦劍餞漸濺澗建僵姜將漿江疆蔣槳獎講匠醬降蕉椒礁焦膠交郊澆驕嬌嚼攪鉸矯僥腳狡角餃繳絞剿教酵轎較叫窖揭接皆稭街階截劫節莖睛晶鯨京驚精粳經井警景頸靜境敬鏡徑痙靖竟競淨炯窘揪究糾玖韭久灸九酒廄救舊臼舅咎就疚鞠拘狙疽居駒菊局咀矩舉沮聚拒據巨具距踞鋸俱句懼炬劇捐鵑娟倦眷卷絹撅攫抉掘倔爵桔傑捷睫竭潔結解姐戒藉芥界借介疥誡屆巾筋斤金今津襟緊錦僅謹進靳晉禁近燼浸盡勁荊兢覺決訣絕均菌鈞軍君峻俊竣浚郡駿喀咖卡咯開揩楷凱慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕顆科殼咳可渴克刻客課肯啃墾懇坑吭空恐孔控摳口扣寇枯哭窟苦酷庫褲誇垮挎跨胯塊筷儈快寬款匡筐狂框礦眶曠況虧盔巋窺葵奎魁傀饋愧潰坤昆捆困括擴廓闊垃拉喇蠟臘辣啦萊來賴藍婪欄攔籃闌蘭瀾讕攬覽懶纜爛濫琅榔狼廊郎朗浪撈勞牢老佬姥酪烙澇勒樂雷鐳蕾磊累儡壘擂肋類淚棱楞冷厘梨犁黎籬狸離漓理李裏鯉禮莉荔吏栗麗 "
   
+   " 厲勵礫曆利傈例俐痢立粒瀝隸力璃哩倆聯蓮連鐮廉憐漣簾斂臉鏈戀煉練糧涼梁粱良兩輛量晾亮諒撩聊僚療燎寥遼潦了撂鐐廖料列裂烈劣獵琳林磷霖臨鄰鱗淋凜賃吝拎玲菱零齡鈴伶羚淩靈陵嶺領另令溜琉榴硫餾留劉瘤流柳六龍聾嚨籠窿隆壟攏隴樓婁摟簍漏陋蘆盧顱廬爐擄鹵虜魯麓碌露路賂鹿潞祿錄陸戮驢呂鋁侶旅履屢縷慮氯律率濾綠巒攣孿灤卵亂掠略掄輪倫侖淪綸論蘿螺羅邏鑼籮騾裸落洛駱絡媽麻瑪碼螞馬罵嘛嗎埋買麥賣邁脈瞞饅蠻滿蔓曼慢漫謾芒茫盲氓忙莽貓茅錨毛矛鉚卯茂冒帽貌貿麽玫枚梅酶黴煤沒眉媒鎂每美昧寐妹媚門悶們萌蒙檬盟錳猛夢孟眯醚靡糜迷謎彌米秘覓泌蜜密冪棉眠綿冕免勉娩緬面苗描瞄藐秒渺廟妙蔑滅民抿皿敏憫閩明螟鳴銘名命謬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌謀牟某拇牡畝姆母墓暮幕募慕木目睦牧穆拿哪呐鈉那娜納氖乃奶耐奈南男難囊撓腦惱鬧淖呢餒內嫩能妮霓倪泥尼擬你匿膩逆溺蔫拈年碾攆撚念娘釀鳥尿捏聶孽齧鑷鎳涅您檸獰凝甯擰濘牛扭鈕紐膿濃農弄奴努怒女暖虐瘧挪懦糯諾哦歐鷗毆藕嘔偶漚啪趴爬帕怕琶拍排牌徘湃派攀潘盤磐盼畔判叛乓龐旁耪胖抛咆刨炮袍跑泡呸胚培裴賠陪配佩沛噴盆砰抨烹澎彭蓬棚硼篷膨朋鵬捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片騙飄漂瓢票撇瞥拼頻貧品聘乒坪蘋萍平憑瓶評屏坡潑頗婆破魄迫粕剖撲鋪仆莆葡菩蒲埔樸圃 "
   
+   " 普浦譜曝瀑期欺棲戚妻七淒漆柒沏其棋奇歧畦崎臍齊旗祈祁騎起豈乞企啓契砌器氣迄棄汽泣訖掐洽牽扡釺鉛千遷簽仟謙乾黔錢鉗前潛遣淺譴塹嵌欠歉槍嗆腔羌牆薔強搶橇鍬敲悄橋瞧喬僑巧鞘撬翹峭俏竅切茄且怯竊欽侵親秦琴勤芹擒禽寢沁青輕氫傾卿清擎晴氰情頃請慶瓊窮秋丘邱球求囚酋泅趨區蛆曲軀屈驅渠取娶齲趣去圈顴權醛泉全痊拳犬券勸缺炔瘸卻鵲榷確雀裙群然燃冉染瓤壤攘嚷讓饒擾繞惹熱壬仁人忍韌任認刃妊紉扔仍日戎茸蓉榮融熔溶容絨冗揉柔肉茹蠕儒孺如辱乳汝入褥軟阮蕊瑞銳閏潤若弱撒灑薩腮鰓塞賽三三傘散桑嗓喪搔騷掃嫂瑟色澀森僧莎砂殺刹沙紗傻啥煞篩曬珊苫杉山刪煽衫閃陝擅贍膳善汕扇繕墒傷商賞晌上尚裳梢捎稍燒芍勺韶少哨邵紹奢賒蛇舌舍赦攝射懾涉社設砷申呻伸身深娠紳神沈審嬸甚腎慎滲聲生甥牲升繩省盛剩勝聖師失獅施濕詩屍虱十石拾時什食蝕實識史矢使屎駛始式示士世柿事拭誓逝勢是嗜噬適仕侍釋飾氏市恃室視試收手首守壽授售受瘦獸蔬樞梳殊抒輸叔舒淑疏書贖孰熟薯暑曙署蜀黍鼠屬術述樹束戍豎墅庶數漱恕刷耍摔衰甩帥栓拴霜雙爽誰水睡稅吮瞬順舜說碩朔爍斯撕嘶思私司絲死肆寺嗣四伺似飼巳松聳慫頌送宋訟誦搜艘擻嗽蘇酥俗素速粟僳塑溯宿訴肅酸蒜算雖隋隨綏髓碎歲穗遂隧祟孫損筍蓑梭唆縮瑣索鎖所塌他它她塔獺撻蹋踏胎苔擡台泰酞太態汰坍攤貪癱灘壇 "
   
+   " 檀痰潭譚談坦毯袒碳探歎炭湯塘搪堂棠膛唐糖倘躺淌趟燙掏濤滔縧萄桃逃淘陶討套特藤騰疼謄梯剔踢銻提題蹄啼體替嚏惕涕剃屜天添填田甜恬舔腆挑條迢眺跳貼鐵帖廳聽烴汀廷停亭庭挺艇通桐酮瞳同銅彤童桶捅筒統痛偷投頭透凸禿突圖徒途塗屠土吐兔湍團推頹腿蛻褪退吞屯臀拖托脫鴕陀馱駝橢妥拓唾挖哇蛙窪娃瓦襪歪外豌彎灣玩頑丸烷完碗挽晚皖惋宛婉萬腕汪王亡枉網往旺望忘妄威巍微危韋違桅圍唯惟爲濰維葦萎委偉僞尾緯未蔚味畏胃喂魏位渭謂尉慰衛瘟溫蚊文聞紋吻穩紊問嗡翁甕撾蝸渦窩我斡臥握沃巫嗚鎢烏汙誣屋無蕪梧吾吳毋武五捂午舞伍侮塢戊霧晤物勿務悟誤昔熙析西硒矽晰嘻吸錫犧稀息希悉膝夕惜熄烯溪汐犀檄襲席習媳喜銑洗系隙戲細瞎蝦匣霞轄暇峽俠狹下廈夏嚇掀鍁先仙鮮纖鹹賢銜舷閑涎弦嫌顯險現獻縣腺餡羨憲陷限線相廂鑲香箱襄湘鄉翔祥詳想響享項巷橡像向象蕭硝霄削哮囂銷消宵淆曉小孝校肖嘯笑效楔些歇蠍鞋協挾攜邪斜脅諧寫械卸蟹懈泄瀉謝屑薪芯鋅欣辛新忻心信釁星腥猩惺興刑型形邢行醒幸杏性姓兄凶胸匈洶雄熊休修羞朽嗅鏽秀袖繡墟戌需虛噓須徐許蓄酗敘旭序畜恤絮婿緒續軒喧宣懸旋玄選癬眩絢靴薛學穴雪血勳熏循旬詢尋馴巡殉汛訓訊遜迅壓押鴉鴨呀丫芽牙蚜崖衙涯雅啞亞訝焉咽閹煙淹鹽嚴研蜒岩延言顔閻炎沿奄掩眼衍演豔堰燕厭硯雁唁彥焰宴諺驗殃央鴦秧楊揚 "
   
+   " 佯瘍羊洋陽氧仰癢養樣漾邀腰妖瑤搖堯遙窯謠姚咬舀藥要耀椰噎耶爺野冶也頁掖業葉曳腋夜液一壹醫揖銥依伊衣頤夷遺移儀胰疑沂宜姨彜椅蟻倚已乙矣以藝抑易邑屹億役臆逸肄疫亦裔意毅憶義益溢詣議誼譯異翼翌繹茵蔭因殷音陰姻吟銀淫寅飲尹引隱印英櫻嬰鷹應纓瑩螢營熒蠅迎贏盈影穎硬映喲擁傭臃癰庸雍踴蛹詠泳湧永恿勇用幽優悠憂尤由郵鈾猶油遊酉有友右佑釉誘又幼迂淤于盂榆虞愚輿余俞逾魚愉渝漁隅予娛雨與嶼禹宇語羽玉域芋郁籲遇喻峪禦愈欲獄育譽浴寓裕預豫馭鴛淵冤元垣袁原援轅園員圓猿源緣遠苑願怨院曰約越躍鑰嶽粵月悅閱耘雲鄖勻隕允運蘊醞暈韻孕匝砸雜栽哉災宰載再在咱攢暫贊贓髒葬遭糟鑿藻棗早澡蚤躁噪造皂竈燥責擇則澤賊怎增憎曾贈紮喳渣劄軋鍘閘眨柵榨咋乍炸詐摘齋宅窄債寨瞻氈詹粘沾盞斬輾嶄展蘸棧占戰站湛綻樟章彰漳張掌漲杖丈帳賬仗脹瘴障招昭找沼趙照罩兆肇召遮折哲蟄轍者鍺蔗這浙珍斟真甄砧臻貞針偵枕疹診震振鎮陣蒸掙睜征猙爭怔整拯正政幀症鄭證芝枝支吱蜘知肢脂汁之織職直植殖執值侄址指止趾只旨紙志摯擲至致置幟峙制智秩稚質炙痔滯治窒中盅忠鍾衷終種腫重仲衆舟周州洲謅粥軸肘帚咒皺宙晝驟珠株蛛朱豬諸誅逐竹燭煮拄矚囑主著柱助蛀貯鑄築住注祝駐抓爪拽專磚轉撰賺篆樁莊裝妝撞壯狀椎錐追贅墜綴諄准捉拙卓桌琢茁酌啄著灼濁茲咨資姿滋淄孜紫仔籽滓子自漬字鬃棕蹤宗綜總縱鄒走奏揍租足卒族祖詛阻組鑽纂嘴醉最罪尊遵昨左佐柞做作坐座 " ;

  
public   const   string  simpleString       =   " 啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川穿椽传船喘串疮窗幢床闯创吹炊捶锤垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递 "
   
+   " 缔颠掂滇碘点典靛垫电佃甸店惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺废沸费芬酚吩氛分纷坟焚汾粉奋份忿愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共钩勾沟苟狗垢构购够辜菇咕箍估沽孤姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪户花哗华猾滑画划化话槐徊怀淮坏欢环桓还缓换患 "
   
+   " 唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几脊己蓟技冀季伎祭剂悸济寄寂计记既忌际妓继纪嘉枷夹佳家加荚颊贾甲钾假稼价架驾嫁歼监坚尖笺间煎兼肩艰奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯窘揪究纠玖韭久灸九酒厩救旧臼舅咎就疚鞠拘狙疽居驹菊局咀矩举沮聚拒据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋禁近烬浸尽劲荆兢觉决诀绝均菌钧军君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾 "
   
+   " 历利傈例俐痢立粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱零龄铃伶羚凌灵陵岭领另令溜琉榴硫馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥米秘觅泌蜜密幂棉眠绵冕免勉娩缅面苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨烹澎彭蓬棚硼篷膨朋鹏捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片骗飘漂瓢票撇瞥拼频贫品聘乒坪苹萍平凭瓶评屏坡泼颇婆破魄迫粕剖扑铺仆莆葡菩蒲埔朴圃普浦谱曝 "
   
+   " 瀑期欺栖戚妻七凄漆柒沏其棋奇歧畦崎脐齐旗祈祁骑起岂乞企启契砌器气迄弃汽泣讫掐洽牵扦钎铅千迁签仟谦乾黔钱钳前潜遣浅谴堑嵌欠歉枪呛腔羌墙蔷强抢橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍切茄且怯窃钦侵亲秦琴勤芹擒禽寝沁青轻氢倾卿清擎晴氰情顷请庆琼穷秋丘邱球求囚酋泅趋区蛆曲躯屈驱渠取娶龋趣去圈颧权醛泉全痊拳犬券劝缺炔瘸却鹊榷确雀裙群然燃冉染瓤壤攘嚷让饶扰绕惹热壬仁人忍韧任认刃妊纫扔仍日戎茸蓉荣融熔溶容绒冗揉柔肉茹蠕儒孺如辱乳汝入褥软阮蕊瑞锐闰润若弱撒洒萨腮鳃塞赛三叁伞散桑嗓丧搔骚扫嫂瑟色涩森僧莎砂杀刹沙纱傻啥煞筛晒珊苫杉山删煽衫闪陕擅赡膳善汕扇缮墒伤商赏晌上尚裳梢捎稍烧芍勺韶少哨邵绍奢赊蛇舌舍赦摄射慑涉社设砷申呻伸身深娠绅神沈审婶甚肾慎渗声生甥牲升绳省盛剩胜圣师失狮施湿诗尸虱十石拾时什食蚀实识史矢使屎驶始式示士世柿事拭誓逝势是嗜噬适仕侍释饰氏市恃室视试收手首守寿授售受瘦兽蔬枢梳殊抒输叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠属术述树束戍竖墅庶数漱恕刷耍摔衰甩帅栓拴霜双爽谁水睡税吮瞬顺舜说硕朔烁斯撕嘶思私司丝死肆寺嗣四伺似饲巳松耸怂颂送宋讼诵搜艘擞嗽苏酥俗素速粟僳塑溯宿诉肃酸蒜算虽隋随绥髓碎岁穗遂隧祟孙损笋蓑梭唆缩琐索锁所塌他它她塔獭挞蹋踏胎苔抬台泰酞太态汰坍摊贪瘫滩坛檀痰潭谭谈 "
   
+   " 坦毯袒碳探叹炭汤塘搪堂棠膛唐糖倘躺淌趟烫掏涛滔绦萄桃逃淘陶讨套特藤腾疼誊梯剔踢锑提题蹄啼体替嚏惕涕剃屉天添填田甜恬舔腆挑条迢眺跳贴铁帖厅听烃汀廷停亭庭挺艇通桐酮瞳同铜彤童桶捅筒统痛偷投头透凸秃突图徒途涂屠土吐兔湍团推颓腿蜕褪退吞屯臀拖托脱鸵陀驮驼椭妥拓唾挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误昔熙析西硒矽晰嘻吸锡牺稀息希悉膝夕惜熄烯溪汐犀檄袭席习媳喜铣洗系隙戏细瞎虾匣霞辖暇峡侠狭下厦夏吓掀锨先仙鲜纤咸贤衔舷闲涎弦嫌显险现献县腺馅羡宪陷限线相厢镶香箱襄湘乡翔祥详想响享项巷橡像向象萧硝霄削哮嚣销消宵淆晓小孝校肖啸笑效楔些歇蝎鞋协挟携邪斜胁谐写械卸蟹懈泄泻谢屑薪芯锌欣辛新忻心信衅星腥猩惺兴刑型形邢行醒幸杏性姓兄凶胸匈汹雄熊休修羞朽嗅锈秀袖绣墟戌需虚嘘须徐许蓄酗叙旭序畜恤絮婿绪续轩喧宣悬旋玄选癣眩绚靴薛学穴雪血勋熏循旬询寻驯巡殉汛训讯逊迅压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧 "
   
+   " 仰痒养样漾邀腰妖瑶摇尧遥窑谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕匝砸杂栽哉灾宰载再在咱攒暂赞赃脏葬遭糟凿藻枣早澡蚤躁噪造皂灶燥责择则泽贼怎增憎曾赠扎喳渣札轧铡闸眨栅榨咋乍炸诈摘斋宅窄债寨瞻毡詹粘沾盏斩辗崭展蘸栈占战站湛绽樟章彰漳张掌涨杖丈帐账仗胀瘴障招昭找沼赵照罩兆肇召遮折哲蛰辙者锗蔗这浙珍斟真甄砧臻贞针侦枕疹诊震振镇阵蒸挣睁征狰争怔整拯正政帧症郑证芝枝支吱蜘知肢脂汁之织职直植殖执值侄址指止趾只旨纸志挚掷至致置帜峙制智秩稚质炙痔滞治窒中盅忠钟衷终种肿重仲众舟周州洲诌粥轴肘帚咒皱宙昼骤珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱主著柱助蛀贮铸筑住注祝驻抓爪拽专砖转撰赚篆桩庄装妆撞壮状椎锥追赘坠缀谆准捉拙卓桌琢茁酌啄着灼浊兹咨资姿滋淄孜紫仔籽滓子自渍字鬃棕踪宗综总纵邹走奏揍租足卒族祖诅阻组钻纂嘴醉最罪尊遵昨左佐柞做作坐座 " ;

  
public   const   string  PARTNUMBER_FORBIDDEN_CHARACTERS  =   " ?*'%/-%#"/,._[]^&()~!|@$  "
  
public   const   string  PARTNUMBER_FORBIDDEN_CHARACTERS_SMARTSEARCH  =   " *'/-#"/,._[]^&()~!|@$  "
  
public   const   string  NONELIST = " (1=2) " ;
  
public   const   string  GLOBALLIST = " (1=1) " ;
  
// used by session
   public   const   string  SMART_PARTNUMBER  =   " PartNumber " ;
  
public   const   string  SYSTEM_LAST_ERROR  =   " SystemLastError " ;
  
public   const   string  USER_PRIVILIGE_FUNCTION_POINT_LIST  =   " User_Privilige_Function_Point_List " ;
  
// used by session
   public   static   string  ConnectionString  =   string .Empty;
     
  
private   const   string  RANKFUNCTION  =   " dbo.GetQueryRank('{0}','{1}',PrefixStrExtracted,BasePartNumberExtracted) " ;
  
// 海外税率代表值
   public   const   int  OVERSEA_TAX_CODE   =    9 ;
  
// 其他税率代表值
   public   const   int  OTHER_TAX_CODE    =   10 ;
  
// 0%税率代表值
   public   const   int   ZERO_TAX_CODE     =   7 ;
  
  
public   static   string  NO_PRIVILEGE_PAGE
  {
   
get
   {
    
return  ApplicationPath + " AccessDenied.aspx " ;
   }
  }

  
static  Utility()
  {
   
try
   {
    ConnectionString 
=  ConfigurationSettings.AppSettings[ " DBMConnectionString " ].ToString();   
   }
   
catch
   {
   }
  } 
 
  
///   <summary>
  
///  返回应用程序的路径
  
///  例如:如果应用程式是根目录,则返回"/";
  
///   如果应用程式是其他虚拟目录,则返回"/Virtual Path/"
  
///   </summary>
  
///   <returns> 返回应用程式的路径 </returns>
   public   static   string  ApplicationPath
  {
   
get
   {   
    
string  applicationPath  =  HttpContext.Current.Request.ApplicationPath;
    
if  (applicationPath  !=   " / " )
    {
     applicationPath 
=  applicationPath +   " / " ;
    }
    
return  applicationPath;
   }
  }

  
///   <summary>
  
///  返回应用程序的路径
  
///  例如:如果应用程式是根目录,则返回" https://www.domain.com/ ";
  
///   如果应用程式是其他虚拟目录,则返回" https://www.domain.com/Virtual  Path/"
  
///   </summary>
  
///   <returns> 返回应用程式的路径 </returns>
   public   static   string  ApplicationSSLPath
  {
   
get
   {
    
bool  useSSL =   false ;
    
try
    {
     useSSL
=  Convert.ToBoolean(ConfigurationSettings.AppSettings[ " UseSSL " ]);
    }
    
catch
    {
     useSSL 
=   false ;
    }
 
    
return   " http "   +  (useSSL  ?   " s "  :  "" +   " :// "   +  HttpContext.Current.Request.ServerVariables[ " HTTP_HOST " ].ToString().ToLower()  +  ApplicationPath;
   }
  }

  
  
///   <summary>
  
///  如果有什么信息在客户的弹出的,则调用此函数
  
///   </summary>
  
///   <param name="message"></param>
   public   static   void  Message( string  message)
  {
   
string  script  = " <script> "
   script 
+= " window.alert(" " + message.Replace( " ' " " /' " + " "); " ;  
   script 
+= " </script> " ;
   HttpContext.Current.Response.Write(script);
  }

  
///   <summary>
  
///  如果有什么信息在客户的弹出的,则调用此函数
  
///   </summary>
  
///   <param name="message"></param>
   public   static   void  Message(System.Web.UI.Page page,  string  message)
  {
   
string  script  = " <script> "
   script 
+= " window.alert(" " + message.Replace( " ' " " /' " + " "); " ;  
   script 
+= " </script> " ;
   
// Guid.NewGuid().ToString("N")是指在一个界面中可能有多个调用要弹出消息的内容
   page.RegisterClientScriptBlock( " Clientmsg " + Guid.NewGuid().ToString( " N " ), script);
  }

  
///   <summary>
  
///  对一个字符串进行剪切,对多于该字符数的用“...”表示,则以ToolTip进行提示
  
///   </summary>
  
///   <param name="sValue"> 要剪切的字符串 </param>
  
///   <param name="size"> 要保留的字符数 </param>
  
///   <returns> 返回剪切好的及ToolTip的整个Html格式的字符串 </returns>
   public   static   string  CutString( string  sValue,  int  size)
  {
   
string  m_retu = "" ;
   
if (sValue.Length  >  size)
   {
    m_retu
=   " <span title=" "   +  
     HttpContext.Current.Server.HtmlDecode(sValue) 
+   " "> "  
     
+  HttpContext.Current.Server.HtmlEncode(sValue.Substring( 0 ,size))  +   " ...</span> " ;
   }
   
else
   {
    m_retu
=  sValue;
   }
   
return  m_retu;
  }

  
///   <summary>
  
///  把文本框的内容格式成相应的Html在网页中显示
  
///   </summary>
  
///   <param name="sValue"> 要格式的字符串 </param>
  
///   <returns> 格式好的Html字符串 </returns>
   public   static   string  ToHtml( string  sValue)
  {
   
string  m_retu = "" ;
   
if  (sValue  !=   null )
   {
    m_retu 
=  HttpUtility.HtmlEncode(sValue);
    m_retu 
=  m_retu.Replace( " " " <br /> " );
    m_retu 
=  m_retu.Replace( " " " <br /> " );
    m_retu 
=  m_retu.Replace( " " " <br /> " );
   }
   
return  m_retu;
  }


  
///   <summary>
  
///  检查是否为Guid类型的字符串
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsGuid( object  o)
  {
   
try
   {
    Guid a
=    new  Guid(o.ToString());
    
    
return   true ;
   }
   
catch
   {
    
return   false ;
   }
  }
  
///   <summary>
  
///  检查是否为整数的字符串
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsInt( object  o)
  {
   
try
   {
    Convert.ToInt32(o);
    
return   true ;
   }
   
catch  
   {
    
return   false ;
   }
  }
  
  
///   <summary>
  
///  检查是否为日期型的字符串
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsDateTime( object  o)
  {
   
if (o == null return   false ;
   
try
   {
    Convert.ToDateTime(o);
    
return   true ;
   }
   
catch
   {
    
return   false ;
   }
  }

  
///   <summary>
  
///  检查是否为浮点型
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsDouble( object  o)
  {
   
double  num1;

   
if (IsNull(o))  return   false ;

   
if  ( ! double .TryParse(o.ToString(), NumberStyles.Any,  null out  num1))
   {
    
return   false ;
   }
   
   
return   true ;
  }

  
///   <summary>
  
///   检查是否为Single型
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsSingle( object  o)
  {
   
try
   {
    Convert.ToSingle(o);
    
return   true ;
   }
   
catch  
   {
    
return   false ;
   }
  }

  
///   <summary>
  
///  检查是否为Decimal型
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsDecimal( object  o)
  {
   
try
   {
    Convert.ToDecimal(o);
    
return   true ;
   }
   
catch  
   {
    
return   false ;
   }
  }

  
///   <summary>
  
///  检查是否为bool型
  
///   </summary>
  
///   <param name="o"> 要检查的字符串 </param>
  
///   <returns> 如果是,则返回true,如果不是,则返回false </returns>
   public   static   bool  IsBool( object  o)
  {
   
try
   {
    Convert.ToBoolean(o);
    
return   true ;
   }
   
catch  
   {
    
return   false ;
   }
  }

  
///   <summary>
  
///  当前的用户
  
///   </summary>
   public   static   UserToken CurrentUser
  {
   
get
   {
    UserToken token
=   (UserToken)System.Web.HttpContext.Current.Session[ " UserToken " ];
    
if (token  ==   null )
    {
     FormsAuthentication.SignOut(); 
     HttpContext.Current.Response.Redirect(Utility.ApplicationPath 
+   " Security/SignIn.aspx " );
    }
    
return  token;
   }
  }


  
///   <summary>
  
///  当前的用户权限
  
///   </summary>
   public   static  UserPermissions CurrentPermissions
  {
   
get
   {
    UserPermissions permission
=   (UserPermissions) HttpContext.Current.Session[ " UserPermissions " ];
    
if (permission  ==   null )
    {
     FormsAuthentication.SignOut(); 
     HttpContext.Current.Response.Redirect(Utility.ApplicationPath 
+   " Security/SignIn.aspx " );
    }
    
return  permission;
   }
  }


  
///   <summary>
  
///  根据币种代码取回货币符号
  
///   </summary>
  
///   <param name="CurrentPage"> 取回币种的页,传入该参数的目的是为了获取界面的语言 </param>
  
///   <param name="CurrencyCode"> 货币代码 </param>
  
///   <returns> 货币符号 </returns>
   public   static   string  GetCurrencySymbolByCode(System.Web.UI.Page CurrentPage, string  CurrencyCode)
  {
   
string  m_retu;
   
if (CurrencyCode.Trim() == "" )
    m_retu
= "" ;
   
else
    
//  m_retu= StringMapCache.RetrieveDisplayValue((int)ObjectTypeEnum.Organization,"CurrencyCode",int.Parse(CurrencyCode),"en-us");
    m_retu  =  StringMapCache.RetrieveDisplayValue(( int )ObjectTypeEnum.Organization, " CurrencyCode " , int .Parse(CurrencyCode));
   
return  m_retu;
  }

  
///   <summary>
  
///  根据币种代码取回货币符号
  
///   </summary>
  
///   <param name="CurrencyCode"> 货币代码 </param>
  
///   <returns> 货币符号 </returns>
   public   static   string  GetCurrencySymbolByCode( string  CurrencyCode)
  {
   
string  m_retu;
   
if (CurrencyCode.Trim() == "" )
    m_retu
= "" ;
   
else
    m_retu 
=  StringMapCache.RetrieveDisplayValue(( int )ObjectTypeEnum.Organization, " CurrencyCode " , int .Parse(CurrencyCode));
   
return  m_retu;
  }

  
///   <summary>
  
///  加入一些用户信息到记录行中
  
///  如果是新增的,则加入以下内容:新增的初始信息和修改的初始信息
  
///  如果是修改的,则加入以下内容:修改的初始信息
  
///   </summary>
  
///   <param name="m_dr"> 要加入记录的行 </param>
  
///   <param name="isInsert"> 是否为新增 </param>
   public   static   void  AddUserInfoToRow(System.Data.DataRow m_dr, bool  isInsert)
  {
   
if (isInsert)
   {
    
if (m_dr.Table.Columns.Contains( " StateCode " ))
    {
     m_dr[
" StateCode " =   1 // 处于初始状态
    }
    m_dr[
" ModifiedBy " ] = CurrentUser.EntityID;
    m_dr[
" ModifiedOn " ] =  DateTime.UtcNow;
    m_dr[
" ModifiedbyName " = CurrentUser.EntityAlias;
    m_dr[
" CreatedBy " ] = CurrentUser.EntityID;
    m_dr[
" CreatedOn " ] = DateTime.UtcNow ;
    m_dr[
" CreatedbyName " ] = CurrentUser.EntityAlias;
    m_dr[
" DeletionStateCode " = 0
    
try
    {
     m_dr[
" OwningUser " =  CurrentUser.EntityID;
    }
    
catch {}
   }
   
else
   {
    
    m_dr[
" ModifiedBy " ] = CurrentUser.EntityID;
    m_dr[
" ModifiedOn " ] =  DateTime.UtcNow;
    m_dr[
" ModifiedbyName " = CurrentUser.EntityAlias;
   }
  }
  
///   <summary>
  
///  更改某行时的更改元数据信息[20040120SUN]
  
///   </summary>
  
///   <returns></returns>
   public   static   string  ModifiedInfoSQL()
  {
   System.Text.StringBuilder   sqlStringBuilder 
=    new  StringBuilder( 200 );
   sqlStringBuilder.Append(
"   ModifiedOn=' " + DateTime.UtcNow.ToString() + " " );
   sqlStringBuilder.Append(
"  , ModifiedBy=' " + Utility.CurrentUser.EntityID.ToString() + " " );
   
return  sqlStringBuilder.ToString();

  }
  
///   <summary>
  
///  根据UserID取回用户的名称
  
///   </summary>
  
///   <param name="sUserID"> 用户的ID </param>
  
///   <returns> 取回用户的名称 </returns>
   public   static   string  GetUserDisplayNameByUserGuid( string  sUserID)
  {
   
string  m_retu = "" ;
   
try
   {
    
    
if (IsGuid(sUserID))
    {
     Connection conn 
=   new  Connection();
     User oUser 
=  conn.GetUserByID( new  Guid(sUserID));
     m_retu 
=  oUser.EntityAlias;
     oUser 
=   null ;
    }
   }
   
catch
   {
    m_retu
= string .Empty;
   }
   
return  m_retu;
  }
  
///   <summary>
  
///  根据用户名称取得ID
  
///   </summary>
  
///   <param name="userName"></param>
  
///   <returns></returns>
   public   static  Guid GetUserIDByUserName( string  userName)
  {
   
using (ConnectionBR c  =   new  ConnectionBR())
   {
    
try
    {
     
return  (Guid) c.ExecuteScalar( " Select EntityID FROM EntityBase WHERE EntityAlias = ' " + userName.Trim() + " ' " );
    }
    
catch
    {
     
return  Guid.Empty;
    }
   }
  }


  
private   static   string  EncodeString( object  theValue)
  {
   
return  String.Format( " {0} " , theValue.ToString().Replace( " ' " " '' " ));
  }

  
public   static   object  ToString( string  str)
  {
   
return  ToString(str, DBNull.Value);
  }

  
public   static   object  ToString( string  str,  object  defaultValue)
  {
   str
= str.Trim();  // add by hjs 2004-9-23
    if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsNull(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||  str  ==   string .Empty )
   {
    
return  defaultValue;
   }
   
else
   {
    
return  EncodeString(str);
   }
  }


  
///   <summary>
  
/// 去除空格
  
///   </summary>
  
///   <returns></returns>
   public   static   object  ToString( string  str, bool  removespace)
  {
   
if (removespace)
   {
    
return  ToString(str.Replace( "   " , "" ),DBNull.Value);
   }
   
else
   {
    
return  ToString(str,DBNull.Value);
   }
  }

  
public   static   int  GetInt( object  obj)
  {
   
return  GetInt(obj,  int .MinValue);
  }

  
public   static   int  GetInt( object  obj,  int  defaultValue)
  {
   
if (IsNull(obj)  ||   ! IsInt(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToInt32(obj);
   }
  }


  
public   static   object  ToInt( string  str)
  {
   
return  ToInt(str, DBNull.Value);
  }

  
public   static   object  ToInt( string  str,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsInt(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsInt(str.Trim()))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToInt32(str.Trim());
   }
  }

 

  
public   static   decimal  GetDecimal( object  obj)
  {
   
return  GetDecimal(obj,  decimal .MinValue);
  }

  
public   static   decimal  GetDecimal( object  obj,  decimal  defaultValue)
  {
   
string  str = obj  as   string ;
   
if (str != null )
   {
    
// 这是把$等符号去掉.
     if (str.Length > 0 )
    {
     
if (str[ 0 ] > ' 9 '   ||  str[ 0 ] < 0 )
     {
      str
= str.Substring( 1 ,str.Length - 1 );
     }
    }
    obj
= str;
   }
   
if (IsNull(obj)  ||   ! IsDecimal(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDecimal(obj);
   }
  }


  
public   static   object  ToDecimal( string  str)
  {
   
return  ToDecimal(str, DBNull.Value);
  }

  
public   static   object  ToDecimal( string  str,  object  defaultValue)
  {
   
// 这是把$等符号去掉.
    if (str.Length > 0 )
   {
    
if (str[ 0 ] > ' 9 '   ||  str[ 0 ] < 0 )
    {
     str
= str.Substring( 1 ,str.Length - 1 );
    }
   }

   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsDecimal(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsDecimal(str.Trim()))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDecimal(str.Trim());
   }
  }

 

  
public   static   double  GetDouble( object  obj)
  {
   
return  GetDouble(obj,  double .NaN);
  }

  
public   static   double  GetDouble( object  obj,  double  defaultValue)
  {
   
string  str = obj  as   string ;
   
if (str != null )
   {
    
// 这是把$等符号去掉.
     if (str.Length > 0 )
    {
     
if (str[ 0 ] > ' 9 '   ||  str[ 0 ] < 0 )
     {
      str
= str.Substring( 1 ,str.Length - 1 );
     }
    }
    obj
= str;
   }

   
if (IsNull(obj)  ||   ! IsDouble(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDouble(obj);
   }
  }


  
public   static   object  ToDouble( string  str)
  {
   
return  ToDouble(str, DBNull.Value);
  }

  
public   static   object  ToDouble( string  str,  object  defaultValue)
  {

   
if (str.Length > 0 )
   {
    
if (str[ 0 ] > ' 9 '   ||  str[ 0 ] < 0 )
    {
     str
= str.Substring( 1 ,str.Length - 1 );
    }
   }

   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsDouble(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsDouble(str.Trim()))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDouble(str.Trim());
   }
  }


  
public   static   string  GetString( object  obj)
  {
   
return  GetString(obj, string .Empty);
  }
  
public   static   string  GetString( object  obj, string  defaultValue)
  {
   
if ( ! IsNull(obj))
   {
    
return  obj.ToString();
   }
   
else
   {
    
return  defaultValue;
   }
  }
  
public   static   Guid GetGuid( object  obj)
  {
   
return  GetGuid(obj, Guid.Empty);
  }
        
  
public   static  Guid GetGuid( object  obj, Guid defaultValue)
  {
   
if (IsNull(obj)  ||   ! IsGuid(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return   new  Guid(obj.ToString());
   }
  }
 
  
public   static   object  ToGuid( object  str)
  {
   
if (str == null )
   {
    
return  ToGuid( null , DBNull.Value);
   }
   
else
   {
    
return  ToGuid(str.ToString(), DBNull.Value);
   }
  }

  
public   static   object  ToGuid( string  str)
  {
   
return  ToGuid(str, DBNull.Value);
  }

  
public   static   object  ToGuid( string  str,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsGuid(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsGuid(str.Trim()))
   {
    
return  defaultValue;
   }
   
else
   {
    
return   new  Guid(str.Trim());
   }
  }

 


  
public   static   bool  GetBool( object  obj)
  {
   
return  GetBool(obj,  false );
  }

  
public   static   bool  GetBool( object  obj,  bool  defaultValue)
  {
   
if (IsNull(obj)  ||   ! IsBool(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToBoolean(obj);
   }

  }


  
public   static   object  ToBool( string  str)
  {
   
return  ToBool(str, DBNull.Value);
  }

  
public   static   object  ToBool( string  str,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsBool(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (str  ==   null   ||  str.Trim()  ==   string .Empty)
   {
    
return  defaultValue;
   }
   
else  
   {
    
string  str1  =  str.ToLower().Trim();
    
if (str1  ==   " 1 "   ||  str1  ==   " true " )
    {
     
return   true ;
    }
    
else   if ( str1  ==   " 0 "   ||  str1  ==   " false " )
    {
     
return   false ;
    }
    
else
    {
     
return  defaultValue;
    }
   }
  }


  
public   static  DateTime GetDateTime( object  obj)
  {
   
return  GetDateTime(obj, DateTime.Now);
  }

  
public   static  DateTime GetDateTime( object  obj, DateTime defaultValue)
  {
   
if (IsNull(obj)  ||   ! IsDateTime(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDateTime(obj);
   }
  }


  
public   static   object  ToDateTime( string  str)
  {
   
return  ToDateTime(str, DBNull.Value);
  }

  
public   static   object  ToDateTime( string  str,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsDateTime(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsDateTime(str.Trim()))
   {
    
return  defaultValue;
   }
   
else  
   {
   
    
return  Convert.ToDateTime(str.Trim()).ToUniversalTime();
   }
  }

  
public   static   object  ToDateTime( object  date,  object  time)
  {
   
return  ToDateTime(date, time, DBNull.Value);
  }

  
public   static   object  ToDateTime( object  date,  object  time,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsDateTime(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(date)  ||   ! IsDateTime(date))
   {
    
return  defaultValue;
   }

   
string  selectTime  =  time  ==   null   ||  time.ToString().Trim()  ==   string .Empty  ?   " 12:00 PM "  : time.ToString().Trim();

   DateTime dateTime1 
=  Convert.ToDateTime(date.ToString().Trim());

   
return  Convert.ToDateTime(dateTime1.ToShortDateString()  +   "   "   +  selectTime).ToUniversalTime();
  }

  
private   static   byte [] ToBytes( string  str)
  {
   
return  Encoding.UTF8.GetBytes(str);
  }


  
public   static   bool  IsNull( object  obj)
  {
   
if  ((obj  !=   null &&   ! Convert.IsDBNull(obj))
   {
    
return   false ;
   }
   
return   true ;
  }
 
  
  
///   <summary>
  
///  序列化一个对象,把一个对象序列化成一个字符串
  
///   </summary>
  
///   <param name="obj"> 对象 </param>
  
///   <returns> 序列化好的字符串 </returns>
   public   static   string  SerializeObject( object  obj)
  {
   XmlDocument document1 
=   new  XmlDocument();
   
using  (MemoryStream stream1  =   new  MemoryStream())
   {
    
using  (StreamWriter writer1  =   new  StreamWriter(stream1, Encoding.Unicode))
    {
     
try
     {
      
new  XmlSerializer(obj.GetType()).Serialize(stream1, obj);
     }
     
catch
     {
      
if  ( ! (obj  is  Exception))
      {
       
throw ;
      }
      
return  ((Exception) obj).ToString();
     }
     stream1.Seek((
long 0 , SeekOrigin.Begin);
     document1.Load(stream1);
     
return  document1.DocumentElement.OuterXml;
    }
   }
  }
 
  
///   <summary>
  
///  序列化一个对象数组,把一个对象数组序列化成一个字符串
  
///   </summary>
  
///   <param name="arr"> 对象数组 </param>
  
///   <returns> 序列化好的字符串 </returns>
   public   static   string  SerializeObjectArray( object [] arr)
  {
   StringBuilder builder1 
=   new  StringBuilder();
   builder1.Append(
" <details> " );
   
object [] objArray1  =  arr;
   
for  ( int  num1  =   0 ; num1  <  objArray1.Length; num1 ++ )
   {
    
object  obj1  =  objArray1[num1];
    builder1.Append(SerializeObject(obj1));
   }
   builder1.Append(
" </details> " );
   XmlDocument document1 
=   new  XmlDocument();
   document1.LoadXml(builder1.ToString());
   
return  document1.OuterXml;
  }

 

  
  
///   <summary>
  
///  把货币金额转成英文的大写.
  
///   </summary>
  
///   <param name="sAmount"> 要转换大写的货币金额 </param>
  
///   <param name="bShowSuffix"> 是否要显示小数点后面的同容 </param>
  
///   <returns> 格式好的字符串 </returns>
   public   static   string  GetAmountEnglisth( string  sAmount, bool  bShowSuffix)
  {
   
string []  numAry  = " One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen,Sixteen,Seventeen,Eighteen,Nineteen " .Split( ' , ' );
   
string []  num10Ary  = " Ten,Twenty,Thirty,Forty,Fifty,Sixty,Seventy,Eighty,Ninety " .Split( ' , ' );
   
string []  carrySymbolAry  = " Hundred,Thousand,Million,Billion " .Split( ' , ' );


   
decimal  d  =  Convert.ToDecimal(sAmount);
   
if (d > 100000000000 return   "" ;
   
string  sValue  =  d.ToString( " #0 " );
   
string  sInt  = "" ;
   
string  sDec  = "" ;
   
if (bShowSuffix)
   {
    sValue 
=  d.ToString( " #0.00 " );
    
int  iZeroPos  =  sValue.IndexOf( " . " );
    sInt 
=  sValue.Substring( 0 ,iZeroPos);
    sDec 
=  sValue.Substring(iZeroPos + 1 );
   }
   
else
   {
    sInt 
=  sValue;
   }
   
   
if (sInt.Length > 11 )
   {
    
return   " can not translate so big number!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " ;
   }

   System.Text.StringBuilder sbRes 
=   new   System.Text.StringBuilder();
   
for  ( int  i = 0 ;i < sInt.Length;i ++ )
   {
    
int  iPos  =  sInt.Length -  i;
    
int  iCarryPos  =  iPos  %   3 ;
  
    
int  num  =  Convert.ToInt32(sInt.Substring(i, 1 ));
    
if (num  == 0 )
    {
    
     
if (iCarryPos  == 2 )
     {
      sbRes.Append(
"  and " );
     }
    
     
if (iPos  == 4   ||  iPos  == 7   ||  iPos  ==   10 )
     {
      
int  iSectionPos  =  ( int )Math.Floor((iPos / 3 ));
      sbRes.Append(
"   "   +  carrySymbolAry[iSectionPos]);
     }


     
continue ;
    } 
     
    
if (iCarryPos  == 0
    {
     sbRes.Append(
"   "   +  numAry[num - 1 +   "  Hundred " );
    }
    
else   if (iCarryPos  == 2 )
    {
     
if (sbRes.Length > 7 )
     {
     
      sbRes.Append(
"  and " );
     
     }
     
if (num  == 1 //  evelven twelve etc..
     {
      i
++ ;
      
int  numNext  =  Convert.ToInt32(sInt.Substring(i, 1 ));
      num 
=  num * 10 + numNext;
      sbRes.Append(
"   " + numAry[num - 1 ]);
      iPos 
=  sInt.Length -  i;  // Recalculate iPos;
     }
     
else
     {
      sbRes.Append(
"   " + num10Ary[num - 1 ]);
     }
   
      
    }
    
else   if (iCarryPos  == 1 )
    {
     
if (sbRes.Length > 0 )
     {
      
if (sbRes.ToString().Substring(sbRes.Length - 2 , 2 == " ty " )
      {
       sbRes.Append(
"   " );
      }
     }
     sbRes.Append(
"   "   + numAry[num - 1 ]);
    }
    

    
if (iPos  == 4   ||  iPos  == 7   ||  iPos  ==   10 )
    {
     
int  iSectionPos  =  ( int )Math.Floor((iPos / 3 ));
     sbRes.Append(
"   "   +  carrySymbolAry[iSectionPos]);
    }
   }

   
string  res  =  sbRes.ToString();
   
while  (res.IndexOf( "  and and " ) >- 1 )
   {
    res 
=  res.Replace( "  and and " , "  and " );
   }
   res 
=  res.Trim();
   
while  (res.Length > 3   &&  res.Substring(res.Length - 3 , 3 ) == " and " )
   {
    res 
=  res.Substring( 0 ,res.Length - 3 );
   }
   res 
=  res.Replace( " " , " - " );
   
   
   res 
=  res.Replace( "  and Thousand " , "  Thousand " );
   res 
=  res.Replace( "  and Million " , "  Million " );
   res 
=  res.Replace( "  and Billion " , "  Billion " );

   res 
=  res.Replace( " Million Thousand " , " Million " );
   res 
=  res.Replace( " Billion Million " , " Billion " );
   
   
   
if (bShowSuffix)
   {
    
    
int  iCents  = Convert.ToInt32(sDec);
    
if  (iCents > 0 )
    {
     res 
+=   "  and " ;
     
if (iCents < 20 )
     {
      res 
+=   "   "   + numAry[iCents - 1 ];
     }
     
else
     {
      res 
+=   "   "   +  num10Ary[Convert.ToInt32(sDec.Substring( 0 , 1 )) - 1 ];
      
if (sDec.Substring( 1 , 1 ) != " 0 " )
      {
       res 
+=   "   "   +  numAry[Convert.ToInt32(sDec.Substring( 1 , 1 )) - 1 ];
      }
     }
     res 
+= "  Cents " ;
    
    }
    
else
    {
     res 
+= "  Even " ;
    }
   }
   
// 替换多的END信息
   res  =  res.Replace( "  and  " , " | " );
   
if (res.IndexOf( " | " ) < 0 )
   {
    
return  res;
   }
   
else
   {
    
string [] p  =  res.Split( new   char []{ ' | ' });
    
if (p.Length == 2 )
    {
     
return  p[ 0 ] + "  and  " +  p[ 1 ];
    }
    
else
    {
     
string  temp  =   string .Empty;
     
for ( int  i = 0 ;i < p.Length;i ++ )
     {
      
if (i != p.Length - 1 )
      {
       temp 
+= "   " +  p[i];
      }
      
else
      {
       temp 
+= "  and  " +  p[i];
      }
     }
     
return  temp;
    }
   }


  }
   
  
///   <summary>
  
///  把货币金额从数字转为大写
  
///   </summary>
  
///   <param name="sAmount"> 要转换大写的货币金额 </param>
  
///   <param name="bShowSuffix"> 是否要显示小数点后面的同容 </param>
  
///   <returns> 格式好的字符串 </returns>
   public   static   string  GetAmountChinese( string  sAmount, bool  bShowSuffix)
  {
   
string [] numAry  =   new   string []{ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " };
   
string [] posAry  =   new   string []{ "" , " " , " " , " " , " " , " " , " " , " " , " 亿 " , " " , " " , " " };
   
string [] decAry  =   new   string []{ " " , " " };
   
try
   {
    
decimal .Parse(sAmount);
   }
   
catch
   {
    
return   " 零圆 " ;
   }
  
   
string  res  = ""  ;
   
decimal  d  =  Convert.ToDecimal(sAmount);
   
string  sValue  =  d.ToString( " #0 " );
   
string  sInt  =  sValue;
   
string  sDec  = "" ;
   
int  iZeroPos  =   0 ;
   
if (bShowSuffix)
   {
    sValue  
=  d.ToString( " #0.00 " );
    iZeroPos 
=  sValue.IndexOf( " . " );
    sInt 
=  sValue.Substring( 0 ,iZeroPos);
    sDec 
=  sValue.Substring(iZeroPos + 1 );
   }
    
    
   
if (bShowSuffix)
   {
   
    sInt 
=  sValue.Substring( 0 ,iZeroPos);
   }
   
   
if (sInt.Length > 11 )
   {
    
return   " can not translate so big number!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " ;
   }
   
for  ( int  i = 0 ;i < sInt.Length;i ++ )
   {
    res 
+=  numAry[Convert.ToInt32(sInt.Substring(i, 1 ))]  +  posAry[sInt.Length - i - 1 ];
   }
  
   res 
=  res.Replace( " 零圆 " , "" );
   res 
=  res.Replace( " 零拾 " , " " );
   res 
=  res.Replace( " 零佰 " , " " );
   res 
=  res.Replace( " 零仟 " , " " );
  
   
   
while  (res.IndexOf( " 零亿 " ) >- 1 )
   {
    res 
=  res.Replace( " 零亿 " , " 亿 " );
   }
   
while  (res.IndexOf( " 零万 " ) >- 1 )
   {
    res 
=  res.Replace( " 零万 " , " " );
   }
   res 
=  res.Replace( " 亿万 " , " 亿 " );
   
while  (res.IndexOf( " 零零 " ) >- 1 )
   {
    res 
=  res.Replace( " 零零 " , " " );
   }
   
if (res.Substring(res.Length - 1 , 1 == " " )
   {
    res 
=  res.Substring( 0 ,res.Length - 1 );
   }

   res 
+= " " ;
   
if (bShowSuffix)
   {
    
for ( int  i = 0 ;i < sDec.Length;i ++ )
    {
     res 
+=  numAry[Convert.ToInt32(sDec.Substring(i, 1 ))]  +  decAry[i] ;
    }

    res 
= res.Replace( " 零角零分 " , " " );
   }
   
   
if (res  == " " )
   {
    res 
= " 零圆 " ;
   }
   
return  res;
  }


  
///   <summary>
  
///  把URL格式转换成可以点击的URL内容
  
///   </summary>
  
///   <param name="url"> 要连接的URL地址 </param>
  
///   <param name="DisplayName"> 显示到界面的内容 </param>
  
///   <returns> 已格式好的字符串 </returns>
   public   static   string  GetURLDisplayString( string  url, string  DisplayName)
  {
   
if (url  == "" return   "" ;
   
if  (url.Length >= 7 )
   {
    
if (url.Substring( 0 , 7 ).ToUpper() != " HTTP:// " )
    {
     url 
= " Http:// "   + url;
    }
   }
   
   
if  (DisplayName.Length > 15 )
   {
    DisplayName 
=  DisplayName.Substring( 0 , 15 ) + " ... " ;
   }
   
   
return   " <a href=' "   +  url  + " ' target='_blank'> "   +  DisplayName  + " </a> " ;
  }

  
///   <summary>
  
///  把Email格式成可点击的Email显示格式
  
///   </summary>
  
///   <param name="email"> Email地址 </param>
  
///   <returns> 已格式好的字符串 </returns>
   public   static   string  GetEmailDisplayValue( string  email)
  {
   
if (email.Trim()  == "" return "" ;
   
return   " <a href="mailto: " + email + " "> " + email + " </a> " ;
  } 

 

  
///   <summary>
  
///  刷新父窗口,并确定是是要刷新父窗口,确定是否关闭本页。
  
///   </summary>
  
///   <param name="win"> 要进行操作的页面 </param>
  
///   <param name="refreshParent"> 是否要刷新父窗口 </param>
  
///   <param name="close"> 是否要关闭本窗口 </param>
   public   static   void  RefreshWindow(System.Web.UI.Page win,  bool  refreshParent,  bool  close)
  {
   
if ( ! refreshParent  &&   ! close)  return ;


   
string  script  = " <script> " ;
   
if (refreshParent)
   {
    script 
+= " if(top.opener.refresh==null){ " ;
    script 
+=   " try{top.opener.location.href = top.opener.location.href;}catch(e){} " ;
    script 
+= " }else{top.opener.refresh();} " ;
   }

   
if (close)
   {
    script 
+= " top.close(); " ;
   }

   script 
+= " </script> " ;

   
if ( ! win.IsClientScriptBlockRegistered( " RefreshWindowScript " ))
   {
    win.RegisterClientScriptBlock(
" RefreshWindowScript " , script);
   }
  }
  
///   <summary>
  
///  刷新父窗口,并确定是是要刷新父窗口,确定是否关闭本页。
  
///   </summary>
  
///   <param name="win"> 要进行操作的页面 </param>
  
///   <param name="refreshParent"> 是否要刷新父窗口 </param>
  
///   <param name="close"> 是否要关闭本窗口 </param>
   public   static   void  OpenExportWindow(System.Web.UI.Page win,  string  exportWin)
  {
   


   
string  script  = " <script> " ;
  
   script 
+=   " try{window.open(' " + exportWin + " ');}catch(e){} " ;
   

   script 
+= " </script> " ;

   
if ( ! win.IsClientScriptBlockRegistered( " OpenExportWindow " ))
   {
    win.RegisterClientScriptBlock(
" OpenExportWindow " , script);
   }
  }
  
///   <summary>
  
///  刷新父窗口,并确定是是要刷新父窗口,确定是否关闭本页。
  
///   </summary>
  
///   <param name="win"> 要进行操作的页面 </param>
  
///   <param name="refreshParent"> 是否要刷新父窗口 </param>
  
///   <param name="close"> 是否要关闭本窗口 </param>
   public   static   void  RefreshParentWindow(System.Web.UI.Page win,  bool  refreshParent,  bool  close)
  {
   
if ( ! refreshParent  &&   ! close)  return ;


   
string  script  = " <script> " ;
   
if (refreshParent)
   {
    script 
+=   " try{top.opener.refresh();}catch(e){} " ;
   }

   
if (close)
   {
    script 
+= " top.close(); " ;
   }

   script 
+= " </script> " ;

   
if ( ! win.IsClientScriptBlockRegistered( " RefreshParentWindowScript " ))
   {
    win.RegisterClientScriptBlock(
" RefreshParentWindowScript " , script);
   }
   
   
  }
  
public   static   string  GetPageBgColorFormat()
  {
   
//  return System.Drawing.Color.FromArgb(240,240,240);
    return   " White " ;
  }
  
public   static   string  GetUserPageBgColorFormat()
  {
   
//  return System.Drawing.Color.FromArgb(240,240,240);
   SystemUserSettingBR systemUserSettingBR  =   new  SystemUserSettingBR();
   
string  color  =  systemUserSettingBR.GetValueByKey( " BgColor " );
   
if (color != null )
   {
    
return  color;
   }
   
else
   {
    
return  GetPageBgColorFormat();
   }
  }
  
///   <summary>
  
///  取回电话组合的格式
  
///   </summary>
  
///   <param name="phoneCountryKey"> 电话的国家码 </param>
  
///   <param name="phoneAreaKey"> 电话的地址码 </param>
  
///   <param name="phoneKey"> 电话号码 </param>
  
///   <param name="phoneExtKey"> 分号 </param>
  
///   <returns> 返回组合好的电话格式 </returns>
   public   static   string  GetPhoneFormat( string  phoneCountryKey,  string  phoneAreaKey,  string  phoneKey,  string  phoneExtKey)
  {
   
string  strRetu = "" ;

   
if (phoneCountryKey != null   &&  phoneCountryKey != string .Empty)
   {
    strRetu
= phoneCountryKey;
   }
   
if (phoneAreaKey != null   &&  phoneAreaKey != string .Empty)
   {
    strRetu
+= " ( " + phoneAreaKey + " ) " ;
   }
   
if (phoneKey != null   &&  phoneKey != string .Empty)
   {
    strRetu
+= phoneKey;
   }
   
if (phoneExtKey != null   &&  phoneExtKey != string .Empty)
   {
    strRetu
+= "  Ext  " + phoneExtKey;
   }
   
return  strRetu;
  }

  
public   static   string  GetPhoneFormat( object  phoneCountryKey,  object  phoneAreaKey,  object  phoneKey,  object  phoneExtKey)
  {
   
string  strRetu = "" ;

   
if (phoneCountryKey != null   &&  phoneCountryKey.ToString() != string .Empty)
   {
    strRetu
= phoneCountryKey.ToString();
   }
   
if (phoneAreaKey != null   &&  phoneAreaKey.ToString() != string .Empty)
   {
    strRetu
+= " ( " + phoneAreaKey.ToString() + " ) " ;
   }
   
if (phoneKey != null   &&  phoneKey.ToString() != string .Empty)
   {
    strRetu
+= phoneKey.ToString();
   }
   
if (phoneExtKey != null   &&  phoneExtKey.ToString() != string .Empty)
   {
    strRetu
+= "  Ext  " + phoneExtKey.ToString();
   }
   
return  strRetu;
  }

  
///   <summary>
  
///  取得utc时间的当地时间
  
///   </summary>
  
///   <param name="dt"></param>
  
///   <returns></returns>
   public   static   string  GetUtcLocalString( object  obj)
  {
   DateTime d 
=  Convert.ToDateTime(obj);
   
return  GetUtcLocalString(d,  " d " );
   
  }

  
///   <summary>
  
///  by hjs 2004-10-20 取得utc时间的当地时间
  
///   </summary>
  
///   <param name="dt"></param>
  
///   <returns></returns>
   public   static   string  GetUtcLocalString(DateTime d)
  {
   
return  GetUtcLocalString(d,  " d " );
   
  }

  
///   <summary>
  
///  
  
///   </summary>
  
///   <param name="d"> a DateTime value </param>
  
///   <param name="outputFormat"> 'd', 't', 'g', or 'gbr' </param>
  
///   <returns></returns>
   public   static   string  GetUtcLocalString(DateTime d,  string  outputFormat)
  {
   
string  localTimeFormat  =   " <script>document.write(ebcUTC2Loc({0},{1},{2},{3},{4},{5},' "   +  outputFormat  + " '));</script> " ;
   
return   string .Format(localTimeFormat, d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
   
  }


  
public   static   void  ParsePartNumber( string  partNumber,  ref   string  prefix,  ref   string  partBase,  ref   string  partitionSupport)
  {
   
if (partNumber  ==   null   ||  partNumber  ==   string .Empty)
   {
    prefix 
=   string .Empty;
    partBase
=   string .Empty;
    partitionSupport 
=   string .Empty;
    
return ;
   }
   Regex regex 
=   new  Regex( " [0-9] " );
   Match match 
=  regex.Match(partNumber);
   
if (match.Success)
   {
    prefix 
=  partNumber.Substring( 0 ,match.Index);
    partBase 
=  partNumber.Substring(match.Index);
    partitionSupport 
=  partNumber.Substring(match.Index,  1 );
   }
   
else
   {
    prefix 
=  partNumber;
    partitionSupport 
=   " -1 " ;
   }

  }

  
public   static   void  ParsePartNumberExtracted( string  partNumber,  ref   string  prefix,  ref   string  partBase,  ref   string  partitionSupport)
  {
   
string  l_PartNumber  =  GetPartNumberExtracted(partNumber);
   ParsePartNumber(partNumber, 
ref  prefix,  ref  partBase,  ref  partitionSupport);
  }

  
///   <summary>
  
///  把型号拆分放在记录行中.
  
///   </summary>
  
///   <param name="partNumber"> 输入型号 </param>
  
///   <param name="m_dr"> 要分拆型号的记录 </param>
  
///   <remarks> Prefix->PrefixStr[SUN20041109] </remarks>
   public   static   void  ParsePartNumberExtractedToRow( string  partNumber,System.Data.DataRow m_dr)
  {
   m_dr[
" PartNumber " ] = partNumber;
   
string  l_PartNumber  =  GetPartNumberExtracted(partNumber);
   
string  prefix = "" ,partBase = "" ,partitionSupport = "" ;
   ParsePartNumber(l_PartNumber, 
ref  prefix,  ref  partBase,  ref  partitionSupport);
   m_dr[
" PrefixStr " ] = prefix;
   m_dr[
" PartitionSupport " ] = Utility.ToInt(partitionSupport);
   m_dr[
" PartNumberExtracted " ] = l_PartNumber;
  }

  
  
public   static   string  GetPartNumberExtracted( string  partNumber)
  {
   
if  (partNumber  ==   null   ||  partNumber  ==   string .Empty)
   {
    
return   "" ;
   }

   
for ( int  i  =   0 ; i <  PARTNUMBER_FORBIDDEN_CHARACTERS.Length; i ++ )
   {
    partNumber 
=  partNumber.Replace(PARTNUMBER_FORBIDDEN_CHARACTERS.Substring(i,  1 ),  "" );
   }
   
return  partNumber;
  }

  
public   static   string  GetPartNumberExtracted( string  partNumber, int  partNumberSearchFlg)
  {
   
if  (partNumber  ==   null   ||  partNumber  ==   string .Empty)
   {
    
return   "" ;
   }
   
if (partNumberSearchFlg != 5 )
    partNumber
= GetPartNumberExtracted(partNumber);
   
else
   {
    
for ( int  i  =   0 ; i <  PARTNUMBER_FORBIDDEN_CHARACTERS_SMARTSEARCH.Length; i ++ )
    {
     partNumber 
=  partNumber.Replace(PARTNUMBER_FORBIDDEN_CHARACTERS_SMARTSEARCH.Substring(i,  1 ),  "" );
    }
   }
   
return  partNumber;
  }

  
public   static   string  GetPartNumberFilterExpression( string  partNumber)
  {
   
string  l_PartNumber  =   string .Empty;

   l_PartNumber 
=  GetPartNumberExtracted(partNumber);

   
if (l_PartNumber == string .Empty)
   {
    
return   string .Empty;
   }
   
string  l_prefix  =   string .Empty;
   
string  l_partBase  =   string .Empty;
   
string  l_partitionSupport  =   " -1 " ;
   Utility.ParsePartNumber(Utility.ToString(l_PartNumber).ToString(), 
ref  l_prefix,  ref  l_partBase,  ref  l_partitionSupport);

   
// System.Text.StringBuilder  filterExpression= new System.Text.StringBuilder("PartitionSupport = '" + l_partitionSupport  + "'" );
   System.Text.StringBuilder  filterExpression =   new  System.Text.StringBuilder();

   
if (l_partBase  !=   string .Empty)
   {
    
if (l_prefix  !=   string .Empty)
    {
     filterExpression.Append(
" PrefixStrExtracted LIKE N' "   +  l_prefix   +   " %' AND BasePartNumberExtracted LIKE N' "   +  l_partBase   +   " %' "  );
    }
    
else
    {
     filterExpression.Append(
" BasePartNumberExtracted LIKE N' "   +  l_partBase   +   " %' "  );
    }
    
   }
   
else   if (l_prefix  !=   string .Empty)
   {
    filterExpression.Append(
" PrefixStrExtracted LIKE N' "   +  l_prefix   +   " %' "  );
   }

   
return  filterExpression.ToString();
  }

  
///   <summary>
  
///  取回要查找型号的条件字符串
  
///   </summary>
  
///   <param name="reqFindPartNumber"> 要查的型号 </param>
  
///   <returns> 返回要查找型号的条件字符串 </returns>
   public   static   string  GetPartNumberRankExpression( string  reqFindPartNumber)
  {
   
string  m_RANKFUNCTION  =   " dbo.GetQueryRank('{0}','{1}',PrefixStrExtracted,BasePartNumberExtracted) " ;

  
   
string  PartNumberExtracted = string .Empty;

   PartNumberExtracted 
=  GetPartNumberExtracted(reqFindPartNumber);

   
if (PartNumberExtracted  ==   string .Empty)
   {
    
return   " 1=2 " ;
   }

   
string  prefix  =   string .Empty;
   
string  partBase  =   string .Empty;
   
string  partitionSupport  =   " -1 " ;

   Utility.ParsePartNumber(Utility.ToString(reqFindPartNumber).ToString(), 
ref  prefix,  ref  partBase,  ref  partitionSupport);

   
if (prefix  ==   string .Empty  &&  partBase  ==   string .Empty)
   {
    
return   " 1=2 " ;
   }

   StringBuilder filterExpression 
=   new  StringBuilder( " PartitionSupport = ' "   +  partitionSupport   +   " ' "  );
   
if (partBase  !=   string .Empty)
   {
    
if (partBase.Length  < 3 )
    {
     
if (prefix  !=   string .Empty)
     {
      filterExpression.Append(
" AND PrefixStrExtracted = N' "   +  prefix   +   " ' AND BasePartNumberExtracted LIKE N' "   +  partBase   +   " %' "  );
     }
     
else
     {
      filterExpression.Append(
" AND BasePartNumberExtracted = N' "   +  partBase   +   " ' "  );
     }
    }
    
else
    {
     filterExpression.Append(
" AND BasePartNumberExtracted LIKE N' "   +  partBase   +   " %' "  );
    }
   }
   
else   if (prefix  !=   string .Empty)
   {
    filterExpression.Append(
" AND PrefixStrExtracted LIKE N' "   +  prefix   +   " %' "  );
   }
   filterExpression.Append(
"  AND  "   +  String.Format(m_RANKFUNCTION, prefix,partBase)  +   "  IN (1,2,3,4) " );
   
return  filterExpression.ToString();
  }
  
///   <summary>
  
///  得到兑换率信息集合
  
///   </summary>
  
///   <returns></returns>
   public   static   string  GetExchangeRateInfoOfJavaScript()
  {
   System.Text.StringBuilder sb 
=   new  StringBuilder( 200 );
   sb.Append(
"  var ExchangeRateInfo = ' " );
   System.Data.DataRow[] m_strMap_arr
= StringMapCache.RetrieveStringMap( " ObjectTypeCode= " + (( int )ObjectTypeEnum.Organization).ToString() + "  AND FieldName='CurrencyCode'   " , "" );
   
if (m_strMap_arr.Length == 0 )
   {
    
return  sb.Append( " '; " ).ToString();
   }
   
foreach (DataRow dr  in  m_strMap_arr)
   {
    sb.Append(dr[
" FieldValue " ].ToString().Trim() + " | " );
    sb.Append(Utility.GetDecimal(dr[
" InternalValue " ], 1 ).ToString().Trim() + " # " );
      
   }
   
string  resultString  =  sb.ToString().Substring( 0 ,sb.ToString().Length - 1 );
   
   
return  resultString + " '; " ;
  }
  
public   static   void  SetSmartPartNumber()
  {
   
if (HttpContext.Current.Request.QueryString[ " PartNumber " ] != null )
    HttpContext.Current.Session[
" PartNumber " =    HttpContext.Current.Request.QueryString[ " PartNumber " ];
   
else
    HttpContext.Current.Session[
" PartNumber " ] = string .Empty;
  }
  
///   <summary>
  
///  根据币种取回币种的计算值
  
///   </summary>
  
///   <param name="currencyCode"> 币种代码 </param>
  
///   <returns></returns>
   public   static   decimal  GetExchangeRateByCurrencyCode( string  currencyCode)
  {
   
decimal  m_retu = 0 ;
   
if (currencyCode.Trim() == "" )
    m_retu
= 1 ;
   
else
   {
    System.Data.DataRow[] m_strMap_arr
= StringMapCache.RetrieveStringMap( " ObjectTypeCode= " + (( int )ObjectTypeEnum.Organization).ToString() + "  AND FieldName='CurrencyCode'  AND FieldValue= " + currencyCode, "" );
    
if (m_strMap_arr.Length > 0 )
    {
     m_retu
= Utility.GetDecimal(m_strMap_arr[ 0 ][ " InternalValue " ], 1 );
    }
   }
   
return  m_retu;
  }
  
///   <summary>
  
///  根据前一个币种及价格转换成后一币种的价格[20050120SUN]
  
///   </summary>
  
///   <returns></returns>
   public   static   decimal  GetTransferPrice( decimal  price , int  firstCurrencyCode, int  secondCurrencyCode)
  {
       
   
try
   {
    
return  price * (GetExchangeRateByCurrencyCode(secondCurrencyCode.ToString()) / GetExchangeRateByCurrencyCode(firstCurrencyCode.ToString()));
   }
   
catch
   {
    
return  price;
   }

  }
  
///   <summary>
  
///  根据税率类型取回计算值
  
///   </summary>
  
///   <param name="taxRateCode"> 币种代码 </param>
  
///   <returns></returns>
   public   static   decimal  GetTaxRateByTaxRateCode( string  taxRateCode)
  {
   
decimal  m_retu = 0 ;
   
if (taxRateCode.Trim() == "" )
    m_retu
= 0 ;
   
else
   {
    System.Data.DataRow[] m_strMap_arr
= StringMapCache.RetrieveStringMap( " ObjectTypeCode= " + (( int )ObjectTypeEnum.Organization).ToString() + "  AND FieldName='TaxRateCode' AND LangID='en-us' AND FieldValue= " + taxRateCode, "" );
    
if (m_strMap_arr.Length > 0 )
    {
     m_retu
= Utility.GetDecimal(m_strMap_arr[ 0 ][ " InternalValue " ], 0 );
    }
   }
   
return  m_retu;
  }

  
public   static   bool  CompareDoubleIsEqual( double  first, double  secord)
  {
   
return  System.Math.Abs(first - secord) < 0.01 ;
  }

  
public   static   bool  CompareDecimalIsEqual( decimal  first, decimal  secord)
  {
   
return  System.Math.Abs(first - secord) < Convert.ToDecimal( 0.01 );
  }


  
public   static   string  CurrentAccountPeriod
  {
   
get
   {
    DataSet ds 
=   null ;
    
using  (AccountSubjectMapBR br = new  AccountSubjectMapBR())
    {
     ds 
=  br.GetSubjectByAlias( " AccountPeriod " );
    }
     
    
if (ds  !=   null   &&  ds.Tables[ 0 ].Rows.Count  ==   1 )
    {
     
return  ds.Tables[ 0 ].Rows[ 0 ][ " SubjectNo " ].ToString();
    }

    
return   string .Empty;
   }
  }

  
///   <summary>
  
///  取回指定记录的ID序列号,如果没有值,则会传过来一个'0000-0000-...'
  
///  该函数只是方便把一个或二个记录集的ID字段组合成'ID','ID'的形式
  
///   </summary>
  
///   <param name="specifyIDName"> 要取回那个字段的ID </param>
  
///   <param name="m_FirstDs"> 第一个记录集 </param>
  
///   <param name="m_SecordDs"> 第二个记录集 </param>
  
///   <returns></returns>
   public   static   string  GetSpecifyRecordIDs( string  specifyIDName,System.Data.DataSet m_FirstDs,System.Data.DataSet m_SecordDs)
  {
   
string  m_retu = "" ;
   
foreach (System.Data.DataRow m_dr  in  m_FirstDs.Tables[ 0 ].Rows)
   {
    
if (m_retu == "" )
    {
     
if (m_dr.RowState == System.Data.DataRowState.Deleted)
     {
      m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName,System.Data.DataRowVersion.Original]).ToString() + " ' " ;
     }
     
else
     {
      m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
     }
    }
    
else
    {
     
if (m_dr.RowState == System.Data.DataRowState.Deleted)
     {
      m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName,System.Data.DataRowVersion.Original]).ToString() + " ' " ;
     }
     
else
     {
      m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
     }
    }
   }
   
if (m_SecordDs != null )
   {
    
foreach (System.Data.DataRow m_dr  in  m_SecordDs.Tables[ 0 ].Rows)
    {
     
if (m_retu == "" )
     {
      
if (m_dr.RowState == System.Data.DataRowState.Deleted)
      {
       m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName,System.Data.DataRowVersion.Original]).ToString() + " ' " ;
      }
      
else
      {
       m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
      }
     }
     
else
     {
      
if (m_dr.RowState == System.Data.DataRowState.Deleted)
      {
       m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName,System.Data.DataRowVersion.Original]).ToString() + " ' " ;
      }
      
else
      {
       m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
      }
     }
    }
   }
   
if (m_retu.Trim() == "" )
   {
    m_retu
= " ' " + Guid.Empty.ToString() + " ' " ;
   }
   
return  m_retu;
  }

  
///   <summary>
  
///  取回正常的日期和时间,不经过本地时间和全局时间的转换
  
///   </summary>
  
///   <param name="obj"></param>
  
///   <returns></returns>
   public   static  DateTime GetNormalDateTime( object  obj,DateTime defaultValue)
  {
   
if (IsNull(obj)  ||   ! IsDateTime(obj))
   {
    
return  defaultValue;
   }
   
else
   {
    
return  Convert.ToDateTime(obj);
   }
  }
 
  
public   static  DateTime GetNormalDateTime( object  obj)
  {
   
return  GetNormalDateTime(obj,System.DateTime.Now);
  }

  
///   <summary>
  
///  转为正常时间,不经过本地时间和全局时间的转换
  
///   </summary>
  
///   <param name="str"></param>
  
///   <param name="defaultValue"></param>
  
///   <returns></returns>
   public   static   object  ToNormalDateTime( string  str,  object  defaultValue)
  {
   
if (defaultValue  !=  DBNull.Value)
   {
    defaultValue 
=  IsDateTime(defaultValue)  ?  defaultValue : DBNull.Value;
   }

   
if (IsNull(str)  ||   ! IsDateTime(str.Trim()))
   {
    
return  defaultValue;
   }
   
else  
   {
    
return  Convert.ToDateTime(str.Trim());
   }
  }

  
public   static   object  ToNormalDateTime( string  str)
  {
   
return  ToNormalDateTime(str,DBNull.Value);
  }

  
///   <summary>
  
///  取回时间格式
  
///   </summary>
  
///   <returns> 给定的时间格式 </returns>
   public   static   string  GetDateFormat()
  {
   
string  m_retu =   " yyyy-MM-dd " ;
   
string  datetimeCode = "" ;
   datetimeCode
= new  SystemUserSettingBR().GetValueByKey( " DefaultDateFormat " );
   
if (datetimeCode == null   ||  datetimeCode == string .Empty)
   {
    datetimeCode
= OrganizationCache.RetrieveOrganization()
     .Settings.DefaultDateFormatCode.ToString();
   }
   
try
   {
    m_retu
= StringMapCache.RetrieveDisplayValue(ObjectTypeEnum.Organization, " DateFormatCode " ,
     datetimeCode);
   }
   
catch
   {
   }
   
if (m_retu == string .Empty)
   {
    m_retu
=   " yyyy-MM-dd " ;
   }
   
   
return  m_retu;
  }

  
public   static   string  GetLongDateFormat()
  {
   
string  m_retu =   " MM/dd/yyyy hh:mm:ss " ;
   
   
return  m_retu;
  }

  
///   <summary>
  
///  得到价格的显示格式
  
///   </summary>
  
///   <returns></returns>
  
///   <remarks> [SUN20041207] </remarks>
   public   static   string  GetPriceFormat()
  {
   
string  m_retu =   " ###,##0.00 " ;
   
string  m_priceCode = "" ;
   m_priceCode
= new  SystemUserSettingBR().GetValueByKey( " DefaultPriceFormat " );
   
if (m_priceCode == null   ||  m_priceCode == string .Empty)
   {
    m_priceCode
= OrganizationCache.RetrieveOrganization()
     .Settings.PricingDecimalPrecision.ToString();
   }
   
// 先取个人的币种格式,如果不能取到,则了系统的。
    try
   {
    m_retu
= StringMapCache.RetrieveDisplayValue(ObjectTypeEnum.Organization, " NumberFormatCode " ,
     m_priceCode);
   }
   
catch {}
   
if (m_retu == string .Empty)
   {
    m_retu
=   " ###,##0.00 " ;
   }
   
   
return  m_retu;
  }

  
///   <summary>
  
///  数量的格式
  
///   </summary>
  
///   <returns></returns>
   public   static   string  GetQTYFormat()
  {
   
return   "" ;
  }
        
  
///   <summary>
  
///  得到小数位个数
  
///   </summary>
  
///   <returns></returns>
   public   static   int  GetPriceFloatCount()
  {
   
string  m_retu  =  GetPriceFormat();
   
try
   {
    
return  m_retu.Length  -  (m_retu.IndexOf( " . " ) + 1 );
   }
   
catch
   {
      
   }
   
return   2 ;
  }

  
///   <summary>
  
///  检查单一深度的权限
  
///   </summary>
  
///   <param name="permissionType"> 要检查的许可类型 </param>
  
///   <returns></returns>
   public   static   bool  CheckSinglePermission(PrivilegeDepth permissionType)
  {
   
return  permissionType != PrivilegeDepth.None;
  }


  
///   <summary>
  
///  检查是否对指定拥有者的某条记录具有指定许可
  
///   </summary>
  
///   <param name="permissionType"> 要检查的许可类型 </param>
  
///   <param name="guidOwningUser"> 客户拥有者 </param>
  
///   <returns></returns>
   public   static   bool  CheckPermission(PrivilegeDepth permissionType,Guid guidOwningUser)
  {

   
if (permissionType == PrivilegeDepth.None)
   {
    
return   false ;
   }
   
if (permissionType == PrivilegeDepth.Global)
   {
    
return   true ;
   }
   
if (permissionType == PrivilegeDepth.Deep)
   {
    
if (EBiz.DBM.API.Utility.CurrentUser.MemberAllUserIDs.IndexOf(guidOwningUser.ToString()) >= 0 )
    {
     
return   true ;
    }
   }
   
if (permissionType == PrivilegeDepth.Local)
   {
    
if (EBiz.DBM.API.Utility.CurrentUser.MemberUserIDs.IndexOf(guidOwningUser.ToString()) >= 0 )
    {
     
return   true ;
    }
   }
   
if (permissionType == PrivilegeDepth.Basic)
   {
    
if (EBiz.DBM.API.Utility.CurrentUser.EntityID == guidOwningUser  ||  guidOwningUser == Guid.Empty)
    {
     
return   true ;
    }
   }
   
return   false ;
  }

  
///   <summary>
  
///  获取列表SQL过滤IDs表达式
  
///   </summary>
  
///   <param name="ids"> 要检查的Ids, 如,CustomerList </param>
  
///   <returns></returns>
   public   static   string  GetOwningUserFilterExpression( string  ids)
  {

   
if (ids ==   string .Empty)
   {
    
return  GLOBALLIST;
   }
   
if (ids == " ' " + Guid.Empty.ToString() + " ' " )
   {
    
return  NONELIST;
   }

   
string  filterExpression  =   string .Empty;

   
string [] guids  =  ids.Split( " , " .ToCharArray());

   
foreach ( string  id  in  guids)
   {
    
if (filterExpression.IndexOf(id)  <   0 )
    {
     
if (filterExpression.Trim().Length  >   0 )
     {
      filterExpression 
+= "  OR  " ;
     }

     filterExpression 
+=   " OwningUser= "   +  id;
    }
   }

   
if (filterExpression.Trim().Length  >   0 )
   {
    
return   "  ( "   +  filterExpression.Trim()  +   " " ;
   }
   
else
   {
    
return   string .Empty;
   }

  }
  
///   <summary>
  
///  根据拥有者标示获取列表SQL过滤IDs表达式
  
///   </summary>
  
///   <param name="ids"> 要检查的Ids, 如,CustomerList </param>
  
///   <returns></returns>
  
///   <remarks> SUN[20041217] </remarks>
   public   static   string  GetOwningUserFilterExpression( string  ids, string  ownerFlag)
  {

   
if (ids ==   string .Empty)
   {
    
return  GLOBALLIST;
   }
   
if (ids == " ' " + Guid.Empty.ToString() + " ' " )
   {
    
return  NONELIST;
   }

   
string  filterExpression  =   string .Empty;

   
string [] guids  =  ids.Split( " , " .ToCharArray());

   
foreach ( string  id  in  guids)
   {
    
if (filterExpression.IndexOf(id)  <   0 )
    {
     
if (filterExpression.Trim().Length  >   0 )
     {
      filterExpression 
+= "  OR  " ;
     }

     filterExpression 
+=  ownerFlag + " = "   +  id;
    }
   }

   
if (filterExpression.Trim().Length  >   0 )
   {
    
return   "  ( "   +  filterExpression.Trim()  +   " " ;
   }
   
else
   {
    
return   string .Empty;
   }
  }

  
///   <summary>
  
///  取回可以看到那几个仓库的库存的条件
  
///   </summary>
  
///   <param name="fieldName"> 仓库的字段名 </param>
  
///   <returns></returns>
   public   static   string  GetWarehouseCondition( string  fieldName)
  {
   
string  ids = Utility.CurrentPermissions.WarehouseList;
   
if (ids ==   string .Empty)
   {
    
return  GLOBALLIST;
   }
   
if (ids == " ' " + Guid.Empty.ToString() + " ' " )
   {
    
return  NONELIST;
   }

   EBiz.DBM.Common.DataSets.WarehouseDataSet 
    m_wh_ds
= new  WarehouseBR().GetByWhere( "" , " OwnerID in ( " + ids + " ) " , "" );

   ids
= " ' " + Guid.Empty.ToString() + " ' " ;
   
foreach (System.Data.DataRow m_dr  in  m_wh_ds.Warehouse)
   {
    ids
+= " ,' " + m_dr[ " WarehouseID " ].ToString() + " ' " ;
   }


   
string  filterExpression  =   string .Empty;

   
string [] guids  =  ids.Split( " , " .ToCharArray());

   
foreach ( string  id  in  guids)
   {
    
if (filterExpression.IndexOf(id)  <   0 )
    {
     
if (filterExpression.Trim().Length  >   0 )
     {
      filterExpression 
+= "  OR  " ;
     }

     filterExpression 
+=  fieldName + " = "   +  id;
    }
   }

   
if (filterExpression.Trim().Length  >   0 )
   {
    
return   "  ( "   +  filterExpression.Trim()  +   " " ;
   }
   
else
   {
    
return  NONELIST;
   }
  }

  
///   <summary>
  
///  
  
///   </summary>
  
///   <param name="partNumber"></param>
  
///   <param name="partNumberSearchFlg"> 1-Exact Prefix / Best Base,2-Exact Prefix / Exact Base,3-Any Prefix / Exact Base,4--Any Prefix / Best Base,5--smart search </param>
  
///   <returns></returns>
   public   static   string  GetPartNumberFilterExpression( string  partNumber, int  partNumberSearchFlg)
  {
   
string  partNumberExtracted = Utility.GetPartNumberExtracted(partNumber);
   
string  s_partNumberExtracted = string .Empty;
   
string  s_prefix = string .Empty;
   
if (partNumberExtracted  ==   string .Empty)
   {
    
return   " 1=2 " ;
   }

   
string  prefix  =   string .Empty;
   
string  partBase  =   string .Empty;
   
string  partitionSupport  =   " -1 " ;
   
if (partNumberSearchFlg == 5 )
   {
    s_partNumberExtracted
= Utility.GetPartNumberExtracted(partNumber, 5 );
    Utility.ParsePartNumber(s_partNumberExtracted,
ref  s_prefix, ref  partBase, ref  partitionSupport);
   }
   Utility.ParsePartNumber(partNumberExtracted,
ref  prefix, ref  partBase, ref  partitionSupport);
   StringBuilder filterExpression 
=   new  StringBuilder( " PartitionSupport = ' "   +  partitionSupport   +   " ' "  );

   
if (partBase  !=   string .Empty)
   {
    
if (partBase.Length  < 3 )
    {
     
if (prefix  !=   string .Empty)
     {
      
if (partNumberSearchFlg == 5 && s_prefix != string .Empty)
       filterExpression.Append(
" AND patindex(' " + s_prefix.Replace( " ? " , " % " ) + " ',PrefixStrExtracted)>0 AND BasePartNumberExtracted LIKE ' "   +  partBase   +   " %' "  );
      
else
       filterExpression.Append(
" AND PrefixStrExtracted = ' "   +  prefix   +   " ' AND BasePartNumberExtracted LIKE ' "   +  partBase   +   " %' "  );
     }
     
else
     {
      filterExpression.Append(
" AND BasePartNumberExtracted = ' "   +  partBase   +   " ' "  );
     }
    }
    
else
    {
     
if (partNumberSearchFlg == 5 && s_prefix != string .Empty)
      filterExpression.Append(
" AND patindex(' " + s_prefix.Replace( " ? " , " % " ) + " ',PrefixStrExtracted)>0  AND BasePartNumberExtracted LIKE ' "   +  partBase   +   " %' "  );
     
else  
      filterExpression.Append(
" AND BasePartNumberExtracted LIKE ' "   +  partBase   +   " %' "  );
    }
   }
   
else   if (prefix  !=   string .Empty)
   {
    
if (partNumberSearchFlg == 5 && s_prefix != string .Empty)
     filterExpression.Append(
" AND patindex(' " + s_prefix.Replace( " ? " , " % " ) + " ',PrefixStrExtracted)>0 "  );
    filterExpression.Append(
" AND PrefixStrExtracted LIKE ' "   +  prefix   +   " %' "  );
   }

  
   
if (partNumberSearchFlg  ==   5 ) // smart search智能查询:
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1,2,3,4) " );
   }
   
else   if (partNumberSearchFlg  ==   2 ) // Exact Prefix / Exact Base准确前缀/准确基码
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1)  " );
   }
   
else   if (partNumberSearchFlg  ==   1 ) // Exact Prefix / Best Base准确前缀/最佳基码
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1,2)  " );
   }
   
else   if (partNumberSearchFlg  ==   3 ) // Any Prefix / Exact Base任意前缀/准确基码
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1,3)  " );
   }
   
else   if (partNumberSearchFlg  ==   4 ) // Any Prefix / Best Base任意前缀/最佳基码
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1,2,3,4)  " );
   }
   
else
   {
    filterExpression.Append(
"  AND  "   +  String.Format(RANKFUNCTION, prefix,partBase)  +   "  IN (1,2)  " );
   }


   
return  filterExpression.ToString();
  }
  
public   static   string  GetClientScriptBlock( string  str)
  {
   
string  res  = " <script language='javascript'> <!-- "   +  str  + " --></script> " ;
   
return  res;
  }
  
#region  UserInfoScript
  
public   static   string  GetUserInfoScriptString()
  {
   DataSet ds 
=   new  ConnectionBR().GetByWhere( " EntityID, LoginName " , "" " LoginName " , " View_User_Joined " );
   System.Text.StringBuilder sb 
=   new  System.Text.StringBuilder();
   sb.Append(
" <script language='javascript'> " );
   sb.Append(getArrayUserGroup(
" self " ,getUserInfo( 1 ,ds.Tables[ 0 ])));
   sb.Append(getArrayUserGroup(
" group " ,getUserInfo( 2 ,ds.Tables[ 0 ])));
   sb.Append(getArrayUserGroup(
" unit " ,getUserInfo( 3 ,ds.Tables[ 0 ])));
   sb.Append(getArrayUserGroup(
" all " ,getUserInfo( 4 ,ds.Tables[ 0 ])));
   sb.Append(
" </script> " );
   
return  sb.ToString();
  }
  
///   <summary>
  
///  得到用户分类的数据集合
  
///   </summary>
  
///   <param name="name"></param>
  
///   <param name="htInfo"></param>
  
///   <returns></returns>
   public   static   string  getArrayUserGroup( string  name, string []  htInfo)
  {
   
string  arrayName  =   " ussg_ " + name + " _array " ; // 生成用户标示集合名
   System.Text.StringBuilder sb  =   new  System.Text.StringBuilder( 500 );
   sb.Append(
" var  " + arrayName + " = new Array(); " );
   
for ( int  i = 0 ;i < htInfo.Length;i ++ )
   {
    
if (htInfo[i] == null || htInfo[i] == string .Empty)
    {
     
continue ;
    }
    
else
    {
     sb.Append(arrayName
+ " [ " + i.ToString() + " ]= " + htInfo[i] + " ; " );
    }
      
   }
   
return  sb.ToString();
  }
  
///   <summary>
  
///  得到用户数据集合
  
///   </summary>
  
///   <param name="flag"></param>
  
///   <param name="dtInfo"></param>
  
///   <returns></returns>
   public   static   string [] getUserInfo( int  flag ,DataTable dtInfo)
  {
   
string [] htInfo  = null ;
   
if (flag == 1 )
   {
    htInfo 
=    new   string [ 1 ];
     
    htInfo[
0 =   " ' " + Utility.CurrentUser.EntityID + " | " + Utility.CurrentUser.EntityAlias + " ' " ;
    
return  htInfo;

   }
   
else
   {
   
    
string  ids  =   string .Empty;
    
if (flag == 4 ) // 全部
    {
     htInfo 
=   new   string [dtInfo.Rows.Count];
     
for ( int  i = 0 ;i < dtInfo.Rows.Count;i ++ )
     {
      
      
string  loginName  =  dtInfo.Rows[i][ " LoginName " ].ToString();
      
string  guid       =  dtInfo.Rows[i][ " EntityID " ].ToString();
      htInfo[i] 
=   " ' " + guid + " | " + loginName + " ' " ;
     }
     
return  htInfo;
    }
    
else   if (flag == 2 || flag == 3 ) // 主或者是团队
    {
     
if (flag == 2 ) // group
     {
      ids
= Utility.CurrentUser.MemberUserIDs.ToString().Replace( " ' " , "" );
     }
     
if (flag == 3 )
     {
      ids
= Utility.CurrentUser.MemberAllUserIDs.ToString().Replace( " ' " , "" );
     }
     
int  index  =   0 ; // 下标索引
      string [] guids  =  ids.Split( " , " .ToCharArray());
     htInfo 
=   new   string [guids.Length];
     
for ( int  i = 0 ;i < guids.Length;i ++ )
     {
      
string  loginName  =   string .Empty;
      DataRow[] drs 
=  dtInfo.Select( " EntityID=' " + guids[i] + " ' " );
      
if (drs.Length == 1 )
      {
       loginName 
=  drs[ 0 ][ " LoginName " ].ToString();
       htInfo[index] 
=   " ' " + guids[i] + " | " + loginName + " ' " ;
       index
++ ;
       
      }
   
     }
     
return  htInfo;

    }
    
else
    {
     
return   null ;
    }


   }
  
  }
  
#endregion

  
///   <summary>
  
///  这是取回事务对象,如果有调用,请维护好提交和回滚
  
///   </summary>
  
///   <returns></returns>
   public   static  System.Data.SqlClient.SqlTransaction GetTransaction()
  {
   System.Data.SqlClient.SqlConnection m_con
= new  System.Data.SqlClient.SqlConnection(Utility.ConnectionString);
   m_con.Open();
   System.Data.SqlClient.SqlTransaction m_transaction
=
    m_con.BeginTransaction();
   
return  m_transaction;
  }

  
///   <summary>
  
///  取回指定记录的ID序列号,如果没有值,则会传过来一个'0000-0000-...'
  
///   </summary>
  
///   <param name="specifyIDName"> 要取回那个字段的ID </param>
  
///   <param name="m_FirstDs"> 第一个记录集 </param>
  
///   <param name="m_SecordDs"> 第二个记录集 </param>
  
///   <returns></returns>
   public   static   string  GetSpecifyRecordIDs( string  specifyIDName,System.Data.DataSet m_FirstDs,System.Data.DataSet m_SecordDs, string  condition)
  {
   
string  m_retu = "" ;
   
foreach (System.Data.DataRow m_dr  in  m_FirstDs.Tables[ 0 ].Select(condition))
   {
    
if (m_retu == "" )
    {
     m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
    }
    
else
    {
     m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
    }
   }
   
if (m_SecordDs != null )
   {
    
foreach (System.Data.DataRow m_dr  in  m_SecordDs.Tables[ 0 ].Select(condition))
    {
     
if (m_retu == "" )
     {
      m_retu
= " ' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
     }
     
else
     {
      m_retu
+= " ,' " + Utility.GetGuid(m_dr[specifyIDName]).ToString() + " ' " ;
     }
    }
   }
   
if (m_retu.Trim() == "" )
   {
    m_retu
= " ' " + Guid.Empty.ToString() + " ' " ;
   }
   
return  m_retu;
  }

  
///   <summary>
  
///  这是根据一个某个条件(一般是主键的条件),取回一行记录,可能为空
  
///   </summary>
  
///   <param name="m_dt"></param>
  
///   <param name="condition"></param>
  
///   <returns> 如果条件不合,则取回来的是空值 </returns>
   public   static  System.Data.DataRow GetDataRowFromTableByCondition(System.Data.DataSet m_ds, string  condition)
  {
   System.Data.DataRow[] m_arr
= m_ds.Tables[ 0 ].Select(condition);
   
if (m_arr.Length == 0 )
    
return   null ;
   
else
    
return  m_arr[ 0 ];
  }
  
///   <summary>
  
///  取得当前页面的名称
  
///   </summary>
  
///   <returns></returns>
   public   static   string  GetCurrentPageName()
  {
   
  
   
string  pageName  =  System.Web.HttpContext.Current.Request.FilePath;
   
if (pageName.IndexOf( " / " ) < 0 )
   {
    
return  pageName;
   }
   
else
   {
    pageName 
=  pageName.Substring(pageName.LastIndexOf( " / " ) + 1 );
    pageName 
=  pageName.Substring( 0 ,pageName.LastIndexOf( " . " ));
    
return  pageName;
    
   }
   
  }
  
public   static   string  GetCurrencySymbol( int  currencyCode)
  {
   
if (currencyCode == 1 )
   {
    
return   " " ;
   }
   
if (currencyCode == 2 )
   {
    
return   " US$ " ;
   }
   
return   "" ;
  }
  
public   static   void  BillEncode(System.Data.DataSet ds)
  {
   BillEncode(ds,
false );
  }

  
///   <summary>
  
///  单据编码据总项传入,进行编码
  
///   </summary>
  
///   <param name="ds"></param>
  
///   <param name="UpdateToCode"> 为true表示在编辑状态下也要重新生成他的编码 </param>
  
///   <returns></returns>
   public   static   void  BillEncode(System.Data.DataSet ds, bool  UpdateToCode)
  {
   
// 如果传来的数据集不含有ObjectTypeCode字段的话,就说明他不是编码的数据
    if ( ! ds.Tables[ 0 ].Columns.Contains( " ObjectTypeCode " ))
   {
    
return ;
   }

   
foreach (System.Data.DataRow m_dr  in  ds.Tables[ 0 ].Rows)
   {
    
if (m_dr.RowState == System.Data.DataRowState.Deleted)
     
continue ;
    
string  m_OrderNumber = string .Empty;
    
// 如果ObjectTypeCode不存在的话,就不是编码的数据
     if (m_dr[ " ObjectTypeCode " ] == System.DBNull.Value)
    {
     
continue ;
    }
    m_OrderNumber
= " X " ; // 第一位等下面用switch来做

    
switch ((EBiz.DBM.Common.Types.ObjectTypeEnum)m_dr[ " ObjectTypeCode " ])
    {
     
case  EBiz.DBM.Common.Types.ObjectTypeEnum.CustomerPayment:
     
case  EBiz.DBM.Common.Types.ObjectTypeEnum.PaymentToSupplier:
     {
      EBiz.DBM.Common.DataSets.AccountDataSet m_account_ds
= new  AccountBR().GetByAccountID(Utility.GetGuid(m_dr[ " AccountID " ]));
      
if (m_account_ds == null   ||  m_account_ds.Tables[ 0 ].Rows.Count == 0 )
      {
       m_OrderNumber
+= " XXX " ;
      }
      
else
      {
       
string  m_t = StringMapCache.RetrieveAbbreviation(( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization, " TaxRateCode " ,Utility.GetInt(m_account_ds.Tables[ 0 ].Rows[ 0 ][ " TaxRateCode " ], 0 ));
       
if (m_t == string .Empty)
       {
        m_t
= " X " ;
       }
       m_OrderNumber
+= m_t;

       m_t
= StringMapCache.RetrieveAbbreviation(( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization, " PaymentTermCode " ,Utility.GetInt(m_account_ds.Tables[ 0 ].Rows[ 0 ][ " PaymentTermsCode " ], 0 ));
       
if (m_t == string .Empty)
       {
        m_t
= " X " ;
       }
       m_OrderNumber
+= m_t;
       m_OrderNumber
+= " X " ;

      }
      
break ;
     }
     
default :
     {
      
// 第二位编码--税率
       if (m_dr.Table.Columns.Contains( " TaxRateCode " ))
      {
       
if (m_dr[ " TaxRateCode " ] == System.DBNull.Value)
       {
        m_OrderNumber
+= " X " ;
       }
       
else
       {
        
string  m_t = StringMapCache.RetrieveAbbreviation(( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization, " TaxRateCode " ,( int )m_dr[ " TaxRateCode " ]);
        
if (m_t == string .Empty)
        {
         m_t
= " X " ;
        }
        m_OrderNumber
+= m_t;
       }
      }
      
else
      {
       m_OrderNumber
+= " X " ;
      }
      
// 第三位编码
       if (m_dr.Table.Columns.Contains( " PaymentTermCode " ))
      {
       
if (m_dr[ " PaymentTermCode " ] == System.DBNull.Value)
       {
        m_OrderNumber
+= " X " ;
       }
       
else
       {
        
string  m_t = StringMapCache.RetrieveAbbreviation(( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization, " PaymentTermCode " ,( int )m_dr[ " PaymentTermCode " ]);
        
if (m_t == string .Empty)
        {
         m_t
= " X " ;
        }
        m_OrderNumber
+= m_t;
       }
      }
      
else
      {
       m_OrderNumber
+= " X " ;
      }
      
// 第四位编码
       if (m_dr.Table.Columns.Contains( " FreightPaymentTermCode " ))
      {
       
if (m_dr[ " FreightPaymentTermCode " ] == System.DBNull.Value)
       {
        m_OrderNumber
+= " X " ;
       }
       
else
       {
        
string  m_t = StringMapCache.RetrieveAbbreviation(( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization, " FreightPaymentTermCode " ,( int )m_dr[ " FreightPaymentTermCode " ]);
        
if (m_t == string .Empty)
        {
         m_t
= " X " ;
        }
        m_OrderNumber
+= m_t;
       }
      }
      
else
      {
       m_OrderNumber
+= " X " ;
      }
      
break ;
     }
    }
     
    m_OrderNumber
+= " - " ;

    
if (m_dr.RowState == System.Data.DataRowState.Added  ||  UpdateToCode)
    {
     
// 拥有者
     Guid m_OwningUser = Guid.Empty;
     
string  m_OwningName = string .Empty;
     
if (m_dr.Table.Columns.Contains( " OwningUser " ))
     {
      
if (m_dr[ " OwningUser " ] != System.DBNull.Value)
      {
       m_OwningUser
= (Guid)m_dr[ " OwningUser " ];
      }
     }
     
else   if (m_dr.Table.Columns.Contains( " CreatedBy " ))
     {
      
if (m_dr[ " CreatedBy " ] != System.DBNull.Value)
      {
       m_OwningUser
= (Guid)m_dr[ " CreatedBy " ];
      }
     }
     
// 取Name
      if (m_OwningUser == Utility.CurrentUser.EntityID)
     {
      m_OwningName
= Utility.CurrentUser.EntityAlias;
     }
     
else
     {
      
try
      {
       Entity m_u_ds
= new  EBiz.Security.API.Connection().GetEntityByID(m_OwningUser);
       m_OwningName
= m_u_ds.EntityAlias;
      }
      
catch
      {
       m_OwningName
= string .Empty;
      }
     }
     m_OrderNumber
+= m_OwningName;
     
// 年代编码 
     System.DateTime m_Day = System.DateTime.Today;
     
if (m_dr.Table.Columns.Contains( " CreatedOn " ))
     {
      
if (m_dr[ " CreatedOn " ] != System.DBNull.Value)
      {
       m_Day
= (System.DateTime)m_dr[ " CreatedOn " ];
      }
     }
     
char  m_YearCode = ' A ' ;
     
try
     {
      m_YearCode
= Convert.ToChar(Convert.ToInt64( ' A ' ) + (m_Day.Year - 2000 ));
     }
     
catch
     {
      m_YearCode
= Convert.ToChar(Convert.ToInt64( ' A ' ) + (System.DateTime.Today.Year - 2000 ));
     }
     m_OrderNumber
+= m_YearCode; //
     m_OrderNumber += m_Day.Month.ToString( " 00 " ); //
     m_OrderNumber += m_Day.Day.ToString( " 00 " ); //

     
switch ((EBiz.DBM.Common.Types.ObjectTypeEnum)m_dr[ " ObjectTypeCode " ])
     {
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.SalesOrder:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " S " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " SalesOrderBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.DeliveryToCustomer:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " L " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " DeliveryToCustomerBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.PurchaseOrder:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " P " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " PurchaseOrderBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.SupplierDelivery:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " J " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " SupplierDeliveryBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.SalesInvoice:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       
if (Utility.GetInt(m_dr[ " BillTypeCode " ], 0 ) == 1 ) // 货单发票
       {
        m_OrderNumber
= " I " + m_OrderNumber;
        m_OrderNumber
+= GetSerialNumberFromTable( " SalesInvoiceBase " ,m_Day,m_OwningUser, " BillTypeCode=1 " );
       }
       
else // 形式发票
       {
        m_OrderNumber
= " F " + m_OrderNumber;
        m_OrderNumber
+= GetSerialNumberFromTable( " SalesInvoiceBase " ,m_Day,m_OwningUser, " BillTypeCode=2 " );
       }
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.PurchaseInvoice:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       
if (Utility.GetInt(m_dr[ " BillTypeCode " ], 0 ) == 1 ) // 货单发票
       {
        m_OrderNumber
= " K " + m_OrderNumber;
        m_OrderNumber
+= GetSerialNumberFromTable( " PurchaseInvoiceBase " ,m_Day,m_OwningUser, " BillTypeCode=1 " );
       }
       
else // 形式发票
       {
        m_OrderNumber
= " G " + m_OrderNumber;
        m_OrderNumber
+= GetSerialNumberFromTable( " PurchaseInvoiceBase " ,m_Day,m_OwningUser, " BillTypeCode=2 " );
       }
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.RMAFromCustomer:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " M " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " RMAFromCustomerBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.RMAToSupplier:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " N " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " RMAToSupplierBase " ,m_Day,m_OwningUser, "" );
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.CustomerPayment:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " P " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " PaymentBase " ,m_Day,m_OwningUser, " ObjectTypeCode= " + (( int )EBiz.DBM.Common.Types.ObjectTypeEnum.CustomerPayment).ToString());
       
break ;
      }
      
case  EBiz.DBM.Common.Types.ObjectTypeEnum.PaymentToSupplier:
      {
       m_OrderNumber
= m_OrderNumber.Substring( 1 );
       m_OrderNumber
= " T " + m_OrderNumber;
       m_OrderNumber
+= GetSerialNumberFromTable( " PaymentBase " ,m_Day,m_OwningUser, " ObjectTypeCode= " + (( int )EBiz.DBM.Common.Types.ObjectTypeEnum.PaymentToSupplier).ToString());
       
break ;
      }

     }
    }
    
else
    {
     m_dr[
" OrderNumber " ] = m_dr[ " OrderNumber " ].ToString().Substring( 0 , 1 ) + m_OrderNumber.Substring( 1 , 4 ) + m_dr[ " OrderNumber " ].ToString().Substring( 5 );
    }

    
if (m_OrderNumber.Length > 12 )
    {
     m_dr[
" OrderNumber " ] = m_OrderNumber;
    }
   }
  }

  
///   <summary>
  
///  取回当天,当人的当前单的序号
  
///   </summary>
  
///   <param name="TableName"></param>
  
///   <param name="m_Day"></param>
  
///   <param name="m_OwningUser"></param>
  
///   <param name="OtherCondition"></param>
  
///   <returns></returns>
   private   static   string  GetSerialNumberFromTable( string  TableName,System.DateTime m_Day,Guid m_OwningUser, string  OtherCondition)
  {
   
string  m_return = string .Empty;
   System.Data.DataSet m_tem_ds
= null ;
   
try
   {
    
string  m_sql = " Select Max(cast(SUBSTRING(coalesce(OrderNumber,''),coalesce(Len(OrderNumber),0)-2,3) as int)) From  " + TableName + "  WHERE CreatedOn>=' " + m_Day.ToString( " MM/dd/yyyy 00:00:00 " ) + " ' AND CreatedOn<=' " + m_Day.ToString( " MM/dd/yyyy 23:59:59 " ) + " ' AND OwningUser=' " + m_OwningUser.ToString() + " ' " ;
    
if (OtherCondition != null   &&  OtherCondition != string .Empty)
    {
     m_sql
+= "  AND  " + OtherCondition;
    }
    m_tem_ds
= new  ConnectionBR().ProcessQuery(m_sql);
   }
   
catch {}
   
if (m_tem_ds == null )
   {
    m_return
= " 000 " ;
   }
   
else
   {
    
if (m_tem_ds.Tables[ 0 ].Rows.Count == 0   ||  m_tem_ds.Tables[ 0 ].Rows[ 0 ][ 0 ] == System.DBNull.Value)
    {
     m_return
= " 001 " ;
    }
    
else
    {
     
int  inttem = ( int )m_tem_ds.Tables[ 0 ].Rows[ 0 ][ 0 ] + 1 ;
     
string  str_tem = " 000 " + inttem.ToString();
     str_tem
= str_tem.Substring(str_tem.Length - 3 , 3 );

     m_return
= str_tem;
    }
   }
   
return  m_return;
  }

  
///   <summary>
  
///  根据权限深度取IDS
  
///   </summary>
  
///   <param name="deep"></param>
  
///   <returns></returns>
   public   static   string  GetIDsByDeep(PrivilegeDepth deep)
  {
   UserToken token
= (UserToken)System.Web.HttpContext.Current.Session[ " UserToken " ];
   
string  ids  =  UserPermissions.EMPTY_ID;
   
if  (deep == PrivilegeDepth.Global)
   {
    ids 
=   string .Empty;
   }
   
else   if (deep == PrivilegeDepth.Deep)
   {
    ids 
=  token.MemberAllUserIDs;
   }
   
else   if (deep == PrivilegeDepth.Local)
   {
    ids 
=  token.MemberUserIDs;
   }
   
else   if (deep == PrivilegeDepth.Basic)
   {
    ids 
=   " ' "   +  token.EntityID.ToString()  +   " ',' "   +  Guid.Empty.ToString()  +   " ' " ;
   }
   
else
   {
    ids 
=  UserPermissions.EMPTY_ID;
   }

   
return  ids;
  }

  
///   <summary>
  
///  得到型号的显示格式
  
///   </summary>
  
///   <param name="partNumber"></param>
  
///   <param name="key"></param>
  
///   <returns></returns>
   public   static   string  GetPartFormat( string  partNumber,  string  key)
  {
   
if (key  ==   null   ||  key  ==   string .Empty)
   {
    
return   string .Empty;
   }
   
   
string  prefix  =   string .Empty;
   
string  partBase  =   string .Empty;
   
string  partitionSupport  =   " -1 " ;

   ParsePartNumber(key, 
ref  prefix,  ref  partBase,  ref  partitionSupport);

   
string  patternExact  =   string .Empty;
   
string  patternBase  =   string .Empty;

   
foreach ( char  c  in  key)
   {
    
if  (c == ' + ' continue
    
    patternExact 
+=   @" W* "   +  c;
   }

   
if (partBase  !=   string .Empty)
   {
    
foreach ( char  c  in  partBase)
    {
     patternBase 
+=   @" W* "   +  c;
    }
   }

   Regex regexExact 
=   new  Regex(patternExact, RegexOptions.IgnoreCase);
   
   Match match 
=  regexExact.Match(partNumber);
   
if (match.Success)
   {
    
return  partNumber.Substring( 0 ,match.Index)  +   " <b><font color='red'> "   +  match.Value  +   " </font></b> "   +  partNumber.Substring(match.Index  +  match.Value.Length);
   }
   
else   if (partBase  !=   string .Empty)
   {
    Regex regexBase 
=   new  Regex(patternBase, RegexOptions.IgnoreCase);

    Match m 
=  regexBase.Match(partNumber);
    
if (m.Success)
    {
     
return  partNumber.Substring( 0 ,m.Index)  +   " <b><font color='red'> "   +  m.Value  +   " </font></b> "   +  partNumber.Substring(m.Index  +  m.Value.Length);
    }
    
else
    {
     
return  partNumber;
    }
   }
   
else
   {
    
return  partNumber;
   }
  }

  
public   static   string  GetAddressConditionByWarehouse( string  warehouseID)
  {
   System.Text.StringBuilder filterExpression
= new  StringBuilder();
   
string  addressID = Guid.Empty.ToString();
   
string  address2ID = Guid.Empty.ToString();
   
string  address3ID = Guid.Empty.ToString();
   
string  address4ID = Guid.Empty.ToString();
   
string  address5ID = Guid.Empty.ToString();
   
string  address6ID = Guid.Empty.ToString();

   System.Data.DataSet m_ds
= new  EBiz.DBM.API.WarehouseBR().GetByWhere( "" , " WarehouseID=' " + warehouseID.Trim() + " ' " , "" );
   
if (m_ds.Tables[ 0 ].Rows.Count > 0 )
   {
    addressID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " AddressID " ]).ToString();
    address2ID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " Address2ID " ]).ToString();
    address3ID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " Address3ID " ]).ToString();
    address4ID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " Address4ID " ]).ToString();
    address5ID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " Address5ID " ]).ToString();
    address6ID
= Utility.GetGuid(m_ds.Tables[ 0 ].Rows[ 0 ][ " Address6ID " ]).ToString();
   }
   m_ds
= new  EBiz.DBM.API.WarehouseBR().GetAll();
   
string  m_con = string .Empty;
   
foreach (System.Data.DataRow m_dr  in  m_ds.Tables[ 0 ].Rows)
   {
    
if (Utility.GetGuid(m_dr[ " AddressID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " AddressID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " AddressID " ].ToString() + " ' "
     }
    }
    
if (Utility.GetGuid(m_dr[ " Address2ID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " Address2ID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " Address2ID " ].ToString() + " ' "
     }
    }
    
if (Utility.GetGuid(m_dr[ " Address3ID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " Address3ID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " Address3ID " ].ToString() + " ' "
     }
    }
    
if (Utility.GetGuid(m_dr[ " Address4ID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " Address4ID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " Address4ID " ].ToString() + " ' "
     }
    }
    
if (Utility.GetGuid(m_dr[ " Address5ID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " Address5ID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " Address5ID " ].ToString() + " ' "
     }
    }
    
if (Utility.GetGuid(m_dr[ " Address6ID " ]) != Guid.Empty)
    {
     
if (m_con == string .Empty)
     {
      m_con
= " ' " + m_dr[ " Address6ID " ].ToString() + " ' " ;
     }
     
else
     {
      m_con
+= " ,' " + m_dr[ " Address6ID " ].ToString() + " ' "
     }
    }
   }
   
if (m_con != string .Empty)
   {
    m_con
= " AccountAddressID NOT IN ( " + m_con + " ) " ;
   }
   m_ds
= new  EBiz.DBM.API.AccountAddressBR().GetByWhere( "" , " ParentID=' " + EBiz.DBM.API.OrganizationCache.RetrieveOrganization().ID.ToString()  + " ' AND ParentObjectTypeCode= " + (( int )EBiz.DBM.Common.Types.ObjectTypeEnum.Organization).ToString() + (m_con == string .Empty ? "" :( "  AND  " + m_con)), "" );

   
string  tem = "" ;
   
if (addressID != string .Empty)
   {
    tem
= " AddressID=' " + addressID.ToString() + " ' " ;
   }
   
if (address2ID != string .Empty)
   {
    
if (tem != string .Empty)
     tem
+= "  OR  " ;
    tem
+= " AddressID=' " + address2ID.ToString() + " ' " ;
   }
   
if (address3ID != string .Empty)
   {
    
if (tem != string .Empty)
     tem
+= "  OR  " ;
    tem
+= " AddressID=' " + address3ID.ToString() + " ' " ;
   }
   
if (address4ID != string .Empty)
   {
    
if (tem != string .Empty)
     tem
+= "  OR  " ;
    tem
+= " AddressID=' " + address4ID.ToString() + " ' " ;
   }
   
if (address5ID != string .Empty)
   {
    
if (tem != string .Empty)
     tem
+= "  OR  " ;
    tem
+= " AddressID=' " + address5ID.ToString() + " ' " ;
   }
   
if (address6ID != string .Empty)
   {
    
if (tem != string .Empty)
     tem
+= "  OR  " ;
    tem
+= " AddressID=' " + address6ID.ToString() + " ' " ;
   }

   filterExpression.Append(
" ( " );
   
if (tem != string .Empty)
   {
    filterExpression.Append(tem);
   }
   filterExpression.Append(
"  or WarehouseID=' " + Utility.GetGuid(warehouseID).ToString() + " ' " );
   
foreach (System.Data.DataRow m_dr  in  m_ds.Tables[ 0 ].Rows)
   {
    filterExpression.Append(
"  OR AddressID=' " + m_dr[ " AccountAddressID " ].ToString() + " " );
   }
   filterExpression.Append(
" ) " );
   
return  filterExpression.ToString();
  }
  
///   <summary>
  
///  得到清单费用计算比率值(运费, 关税等)
  
///   </summary>
  
///   <returns></returns>
   public   static   decimal  GetChargeRateValue()
  {
   
return   1.04M ;
  }
 
  
///   <summary>
  
///  涉及到库存销售的比值。
  
///   </summary>
  
///   <param name="soTaxCode"></param>
  
///   <param name="ioTaxCode"></param>
  
///   <returns></returns>
   public   static   decimal  GetStockFeeRateValue( int  soTaxCode, int  ioTaxCode)
  {
   
if (ioTaxCode == int .MinValue) //
   {
    
return   1.06135M ;
   }
   
else
   {
        
return  GetContactFeeRateValue(soTaxCode,ioTaxCode);
   }
  }
  
///   <summary>
  
///  取出关系到销售税率与采购税率的计算值
  
///   </summary>
  
///   <param name="soTaxCode"></param>
  
///   <param name="poTaxCode"></param>
  
///   <returns></returns>
   public   static   decimal  GetContactFeeRateValue( int  soTaxCode, int  poTaxCode)
  {
   
if (poTaxCode == int .MinValue) // 无税率,按海外采购计算
   {
    
return   1.06135M ;
   }
   
else
   {
    
if (poTaxCode == OVERSEA_TAX_CODE || poTaxCode == OTHER_TAX_CODE) // 海外采购
    {
     
// 取出存在于中文中的计算值
      decimal  computeValue  =  StringMapCache.RetrieveIntervalValue(( int )ObjectTypeEnum.Organization, " TaxRateCode " ,soTaxCode, " zh-CN " );
     
if (computeValue != 0 )
     {
      
return  computeValue;
     }
     
else
     {
      
return   1 ;
     }

    }
    
else
    {
     
return   1 ;
    }
   }
 }
    
///   <summary>
    
///  得到拥有者表达式
    
///   </summary>
    
///   <param name="listByAccount"></param>
    
///   <param name="list"></param>
    
///   <returns></returns>
   public   static   string  GetOwnerListExpression( string  listByAccount, string  list)
    {
     
     
if (System.Web.HttpContext.Current.Request.QueryString[ " id " ] != null )
     {
      
return   Utility.GetOwningUserFilterExpression(listByAccount, " AccountOwningUser " ); 
     }
     
else
     {
      
return  Utility.GetOwningUserFilterExpression(list);
     }
    } 
  
///   <summary>
  
///  得到拥有者表达式
  
///   </summary>
  
///   <param name="listByAccount"></param>
  
///   <param name="list"></param>
  
///   <returns></returns>
   public   static   string  GetOwnerListExpression( string  listByAccount, string  list, string  ownerFlag)
  {
     
   
if (System.Web.HttpContext.Current.Request.QueryString[ " id " ] != null )
   {
    
return   Utility.GetOwningUserFilterExpression(listByAccount, " AccountOwningUser " ); 
   }
   
else
   {
    
return  Utility.GetOwningUserFilterExpression(list,ownerFlag);
   }
  } 
 
  
///   <summary>
  
///  判断两个税率是否相同
  
///   </summary>
  
///   <param name="taxCode1"></param>
  
///   <param name="taxCode2"></param>
  
///   <returns></returns>
   public   static   bool  JudgeTaxCodeSame( int  taxCode1, int  taxCode2)
  {
   
if (taxCode1 == taxCode2)
   {
    
return   true ;
   }
   
else
   {
    
if (taxCode1 == 9 || taxCode1 == 10 ) // 海外与其他,不可能相同
    {
     
return   false ;
    }
    
else
    {
     
if (taxCode1 == 1 && taxCode2 == 2 )
     {
       
return   true ;
     }
     
     
if (taxCode1 == 2 && taxCode2 == 1 )
     {
      
return   true ;
     }
     
if (taxCode1 == 3 && taxCode2 == 4 )
     {
      
return   true ;
     }
     
if (taxCode1 == 4 && taxCode2 == 3 )
     {
      
return   true ;
     }
     
if (taxCode1 == 5 && taxCode2 == 6 )
     {
      
return   true ;
     }
     
if (taxCode1 == 6 && taxCode2 == 5 )
     {
      
return   true ;
     }
     
if (taxCode1 == 7 && taxCode2 == 8 )
     {
      
return   true ;
     }
     
if (taxCode1 == 8 && taxCode2 == 8 )
     {
      
return   true ;
     }
                    
return   false ;

    }
   }
  }
  
///   <summary>
  
///  将简体中文转换繁体中文
  
///   </summary>
  
///   <param name="str"></param>
  
///   <returns></returns>
   public   static   string  ConvertNumerous( string  str)
  {
   System.Text.StringBuilder sb 
=   new  System.Text.StringBuilder();
   
for ( int  i = 0 ;i < str.Length;i ++ )
   {
    
if (simpleString.IndexOf(str[i]) !=- 1 )
    {
     sb.Append(numerousString[simpleString.IndexOf(str[i])]);
    }
    
else
    {
     sb.Append(str[i]);
    }
   }
   
return  sb.ToString();
  }
 }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值