Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            OnSetLanguage();

            DBLL.OptionSysDBLL sys   = new DBLL.OptionSysDBLL();
            DBLL.DBcommon      dbcom = new DBLL.DBcommon();


            DBLL.clsProduct clspro    = new DBLL.clsProduct();
            DataTable       dtProduct = clspro.Select_tb_ProductBybHot(true);
            DataList1.DataSource = dtProduct;
            DataList1.DataBind();

            if (Session["languageGlobal"] == "en")
            {
                DataTable dtNews = dbcom.GetDataTable("select top 5 * from tb_News where bEnable=1 and  nLangType=1 order by nSorting desc,dCreatedTime desc");
                GridView1.DataSource = dtNews;
                GridView1.DataBind();
            }
            else
            {
                DataTable dtNews = dbcom.GetDataTable("select top 5 * from tb_News where bEnable=1 and  nLangType=0 order by nSorting desc,dCreatedTime desc");
                GridView1.DataSource = dtNews;
                GridView1.DataBind();
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         OnSetLanguage();
         DBLL.DBcommon com = new DBLL.DBcommon();
         DataTable     dt  = new DataTable();
         if (Session["languageGlobal"] == "en")
         {
             dt = com.GetDataTable(" select top 1 * from tb_News where nLangType=2 order by nSorting desc,dUpdatedTime desc");
         }
         else
         {
             dt = com.GetDataTable(" select top 1 * from tb_News where nLangType=1 order by nSorting desc,dUpdatedTime desc");
         }
         if (dt != null && dt.Rows.Count > 0)
         {
             lbltitle.Text = dt.Rows[0]["sTitle"].ToString();
             lbltime.Text  = dt.Rows[0]["dUpdatedTime"].ToString();
             string content = common.StripHTML(dt.Rows[0]["sContent"].ToString());
             if (content.Length > 100)
             {
                 lblContent.Text = content.Substring(0, 100) + "...";
             }
             else
             {
                 lblContent.Text = content;
             }
         }
     }
 }
Example #3
0
 public void BindData()
 {
     DBLL.DBcommon dbcon = new DBLL.DBcommon();
     if (Session["languageGlobal"] == "en")
     {
         DataTable dtNews = dbcon.GetDataTable("select  * from tb_News where bEnable=1 and  nLangType=1 order by nSorting desc,dCreatedTime desc");
         DataTableNews     = dtNews;
         lvNews.DataSource = DataTableNews;
         lvNews.PageSize   = 12;
         lvNews.DataBind();
     }
     else
     {
         DataTable dtNews = dbcon.GetDataTable("select  * from tb_News where bEnable=1 and  nLangType=0 order by nSorting desc,dCreatedTime desc");
         DataTableNews     = dtNews;
         lvNews.DataSource = DataTableNews;
         lvNews.PageSize   = 12;
         lvNews.DataBind();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         OnSetLanguage();
         DBLL.clsFAQs  clsfaqs = new DBLL.clsFAQs();
         DBLL.DBcommon dbcom   = new DBLL.DBcommon();
         DataTable     dt      = dbcom.GetDataTable("select top 1 * from tb_FAQs  order by nSorting desc,dCreatedTime desc");
         gvFAQS.DataSource = dt;
         gvFAQS.DataBind();
     }
 }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DBLL.clsProduct      productdt = new DBLL.clsProduct();
            DBLL.clsProductImage proimage  = new DBLL.clsProductImage();
            DBLL.DBcommon        DBcommon  = new DBLL.DBcommon();
            DataTable            dtp       = productdt.sp_selectNormalTableOfAllByProduct(false);
            DataTable            dtpi      = DBcommon.GetDataTable("select * from tb_ProductImage where bEnable=1 order by dCreatedTime desc");
            for (int i = 0; i < dtp.Rows.Count; i++)
            {
                try
                {
                    DataRow[] pirow     = dtpi.Select("nProductID=" + dtp.Rows[i]["nProductID"].ToString());
                    string    sSavepath = "";
                    if (pirow.Length > 0)
                    {
                        string yuanpath = pirow[0]["sPImagePath"].ToString();

                        System.Drawing.Image image, newimage; //定义image类的对象
                        string imagePath;                     //图片路径
                        string imageType;                     //图片类型
                        string imageName;                     //图片名称
                        //提供一个回调方法,用于确定Image对象在执行生成缩略图操作时何时提前取消执行
                        //如果此方法确定 GetThumbnailImage 方法应提前停止执行,则返回 true;否则返回 false
                        System.Drawing.Image.GetThumbnailImageAbort callb = null;



                        string thbasepath = "~/ProductsUpload" + "/thumb/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
                                            DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() +
                                            DateTime.Now.Second.ToString() + dtp.Rows[i]["nProductID"].ToString() + "/";

                        string thsSaveFolderFullPath = Server.MapPath(thbasepath);

                        if (!System.IO.Directory.Exists(thsSaveFolderFullPath))
                        {
                            Directory.CreateDirectory(thsSaveFolderFullPath);
                        }

                        StreamReader re = new StreamReader(Server.MapPath(yuanpath));
                        image     = System.Drawing.Image.FromFile(Server.MapPath(yuanpath));
                        imagePath = yuanpath;
                        //取得图片类型
                        imageType = imagePath.Substring(imagePath.LastIndexOf(".") + 1);
                        //取得图片名称
                        imageName = imagePath.Substring(imagePath.LastIndexOf("/") + 1);



                        ////显示原图
                        //imageSource.ImageUrl = "upFile/" + imageName;
                        //为上传的图片建立引用


                        //int smallW = 100;//小图片宽
                        //int smallH = smallW * image.Height / image.Width;//小图片高

                        int smallH = 100;
                        int smallW = smallH * image.Width / image.Height;
                        //生成缩略图
                        newimage = image.GetThumbnailImage(smallW, smallH, callb, new System.IntPtr());
                        //把缩略图保存到指定的虚拟路径
                        newimage.Save(thsSaveFolderFullPath + "\\" + imageName);
                        //释放image对象占用的资源
                        image.Dispose();
                        //释放newimage对象的资源
                        newimage.Dispose();

                        sSavepath = thbasepath + imageName;
                    }
                    DBcommon.Excute("update tb_Product set sThumbPath='" + sSavepath + "' where nProductID=" + dtp.Rows[i]["nProductID"].ToString());
                }
                catch (Exception)
                {
                }
            }
        }
    }