protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        #region --删除
        if (e.CommandName == "cmdDelete")
        {
            Tz888.BLL.TPPicture          bllobj = new Tz888.BLL.TPPicture();
            Tz888.SQLServerDAL.TPPicture tpobj  = new Tz888.SQLServerDAL.TPPicture();

            DataSet ds = tpobj.GetOnePicMess(e.CommandArgument.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                try
                {
                    string strHtmlURL      = ds.Tables[0].Rows[0]["HtmlURL"].ToString();
                    string strMiniatureUrl = ds.Tables[0].Rows[0]["MiniatureUrl"].ToString();
                    Tz888.Common.FileManage.FileDelete(strHtmlURL);
                    Tz888.Common.FileManage.FileDelete(strMiniatureUrl);
                }
                catch { }
            }

            bool isSuccess = false;
            isSuccess = bllobj.DeletePicMess(e.CommandArgument.ToString());
            if (isSuccess)
            {
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                Response.Write("<script>alert('对编号为" + e.CommandArgument.ToString() + "的删除操作失败。'); </script>");
                return;
            }
        }
        #endregion
    }
示例#2
0
    private void GetInfoPic()
    {
        long CurrentPage = Convert.ToInt64(this.AspNetPager.CurrentPageIndex);
        long PageNum     = Convert.ToInt64(this.AspNetPager.PageSize);
        long TotalCount  = 0;
        long PageCount   = 1;

        Tz888.BLL.TPPicture srvSI = new Tz888.BLL.TPPicture();
        string    MerchantDomain  = (string)ConfigurationManager.AppSettings["MerchantDomain"];
        string    ImageDomain     = (string)ConfigurationManager.AppSettings["ImageDomain"];
        DataSet   ds     = srvSI.dsGetPicMess("*", ViewState["Criteria"].ToString(), "publishT desc", CurrentPage, PageNum, out TotalCount);
        DataTable dtdata = MakeTable();

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            DataRow drs = dtdata.NewRow();
            drs["InfoID"]             = dr["InfoID"].ToString();
            drs["href"]               = MerchantDomain + "/photodetails.aspx?p=" + dr["ProvinceID"].ToString().Trim() + "&id=" + dr["InfoID"].ToString();
            drs["MiniatureUrl"]       = ImageDomain + "/" + dr["MiniatureUrl"].ToString();
            drs["Title"]              = dr["Title"].ToString();
            drs["GradeID"]            = dr["GradeID"].ToString();
            drs["Origin"]             = dr["Origin"].ToString();
            drs["publishT"]           = dr["publishT"].ToString();
            drs["IsCore"]             = dr["IsCore"].ToString();
            drs["LoginName"]          = dr["LoginName"].ToString();
            drs["AuditingStatusDesc"] = dr["AuditingStatusDesc"].ToString();
            dtdata.Rows.Add(drs);
        }
        this.AspNetPager.RecordCount = Convert.ToInt32(TotalCount);
        GridView1.DataSource         = dtdata.DefaultView;

        this.GridView1.DataBind();
        if (TotalCount % PageNum > 0)
        {
            PageCount = TotalCount / PageNum + 1;
        }
        else
        {
            PageCount = TotalCount / PageNum;
        }

        this.pinfo.InnerText = "共" + PageCount + "页";
        this.LblCount.Text   = TotalCount.ToString();


        if (ds.Tables[0].Rows.Count <= 0)
        {
            this.NoMessage.Style.Value = "display:block";
            this.dvCheck.Style.Value   = "display:none";
            this.pinfo2.Style.Value    = "display:none";
        }
        else
        {
            this.NoMessage.Style.Value = "display:none";
            this.dvCheck.Style.Value   = "display:block";
            this.pinfo2.Style.Value    = "display:block";
        }
    }
    private void BathchDelete()
    {
        string idLst = Request.Form["chk"];

        if (idLst.Length > 0)
        {
            Tz888.BLL.TPPicture bllobj = new Tz888.BLL.TPPicture();
            string[]            lst    = idLst.Split(',');
            for (int i = 0; i < lst.Length; i++)
            {
                Tz888.SQLServerDAL.TPPicture tpobj = new Tz888.SQLServerDAL.TPPicture();
                DataSet ds = tpobj.GetOnePicMess(lst[i].ToString());
                if (ds.Tables[0].Rows.Count > 0)
                {
                    try
                    {
                        string strHtmlURL      = ds.Tables[0].Rows[0]["HtmlURL"].ToString();
                        string strMiniatureUrl = ds.Tables[0].Rows[0]["MiniatureUrl"].ToString();
                        Tz888.Common.FileManage.FileDelete(strHtmlURL);
                        Tz888.Common.FileManage.FileDelete(strMiniatureUrl);
                    }
                    catch { }
                }
            }

            bool isSuccess = false;
            isSuccess = bllobj.DeletePicMess(idLst);

            if (isSuccess)
            {
                Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")));
            }
            else
            {
                Response.Write("<script>alert('部分删除操作失败。'); </script>");
            }
        }
    }