2009年2月20日

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" rev="stylesheet" href="http://misc.web.xunlei.com/www_v4/css/css_20090115.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
<title>迅雷在线</title>
<meta name="Keywords" content="迅雷,迅雷5,迅雷6,WEB迅雷,迅雷看看,在线点播,下载,迅雷下载,博客,论坛,BBS,互动,交流,影视,电影,电视,视频,分享,音乐,娱乐,动漫,漫画,动画,美女,写真,图片,网游,游戏" />
<meta name="description" content="迅雷官方网站,提供迅雷软件下载,还有影视、音乐、动漫、漫画、游戏、软件下载、迅雷博客、社区、会员及和客户服务等。" />
<base target="_blank" />
</head>
<body>
<script type="text/javascript" src="funcs.js"></script>
<script type="text/javascript">

function pauseAutoSwitch() {
 clearTimeout(AutoPicSwitchTabTimer) ;
}
function goonAutoSwitch(ident,index,count,TimeLength) {
 clearTimeout(AutoPicSwitchTabTimer) ;
 AutoPicSwitchTabTimer = setTimeout("autoSwitchTab('"+ident+"',"+index+","+count+","+TimeLength+");", TimeLength);
}
function autoSwitchTab(ident,index,count,TimeLength) {
 if (index == count || index > count) {
  index = 0 ;
 }
 switchTab(ident,index,count) ;
 index = index + 1 ;
 AutoPicSwitchTabTimer = setTimeout("autoSwitchTab('"+ident+"',"+index+","+count+","+TimeLength+");", TimeLength);
}
</script>

<script type="text/javascript">
var MaxScreen = 8 ;
var CurScreen = 1 ;
</script>

 

<!-- Float AD Begin -->
<div id="BigAd" style="position: absolute;width:600px;height:300px;visibility: visible;z-index: 1;display:none;"><div id="floatbig"></div><div style="position: relative;top:-300px;width:52px;height:19px;left:548px;background-color:#ccc;"><a href="javascript://" onclick="hiddenFloatAd();return false;" target="_self"><img src="http://misc.web.xunlei.com/new/img/index_new/flaotad_shutdown.gif"></a></div></div>

<div id='FloatCtrl' style='position: absolute;width:98px;visibility: visible;z-index: 1;background-color:#000;display:none;'><div id=floatsmall></div><div class="float:left;width:98px;"><em style="float:left;font-style:normal;margin-left:3px;font-weight:bold;font-size:14px;"><a href="javascript://" onclick="showFloatAd();return false;" target="_self" style="color:#fff;">重播</a></em><em style="float:right;font-style:normal;margin-right:3px;font-weight:bold;font-size:14px;"><a href="javascript://" onclick="hiddenFloatCtrl();return false;" target="_self" style="color:#fff;">关闭</a></em></div></div>

<script src="http://misc.web.xunlei.com/new/js/ptype.js" type="text/javascript"></script>
<script src="http://misc.web.xunlei.com/new/js/eff.js" type="text/javascript"></script>
<script type="text/javascript">
var imgheight_close ;
document.ns = navigator.appName == "Microsoft Internet Explorer" ;
var bdy = (document.documentElement && document.documentElement.clientWidth)?document.documentElement:document.body;
window.screen.width>800 ? imgheight_close=110:imgheight_close=110 ;
BigAdStartTimer = null ;
BigAdEndTimer = null ;
floatAdMove();
FloatCtrlMove();
window.onload = showFloatAd;
</script>
<script type="text/javascript" src="http://biz5.sandai.net/portal/floatbig.js"></script>
<script type="text/javascript" src="http://biz5.sandai.net/portal/floatsmall.js"></script>
<!-- Float AD End -->
</body>
<script type="text/javascript" src="http://misc.web.xunlei.com/new/js/input-ac4www_0908.js"></script>
<script type="text/javascript">setupAC(document.getElementById("searchbox1"),document.getElementById("btnSearch"));</script>
<!-- stat -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
 var pageTracker = _gat._getTracker("UA-1305769-12");
 pageTracker._initData();
 pageTracker._trackPageview();
}catch(e){}
</script>
<script type="text/javascript" src="http://gamestat.xunlei.com/stat/pv.js"></script>
<script type="text/javascript">
function rand(num){
 return Math.floor(Math.random()*num)+1;
}
document.write("<iframe src=http://tracker.movie.xunlei.com/set_movie_stat.php?t=3&id=11&c=pageview&cache="+rand(9999999)+" width=\"0\" height=\"0\"><\/iframe>");
</script>
<script type="text/javascript">
var stat_pageid = 7;
</script>
<script src="http://misc.web.xunlei.com/movie_v2/js/click_stat_watch_page.js" type="text/javascript"></script>
<!-- stat end -->
</html>

