Esempio n. 1
0
 void поискToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         текстпоУмолчаниюToolStripMenuItem_Click(this, e);
         filtersForm.FilterMode = DataOperations.FilterMode.Text;
         string columnName = filtersForm.ColName = MaindataGrid.Columns[MaindataGrid.CurrentCell.ColumnIndex].HeaderText;
         filtersForm.AppDir = AppDir;
         filtersForm.ShowDialog();
         if (filtersForm.DialogResult == DialogResult.Yes)
         {
             Stopwatch perfWatch = new Stopwatch();
             perfWatch.Start();
             string SearchText = filtersForm.textValue;
             DataOperations.SearchTextMode Mode = filtersForm.txtMode;
             int       ColumnIndex  = MaindataGrid.CurrentCell.ColumnIndex;
             DataTable tmpDataTable = (MaindataGrid.DataSource as DataTable).Copy();
             DataTable newTable     = new DataTable();
             Task      taskInThread = Task.Factory.StartNew(() =>
             {
                 newTable = DataOperations.QueryProcess(tmpDataTable, ColumnIndex, SearchText, Mode);
             });
             while (!taskInThread.IsCompleted)
             {
                 toolStripStatusLabel2.Text = "Производится обработка данных...";
                 Application.DoEvents();
             }
             MaindataGrid.DataSource = newTable;
             if (saveSearchResult == SaveSearchResult.Yes)
             {
                 backUpSet[tabControl1.SelectedIndex] = MaindataGrid.DataSource as DataTable;
             }
             FormatDataGrid();
             TimeSpan span = perfWatch.Elapsed;
             toolStripStatusLabel2.Text = string.Empty;
             toolStripStatusLabel1.Text = string.Format("Количество записей удовлетворяющих поисковому запросу '{0}' в столбце <{1}> : {2} (Время загрузки: {3} мин {4} сек {5} мсек)", SearchText, columnName, MaindataGrid.Rows.Count, span.Minutes, span.Seconds, span.Milliseconds);
             MaindataGrid.CurrentCell   = null;
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
         LogManager.Log.AddToLog(AppDir, exc);
     }
 }
Esempio n. 2
0
        void button2_Click(object sender, EventArgs e)
        {
            try
            {
                switch (FilterMode)
                {
                case DataOperations.FilterMode.Integer:
                    intValue = (double)numericUpDown1.Value;
                    switch (comboBox1.SelectedIndex)
                    {
                    case 0:
                        intMode = DataOperations.SearchIntMode.EqualTo;
                        break;

                    case 1:
                        intMode = DataOperations.SearchIntMode.LargerThen;
                        break;

                    case 2:
                        intMode = DataOperations.SearchIntMode.SmallerThen;
                        break;
                    }
                    break;

                case DataOperations.FilterMode.Date:
                    DateTime tmpDate = TimePicker1.Value;
                    StartDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, tmpDate.Hour, tmpDate.Minute, tmpDate.Second);
                    tmpDate   = TimePicker2.Value;
                    EndDate   = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, tmpDate.Hour, tmpDate.Minute, tmpDate.Second);
                    break;

                case DataOperations.FilterMode.Text:
                    if (!string.IsNullOrEmpty(textBox1.Text))
                    {
                        textValue = textBox1.Text;
                    }
                    else
                    {
                        button1_Click(this, e);
                    }
                    switch (comboBox2.SelectedIndex)
                    {
                    case 0:
                        txtMode = DataOperations.SearchTextMode.Equals;
                        break;

                    case 1:
                        txtMode = DataOperations.SearchTextMode.StartWith;
                        break;

                    case 2:
                        txtMode = DataOperations.SearchTextMode.Contains;
                        break;
                    }
                    break;
                }
                DialogResult = DialogResult.Yes;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                LogManager.Log.AddToLog(AppDir, exc);
            }
        }