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 lnkDelMultiMessage_Click(object sender, EventArgs e)
    {
        string[] mid          = hidId.Value.Trim().TrimEnd(',').Split(',');
        string   physicalpath = string.Empty;
        string   thumpath     = string.Empty;
        string   filename     = string.Empty;

        if (mid.Length > 0)
        {
            for (int i = 0; i < mid.Length; i++)
            {
                int id = CommonMethod.ConvertToInt(mid[i], 0);
                if (id > 0)
                {
                    XiHuan_GoodsImageEntity note = new XiHuan_GoodsImageEntity();
                    note.Id = id;
                    note.Retrieve();
                    if (note.IsPersistent)
                    {
                        physicalpath = Server.MapPath(note.ImgSrc);
                        filename     = Path.GetFileNameWithoutExtension(physicalpath);
                        if (File.Exists(physicalpath))
                        {
                            File.Delete(physicalpath);
                        }
                        thumpath = physicalpath.Replace(filename, GlobalVar.DefaultPhotoSize);
                        if (File.Exists(thumpath))
                        {
                            File.Delete(thumpath);
                        }
                        thumpath = physicalpath.Replace(filename, GlobalVar.BigPhotoSize);
                        if (File.Exists(thumpath))
                        {
                            File.Delete(thumpath);
                        }
                        note.Delete();
                    }
                }
            }

            BindReceive();
            if (rptGoodsList.Items.Count == 0)
            {
                Query.ProcessSqlNonQuery("update XiHuan_UserGoods set IsHavePhoto=0 ,DefaultPhoto='images/none.jpg' where Id=" + Request["id"], GlobalVar.DataBase_Name);
            }
            Alert("恭喜:选中的图片已成功删除!");
        }
    }
Example #3
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();
            }
        }
    }
Example #4
0
    protected void lnkDelMessage_Click(object sender, EventArgs e)
    {
        int id = CommonMethod.ConvertToInt(hidId.Value, 0);

        if (id > 0)
        {
            XiHuan_GoodsImageEntity note = new XiHuan_GoodsImageEntity();
            note.Id = id;
            note.Retrieve();
            if (note.IsPersistent)
            {
                string phypath  = Server.MapPath(note.ImgSrc);
                string filename = Path.GetFileNameWithoutExtension(phypath);
                string thumpath = phypath.Replace(filename, filename + GlobalVar.DefaultPhotoSize);
                if (File.Exists(phypath))
                {
                    File.Delete(phypath);
                }
                if (File.Exists(thumpath))
                {
                    File.Delete(thumpath);
                }
                thumpath = phypath.Replace(filename, filename + GlobalVar.BigPhotoSize);
                if (File.Exists(thumpath))
                {
                    File.Delete(thumpath);
                }
                note.Delete();
                BindReceive();
                if (rptGoodsList.Items.Count == 0)
                {
                    Query.ProcessSqlNonQuery("update XiHuan_UserGoods set IsHavePhoto=0 ,DefaultPhoto='images/none.jpg' where Id=" + Request["id"], GlobalVar.DataBase_Name);
                }
                Alert("恭喜:图片已成功删除!");
            }
        }
    }