Example #1
0
    //删除区间
    protected void Button2_Command(object sender, CommandEventArgs e)
    {
        int regionId = Convert.ToInt32(e.CommandArgument);

        bool success = false;

        using (TransactionScope ts = new TransactionScope())
        {
            DataTable lists = item_bll.GetItemListByRegionId(userId, regionId);
            foreach (DataRow dr in lists.Rows)
            {
                int itemId    = Convert.ToInt32(dr["ItemID"]);
                int itemAppId = Convert.ToInt32(dr["ItemAppID"]);

                success = item_bll.DeleteItem(userId, itemId, itemAppId);
                if (!success)
                {
                    break;
                }
            }

            ts.Complete();
        }

        if (success)
        {
            Utility.Alert(this, "删除成功。", "QuJianTongJi.aspx");
        }
        else
        {
            Utility.Alert(this, "删除失败!");
        }
    }
Example #2
0
    //删除操作
    protected void ItemGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int itemId    = Convert.ToInt32(this.ItemGrid.DataKeys[e.RowIndex].Value);
        int regionId  = Convert.ToInt32(((HiddenField)this.ItemGrid.Rows[e.RowIndex].FindControl("RegionIDHid")).Value);
        int itemAppId = Convert.ToInt32(((HiddenField)this.ItemGrid.Rows[e.RowIndex].FindControl("ItemAppIDHid")).Value);

        bool success = false;

        using (TransactionScope ts = new TransactionScope())
        {
            if (regionId > 0)
            {
                DataTable items = bll.GetItemListByRegionId(userId, regionId);
                foreach (DataRow dr in items.Rows)
                {
                    itemId    = Convert.ToInt32(dr["ItemID"]);
                    itemAppId = Convert.ToInt32(dr["ItemAppID"]);

                    success = bll.DeleteItem(userId, itemId, itemAppId);
                }
            }
            else
            {
                success = bll.DeleteItem(userId, itemId, itemAppId);
            }

            ts.Complete();
        }

        if (success)
        {
            this.ItemGrid.EditIndex = -1;
            BindItemGrid();
        }
        else
        {
            //Utility.Alert(this, "删除失败!");
        }
    }