/// <summary>
 ///   <para>Initialize the possible item levels</para>
 /// </summary>
 /// <returns>The list of possible item levels</returns>
 /// <remarks>The array is indexed from 0 to 8 but the item levels range from 1 to 9</remarks>
 public static CodeValue[] getLevels()
 {
     CodeValue[] levels = new CodeValue[9];
     for (int levelIndex = 0; levelIndex < levels.Length; ++levelIndex)
     {
         levels[levelIndex] = new CodeValue(levelIndex + 1, (levelIndex + 1).ToString());
     }
     return levels;
 }
 public static Result isNonEmpty(CodeValue codeValue)
 {
     if (codeValue == null || codeValue.value == null)
     {
         return new DataValidation.Result("The value is empty");
     }
     else
     {
         return new DataValidation.Result();
     }
 }
 public Boolean getSelections(out CodeValue category, out CodeValue subCategory)
 {
     if (m_madeSelection)
     {
         category = (CodeValue)cboCategory.SelectedItem;
         subCategory = (CodeValue)cboSubCategory.SelectedItem;
     }
     else
     {
         category = null;
         subCategory = null;
     }
     return m_madeSelection;
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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 void onCategorySelectionChanged(object sender, EventArgs e)
        {
            ComboBox categoryCbo = (ComboBox)sender;
            CodeValue codeValue = (CodeValue)categoryCbo.SelectedItem;

            // Still in view mode since the change has not yet propagated
            if (m_gui.getCurrentEditor().getTableHandlers()[0].getTableIO().getState().Equals(TableIO.State.View))
            {
                // We are editing.  If the category is enabled then we can only select a component
                Items.ItemCategory category = (Items.ItemCategory)codeValue.code;
                if (!Items.isComponent(category))
                {
                    MessageBox.Show("The category must remain a component");
                    codeValue = new CodeValue((int)Items.ItemCategory.Invalid);
                    categoryCbo.SelectedItem = codeValue;
                    return;
                }
            }

            CodeValue[] listSubCategory = Database.getItemSubCategories(codeValue.code);
            m_subCategoryControl.Items.Clear();
            if (listSubCategory != null && listSubCategory.Length != 0)
            {
                m_subCategoryControl.Items.AddRange(listSubCategory);
                m_subCategoryControl.SelectedItem = listSubCategory.GetValue(0);
                onSubCategorySelectionChanged(null, null); // Hack: Force a selection change event
            }
            else
            {
                m_subCategoryControl.Text = "";
            }

            Items.ItemCategory itemCategory = (Items.ItemCategory)codeValue.code;
            TabPage[] tabPages = getTabPages(itemCategory);
            if (tabPages != null)
            {
                m_gui.setTabPages(tabPages);
                // Rely on the child tables (i.e. Beams) to activate the restrictions when needed
                Restrictions.enableField(false);
                //m_gui.setEditor(Items.getEditorType(itemCategory), false);
                categoryCbo.Focus();
            }
        }