示例#1
0
        private string ColumnasVirtualSQL(DataGridTable dataGridTable)
        {
            string sCols = "";
            IList <DataGridColumnVirtual> currentColumnVirtuals = dataGridTable.ColumnasTablaVirtual.Ordered();

            for (int regIndex = 0; regIndex <= currentColumnVirtuals.Count - 1; ++regIndex)
            {
                DataGridColumnVirtual tempColumnVirtual = currentColumnVirtuals[regIndex];
                string sAlias = "";
                if (regIndex != 0)
                {
                    sCols = sCols + ", ";
                }
                if (!string.IsNullOrEmpty(tempColumnVirtual.AliasTable))
                {
                    sAlias = tempColumnVirtual.AliasTable + ".";
                }
                if (!string.IsNullOrEmpty(tempColumnVirtual.Expression))
                {
                    sCols = sCols + " " + tempColumnVirtual.Expression + " " + tempColumnVirtual.AliasField;
                }
                else
                {
                    sCols = sCols + " " + sAlias + tempColumnVirtual.Name + " " + tempColumnVirtual.AliasField;
                }
            }
            if (!string.IsNullOrEmpty(sCols))
            {
                sCols = " SELECT " + sCols;
            }
            return(sCols);
        }
示例#2
0
        private string CreateStringFromVirtualColumns(string sInit, DataGridTable dataGridTable)
        {
            string columnasVirtuales = ColumnasVirtualSQL(dataGridTable);
            string sBegin            = sInit;

            sBegin += dataGridTable.JoinText;
            sBegin  = string.Format("{0}     (   {1} ) {2} {3}", sBegin, BeginSql(dataGridTable.VirtualTables, sBegin, columnasVirtuales), dataGridTable.AliasTable, dataGridTable.Criterias);
            return(sBegin);
        }
示例#3
0
        private void Init()
        {
            (DataContext as MainWindowViewModel).View = this;
            TableButtons = new List <TableDetails>();

            DataGridTablePanel = new DataGridTable();
            SettingsPanel      = new SettingsPanel()
            {
                Visibility = Visibility.Collapsed
            };
            ActivePanel = DataGridTablePanel;
            DPBasePanel.Children.Add(DataGridTablePanel);
        }
示例#4
0
        private void DataSource(bool bMerge = false)
        {
            DataGridTable         dataGridTable = new DataGridTable();
            IList <DataGridTable> currentTables = _tables.Ordered();

            if (currentTables.Count > 0)
            {
                dataGridTable = currentTables[0];
            }

            /*
             * this invokes an delegate to the upper level for triggering an event to the view model
             */
            QueryDataTable?.Invoke(dataGridTable.Table, dataGridTable.AliasTable, bMerge);
        }
