Example #1
0
	protected void GridView1_Delete(object sender, BXDeleteEventArgs e)
	{
		BXGridView grid = (BXGridView)sender;
		try
		{
			BXInfoBlockCollectionOld elements;
			if (e.Keys != null) //Delete one element
			{
				elements = new BXInfoBlockCollectionOld();
				elements.Add(BXInfoBlockManagerOld.GetById((int)e.Keys["IBlockId"]));
			}
			else //All elements
			{
				elements = BXInfoBlockManagerOld.GetList(MakeCurrentFilter(), null);
			}

			foreach (BXInfoBlockOld element in elements)
			{
				if (element == null)
					throw new PublicException(GetMessageRaw("ExceptionText.BlockIsNotFound"));
				if (!BXIBlock.IsUserCanOperate(element.IBlockId, BXIBlock.Operations.IBlockManageAdmin))
					throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteThisRecord"));

				BXIBlock.Delete(element.IBlockId);

				e.DeletedCount++;
			}
			successMessage.Visible = true;
		}
		catch (Exception ex)
		{
			ProcessException(ex, errorMessage.AddErrorText);
		}
		grid.MarkAsChanged();
	}
Example #2
0
	private DataTable FillTable(BXInfoBlockCollectionOld iblockCollection, int startRowIndex, int maximumRows)
	{
		if (iblockCollection == null)
			iblockCollection = new BXInfoBlockCollectionOld();

		DataTable result = new DataTable();

		result.Columns.Add("num", typeof(int));
		result.Columns.Add("IBlockId", typeof(int));
		result.Columns.Add("Name", typeof(string));
		result.Columns.Add("Sort", typeof(int));
		result.Columns.Add("Active", typeof(string));
		result.Columns.Add("Code", typeof(string));
		result.Columns.Add("ElementsCount", typeof(int));
		result.Columns.Add("SectionsCount", typeof(int));
		result.Columns.Add("Sites", typeof(string));
		result.Columns.Add("IndexContent", typeof(string));
		result.Columns.Add("UpdateDate", typeof(DateTime));

		int ind = -1;
		foreach (BXInfoBlockOld t in iblockCollection)
		{
			ind++;
			if (startRowIndex > ind)
				continue;

			DataRow r = result.NewRow();
			r["num"] = ind;
			r["IBlockId"] = t.IBlockId;
			r["Name"] = t.NameRaw;
			r["Sort"] = t.Sort;
			r["Active"] = (t.Active ? GetMessage("Kernel.Yes") : GetMessage("Kernel.No"));
			r["Code"] = t.CodeRaw;
			r["ElementsCount"] = t.ElementsCount;
			r["SectionsCount"] = t.SectionsCount;
			r["Sites"] = "";
			r["IndexContent"] = (t.IndexContent ? GetMessage("Kernel.Yes") : GetMessage("Kernel.No"));
			if (t.Sites.Count > 0)
			{
				r["Sites"] = t.Sites[0];
				for (int i = 1; i < t.Sites.Count; i++)
					r["Sites"] += ", " + t.Sites[i];
			}
			r["UpdateDate"] = t.UpdateDate;
			result.Rows.Add(r);

			if (maximumRows > 0 && ind == startRowIndex + maximumRows - 1)
				break;
		}

		return result;
	}