///Все управляющие кноки справочника. private void tb_N1_Click(object sender, EventArgs e) { //Filter. if ((sender == tb_N1) || (sender == cm_N1)) { if (!FormFilter.Filter(this, EntityBrief, DGV1.Left, DGV1.Top, ref filter)) { return; } //sys.SM(filter.FullQuery); Var.con.SelectDT(filter.FullQuerySQL, out dt); DGV1.DataSource = dt; } //Refresh. if ((sender == tb_N2) || (sender == cm_N2)) { Var.con.SelectDT(filter.FullQuerySQL, out dt); DGV1.DataSource = dt; } //ShowSQL. if (sender == cm_N8) { sys.SM(filter.FullQuerySQL, MessageType.Information); } //ShowMSQL. if (sender == cm_N9) { sys.SM(filter.FullQueryMSQL, MessageType.Information); } //Sum of the values //if (sender == cm_N10) sys.SM("Функционал пока не работает!"); //Details if (sender == cm_N8) { DGV1.GridInformation(); } //Export to Excel if (sender == cm_N6) { DGV1.ExportToExcel(); } //Save to CSV if (sender == cm_N7) { DGV1.DataGridViewToCSV(""); } //Форма поиска. if ((sender == tb_N6) || (sender == cm_N9)) { fs = FormSearch.FormSearchShow(this.Name, DGV1, null); } }
///Вместо button1.PerformClick(); private void Action(CommandType commandType) { if (commandType == CommandType.Ok) { Close(); } if (commandType == CommandType.Filter) { if (!FormFilter.Filter( this, listParams.EntityBrief, grid1.Left, grid1.Top, ref filter, listParams.OuterWHERE )) { FilterSet = false; return; } FilterSet = true; RefreshGridForm(DirectionQuery.Remote, grid1, filter); } if (commandType == CommandType.ExecSQL) { FilterSet = false; filter.FullQuerySQL = listParams.СustomSQLQuery; RefreshGridForm(DirectionQuery.Remote, grid1, filter); } if (commandType == CommandType.ExecMSQL) { FilterSet = false; filter.FullQuerySQL = sys.Parse(listParams.СustomMSQLQuery); RefreshGridForm(DirectionQuery.Remote, grid1, filter); } if (commandType == CommandType.Refresh) { RefreshGridForm(DirectionQuery.Remote, grid1, filter); } if (commandType == CommandType.Add) { EditObject(""); } if (commandType == CommandType.Edit) { this.listParams.ObjectID = grid1.Value(0, true); if (listParams.DoubleClickReturn) { Close(); } //показываем форму свойств выбранного объекта. EditObject(this.listParams.ObjectID); } if (commandType == CommandType.Del) { int countDeleted = 0; string objectCaption = ""; string[] arrID = grid1.GetSelectedValues(0, true); if (arrID == null) { return; } if (arrID.Length == 0) { return; } string entityName = sys.GetEntityName("", listParams.EntityBrief); if (entityName != "") { objectCaption = entityName; } if (arrID.Length == 1) { objectCaption = objectCaption + " ИД Объекта " + arrID[0]; } else { objectCaption = objectCaption = objectCaption + " Всего объектов " + arrID.Length.ToString(); } if (!sys.SM("Вы действительно ходите удалить " + objectCaption, MessageType.Question)) { return; } if (arrID.Length == 1) { objectCaption = "'" + entityName + "'. ИД Объекта " + arrID[0]; var Obj = new FBA.ObjectRef(); if (!Obj.DeleteObject(DirectionQuery.Remote, "Contract", arrID[0])) { return; } countDeleted = 1; sys.SM(objectCaption + " удален", MessageType.Information); } if (arrID.Length > 1) { var progress1 = new FormProgress("Удаление", "Удаление объектов" + entityName, arrID.Length); progress1.Show(); for (int i = 0; i < arrID.Length; i++) { objectCaption = "'" + entityName + "'. ИД Объекта " + arrID[i]; var Obj = new FBA.ObjectRef(); if (!Obj.DeleteObject(DirectionQuery.Remote, "Contract", arrID[i])) { return; } countDeleted++; progress1.Inc(); } progress1.Dispose(); if (countDeleted == arrID.Length) { objectCaption = "Все объекты " + entityName + " удалены. Всего: " + countDeleted; sys.SM(objectCaption, MessageType.Information); } if (countDeleted < arrID.Length) { objectCaption = "Объекты " + entityName + " удалены. Всего: " + countDeleted + " из " + arrID.Length.ToString(); sys.SM(objectCaption, MessageType.Warning); } if (countDeleted == 0) { objectCaption = "Объекты " + entityName + " удалены не были."; sys.SM(objectCaption); } if (countDeleted > 0) { if (sys.SM("Обновить содержимое справочника " + entityName + "?", MessageType.Question)) { RefreshGridForm(DirectionQuery.Remote, grid1, filter); } } ; } } if (commandType == CommandType.ShowSQL) { sys.SM(filter.FullQuerySQL, MessageType.Information); } if (commandType == CommandType.ShowMSQL) { sys.SM(filter.FullQueryMSQL, MessageType.Information); } if (commandType == CommandType.Details) { grid1.GridInformation(); } if (commandType == CommandType.ExportToExcel) { grid1.SourceGridToExcel(); } if (commandType == CommandType.ExportToCSV) { grid1.SourceGridToCSV(); } if (commandType == CommandType.Search) { dtSearch = FormSearch.FormSearchShow(this.Name, null, grid1); } if (commandType == CommandType.Copy) { grid1.CopyRegion(false, false); } if (commandType == CommandType.CopyAll) { grid1.CopyRegion(true, true); } if (commandType == CommandType.CopyWithCaptions) { grid1.CopyRegion(true, false); } //if (Operation == "Copy") //{ // string Value = sys.GetValueByColumnIndex(DG2, -1, true); // Value.CopyToClipboard(); //} if (commandType == CommandType.SelectAll) { SourceGridSelectAll(grid1); //DG2.SelectAll()); } if (commandType == CommandType.SelectRows) { SourceGridSelectRows(grid1); } if (commandType == CommandType.SelectColumns) { SourceGridSelectColumns(grid1); } if (commandType == CommandType.SelectionModeCell) { SetSelectionMode(SourceGrid.GridSelectionMode.Cell); } if (commandType == CommandType.SelectionModeRow) { SetSelectionMode(SourceGrid.GridSelectionMode.Row); } if (commandType == CommandType.SelectionModeColumn) { SetSelectionMode(SourceGrid.GridSelectionMode.Column); } if (commandType == CommandType.Cancel) { this.listParams.ObjectID = ""; this.Close(); } //Копирование ссылок на выделенные документы. if (commandType == CommandType.CopyDocumentLink) { var links = new StringBuilder(); string[] arrID = grid1.GetSelectedValues(0, true); if (arrID.Length == 0) { return; } for (int i = 0; i < arrID.Length; i++) { links.Append("FBALink.Entity:" + listParams.EntityBrief + ",ObjectID:" + arrID[i] + Var.CR); } links.ToString().CopyToClipboard(); } }