网站积累

数据库连接:
<appSettings/>
<connectionStrings>
    <add name="conn" connectionString="Data Source=FUCK-PC\SQLEXPRESS;Initial Catalog=jxcSystem;Integrated Security=True"/>
  </connectionStrings>
 <system.web>
    <!--出错时跳转页-->
    <customErrors mode="On" defaultRedirect="~/错误页.htm"></customErrors>

构造函数连接数据库:

 public SqlHelper()           {             string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;             conns = new SqlConnection(conn);            }       

打开数据库连接:        

private SqlConnection Getconn()         {             if (conns.State == ConnectionState.Closed)             {                 conns.Open();               }             return conns;         }

执行带参数的增删改:

public int ExecuteNonQuery(string cmdText, SqlParameter[] paras, CommandType ct)         {             int res;             using (cmd = new SqlCommand(cmdText, Getconn()))             {                 cmd.CommandType = ct;                 cmd.Parameters.AddRange(paras);                 res = cmd.ExecuteNonQuery();             }             return res;         }

执行带参数的查询:

public DataTable Execuquery(string cmdText, SqlParameter[] paras, CommandType ct)         {             DataTable dt = new DataTable();             using (cmd = new SqlCommand(cmdText, Getconn()))             {                 cmd.CommandType = ct;                 cmd.Parameters.AddRange(paras);                 sdr = cmd.ExecuteReader();                 dt.Load(sdr);                 sdr.Close();                 return dt;             }         }

错误页js出错后返回:

   <script type="text/javascript">     var i=5;     var intervalId;     intervalId=setInterval("fun()",1000);     function fun()     {     if(i==0){     window.location.href="首页.aspx";     clearInterval(intervalId);     }     document.getElementById("mes").innerHTML=i;     i--;     }     </script>

获得当前系统时间:

<script type="text/javascript">     function fun(){     var date=new Date();     var hh=date.getHours();     var mm=date.getMinutes();     var ss=date.getSeconds();     document.getElementById("lbl1").value="当前时间:"+hh+":"+mm+":"+ss;     setTimeout("fun()",1000);     }     </script>

链接css文件:     <link href="css/firstPage.css" rel="stylesheet" type="text/css" />

posted on 2013-03-19 11:58  平小  阅读(126)  评论(0编辑  收藏  举报