Beispiel #1
0
        public String createSelect(Enum[] field, Net7.Tables table, Enum idField, String value, Int32 queryCount)
        {
            String query = "";

            foreach (Enum enumField in field)
            {
                if (query.Length == 0)
                {
                    query = SELECT;
                }
                else
                {
                    query += ",";
                }
                query += ColumnData.GetName(enumField);
            }
            query += FROM
                     + table.ToString()
                     + WHERE
                     + ColumnData.GetName(idField)
                     + " = "
                     + DB.QueryParameterCharacter
                     + idField.ToString() + queryCount.ToString()
                     + ";";
            //System.Windows.Forms.MessageBox.Show(query, value);
            return(query);
        }
        private void onTableChanged(object sender, EventArgs e)
        {
            searchSearchCriteriaLst.Items.Clear();
            m_table = (Net7.Tables)guiTableCbo.SelectedItem;

            ColumnData.ColumnDataInfo[] fields = null;
            switch (m_table)
            {
            case Net7.Tables.item_base:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_base>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_base._id);
                break;

            case Net7.Tables.item_ammo:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_ammo>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_ammo._item_id);
                break;

            case Net7.Tables.item_beam:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_beam>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_beam._item_id);
                break;

            case Net7.Tables.item_device:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_device>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_device._item_id);
                break;

            case Net7.Tables.item_engine:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_engine>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_engine._item_id);
                break;

            case Net7.Tables.item_missile:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_missile>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_missile._item_id);
                break;

            case Net7.Tables.item_manufacture:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_manufacture>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_manufacture._item_id);
                break;

            case Net7.Tables.item_projectile:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_projectile>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_projectile._item_id);
                break;

            case Net7.Tables.item_reactor:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_reactor>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_reactor._item_id);
                break;

            case Net7.Tables.item_shield:
                fields      = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_shield>(true);
                m_primaryId = ColumnData.GetName(Net7.Table_item_shield._item_id);
                break;

            default:
                throw (new Exception("FrmItemTree.onTableChanged() does not handle the table " + m_table.ToString()));
            }
            m_dlgSearchCriteria.configure(fields);
        }
        private void onTableChanged(object sender, EventArgs e)
        {
            searchSearchCriteriaLst.Items.Clear();
            m_table = (Net7.Tables)guiTableCbo.SelectedItem;

            ColumnData.ColumnDataInfo[] fields = null;
            switch (m_table)
            {
                case Net7.Tables.item_base:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_base>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_base._id);
                    break;
                case Net7.Tables.item_ammo:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_ammo>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_ammo._item_id);
                    break;
                case Net7.Tables.item_beam:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_beam>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_beam._item_id);
                    break;
                case Net7.Tables.item_device:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_device>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_device._item_id);
                    break;
                case Net7.Tables.item_engine:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_engine>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_engine._item_id);
                    break;
                case Net7.Tables.item_missile:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_missile>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_missile._item_id);
                    break;
                case Net7.Tables.item_manufacture:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_manufacture>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_manufacture._item_id);
                    break;
                case Net7.Tables.item_projectile:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_projectile>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_projectile._item_id);
                    break;
                case Net7.Tables.item_reactor:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_reactor>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_reactor._item_id);
                    break;
                case Net7.Tables.item_shield:
                    fields = CommonTools.Enumeration.ToColumnDataInfo<Net7.Table_item_shield>(true);
                    m_primaryId = ColumnData.GetName(Net7.Table_item_shield._item_id);
                    break;
                default:
                    throw (new Exception("FrmItemTree.onTableChanged() does not handle the table " + m_table.ToString()));
            }
            m_dlgSearchCriteria.configure(fields);
        }
        private void onSearchClick(object sender, EventArgs e)
        {
            String        query         = "";
            List <String> sqlParameters = new List <String>();
            List <String> sqlValues     = new List <String>();
            int           parameterId   = 0;

            foreach (SearchCriteria searchCriteria in this.guiSearchCriteriaTbl.Items)
            {
                if (query.Length != 0)
                {
                    query += " AND ";
                }
                query += searchCriteria.getQuery() + parameterId.ToString();
                sqlParameters.Add(searchCriteria.sqlParameter + parameterId.ToString());
                sqlValues.Add(searchCriteria.sqlValue);
                parameterId++;
            }

            if (query.Length != 0)
            {
                String select = "";
                foreach (Enum column in m_columns)
                {
                    if (select.Length == 0)
                    {
                        select = DB.SELECT;
                    }
                    else
                    {
                        select += ",";
                    }
                    select += ColumnData.GetName(column);
                }
                query = select
                        + DB.FROM
                        + m_table.ToString()
                        + DB.WHERE
                        + query;

                DataTable dataTable = DB.Instance.executeQuery(query, sqlParameters.ToArray(), sqlValues.ToArray());
                guiResultTbl.Items.Clear();
                guiResultLbl.Text = dataTable.Rows.Count.ToString() + " items";

                ListViewItem  listViewItem;
                List <String> rowData = new List <string>();
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    rowData.Clear();
                    for (int columnIndex = 0; columnIndex < dataTable.Columns.Count; columnIndex++)
                    {
                        rowData.Add(dataRow[columnIndex].ToString());
                    }

                    listViewItem = new ListViewItem(rowData.ToArray());
                    guiResultTbl.Items.Add(listViewItem);
                }

                if (m_adjustedColumnWidths == false)
                {
                    List <int> columnWidth = new List <int>();
                    m_adjustedColumnWidths = true;
                    foreach (ColumnHeader columnHeader in guiResultTbl.Columns)
                    {
                        columnHeader.Width = -2;
                        columnWidth.Add(columnHeader.Width);
                    }
                }
            }
        }
        public void configure(Net7.Tables table)
        {
            if (!m_table.Equals(table))
            {
                // Clear the previous search results
                guiSearchCriteriaTbl.Items.Clear();
                guiResultTbl.Items.Clear();
                guiResultLbl.Text = "";
            }

            m_table = table;
            ColumnData.ColumnDataInfo[] fields = null;
            switch (m_table)
            {
            case Net7.Tables.effects:
                m_columns = new Enum[] { Net7.Table_effects._effect_id, Net7.Table_effects._description, Net7.Table_effects._base_asset_id };
                fields    = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_effects>(true);
                break;

            case Net7.Tables.factions:
                m_columns = new Enum[] { Net7.Table_factions._faction_id, Net7.Table_factions._name };
                fields    = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_factions>(true);
                break;

            case Net7.Tables.item_base:
                m_columns = new Enum[] { Net7.Table_item_base._id,
                                         Net7.Table_item_base._name,
                                         Net7.Table_item_base._category,
                                         Net7.Table_item_base._sub_category,
                                         Net7.Table_item_base._level,
                                         Net7.Table_item_base._status };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_item_base>(true);
                break;

            case Net7.Tables.missions:
                m_columns = new Enum[] { Net7.Table_missions._mission_id,
                                         Net7.Table_missions._mission_name,
                                         Net7.Table_missions._mission_type,
                                         Net7.Table_missions._mission_key };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_missions>(true);
                break;

            case Net7.Tables.mob_base:
                m_columns = new Enum[] { Net7.Table_mob_base._mob_id,
                                         Net7.Table_mob_base._name };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_mob_base>(true);
                break;

            case Net7.Tables.starbase_npcs:
                m_columns = new Enum[] { Net7.Table_starbase_npcs._npc_Id,
                                         Net7.Table_starbase_npcs._first_name,
                                         Net7.Table_starbase_npcs._last_name };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_starbase_npcs>(true);
                break;

            case Net7.Tables.sectors:
                m_columns = new Enum[] { Net7.Table_sectors._sector_id,
                                         Net7.Table_sectors._name };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_sectors>(true);
                break;

            case Net7.Tables.sector_objects:
                m_columns = new Enum[] { Net7.Table_sector_objects._sector_object_id,
                                         Net7.Table_sector_objects._name,
                                         Net7.Table_sector_objects._base_asset_id,
                                         Net7.Table_sector_objects._sector_id };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_sector_objects>(true);
                break;

            case Net7.Tables.skills:
                m_columns = new Enum[] { Net7.Table_skills._skill_id,
                                         Net7.Table_skills._name };
                fields = CommonTools.Enumeration.ToColumnDataInfo <Net7.Table_skills>(true);
                break;

            default:
                throw (new Exception("DlgSearch.configure() does not handle the table " + table.ToString()));
            }

            guiResultTbl.Columns.Clear();
            m_adjustedColumnWidths = false;

            ColumnHeader columnHeader;

            for (int columnIndex = 0; columnIndex < m_columns.Length; columnIndex++)
            {
                columnHeader = new ColumnHeader();
                columnHeader.DisplayIndex = columnIndex;
                columnHeader.Text         = ColumnData.GetName(m_columns[columnIndex]);
                columnHeader.Width        = -2;
                guiResultTbl.Columns.Add(columnHeader);
            }

            m_dlgSearchCriteria = new DlgSearchCriteria();
            m_dlgSearchCriteria.configure(fields);
        }