温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:缤纷企业管理系统源码
当前文件:
BinFenEnterpriseWeb/App_Code/CommFun.cs[2K,2009-6-12 11:33:52],打开代码结构图
BinFenEnterpriseWeb/App_Code/CommFun.cs[2K,2009-6-12 11:33:52],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
namespace Web 12
{ 13
/// <summary> 14
/// CommFun 的摘要说明 15
/// </summary> 16
public class CommFun 17
{ 18
public CommFun() 19
{ 20
// 21
// TODO: 在此处添加构造函数逻辑 22
// 23
} 24
public string CutChar(string strChar, int intLength) 25
{ 26
//取得自定义长度的字符串 27
if (strChar.Length > intLength) 28
{ return strChar.Substring(0, intLength); } 29
else 30
{ return strChar; } 31
32
} 33
public static string GetLimitChar(string txt, int lenght) 34
{ 35
//取得自定义长度的字符串 中文123456789 36
string outputtext = ""; 37
if (txt.Length > lenght) 38
{ 39
//int tempnum = 0; 40
int tempnum1 = 0; 41
int tempnum2 = 0; 42
byte[] byitem =System.Text.ASCIIEncoding.ASCII.GetBytes(txt); 43
for (int i = 0; i < txt.Length; i++) 44
{ 45
46
if ((int)byitem[i] != 63) tempnum1++; else tempnum2++; 47
48
if (tempnum2*2 + tempnum1 >= lenght*2) break; 49
50
} 51
outputtext = txt.Substring(0, tempnum2 + tempnum1); 52
53
54
} 55
else 56
{ 57
outputtext = txt; 58
} 59
return outputtext; 60
} 61
public static void IsAdmin() 62
{ 63
//查看是否为超级管理员 64
if (HttpContext.Current.Session["Admin"] != "yes") 65
{ 66
HttpContext.Current.Response.Write(@"<script>alert('你还没有登录或登录超时!');window.location.href='login.aspx';</script>"); 67
68
69
70
} 71
72
} 73
74
} 75
}






}