Example #1
0
    protected void lnkSetDefault_Click(object sender, EventArgs e)
    {
        int    imgid        = CommonMethod.ConvertToInt(hidId.Value, 0);
        string filename     = string.Empty;
        string physicalpath = string.Empty;
        string thumpath     = string.Empty;

        if (imgid > 0)
        {
            XiHuan_GoodsImageEntity defaultimage = new XiHuan_GoodsImageEntity();
            defaultimage.Id = imgid;
            defaultimage.Retrieve();
            if (defaultimage.IsPersistent)
            {
                physicalpath = Server.MapPath(defaultimage.ImgSrc);
                filename     = Path.GetFileNameWithoutExtension(physicalpath);
                thumpath     = physicalpath.Replace(filename, filename + GlobalVar.DefaultPhotoSize);
                if (!File.Exists(physicalpath))//没有缩略图,需要生成缩略图
                {
                    PicHelper.MakeThumbnail(physicalpath, thumpath, 85, 85);
                    thumpath = physicalpath.Replace(filename, filename + GlobalVar.BigPhotoSize);
                    PicHelper.MakeThumbnail(physicalpath, thumpath, 200, 220);
                }

                Query.ProcessSqlNonQuery(@"update XiHuan_GoodsImage set IsDefaultPhoto=0 where IsDefaultPhoto=1 and GoodsId=" + Request["id"]
                                         + ";update XiHuan_UserGoods set DefaultPhoto='" + defaultimage.ImgSrc.Replace(filename, filename + GlobalVar.DefaultPhotoSize) + "' where Id=" + Request["id"],
                                         GlobalVar.DataBase_Name);
                defaultimage.IsDefaultPhoto = 1;
                defaultimage.Save();
                CommonMethod.readAspxAndWriteHtmlSoruce("showdetail.aspx?id=" + defaultimage.GoodsId, CommonMethod.FinalString(Request["detailurl"]));
                Alert("恭喜:成功设置为默认图片!");
                BindReceive();
            }
        }
    }
Example #2
0
    protected void lnkCancleDefault_Click(object sender, EventArgs e)
    {
        int imgid = CommonMethod.ConvertToInt(hidId.Value, 0);

        if (imgid > 0)
        {
            XiHuan_GoodsImageEntity defaultimage = new XiHuan_GoodsImageEntity();
            defaultimage.Id = imgid;
            defaultimage.Retrieve();
            if (defaultimage.IsPersistent)
            {
                defaultimage.IsDefaultPhoto = 0;
                defaultimage.Save();
                Alert("恭喜:已成功取消默认图片!");
                BindReceive();
            }
        }
    }