protected override async void OnToolWindowAcceptClick(object sender, EventArgs e) { DBItem bufRow = ((TableLayoutList)toolWindow.Target).FieldSource as DBItem; if (!bufRow.Attached) { question.SecondaryText = "Check"; if (Status == TableEditorStatus.Search && list.ListSource.Count > 0) { question.Text = Locale.Get("TableEditor", "Found duplicate records!\nContinee?"); if (MessageDialog.AskQuestion(ParentWindow, question) == Command.No) { return; } } if (mode == TableEditorMode.Referencing) { if (bufRow[baseColumn].ToString() != OwnerRow.PrimaryId.ToString()) { question.Text = Locale.Get("TableEditor", "Change reference?"); if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes) { bufRow[baseColumn] = OwnerRow.PrimaryId; } } } Table.Add(bufRow); try { await bufRow.Save(GuiEnvironment.User); } catch (Exception ex) { Helper.OnException(ex); toolWindow.Visible = true; } if (bufRow.UpdateState != DBUpdateState.Default) { return; } if (status == TableEditorStatus.Clone) { question.Text = Locale.Get("TableEditor", "Clone References?"); if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes) { var relations = Table.GetChildRelations(); foreach (var relation in relations) { question.Text = string.Format(Locale.Get("TableEditor", "Clone Reference {0}?"), relation.Table); if (MessageDialog.AskQuestion(ParentWindow, question) == Command.No) { continue; } var refrows = clonedRow.GetReferencing(relation, DBLoadParam.Load | DBLoadParam.Synchronize); foreach (DBItem refrow in refrows) { var newRow = refrow.Clone() as DBItem; newRow.PrimaryId = DBNull.Value; newRow[relation.Column] = bufRow.PrimaryId; relation.Table.Add(newRow); } await relation.Table.Save(); } } } //if (MessageDialog.ShowMessage(_rowTool, "Добавить еще поле?", "Добавление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == Command.Yes) //{ // Status = _status; // return; //} } //else if ((bufRow.DBState & DBRowState.Default) != DBRowState.Default) //{ // // if (_mode == TableFormMode.RefingTable) // bufRow[_ocolumn] = _orow.Id; // Save(Table); // if ((bufRow.DBState & DBRowState.Default) != DBRowState.Default) // return; //} Status = TableEditorStatus.Default; Selected = bufRow; if (mode == TableEditorMode.Reference) { OnItemSelect(new ListEditorEventArgs(bufRow)); } }