温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日企业下载管理系统源码
当前文件:
MingriEnterprise/App_Code/CAN.cs,打开代码结构图
MingriEnterprise/App_Code/CAN.cs,打开代码结构图1using 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
//该源码下载自www.51aspx.com(51aspx.com) 12
13
/// <summary> 14
/// CAN 的摘要说明 15
/// </summary> 16
public class CAN 17
{ 18
//int PageSize, RecordCount, PageCount, CurrentPage; 19
public CAN() 20
{ 21
// 22
// TODO: 在此处添加构造函数逻辑 23
// 24
} 25
public SqlConnection SqlCon() 26
{ 27
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 28
return mycon; 29
} 30
public bool ExecSqlCom(string SqlStr) 31
{ 32
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 33
mycon.Open(); 34
SqlCommand mycom = new SqlCommand(SqlStr, mycon); 35
try 36
{ 37
mycom.ExecuteNonQuery(); 38
return true; 39
} 40
catch 41
{ 42
return false; 43
} 44
finally 45
{ 46
mycon.Close(); 47
} 48
} 49
public bool ExecAdapterBind(GridView GridViewN, string SqlStr) 50
{ 51
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 52
mycon.Open(); 53
SqlDataAdapter myada = new SqlDataAdapter(SqlStr, mycon); 54
DataSet myds = new DataSet(); 55
myada.Fill(myds); 56
GridViewN.DataSource = myds; 57
try 58
{ 59
GridViewN.DataBind(); 60
return true; 61
} 62
catch 63
{ 64
return false; 65
} 66
finally 67
{ 68
mycon.Close(); 69
} 70
} 71
public bool ExecAdapterBind2(DataList DataListN, string SqlStr) 72
{ 73
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 74
mycon.Open(); 75
SqlDataAdapter myada = new SqlDataAdapter(SqlStr, mycon); 76
DataSet myds = new DataSet(); 77
myada.Fill(myds); 78
DataListN.DataSource = myds; 79
try 80
{ 81
DataListN.DataBind(); 82
return true; 83
} 84
catch 85
{ 86
return false; 87
} 88
finally 89
{ 90
mycon.Close(); 91
} 92
} 93
public bool DataListDataKeyField(DataList DataListN, string SqlStr, string DKF) 94
{ 95
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 96
mycon.Open(); 97
SqlDataAdapter myada = new SqlDataAdapter(SqlStr, mycon); 98
DataSet myds = new DataSet(); 99
myada.Fill(myds); 100
DataListN.DataSource = myds; 101
DataListN.DataKeyField=DKF; 102
try 103
{ 104
DataListN.DataBind(); 105
return true; 106
} 107
catch 108
{ 109
return false; 110
} 111
finally 112
{ 113
mycon.Close(); 114
} 115
} 116
117
public string SubStr(string sString,int nLeng) 118
{ 119
if(sString.Length<=nLeng) 120
{ 121
return sString; 122
} 123
int nStrLeng=nLeng-1; 124
string sNewStr=sString.Substring(0,nStrLeng); 125
sNewStr=sNewStr+"..."; 126
return sNewStr; 127
} 128
129
public bool ExecAdapterBindInfoString(GridView GridViewN, string SqlStr, string DNK) 130
{ 131
SqlConnection mycon = new SqlConnection("Data Source=(local);User ID=sa;PWD=sa;DataBase=db_ComPany"); 132
mycon.Open(); 133
SqlDataAdapter myada = new SqlDataAdapter(SqlStr, mycon); 134
DataSet myds = new DataSet(); 135
myada.Fill(myds); 136
GridViewN.DataSource = myds; 137
GridViewN.DataKeyNames = new string[] { DNK }; 138
try 139
{ 140
GridViewN.DataBind(); 141
return true; 142
} 143
catch 144
{ 145
return false; 146
} 147
finally 148
{ 149
mycon.Close(); 150
} 151
} 152
public DataSet GetDataSet(string SqlStr,string tbName) 153
{ 154
SqlConnection mycon = new SqlConnection("server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"); 155
mycon.Open(); 156
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, mycon); 157
DataSet myds = new DataSet(); 158
ada.Fill(myds, tbName); 159
return myds; 160
} 161
//public bool N(int PageSize,string SqlStr,) 162
//{ 163
// //设定PageSize 164
// PageSize = 2; 165
166
// //连接语句 167
// SqlConnection mycon = new SqlConnection("server=(local);user id=sa;PWD=sa;database=db_ComPany"); 168
// mycon.Open(); 169
170
// //第一次请求执行 171
// if (!Page.IsPostBack) 172
// { 173
// ListBind(); 174
// CurrentPage = 0; 175
// ViewState["PageIndex"] = 0; 176
177
// //计算总共有多少记录 178
// RecordCount = CalculateRecord(); 179
// //this.Label2.Text = RecordCount.ToString(); 180
181
// //计算总共有多少页 182
// PageCount = RecordCount / PageSize; 183
// //this.Label6.Text = PageCount.ToString(); 184
// ViewState["PageCount"] = PageCount; 185
// } 186
//} 187
//public bool M() 188
//{ 189
190
//} 191
} 192








