public static AssetInformation getAsset(String assetId) { String idColumn = ColumnData.GetName(Net7.Table_assets._base_id); String query = "SELECT " + ColumnData.GetName(Net7.Table_assets._base_id) + ", " + ColumnData.GetName(Net7.Table_assets._descr) + ", " + ColumnData.GetName(Net7.Table_assets._filename) + " FROM " + Net7.Tables.assets.ToString() + " WHERE " + idColumn + " = " + DB.QueryParameterCharacter + idColumn; DataTable dataTable = DB.Instance.executeQuery(query, new String[] { idColumn }, new String[] { assetId }); AssetInformation assetInformation = null; if (dataTable.Rows.Count == 1) { DataRow dataRow = dataTable.Rows[0]; assetInformation = new AssetInformation(); assetInformation.base_id = ColumnData.GetInt32(dataRow, Net7.Table_assets._base_id); assetInformation.descr = ColumnData.GetString(dataRow, Net7.Table_assets._descr); assetInformation.filename = ColumnData.GetString(dataRow, Net7.Table_assets._filename); } return(assetInformation); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { switch ((Net7.Table_item_ammo)dataBinding.enumeration) { case Net7.Table_item_ammo._ammo_type_id: { ComboBox ammoType = (ComboBox)dataBinding.control; ammoType.Items.Clear(); ammoType.Items.AddRange(Database.getItemAmmoTypes(102)); ammoType.Items.AddRange(Database.getItemAmmoTypes(101)); } return(false); case Net7.Table_item_ammo._damage_type: { ComboBox damageType = (ComboBox)dataBinding.control; damageType.Items.Clear(); damageType.Items.AddRange(Database.getItemDamageTypes()); return(false); } case Net7.Table_item_ammo._fire_effect: dataBinding.control.Text = (dataRow == null) ? "0" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_ammo._range_100: dataBinding.control.Text = (dataRow == null) ? "0" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_ammo._damage_100: dataBinding.control.Text = (dataRow == null) ? "10" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
/// <summary> /// <para>Activate this editor</para> /// <para>Tasks include displaying the proper TabPage and displaying the "first" record</para> /// </summary> /// <returns>The DataRow of the "main" table.</returns> public String activate() { // TODO: This should be one of the first functions called // Check whether there are tables and if not then generate an error System.Data.DataRow primaryTableCurrentRow = null; foreach (TableHandler tableHandler in listTableHandler) { if (primaryTableCurrentRow == null) { // Assumes that the first table is the primary one primaryTableCurrentRow = tableHandler.getTableIO().activate(); } else { // Primary table activates every tab tableHandler.getTableIO().activate(); } } String primaryTableId = null; if (primaryTableCurrentRow != null) { primaryTableId = ColumnData.GetString(primaryTableCurrentRow, Net7.Table_item_base._id); } return(primaryTableId); }
public static CodeValue[] getItemAmmoTypes(Int32 subCategory) { List <CodeValue> codeValueList = new List <CodeValue>(); if (subCategory == 100) { // Override the ammo type for beam weapons codeValueList.Add(CodeValue.Formatted(4, "EMP")); codeValueList.Add(CodeValue.Formatted(3, "Energy")); codeValueList.Add(CodeValue.Formatted(2, "Plasma")); } else { String query = "SELECT " + ColumnData.GetName(Net7.Table_item_type._id) + ", " + ColumnData.GetName(Net7.Table_item_type._name) + " FROM " + Net7.Tables.item_ammo_type.ToString() + " WHERE " + ColumnData.GetName(Net7.Table_item_ammo_type._sub_category) + " = " + subCategory + " ORDER BY " + ColumnData.GetName(Net7.Table_item_type._name); DataTable dataTable = DB.Instance.executeQuery(query, null, null); foreach (DataRow dataRow in dataTable.Rows) { codeValueList.Add(CodeValue.Formatted(ColumnData.GetInt32(dataRow, Net7.Table_item_type._id), ColumnData.GetString(dataRow, Net7.Table_item_type._name))); } } return(codeValueList.ToArray()); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { switch ((Net7.Table_item_engine)dataBinding.enumeration) { case Net7.Table_item_engine._rest_race: case Net7.Table_item_engine._rest_prof: // Handles both race and profession restrictions return(Restrictions.displayField(dataRow, Net7.Table_item_engine._rest_race, Net7.Table_item_engine._rest_prof)); case Net7.Table_item_engine._warp: dataBinding.control.Text = (dataRow == null) ? "2000" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_engine._signature_100: dataBinding.control.Text = (dataRow == null) ? "40000" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_engine._thrust_100: dataBinding.control.Text = (dataRow == null) ? "50" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_engine._warp_drain_100: dataBinding.control.Text = (dataRow == null) ? "5.5" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
public static Boolean getItemCategorySubcategory(String itemId, out String category, out String subCategory) { String itemColumn = ColumnData.GetName(Net7.Table_item_base._id); String query = "SELECT " + ColumnData.GetName(Net7.Table_item_base._category) + ", " + ColumnData.GetName(Net7.Table_item_base._sub_category) + " FROM " + Net7.Tables.item_base.ToString() + " WHERE " + itemColumn + " = " + DB.QueryParameterCharacter + itemColumn; DataTable dataTable = DB.Instance.executeQuery(query, new String[] { itemColumn }, new String[] { itemId }); if (dataTable.Rows.Count == 1) { DataRow dataRow = dataTable.Rows[0]; category = ColumnData.GetString(dataRow, Net7.Table_item_base._category); subCategory = ColumnData.GetString(dataRow, Net7.Table_item_base._sub_category); return(true); } category = ""; subCategory = ""; return(false); }
public static List <CodeValue> getItems(String category, String subCategory) { List <CodeValue> valueList = new List <CodeValue>(); String categoryColumn = ColumnData.GetName(Net7.Table_item_base._category); String subCategoryColumn = ColumnData.GetName(Net7.Table_item_base._sub_category); String query = "SELECT " + ColumnData.GetName(Net7.Table_item_base._id) + ", " + ColumnData.GetName(Net7.Table_item_base._name) + " FROM " + Net7.Tables.item_base.ToString() + " WHERE " + categoryColumn + " = " + DB.QueryParameterCharacter + categoryColumn + " AND " + subCategoryColumn + " = " + DB.QueryParameterCharacter + subCategoryColumn + " ORDER BY " + ColumnData.GetName(Net7.Table_item_base._name); DataTable dataTable = DB.Instance.executeQuery(query, new String[] { categoryColumn, subCategoryColumn }, new String[] { category, subCategory }); CodeValue codeValue; foreach (DataRow dataRow in dataTable.Rows) { codeValue = new CodeValue(ColumnData.GetInt32(dataRow, Net7.Table_item_base._id), ColumnData.GetString(dataRow, Net7.Table_item_base._name)); valueList.Add(codeValue); } return(valueList); }
public static Mission getMission(String id) { Mission mission = null; String parameter = "id"; String query = DB.SELECT + "*" + DB.FROM + Net7.Tables.missions + DB.WHERE + ColumnData.GetName(Net7.Table_missions._mission_id) + DB.EQUALS + DB.QueryParameterCharacter + parameter; DataTable dataTable = DB.Instance.executeQuery(query, new String[] { parameter }, new String[] { id }); if (dataTable.Rows.Count == 1) { mission = new Mission(); mission.setId(id); mission.setXml(ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_XML)); mission.setName(ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_name)); String type = ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_type); CommonTools.MissionType missionType; CommonTools.Enumeration.TryParse <CommonTools.MissionType>(type, out missionType); mission.setType(missionType); mission.setKey(ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_key)); } return(mission); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { switch ((Net7.Table_item_beam)dataBinding.enumeration) { case Net7.Table_item_beam._rest_race: case Net7.Table_item_beam._rest_prof: // Handles both race and profession restrictions return(Restrictions.displayField(dataRow, Net7.Table_item_beam._rest_race, Net7.Table_item_beam._rest_prof)); case Net7.Table_item_beam._fire_effect: dataBinding.control.Text = (dataRow == null) ? "0" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_beam._range_100: dataBinding.control.Text = (dataRow == null) ? "1000" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_beam._energy_100: dataBinding.control.Text = (dataRow == null) ? "10" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_beam._reload_100: dataBinding.control.Text = (dataRow == null) ? "4" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_beam._damage_100: dataBinding.control.Text = (dataRow == null) ? "10" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
static public Boolean getAssetCatSubCatFromId(String id, out String category, out String subCategory) { String idColumn = ColumnData.GetName(Net7.Table_assets._base_id); String query = "SELECT " + ColumnData.GetName(Net7.Table_assets._main_cat) + ", " + ColumnData.GetName(Net7.Table_assets._sub_cat) + " FROM " + Net7.Tables.assets.ToString() + " WHERE " + idColumn + " = " + DB.QueryParameterCharacter + idColumn; DataTable dataTable = DB.Instance.executeQuery(query, new String[] { idColumn }, new String[] { id }); if (dataTable.Rows.Count == 1) { DataRow dataRow = dataTable.Rows[0]; category = ColumnData.GetString(dataRow, Net7.Table_assets._main_cat); subCategory = ColumnData.GetString(dataRow, Net7.Table_assets._sub_cat); return(true); } else { category = ""; subCategory = ""; return(false); } }
public static String getFirstMissionId() { //return "8"; String query = DB.SELECT + ColumnData.GetName(Net7.Table_missions._mission_id) + DB.FROM + Net7.Tables.missions.ToString() + DB.LIMIT1; DataTable dataTable = DB.Instance.executeQuery(query, null, null); return(dataTable.Rows.Count == 0 ? null : ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_id)); }
static public String getVersion() { String query = "SELECT " + ColumnData.GetName(Net7.Table_versions._Version) + " FROM " + Net7.Tables.versions.ToString() + " WHERE " + ColumnData.GetName(Net7.Table_versions._EName) + " = 'Item'"; DataTable dataTable = DB.Instance.executeQuery(query, null, null); return(ColumnData.GetString(dataTable.Rows[0], Net7.Table_versions._Version)); }
/// <summary> /// Retrieve the id of the primary table /// </summary> /// <returns></returns> public String getPrimaryId() { String primaryTableId = ""; if (listTableHandler.Count != 0) { System.Data.DataRow primaryTableCurrentRow = primaryTableCurrentRow = listTableHandler[0].getTableIO().getCurrentDataRow(); if (primaryTableCurrentRow != null) { primaryTableId = ColumnData.GetString(primaryTableCurrentRow, Net7.Table_item_base._id); } } return(primaryTableId); }
public void setDescription() { DataTable dataTable = DB.Instance.executeQuery(m_data.m_descriptionQuery, new String[] { m_data.m_descriptionParameter }, new String[] { m_fields.m_field.Text }); String description = ""; if (dataTable != null && dataTable.Rows.Count == 1) { DataRow dataRow = dataTable.Rows[0]; description = ColumnData.GetString(dataRow, m_data.m_descriptionColumn); } m_fields.m_description.Text = description; m_data.m_widgetModified.widgetModified(m_fields.m_field); }
public static AssetInformation[] getAssetItems(String categoryValue, String subCategoryValue) { String categoryColumn = ColumnData.GetName(Net7.Table_assets._main_cat); String subCategoryColumn = ColumnData.GetName(Net7.Table_assets._sub_cat); String[] parameters; String[] values; List <AssetInformation> valueList = new List <AssetInformation>(); String query = "SELECT " + ColumnData.GetName(Net7.Table_assets._base_id) + ", " + ColumnData.GetName(Net7.Table_assets._descr) + ", " + ColumnData.GetName(Net7.Table_assets._filename) + " FROM " + Net7.Tables.assets.ToString() + " WHERE " + categoryColumn + " = " + DB.QueryParameterCharacter + categoryColumn; if (subCategoryValue == null) { parameters = new String[] { categoryColumn }; values = new String[] { categoryValue }; } else { query += " AND " + subCategoryColumn + " = " + DB.QueryParameterCharacter + subCategoryColumn; parameters = new String[] { categoryColumn, subCategoryColumn }; values = new String[] { categoryValue, subCategoryValue }; } query += " ORDER BY " + ColumnData.GetName(Net7.Table_assets._filename); DataTable dataTable = DB.Instance.executeQuery(query, parameters, values); AssetInformation assetInformation; foreach (DataRow dataRow in dataTable.Rows) { assetInformation = new AssetInformation(); assetInformation.base_id = ColumnData.GetInt32(dataRow, Net7.Table_assets._base_id); assetInformation.descr = ColumnData.GetString(dataRow, Net7.Table_assets._descr); assetInformation.filename = ColumnData.GetString(dataRow, Net7.Table_assets._filename); valueList.Add(assetInformation); } return(valueList.ToArray()); }
public static List <String> getEveryItem() { List <String> items = new List <String>(); String query = "SELECT " + ColumnData.GetName(Net7.Table_item_base._id) + " FROM " + Net7.Tables.item_base.ToString() + " ORDER BY " + ColumnData.GetName(Net7.Table_item_base._id); DataTable dataTable = DB.Instance.executeQuery(query, null, null); foreach (DataRow dataRow in dataTable.Rows) { items.Add(ColumnData.GetString(dataRow, Net7.Table_item_base._id)); } return(items); }
public static String[] getAssetCategories() { List <String> valueList = new List <String>(); String query = "SELECT DISTINCT " + ColumnData.GetName(Net7.Table_assets._main_cat) + " FROM " + Net7.Tables.assets.ToString() + " ORDER BY " + ColumnData.GetName(Net7.Table_assets._main_cat); DataTable dataTable = DB.Instance.executeQuery(query, null, null); foreach (DataRow dataRow in dataTable.Rows) { valueList.Add(ColumnData.GetString(dataRow, Net7.Table_assets._main_cat)); } return(valueList.ToArray()); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { Net7.Table_item_manufacture manuField = (Net7.Table_item_manufacture)dataBinding.enumeration; switch (manuField) { case Net7.Table_item_manufacture._difficulty: if (dataRow == null) { System.Windows.Forms.ComboBox difficulty = (System.Windows.Forms.ComboBox)dataBinding.control; difficulty.SelectedItem = difficulty.Items[0]; return(true); } break; case Net7.Table_item_manufacture._comp_1: case Net7.Table_item_manufacture._comp_2: case Net7.Table_item_manufacture._comp_3: case Net7.Table_item_manufacture._comp_4: case Net7.Table_item_manufacture._comp_5: case Net7.Table_item_manufacture._comp_6: { int componentIndex = getComponentIndexFromEnum(manuField); if (componentIndex == -1) { // TODO: Handle data error throw (new Exception("Invalid component index")); } else { dataBinding.control.Text = (dataRow == null) ? UnspecifiedComponentId : ColumnData.GetString(dataRow, dataBinding.enumeration); if (dataBinding.control.Text.Length == 0) { dataBinding.control.Text = UnspecifiedComponentId; } m_listComponentFields[componentIndex].setDescription(); return(true); } } } return(false); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { switch ((Net7.Table_item_reactor)dataBinding.enumeration) { case Net7.Table_item_reactor._rest_race: case Net7.Table_item_reactor._rest_prof: // Handles both race and profession restrictions return(Restrictions.displayField(dataRow, Net7.Table_item_reactor._rest_race, Net7.Table_item_reactor._rest_prof)); case Net7.Table_item_reactor._cap_100: dataBinding.control.Text = (dataRow == null) ? "134" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_reactor._recharge_100: dataBinding.control.Text = (dataRow == null) ? "5.4" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
public static CodeValue[] getItemTypes() { List <CodeValue> valueList = new List <CodeValue>(); String query = "SELECT " + ColumnData.GetName(Net7.Table_item_type._id) + ", " + ColumnData.GetName(Net7.Table_item_type._name) + " FROM " + Net7.Tables.item_type.ToString() + " ORDER BY " + ColumnData.GetName(Net7.Table_item_type._name); DataTable dataTable = DB.Instance.executeQuery(query, null, null); foreach (DataRow dataRow in dataTable.Rows) { valueList.Add(CodeValue.Formatted(ColumnData.GetInt32(dataRow, Net7.Table_item_type._id), ColumnData.GetString(dataRow, Net7.Table_item_type._name))); } return(valueList.ToArray()); }
public void recordCancel() { if (m_state.Equals(TableIO.State.Edit)) { String currentId = ColumnData.GetString(m_dataRow, m_idField); setState(TableIO.State.View); if (recordSearch("SELECT * FROM " + m_tableName + " WHERE " + ColumnData.GetName(m_idField) + " = " + currentId)) { viewRecord(); } } else { setState(TableIO.State.View); } }
static public String getAssetFromDescription(String description) { String descColumn = ColumnData.GetName(Net7.Table_assets._descr); String query = "SELECT " + ColumnData.GetName(Net7.Table_assets._base_id) + " FROM " + Net7.Tables.assets.ToString() + " WHERE " + descColumn + " = " + DB.QueryParameterCharacter + descColumn; DataTable dataTable = DB.Instance.executeQuery(query, new String[] { descColumn }, new String[] { description }); String assetId = ""; if (dataTable.Rows.Count == 1) { DataRow dataRow = dataTable.Rows[0]; assetId = ColumnData.GetString(dataRow, Net7.Table_assets._base_id); } return(assetId); }
public static String[] getAssetSubCategories(String categoryValue) { List <String> valueList = new List <String>(); String categoryColumn = ColumnData.GetName(Net7.Table_assets._main_cat); String query = "SELECT DISTINCT " + ColumnData.GetName(Net7.Table_assets._sub_cat) + " FROM " + Net7.Tables.assets.ToString() + " WHERE " + categoryColumn + " = " + DB.QueryParameterCharacter + categoryColumn + " ORDER BY " + ColumnData.GetName(Net7.Table_assets._sub_cat); DataTable dataTable = DB.Instance.executeQuery(query, new String[] { categoryColumn }, new String[] { categoryValue }); foreach (DataRow dataRow in dataTable.Rows) { valueList.Add(ColumnData.GetString(dataRow, Net7.Table_assets._sub_cat)); } return(valueList.ToArray()); }
/// <summary> /// <para> /// Display the value within the appropriate DataRow column into /// the field contained within DataBinding</para> /// </summary> /// <returns> /// <para>True: the field has been displayed.</para> /// <para>False: the field has not been displayed, use the default code </para> /// </returns> public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { switch ((Net7.Table_item_missile)dataBinding.enumeration) { case Net7.Table_item_missile._rest_race: case Net7.Table_item_missile._rest_prof: // Handles both race and profession restrictions return(Restrictions.displayField(dataRow, Net7.Table_item_missile._rest_race, Net7.Table_item_missile._rest_prof)); case Net7.Table_item_missile._ammo_per_shot: dataBinding.control.Text = (dataRow == null) ? "1" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_missile._energy_100: dataBinding.control.Text = (dataRow == null) ? "50" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); case Net7.Table_item_missile._reload_100: dataBinding.control.Text = (dataRow == null) ? "10" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
private void btnSearch_Click(object sender, EventArgs e) { String query = ""; String filter = ""; List <String> sqlParameters = new List <String>(); List <String> sqlValues = new List <String>(); int parameterId = 0; foreach (SearchCriteria searchCriteria in searchSearchCriteriaLst.Items) { if (filter.Length != 0) { filter += " AND "; } filter += searchCriteria.getQuery() + parameterId.ToString(); sqlParameters.Add(searchCriteria.sqlParameter + parameterId.ToString()); sqlValues.Add(searchCriteria.sqlValue); parameterId++; } if (filter.Length != 0) { searchResultList.Items.Clear(); query = "SELECT " + ColumnData.GetName(Net7.Table_item_base._id) + "," + ColumnData.GetName(Net7.Table_item_base._name) + "," + ColumnData.GetName(Net7.Table_item_base._category) + "," + ColumnData.GetName(Net7.Table_item_base._sub_category) + "," + ColumnData.GetName(Net7.Table_item_base._level) + "," + ColumnData.GetName(Net7.Table_item_base._status) + " FROM " + Net7.Tables.item_base; if (m_table.Equals(Net7.Tables.item_base)) { query += DB.WHERE; } else { query += "," + m_table + DB.WHERE + ColumnData.GetName(Net7.Table_item_base._id) + DB.EQUALS + m_primaryId + " AND "; } query += filter; DataTable dataTable = DB.Instance.executeQuery(query, sqlParameters.ToArray(), sqlValues.ToArray()); searchResultCount.Text = dataTable.Rows.Count.ToString() + " items"; ListViewItem listViewItem; Int32 code; Items.ItemCategory categoryValue; String category; Items.ItemSubCategory subCategoryValue; String subCategory; foreach (DataRow dataRow in dataTable.Rows) { code = ColumnData.GetInt32(dataRow, Net7.Table_item_base._category); categoryValue = (Items.ItemCategory)code; category = Items.CategoryLookup(categoryValue); code = ColumnData.GetInt32(dataRow, Net7.Table_item_base._sub_category); subCategoryValue = (Items.ItemSubCategory)code; subCategory = Items.SubCategoryLookup(subCategoryValue); listViewItem = new ListViewItem(new String[] { ColumnData.GetString(dataRow, Net7.Table_item_base._id), ColumnData.GetString(dataRow, Net7.Table_item_base._name), category, subCategory, ColumnData.GetString(dataRow, Net7.Table_item_base._level), ColumnData.GetString(dataRow, Net7.Table_item_base._status) }); searchResultList.Items.Add(listViewItem); } } }
public Boolean displayField(DataBinding dataBinding, DataRow dataRow) { if (dataBinding.enumeration.Equals(Net7.Table_item_base._id)) { String code = (dataRow == null) ? "" : ColumnData.GetString(dataRow, dataBinding.enumeration); m_baseManufacturingBtn.ForeColor = (code.Length == 0 || Database.hasManufacturing(code)) ? Color.Black : Color.Red; } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._category)) { // Show the relevant tab pages given the category Int32 code = (dataRow == null) ? 50 : ColumnData.GetInt32(dataRow, dataBinding.enumeration); Items.ItemCategory category = (Items.ItemCategory)code; TabPage[] listTabPages; if (m_categoryTabPages.TryGetValue(category, out listTabPages)) { m_gui.setTabPages(listTabPages); } } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._sub_category)) { // Show the relevant tab pages given the sub-category Int32 code = (dataRow == null) ? 0 : ColumnData.GetInt32(dataRow, dataBinding.enumeration); Items.ItemSubCategory subCategory = (Items.ItemSubCategory)code; TabPage[] listTabPages; if (m_subCategoryTabPages.TryGetValue(subCategory, out listTabPages)) { m_gui.setTabPages(listTabPages); } else if (m_subCategoryTabPages.TryGetValue(Items.ItemSubCategory.Other, out listTabPages)) { // Assume that the sub-category refers to a component m_gui.setTabPages(listTabPages); } Int32 category = (dataRow == null) ? 0 : ColumnData.GetInt32(dataRow, Net7.Table_item_base._category); CodeValue[] listSubCategory = Database.getItemSubCategories((int)category); ComboBox subCategories = (ComboBox)dataBinding.control; subCategories.Items.Clear(); subCategories.Items.AddRange(listSubCategory); // Rely on the child tables (i.e. Devices, Beams, Missile/Projectile Launcher) // to activate the restrictions when needed Restrictions.displayField(null, null, null); Restrictions.enableField(false); Int32 subCategoryId = (dataRow == null) ? 0 : ColumnData.GetInt32(dataRow, dataBinding.enumeration); m_gui.setEditor(Items.getEditorType(subCategory), false); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._description)) { // Convert from E&B style String description = (dataRow == null) ? "" : ColumnData.GetString(dataRow, dataBinding.enumeration); dataBinding.control.Text = Utility.ParseDescription(description); return(true); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._custom_flag)) { ((CheckBox)dataBinding.control).Checked = (dataRow == null) ? false : ColumnData.GetBoolean(dataRow, dataBinding.enumeration); return(true); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._2d_asset)) { dataBinding.control.Text = (dataRow == null) ? "744" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._max_stack)) { dataBinding.control.Text = (dataRow == null) ? "1" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._3d_asset)) { dataBinding.control.Text = (dataRow == null) ? "69" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } else if (dataBinding.enumeration.Equals(Net7.Table_item_base._price)) { dataBinding.control.Text = (dataRow == null) ? "0" : ColumnData.GetString(dataRow, dataBinding.enumeration); return(true); } return(false); }
public void displayFields(DataRow dataRow) { tabsMain.SelectedIndex = 0; txtId.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._id); cboLevel.SelectedIndex = dataRow == null ? 0 : ColumnData.GetInt32(dataRow, Database_net7_db.Table_item_base._level) - 1; SetCategory(dataRow == null ? 0 : ColumnData.GetInt32(dataRow, Database_net7_db.Table_item_base._category)); SetSubCategory(dataRow == null ? 0 : ColumnData.GetInt32(dataRow, Database_net7_db.Table_item_base._sub_category)); // TODO: Handle the type column //txtPrice.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._price); //txtStackSize.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._max_stack); //txtName.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._name); txtDescription.Text = dataRow == null ? "" : Utility.ParseDescription(ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._description)); //RefreshManufacturers( dataRow == null ? 0 : ColumnData.GetInt32(dataRow, Database_net7_db.Table_item_base._manufacturer)); //txt2DAsset.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._2d_asset); //txt3DAsset.Text = dataRow == null ? "" : ColumnData.GetString(dataRow, Database_net7_db.Table_item_base._3d_asset); //chkNoTrade.Checked = dataRow == null ? false : ColumnData.GetBoolean(dataRow, Database_net7_db.Table_item_base._no_trade); //chkNoStore.Checked = dataRow == null ? false : ColumnData.GetBoolean(dataRow, Database_net7_db.Table_item_base._no_store); //chkNoDestroy.Checked = dataRow == null ? false : ColumnData.GetBoolean(dataRow, Database_net7_db.Table_item_base._no_destroy); //chkNoManu.Checked = dataRow == null ? false : ColumnData.GetBoolean(dataRow, Database_net7_db.Table_item_base._no_manu); //chkUnique.Checked = dataRow == null ? false : ColumnData.GetBoolean(dataRow, Database_net7_db.Table_item_base._unique); //Obtain the category (in case data was corrupt) int SubCat = Utility.ParseParen(cboSubCategory.Text); DataTable dataTable; int ItemID = txtId.Text.Length == 0 ? 0 : Int32.Parse(txtId.Text); switch ((Items.ItemSubCategory)SubCat) { case Items.ItemSubCategory.Beam_Weapon: dataTable = DB.executeQuery(DB.DatabaseName.net7_db, DB.getQueryBeam(ItemID.ToString())); if (dataTable.Rows.Count == 1) { dataRow = dataTable.Rows[0]; cboBeamDamageType.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._damage_type); txtBeamFireEffect.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._fire_effect); txtBeamRange.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._range_100); txtBeamEnergy.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._energy_100); txtBeamReload.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._reload_100); txtBeamDamage100.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._damage_100); txtBeamDamage200.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_beam._damage_200); } LoadEffects(ItemID); break; case Items.ItemSubCategory.Missle_Launcher: dataTable = DB.executeQuery(DB.DatabaseName.net7_db, DB.getQueryMissile(ItemID.ToString())); if (dataTable.Rows.Count == 1) { dataRow = dataTable.Rows[0]; txtMissleAmmoName.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_missle._ammo); txtMissleRoundsFired.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_missle._ammo_per_shot); //TODO: Add field energy_100 in table item_missle //txtMissleEnergy.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_missle._energy_100); txtMissleReload100.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_missle._reload_100); txtMissleReload200.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_missle._reload_200); } LoadEffects(ItemID); break; case Items.ItemSubCategory.Projectile_Launcher: dataTable = DB.executeQuery(DB.DatabaseName.net7_db, DB.getQueryProjectile(ItemID.ToString())); if (dataTable.Rows.Count == 1) { dataRow = dataTable.Rows[0]; txtProjectileAmmoName.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._ammo); txtProjectileRoundsFired.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._ammo_per_shot); txtProjectileRange.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._range_100); //txtProjectileEnergy.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._energy_100); txtProjectileReload100.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._reload_100); txtProjectileReload200.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_projectile._reload_200); } LoadEffects(ItemID); break; case Items.ItemSubCategory.Ammo: dataTable = DB.executeQuery(DB.DatabaseName.net7_db, DB.getQueryAmmo(ItemID.ToString())); if (dataTable.Rows.Count == 1) { //TODO: Load the launcher name dataRow = dataTable.Rows[0]; cboAmmoLauncher.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._launcher_id); cboAmmoDamageType.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._damage_type); txtAmmoVisual.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._fire_effect); txtAmmoManouv.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._maneuv_100); txtAmmoRange.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._range_100); txtAmmoDamage100.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._damage_100); txtAmmoDamage200.Text = ColumnData.GetString(dataRow, Database_net7_db.Table_item_ammo._damage_200); } break; } }
public void viewRecord() { // Suspend the value changed event notification since the user is // not actually changing the values m_suspendValueChanged = true; // Process each widget bound to a database field foreach (DataBinding dataBinding in listDataBinding) { // Is there an override within the record manager? if (dataBinding.enumeration != null && !m_recordManager.displayField(dataBinding, m_dataRow)) { // Use the standard data manager if (dataBinding.control != null) { if (dataBinding.control.GetType() == typeof(CheckBox)) { ((CheckBox)dataBinding.control).Checked = (m_dataRow == null) ? false : ColumnData.GetBoolean(m_dataRow, dataBinding.enumeration); } else if (dataBinding.control.GetType() == typeof(ListBox)) { // TODO: If the DB value is not available in the list then select first entry and enter edit mode ListBox listBox = (ListBox)dataBinding.control; CodeValue codeValue = new CodeValue(); codeValue.code = (m_dataRow == null) ? 0 : ColumnData.GetInt32(m_dataRow, dataBinding.enumeration); if (m_dataRow == null) { codeValue = listBox.Items.Count == 0 ? null : (CodeValue)listBox.Items[0]; } else { codeValue.code = ColumnData.GetInt32(m_dataRow, dataBinding.enumeration); } listBox.SelectedItem = codeValue; } else if (dataBinding.control.GetType() == typeof(ComboBox)) { // TODO: If the DB value is not available in the list then select first entry and enter edit mode ComboBox comboBox = (ComboBox)dataBinding.control; CodeValue codeValue = new CodeValue(); codeValue.code = (m_dataRow == null) ? 0 : ColumnData.GetInt32(m_dataRow, dataBinding.enumeration); if (m_dataRow == null) { codeValue = comboBox.Items.Count == 0 ? null : (CodeValue)comboBox.Items[0]; } else { codeValue.code = ColumnData.GetInt32(m_dataRow, dataBinding.enumeration); } comboBox.SelectedItem = codeValue; } else { dataBinding.control.Text = (m_dataRow == null) ? "" : ColumnData.GetString(m_dataRow, dataBinding.enumeration); } } } } m_suspendValueChanged = false; // There's a record available so enable the fields enableFields(true); // There's a record available so we can add a new one, delete the current // one, but cannot save nor cancel it (it's not being added nor modified) if (!m_suspendGuiChanged) { m_gui.setGuiEnabled(true, true, false); } }
public static void setMission(Mission mission, Boolean newMission) { String query; String[] parameters = new String[] { "id", "xml", "name", "key", "type" }; String[] values = new String[] { mission.getId(), mission.getXML(), mission.getName(), mission.getKey(), ((int)mission.getType()).ToString() }; if (newMission) { writeXmlLog(mission, LogAction.Add); query = "INSERT INTO " + Net7.Tables.missions + " ( " + ColumnData.GetName(Net7.Table_missions._mission_XML) + "," + ColumnData.GetName(Net7.Table_missions._mission_name) + "," + ColumnData.GetName(Net7.Table_missions._mission_key) + "," + ColumnData.GetName(Net7.Table_missions._mission_type) + " )" + " VALUES (" + DB.QueryParameterCharacter + parameters[1] + "," + DB.QueryParameterCharacter + parameters[2] + "," + DB.QueryParameterCharacter + parameters[3] + "," + DB.QueryParameterCharacter + parameters[4] + "); " + DB.SELECT + ColumnData.GetName(Net7.Table_missions._mission_id) + DB.FROM + Net7.Tables.missions + DB.WHERE + ColumnData.GetName(Net7.Table_missions._mission_id) + " IS NULL;"; // Retrieve the last inserted row DataTable dataTable = DB.Instance.executeQuery(query, parameters, values); // Update the XML mission ID with that of the database auto-created ID mission.setId(ColumnData.GetString(dataTable.Rows[0], Net7.Table_missions._mission_id)); values[0] = mission.getId(); values[1] = mission.getXML(); query = "UPDATE " + Net7.Tables.missions + " SET " + ColumnData.GetName(Net7.Table_missions._mission_XML) + DB.EQUALS + DB.QueryParameterCharacter + parameters[1] + DB.WHERE + ColumnData.GetName(Net7.Table_missions._mission_id) + DB.EQUALS + DB.QueryParameterCharacter + parameters[0]; } else { writeXmlLog(mission, LogAction.Edit); query = "UPDATE " + Net7.Tables.missions + " SET " + ColumnData.GetName(Net7.Table_missions._mission_XML) + DB.EQUALS + DB.QueryParameterCharacter + parameters[1] + "," + ColumnData.GetName(Net7.Table_missions._mission_name) + DB.EQUALS + DB.QueryParameterCharacter + parameters[2] + "," + ColumnData.GetName(Net7.Table_missions._mission_key) + DB.EQUALS + DB.QueryParameterCharacter + parameters[3] + "," + ColumnData.GetName(Net7.Table_missions._mission_type) + DB.EQUALS + DB.QueryParameterCharacter + parameters[4] + DB.WHERE + ColumnData.GetName(Net7.Table_missions._mission_id) + DB.EQUALS + DB.QueryParameterCharacter + parameters[0]; } DB.Instance.executeQuery(query, parameters, values); }