示例#1
0
        /// <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);
        }
示例#2
0
        private int getComponentIndexFromEnum(Net7.Table_item_manufacture component)
        {
            switch (component)
            {
            case Net7.Table_item_manufacture._comp_1:
                return(0);

            case Net7.Table_item_manufacture._comp_2:
                return(1);

            case Net7.Table_item_manufacture._comp_3:
                return(2);

            case Net7.Table_item_manufacture._comp_4:
                return(3);

            case Net7.Table_item_manufacture._comp_5:
                return(4);

            case Net7.Table_item_manufacture._comp_6:
                return(5);
            }
            return(0);
        }