Beispiel #1
0
 /// <summary>
 /// Удаление таблицы.
 /// </summary>
 /// <returns></returns>
 private bool OperationDelete()
 {
     if (!sys.SM("Вы хотите действительно удалить таблицу?", MessageType.Question, "Удаление таблицу"))
     {
         return(false);
     }
     if (!CheckDeleteTable())
     {
         return(false);
     }
     return(Obj.DeleteObject("Main1"));
 }
Beispiel #2
0
        /// <summary>
        /// Удаление сущности
        /// </summary>
        /// <returns>Если true, то сущность удалена успешно.</returns>
        private bool OperationDelete()
        {
            if (!sys.SM("Вы хотите действительно удалить сущность?", MessageType.Question, "Удаление сущности"))
            {
                return(false);
            }
            string sql       = "SELECT Count(*) AS cnt FROM fbaAttribute WHERE AttributeEntityID = " + ID;
            string attrCount = sys.GetValue(DirectionQuery.Remote, sql);

            if (attrCount != "0")
            {
                sys.SM("Ошибка. У сущности есть атрибуты. Удаление невозможно.");
                return(false);
            }
            return(Obj.DeleteObject("Main1"));
        }
Beispiel #3
0
        ///Вместо 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();
            }
        }