1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Web;
5
using System.Web.Security;
6
using System.Web.UI;
7
using System.Web.UI.WebControls;
8
using System.Web.UI.WebControls.WebParts;
9
using System.Web.UI.HtmlControls;
10
using System.Data.SqlClient;
11
using System.Threading;
12
/// <summary>
13
/// BaseClass 的摘要说明
14
/// </summary>
15
16
public class BaseClass
17
{
18
public BaseClass()
19
{
20
//
21
// TODO: 在此处添加构造函数逻辑
22
//
23
}
24
/// <summary>
25
/// 说明:MessageBox用来在客户端弹出对话框。
26
/// 参数:TxtMessage 对话框中显示的内容。
27
/// 创建日期:2007-11-20
28
/// 创建人:冒得味口
29
/// </summary>
30
public string MessageBox(string TxtMessage)
31
{
32
string str;
33
str = "<script language=javascript>alert('" + TxtMessage + "')</script>";
34
return str;
35
}
36
/// <summary>
37
/// 说明:ExecSQL用来执行SQL语句。
38
/// 返回值:操作是否成功(True\False)。
39
/// 参数:sQueryString SQL字符串
40
/// 创建日期:2007-11-22
41
/// 创建人:冒得味口
42
/// </summary>
43
public Boolean ExecSQL(string sQueryString)
44
{
45
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
46
con.Open();
47
SqlCommand dbCommand = new SqlCommand(sQueryString, con);
48
try
49
{
50
dbCommand.ExecuteNonQuery();
51
con.Close();
52
}
53
catch
54
{
55
con.Close();
56
return false;
57
}
58
return true;
59
}
60
/// <summary>
61
/// 说明:GetDataSet数据集,返回数据源的数据集
62
/// 返回值:数据集DataSet
63
/// 参数:sQueryString SQL字符串,TableName 数据表名称
64
/// 创建日期:2007-11-22
65
/// 创建人:冒得味口
66
/// </summary>
67
public System.Data.DataSet GetDataSet(string sQueryString, string TableName)
68
{
69
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
70
con.Open();
71
SqlDataAdapter dbAdapter = new SqlDataAdapter(sQueryString, con);
72
DataSet dataset = new DataSet();
73
dbAdapter.Fill(dataset, TableName);
74
con.Close();
75
return dataset;
76
}
77
/// <summary>
78
/// 说明:SubStr用来将字符串保留到指定长度,将超出部分用“
”代替。
79
/// 返回值:处理后的这符串。
80
/// 参数: sString原字符串。
81
/// nLeng长度。
82
/// 创建日期:2007-12-22
83
/// 创建人:冒得味口
84
/// </summary>
85
public string SubStr(string sString, int nLeng)
86
{
87
if (sString.Length <= nLeng)
88
{
89
return sString;
90
}
91
int nStrLeng = nLeng - 3;
92
string sNewStr = sString.Substring(0, nStrLeng);
93
sNewStr = sNewStr + "
";
94
return sNewStr;
95
}
96
/// <summary>
97
/// 说明:过滤危险字符
98
/// 返回值:处理后的这符串。
99
/// 参数: str原字符串。
100
/// 创建日期:2007-12-22
101
/// 创建人:冒得味口
102
/// </summary>
103
104
public string HtmlEncode(string str)
105
{
106
str = str.Replace("&", "&");
107
str = str.Replace("<", "<");
108
str = str.Replace(">", ">");
109
str = str.Replace("'", "''");
110
str = str.Replace("*", "");
111
str = str.Replace("\n", "<br/>");
112
str = str.Replace("\r\n", "<br/>");
113
//str = str.Replace("?","");
114
str = str.Replace("select", "");
115
str = str.Replace("insert", "");
116
str = str.Replace("update", "");
117
str = str.Replace("delete", "");
118
str = str.Replace("create", "");
119
str = str.Replace("drop", "");
120
str = str.Replace("delcare", "");
121
if (str.Trim().ToString() == "") { str = "无"; }
122
return str.Trim();
123
}
124
/// <summary>
125
/// 防止SQL 注入试攻击
126
///
127
/// </summary>
128
/// <param name="loginName">用户登录名称</param>
129
/// <param name="loginPwd">用户登录密码</param>
130
/// 创建日期:2007-04-05
131
/// 创建人:冒得味口
132
public int checkLogin(string loginName,string loginPwd)
133
{
134
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
135
SqlCommand myCommand = new SqlCommand("select count(*) from tbuser where Name=@loginName and PassWord=@loginPwd", con);
136
myCommand.Parameters.Add(new SqlParameter("@loginName", SqlDbType.NVarChar, 20));
137
myCommand.Parameters["@loginName"].Value = loginName;
138
myCommand.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.NVarChar, 20));
139
myCommand.Parameters["@loginPwd"].Value = loginPwd;
140
myCommand.Connection.Open();
141
int i=(int)myCommand.ExecuteScalar();
142
myCommand.Connection.Close();
143
return i;
144
}
145
146
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78


79

80

81

82

83

84

85

86

87

88

89

90

91

92

93


94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146