posted @ 2009-02-20 15:00 Mars1986 阅读(254) 评论(0) 编辑

2009年1月5日

我们经常出于某种目的需要使用各种各样的日期格式,当然我们可以使用字符串操作来构造各种日期格式,但是有现成的函数为什么不用呢?

SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm

例如:

select getdate()

2004-09-12 11:06:08.177

整理了一下SQL Server里面可能经常会用到的日期格式转换方法:

举例如下:

select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08

select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608

select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12

select CONVERT(varchar(12) , getdate(), 112 )
20040912

select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12

select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004

select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004

select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004

select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004

select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004

select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004

select CONVERT(varchar(12) , getdate(), 108 )
11:06:08

select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1

select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004

select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1

select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177

帮助文档中的信息

Without century (yy) With century (yyyy)
Standard

Input/Output**
- 0 or 100 (*) Default mon dd yyyy hh:miAM (or PM)
1 101 USA mm/dd/yy
2 102 ANSI yy.mm.dd
3 103 British/French dd/mm/yy
4 104 German dd.mm.yy
5 105 Italian dd-mm-yy
6 106 - dd mon yy
7 107 - Mon dd, yy
8 108 - hh:mm:ss
- 9 or 109 (*) Default + milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)
10 110 USA mm-dd-yy
11 111 JAPAN yy/mm/dd
12 112 ISO yymmdd
- 13 or 113 (*) Europe default + milliseconds dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 or 120 (*) ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
- 21 or 121 (*) ODBC canonical (with milliseconds) yyyy-mm-dd hh:mi:ss.mmm(24h)
- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(no spaces)
- 130* Kuwaiti dd mon yyyy hh:mi:ss:mmmAM
- 131* Kuwaiti dd/mm/yy hh:mi:ss:mmmAM

posted @ 2009-01-05 10:06 Mars1986 阅读(19934) 评论(0) 编辑

2008年11月13日

Default.aspx.cs

 

 

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Net.Mail;
using System.Net;
using System.Text;
using System.Collections.Generic;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

 

public class SQLDAL:IDAL
{
   public IList<Model> GetCategories()
    {
        IList<Model> categories = new List<Model>();
        using (SqlDataReader rdr = DBUtility.ExecuteReader(DBUtility.ConnectStr, CommandType.Text, "select * from Category", null))
        {
            while (rdr.Read())
            {
                Model cat = new Model(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2));
                categories.Add(cat);
            }
        }
        return categories;
    }

    public Model GetCategory(string categoryId)
    {
        Model category = null;
        SqlParameter parm = new SqlParameter("@categoryid", SqlDbType.VarChar, 10);
        parm.Value = categoryId;
        using (SqlDataReader rdr = DBUtility.ExecuteReader(DBUtility.ConnectStr, CommandType.Text, "select * from Category where categoryid=@categoryid", parm))
        {
            if (rdr.Read())
                category = new Model(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2));
            else
                category = new Model();
        }
        return category;
    }
}

 

public interface IDAL
{
    IList<Model> GetCategories();
    Model GetCategory(string categoryId);
}


public class Model
{
    private string categoryid;
    private string categoryname;
    private string categorytemp;

    public Model()
    {}

    public Model(string categoryid,string categoryname,string categorytemp) {
        this.categoryid = categoryid;
        this.categoryname = categoryname;
        this.categorytemp = categorytemp;
    }

    public string CategoryId
    {
        get { return this.categoryid; }
    }

    public string CategoryName
    {
        get { return this.categoryname; }
    }

    public string CategoryTemp
    {
        get { return this.categorytemp; }
    }
 
}


