/// 根据提示信息、出错返回方式及返回地址生成Javascript代码 ///
///
///
/// ///
public static string MakeJavaScript(string _Msg, string _Type,string _GotoUrl) {
string strReturn = \;
strReturn = \lanaguage='javascript' type='text/javascript'>alert('\ + _Msg + \;
switch (_Type) {
case \://location.href=_GotoUrl if (_Msg.IndexOf(\登录超时\) >= 0) {
strReturn = strReturn + \ + _GotoUrl + \; } else {
strReturn = strReturn + \ + _GotoUrl + \; } break;
case \://location.href=document.referrer
strReturn = strReturn + \; break;
case \://history.go(-1)
strReturn = strReturn + \; break; case \://关闭
strReturn = strReturn + \; break; }
strReturn = strReturn + \; return strReturn; }
#endregion
#region 判断传入的对象是否为空 ///
/// 判断传入的对象是否为空 ///
///
public static bool IsEmpty(object _str) {
if (_str == null || _str.ToString().Equals(\) || _str.ToString().Length == 0) {
return true; } else {
return false; } }
#endregion
#region 根据传入的对象判断是否已经登录 ///
/// 根据传入的对象判断是否已经登录 ///
///
public static bool IsLogin(object _DananNum) {
string DananNum = \; bool Login = false; try {
DananNum = _DananNum.ToString(); if (IsEmpty(DananNum)) {
Login = false; } else {
Login = true; } } catch {
Login = false; }
return Login; }
#endregion
#region 判断字符是否为汉字 ///
/// 判断字符是否为汉字
///
///
private static bool IsChinese(char c) {
return (int)c >= 0x4E00 && (int)c <= 0x9FA5; }
#endregion
#region 判断字符串是否为汉字 ///
/// 判断字符串是否为汉字 ///
///
public static bool IsChinese(string str) {
bool OReturn = false;
char[] strCharSet = str.ToCharArray(); for (int i = 0; i < strCharSet.Length; i++) {
if (IsChinese(strCharSet[i])) {
OReturn=true; break; } }
return OReturn; }
#endregion
#region 对xml_data目录中的xml文件建立相应的文件夹 ///
/// 对xml_data目录中的xml文件建立相应的文件夹 ///
public static void MakeFolder() {
string folder = Zhigu.Common.StaticVariable.WebRoot + \;
string[] files = System.IO.Directory.GetFileSystemEntries(folder, \); for (int i = 0; i < files.Length; i++) {
int star=files[i].LastIndexOf(\)+1; int last=files[i].LastIndexOf(\);
string filename = files[i].Substring(star, last - star); string foldername = filename.Substring(0, filename.Length - 3); string newfolder = folder + \ + foldername;
if (!System.IO.Directory.Exists(newfolder)) {
System.IO.Directory.CreateDirectory(newfolder); }
string newfilename = newfolder + \ + filename + \; if (File.Exists(newfilename)) {
File.Delete(newfilename); }
System.IO.File.Move(files[i], newfilename); } }
#endregion
#region 判断给定的字符串是否为日期 ///
/// 判断给定的字符串是否为日期 ///
///
public static bool ChkDate(string str) { try {
System.DateTime t1 = System.DateTime.Parse(str); return true;//返回真 } catch {
return false; } }
#endregion
#region 判断给定的字符串是否为数值型 ///
/// 判断给定的字符串是否为数值型 ///
///
public static bool IsNumber(string strNumber) {
Regex objNotNumberPattern = new Regex(\);
Regex objTwoDotPattern = new Regex(\); Regex objTwoMinusPattern = new Regex(\); String strValidRealPattern = \;
String strValidIntegerPattern = \;
Regex objNumberPattern = new Regex(\ + strValidRealPattern + \ + strValidIntegerPattern + \);
return !objNotNumberPattern.IsMatch(strNumber)
&& !objTwoDotPattern.IsMatch(strNumber) && !objTwoMinusPattern.IsMatch(strNumber) && objNumberPattern.IsMatch(strNumber); }
#endregion }
}
(4)、通用变量类(StaticVariable.cs):
using System; using System.Data;
using System.Configuration; using System.Web;
using System.Web.Security; using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
namespace Zhigu.Common {
///
public class StaticVariable {
public StaticVariable() { }
#region 获取系统标题 ///
public static string WebTitle { get {
return \长沙市某某医院\; } }
#endregion
#region 获取子系统标题