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.Data.SqlClient;

public partial class WebMain_Product_Indexproduct_IsHot2 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand cmd = new SqlCommand("select top 6 id,Products,SalePrice from ProductInfo where IsHot='y' and ISPublished='y' order by AddDate desc", conn);
        SqlDataReader sdr = cmd.ExecuteReader();
        if (sdr.HasRows)
        {
            HyperLink h1;
            Label l1;
            TableRow tr;
            TableCell tc;
            while (sdr.Read())
            {
                tc = new TableCell();
                tr = new TableRow();
                h1 = new HyperLink();
                h1.Text =SubStr(sdr.GetString(1),15);
                h1.NavigateUrl = "~/china/productlist.aspx?id="+sdr.GetInt32(0);
                h1.Target = "_blank";
                tc.Controls.Add(h1);
                tr.Controls.Add(tc);
                TB.Controls.Add(tr);
                tc.CssClass = "ishot2";
                tr = new TableRow();
                tc = new TableCell();
                l1 = new Label();
                tc.HorizontalAlign = HorizontalAlign.Right;
                l1.Text ="￥"+ Convert.ToString(sdr.GetDecimal(2).ToString("0.00"));
                tc.Controls.Add(l1);
                tr.Controls.Add(tc);
                tc.CssClass = "ishot3";
                TB.Controls.Add(tr);
            }
            sdr.Close();
        }
        else
        { 
        
        }
        conn.Close();

    }
    public string SubStr(string sString, int nLeng)
    {
        if (sString.Length <= nLeng)
        {
            return sString;
        }
        string sNewStr = sString.Substring(0, nLeng);
        sNewStr = sNewStr + "...";
        return sNewStr;
    }
}