public abstract class DBUtility
{  
        public static readonly string ConnectStr = "server=.;uid=sa;pwd=";

        private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());
 
        public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {

            SqlCommand cmd = new SqlCommand();
            using (SqlConnection conn = new SqlConnection(connectionString)) {
                PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
                int val = cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
                return val;
            }
        }
 
        public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {

            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
            int val = cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            return val;
        }
 
        public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
            int val = cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            return val;
        }
        
        public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {
            SqlCommand cmd = new SqlCommand();
            SqlConnection conn = new SqlConnection(connectionString);
 
            try {
                PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
                SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                cmd.Parameters.Clear();
                return rdr;
            }
            catch {
                conn.Close();
                throw;
            }
        }
 
        public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {
            SqlCommand cmd = new SqlCommand();

            using (SqlConnection connection = new SqlConnection(connectionString)) {
                PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
                object val = cmd.ExecuteScalar();
                cmd.Parameters.Clear();
                return val;
            }
        }

        public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {

            SqlCommand cmd = new SqlCommand();

            PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
            object val = cmd.ExecuteScalar();
            cmd.Parameters.Clear();
            return val;
        }
 
        public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters) {
            parmCache[cacheKey] = commandParameters;
        }
 
        public static SqlParameter[] GetCachedParameters(string cacheKey) {
            SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey];

            if (cachedParms == null)
                return null;

            SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length];

            for (int i = 0, j = cachedParms.Length; i < j; i++)
                clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone();

            return clonedParms;
        }
 
        private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms) {

            if (conn.State != ConnectionState.Open)
                conn.Open();

            cmd.Connection = conn;
            cmd.CommandText = cmdText;

            if (trans != null)
                cmd.Transaction = trans;

            cmd.CommandType = cmdType;

            if (cmdParms != null) {
                foreach (SqlParameter parm in cmdParms)
                    cmd.Parameters.Add(parm);
            }
        }
}

posted @ 2008-11-13 23:22 Mars1986 阅读(132) 评论(0) 编辑

2008年11月12日

using System;
using System.Net;
using System.Net.Mail;
using System.Text;

 

public class MailClient
{
    private SmtpClient client;
    private string errorMessage = "";
    private string fromEmail = "XXX@sina.com";
    private string password = "********";
    private string smtpHost = "smtp.sina.com";
    private string username = "XXX@sina.com";

    public MailClient()
    {
        this.client = new SmtpClient(this.smtpHost);
        this.client.DeliveryMethod = SmtpDeliveryMethod.Network;
        this.client.UseDefaultCredentials = false;
        this.client.Credentials = new NetworkCredential(this.username, this.password);
    }

    public bool Send(string toEmail, string subject, string body, bool isBodyHtml)
    {
        MailMessage message = new MailMessage();
        message.Subject = subject;
        message.SubjectEncoding = Encoding.UTF8;
        message.From = new MailAddress(this.fromEmail);
        message.To.Add(toEmail);
        message.Body = body;
        message.BodyEncoding = Encoding.UTF8;
        message.IsBodyHtml = isBodyHtml;
        try
        {
            this.client.Send(message);
            return true;
        }
        catch (Exception exception)
        {
            this.errorMessage = exception.Message;
            return false;
        }
    }

    public string ErrorMessage
    {
        get
        {
            return this.errorMessage;
        }
    }
}

 

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

 

if (mc.Send("XXX@163.com", "title", "<a href='#'>nihao</a>", true))
            Response.Write("good");
        else
            Response.Write("bad");

 

代码亲测,绝对能用。邮箱支持sina ,qq,163的好像不支持。

 

 

posted @ 2008-11-12 22:15 Mars1986 阅读(204) 评论(1) 编辑

2008年9月22日

我刚搜索出来的结果 试过好用, 和大家分享一下。

 

<system.web>

  
    <httpHandlers>
      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />

    </httpHandlers>
 
    <compilation debug="false" strict="false" explicit="true">
      <buildProviders>
        <add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
      </buildProviders>
    </compilation>



 </system.web>

posted @ 2008-09-22 21:13 Mars1986 阅读(331) 评论(0) 编辑

2008年9月15日

posted @ 2008-09-15 12:45 Mars1986 阅读(29) 评论(0) 编辑