コード例 #1
0
ファイル: list_columns.aspx.cs プロジェクト: wjszxli/xdjb
    //批量删除
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        TPortalClass.JpColumns JpColumns = new TPortalClass.JpColumns();
        string ls_tip = "删除成功!";
        for (int i = 0; i < rptList.Items.Count; i++)
        {
            //int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
            string id = ((HiddenField)rptList.Items[i].FindControl("hidId")).Value;
            CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
            if (cb.Checked)
            {
                //判断是否还有子栏目,如果有子栏目不能删除
                DataTable dt_sub = JpColumns.GetSubColumnsOrderbysort_online(id);
                if (dt_sub.Rows.Count > 0)
                {
                    ls_tip = "有下一级栏目的信息无法删除,请先删除下一级栏目!";
                }
                else
                {
                    JpColumns.cid = id;
                    JpColumns.Delete();
                }
            }
        }
        string pageUrl = JpCommon.CombUrlTxt("list_columns.aspx", "page={0}&rnd={1}&cid={2}",
            "" + this.txtPage.Text + "", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtcid_url.Text + "");

        //写系统日志
        string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (userip == null || userip == "")
        {
            userip = Request.ServerVariables["REMOTE_ADDR"];
        }
        JpCommon.WriteLog(userip, "删除", "批量删除栏目记录", Session["uid"].ToString(), Session["uname"].ToString());
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + pageUrl + "';</script>");
    }