public void CreateReconiliatonTable(Point3d insertionPoint, global::Enterprise.OrganizationalStructure.Enterprise source)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = doc.TransactionManager.StartTransaction();
using ( tr )
{
Autodesk.AutoCAD.DatabaseServices.Table tbl = new Autodesk.AutoCAD.DatabaseServices.Table();
DBDictionary tsd = (DBDictionary)tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead);
object yy = tsd["ReconciliationTable"];
tbl.TableStyle = (yy as TableStyle).ObjectId;
tbl.SetSize(source.OrganizationalStructure.Departments.Count + 3, 4);
//tbl.Width = 65;
tbl.Columns[0].Width = 17;
tbl.Columns[1].Width = 23;
tbl.Columns[2].Width = 17;
tbl.Columns[3].Width = 14;
tbl.SetRowHeight(5);
tbl.BreakEnabled = false;
tbl.Position = new Point3d(insertionPoint.X - 185, insertionPoint.Y, 0);
tbl.Cells[0, 0].TextString = "СОГЛАСОВАНО";
tbl.Cells[1, 0].TextString = "Подразделение";
tbl.Cells[1, 1].TextString = "Фамилия";
tbl.Cells[1, 2].TextString = "Подпись";
tbl.Cells[1, 3].TextString = "Дата";
for ( int i = 1; i < source.OrganizationalStructure.Departments.Count; i++ )
{
tbl.Cells[i + 2, 0].TextString = source.OrganizationalStructure.Departments[i].AbbreviatedNumber;
tbl.Cells[i + 2, 1].TextString = source.OrganizationalStructure.Departments[i].Head;
}
tbl.GenerateLayout();
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(tbl);
tr.AddNewlyCreatedDBObject(tbl, true);
tr.Commit();
}
}