Exemplo n.º 1
0
        /// <summary>
        /// Метод. Быстрый поиск.
        /// </summary>
        private void FastSearch()
        {
            int[] selectedRows    = grid1.Selection.GetSelectionRegion().GetRowsIndex();
            int[] selectedColumns = grid1.Selection.GetSelectionRegion().GetColumnsIndex();
            if (selectedColumns.Length == 0)
            {
                sys.SM("Выделите колонку, в которой нужно производить поиск");
                return;
            }
            int firstRow  = 0;
            int findCount = 0;

            if (selectedRows.Length > 0)
            {
                firstRow = selectedRows[0] + 1;
            }
            if (firstRow == grid1.Rows.Count)
            {
                firstRow = 0;
            }
            FormSearch.SerchTextSourceGrid(grid1,
                                           null,              //System.Windows.Forms.DataGridView DGResult,
                                           cbFastSearch.Text, //string SearchText,
                                           firstRow,          //int FirstRow,
                                           false,             //bool CaseSensitivity,
                                           true,              //bool OnlySelectedColumns,
                                           false,             //bool OnlySelectedRows,
                                           false,             //bool OnlySelectedArea,
                                           2,                 //int SearchDirection,
                                           4,                 //int SearchPart,
                                           selectedRows,
                                           selectedColumns,
                                           ref findCount);
            FormSearch.SetHistorySearch(cbFastSearch.Text);
        }
Exemplo n.º 2
0
        ///Все управляющие кноки справочника.
        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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Получение фокуса ввода
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cbFastSearch_Enter(object sender, EventArgs e)
 {
     if (wasSetHistorySearch)
     {
         return;
     }
     FormSearch.GetHistorySearch(cbFastSearch);
     wasSetHistorySearch = true;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Метод СТАТИЧЕСКИЙ для вызова данной формы.
        /// </summary>
        /// <param name="formName">Имя формы</param>
        /// <param name="gridDG">Можно искать по гриду FBA.DataGridViewFBA</param>
        /// <param name="gridSG">Можно искать по гриду FBA.GridFBA</param>
        /// <returns></returns>
        public static FormSearch FormSearchShow(string formName, FBA.DataGridViewFBA gridDG, FBA.GridFBA gridSG)
        {
            if (Var.FormSearchParam.Contains(formName + ";"))
            {
                return(null);
            }
            Var.FormSearchParam = Var.FormSearchParam + formName + ";";
            var F1 = new FormSearch(formName, gridDG, gridSG);

            //История поиска.
            GetHistorySearch(F1.EditFBA1.comboBox);

            int GridLeft = 0; //Чтобы высчитать координаты появления формы поиска на экране относительно грида.
            int GridTop  = 0; //Чтобы высчитать координаты появления формы поиска на экране относительно грида.

            //Установка местоположения появления формы.
            if (gridDG != null)
            {
                GridLeft = gridDG.Left;
                GridTop  = gridDG.Top;
            }
            if (gridSG != null)
            {
                GridLeft = gridSG.Left;
                GridTop  = gridSG.Top;
            }

            var   p1 = new Point(GridLeft, GridTop);
            Point p2 = F1.PointToScreen(p1);

            F1.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
            F1.Left          = p2.X + 70;
            F1.Top           = p2.Y - 20;
            F1.Show();
            return(F1);
        }
Exemplo n.º 5
0
 ///Показ формы поиска.
 private void ShowFormSearch(DataGridViewFBA DGV)
 {
     FormSearch.FormSearchShow(this.Name, DGV, null);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Удалить историю поиска
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void deleteHistoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormSearch.DeleteSearchHistory(cbFastSearch);
 }
Exemplo n.º 7
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();
            }
        }