示例#5
0
        private string BeginSql(DataGridTables dataGridTables, string sqlQuery, string columnNames)
        {
            string sBegin = "";
            IList <DataGridTable> orderedDataGridTables = dataGridTables.Ordered();

            for (int currentIndex = 0; currentIndex <= orderedDataGridTables.Count - 1; currentIndex++)
            {
                DataGridTable dataGridTable = orderedDataGridTables[currentIndex];
                if (dataGridTable.VirtualTables.Count != 0)
                {
                    sBegin = CreateStringFromVirtualColumns(sBegin, dataGridTable);
                }
                else
                {
                    sBegin = sBegin + dataGridTable.JoinText;
                    sBegin = sBegin + dataGridTable.Table + " " + dataGridTable.AliasTable + " " +
                             dataGridTable.Criterias;
                }
            }
            string sqlString = columnNames + "\n" + sBegin;

            return(sqlString);
        }
        private void Find_Clicked(object sender, RoutedEventArgs e)
        {
            int indexOfCurrentCategory = SelectedCategory != null?LocalizationCategories.IndexOf(SelectedCategory) : 0;

            Debug.WriteLine("Current cat index: " + indexOfCurrentCategory);

            int    numCategories = LocalizationCategories.Count(); //might need to +1 this
            string searchTerm    = SearchText.ToLower();

            if (string.IsNullOrEmpty(searchTerm))
            {
                return;
            }
            LocalizedString      itemToHighlight = null;
            LocalizationCategory catToHighlight  = null;

            for (int i = 0; i < numCategories; i++)
            {
                bool found = false;
                LocalizationCategory cat = LocalizationCategories[(i + indexOfCurrentCategory) % LocalizationCategories.Count()];
                int startSearchIndex     = 0;
                int numToSearch          = cat.LocalizedStringsForSection.Count();
                if (i == 0 && cat == SelectedCategory && SelectedDataGridItem != null)
                {
                    startSearchIndex = cat.LocalizedStringsForSection.IndexOf(SelectedDataGridItem) + 1;
                    numToSearch     -= startSearchIndex;
                }
                Debug.WriteLine(cat.CategoryName);
                for (int j = 0; j < numToSearch; j++)
                {
                    var ls = cat.LocalizedStringsForSection[(j + startSearchIndex) % cat.LocalizedStringsForSection.Count];

                    //Key
                    if (ls.key.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //English
                    if (ls.INT.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //German
                    if (ShowGerman && ls.DEU != null && ls.DEU.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //Russian
                    if (ShowRussian && ls.RUS != null && ls.RUS.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //Polish
                    if (ShowPolish && ls.POL != null && ls.POL.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //French
                    if (ShowFrench && ls.FRA != null && ls.FRA.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }

                    //Spanish
                    if (ShowSpanish && ls.ESN != null && ls.ESN.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //found
                        found           = true;
                        itemToHighlight = ls;
                        catToHighlight  = cat;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }

            if (itemToHighlight == null)
            {
                SystemSounds.Beep.Play();
            }
            else
            {
                SelectedCategory     = catToHighlight;
                SelectedDataGridItem = itemToHighlight;
                DataGridTable.ScrollIntoView(SelectedDataGridItem);
            }
        }
示例#7
0
        private string ColumnasGridSQL(DataGridTable table = null)
        {
            string sCols  = "";
            string sAlias = null;
            string sCol   = "";
            IList <DataGridColumn> columns = _columns.Ordered();

            string filterTable = "";
            string sMarcar     = "";
            string sPaginado   = "";

            //*===============================================================================
            if ((table != null))
            {
                filterTable = table.AliasTable;
            }
            if (_pageSize == 0)
            {
                _pageSize = 100;
            }
            if (_gridView.DataGridType == KarveGridView.GridType.Search)
            {
                sPaginado = " TOP " + _pageSize;
            }

            //Buscamos todas las columnas de la colleccion para buscar los campos de la virtual
            for (int colIndex = 0; colIndex <= columns.Count - 1; colIndex++)
            {
                if (string.IsNullOrEmpty(filterTable) | columns[colIndex].Table == filterTable)
                {
                    sAlias = ((!string.IsNullOrEmpty(columns[colIndex].Table)) ? columns[colIndex].Table + "." : "");

                    if (colIndex != 0)
                    {
                        sCols = sCols + ", ";
                    }
                    //Añade coma menos en la última
                    if (!string.IsNullOrEmpty(columns[colIndex].Table))
                    {
                        sAlias = columns[colIndex].Table + ".";
                    }
                    //Si hay Expresión prevalece sobre name
                    if (!string.IsNullOrEmpty(columns[colIndex].ExpressionDb))
                    {
                        sCol  = ((string.IsNullOrEmpty(columns[colIndex].ExtendedFieldName)) ? columns[colIndex].AliasField : columns[colIndex].ExtendedFieldName);
                        sCols = sCols + " " + columns[colIndex].ExpressionDb + " " + sCol;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(columns[colIndex].ExtendedFieldName))
                        {
                            columns[colIndex].ExtendedFieldName = columns[colIndex].AliasField;
                        }
                        if (string.IsNullOrEmpty(columns[colIndex].AliasField))
                        {
                            columns[colIndex].AliasField = columns[colIndex].ExtendedFieldName;
                        }

                        if (string.IsNullOrEmpty(filterTable))
                        {
                            sCols = sCols + " " + sAlias + columns[colIndex].ExtendedFieldName + " " + columns[colIndex].AliasField;
                            // cuando se construye la sql de guardar no se pueden usar alias ya que si no no se puede guardar el dataset
                        }
                        else
                        {
                            sCols = sCols + " " + sAlias + columns[colIndex].ExtendedFieldName;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(sCols))
            {
                sCols = " SELECT " + sPaginado + sMarcar + sCols;
            }
            return(sCols);
        }
示例#8
0
        public void SetDataTable(DataTable newTable)
        {
            //DataViewProgress ProgressWindow = new DataViewProgress();
            //ProgressWindow.Show();
            Thread workerThread = new Thread(DisplayProgress);

            workerThread.Start();

            ToolStripMenuItem InsertItem = null;

            this.DataTableForDisplay        = new DataTable();
            DataGridTable.SelectionChanged -= new System.EventHandler(this.DataGridTable_SelectionChanged);
            DataGridTable.Rows.Clear();
            DataGridTable.Columns.Clear();
            this.ColNum = 0;
            this.RowNum = 0;
            HeaderList.Clear();
            Menu.MenuItems.Clear();
            this.DataTableForDisplay = newTable;
            this.ColNum = DataTableForDisplay.Columns.Count;
            this.RowNum = DataTableForDisplay.Rows.Count;
            for (int i = 0; i < ColNum; i++)
            {
                this.DataGridTable.Columns.Add(DataTableForDisplay.Columns[i].ColumnName, DataTableForDisplay.Columns[i].ColumnName);
            }
            for (int i = 0; i < RowNum; i++)
            {
                DataGridTable.Rows.Add();
                for (int j = 0; j < ColNum; j++)
                {
                    this.DataGridTable.Rows[i].Cells[j].Value = DataTableForDisplay.Rows[i][j].ToString();
                }
            }

            DataGridTable.ReadOnly = true;
            DataGridTable.AutoResizeColumns();
            DataGridTable.AllowUserToResizeColumns = true;

            for (int i = 0; i < ColNum; i++)
            {
                HeaderList.Insert(i, DataTableForDisplay.Columns[i].ColumnName);
                InsertItem                 = new ToolStripMenuItem();
                InsertItem.Text            = HeaderList[i];
                InsertItem.ImageIndex      = i;
                InsertItem.CheckOnClick    = true;
                InsertItem.Checked         = true;
                InsertItem.CheckedChanged += new EventHandler(InsertItem_CheckedChanged);
                this.ColcontextMenuStrip.Items.Insert(i, InsertItem);
            }
            for (int i = 0; i < DataGridTable.ColumnCount; i++)
            {
                Menu.MenuItems.Add(DataGridTable.Columns[i].ToString(), Menu_Click);
            }


            DataAdvanceOption = new DataViewAdvance();
            this.SetAdvancedOptions();
            DataAdvanceOption.Visible                  = false;
            DataAdvanceOption.AdvSrchOption.Click     += new EventHandler(AdvancedSearchClick);
            DataAdvanceOption.ColmDisplayOption.Click += new EventHandler(ColumnDisplayClick);
            DataAdvanceOption.AdvSrcCancel.Click      += new EventHandler(AdvSrcCancel_Click);
            DataAdvanceOption.FormClosing             += new FormClosingEventHandler(DataAdvanceOption_FormClosing);

            this.DataGridTable.SortCompare += new DataGridViewSortCompareEventHandler(Custom_SortCompare);

            //Adding event back
            DataGridTable.SelectionChanged += new System.EventHandler(this.DataGridTable_SelectionChanged);

            RequestStop();
        }