现在要开发一个产品管理系统,产品种类无限分类,每类产品的参数名称和参数数量不同.比如产品种类一下的产品参数有:电源,功率,噪音....等
产品种类二下的产品参数有:温度,精度,发射率....等注:不同种类下的产品的参数数量不一定相同.怎么才能实现添加或管理种类一下的产品时,自动显示"电源,功率,噪音"等字段提供输入呢?
而添加或管理种类二下的产品时就自动显示"温度,精度,发射率"等字段.

解决方案 »

  1.   

    我可能会建个种类参数表,列出每个种类可能会有哪些参数,其中包含的列有:种类ID,参数ID,参数名。
      

  2.   

    需要建立一个Key/Value的表,就像SharePoint里面的数据存储一样。key里面放字段,Value里面放真的值。
      

  3.   

    角落里找到的,好象是一个CNBLOGS上的翻译文章using System;
    using System.Collections.Generic;
    using System.Text;namespace Step5 {
    // 发声类型
    public enum SoundType {
    Acoustic = 0,
    Electric
    } // 制造商
    public enum Builder {
    Fender = 0,
    Martin,
    Gibson,
    Collings,
    Olson
    } // 木料
    public enum Wood {
    IndianRoseWood = 0,
    BrazilianRoseWood,
    Mahogany,
    Maple,
    Cocobolo,
    Cedar,
    Alder,
    Sitka
    } // 曼陀林琴的风格
    public enum Style {
    A = 0,
    F
    } // 乐器类型
    public enum InstrumentType {
    Guitar = 0,
    Mandolin,
    Banjo
    }
    }
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace Step5 {
    public class Instrument {
    private string serialNumber; // 序列号
    private double price; // 价格
    private InstrumentSpec spec; // 乐器属性集
    private InstrumentType type; // 乐器类型 public Instrument(string serialNumber, double price, InstrumentSpec spec, InstrumentType type) {
    this.price = price;
    this.serialNumber = serialNumber;
    this.spec = spec;
    this.type = type;
    } public string SerialNumber {
    get { return serialNumber; }
    } public double Price {
    get { return price; }
    set { price = value; }
    } public InstrumentType Type {
    get { return type; }
    } public InstrumentSpec Spec {
    get { return spec; }
    }
    }
    }
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;namespace Step5 {
    public abstract class InstrumentSpec : IEquatable<InstrumentSpec> {
    // 用来保存所有的属性
    private Hashtable properties; public InstrumentSpec(Hashtable properties) {
    if (properties == null)
    properties = new Hashtable();
    else
    this.properties = properties;
    } public Hashtable Properties {
    get { return properties; }
    } public Object GetProperty(object propertyName) {
    return properties[propertyName];
    } public bool Equals(InstrumentSpec other) {
    IEnumerator it = other.properties.Keys.GetEnumerator();
    while (it.MoveNext()) {
    if (properties[it.Current] != other.properties[it.Current])
    return false;
    } return true;
    }
    }
    }
      

  6.   

    只能回三个贴啊using System;
    using System.Collections.Generic;
    using System.Text;namespace Step5 {
    public class Inventory {
    private List<Instrument> instrumentList;// 维护现有的所有乐器 public Inventory() {
    instrumentList = new List<Instrument>();
    } // 向列表中添加 乐器
    public void AddInstrument(string serialNumber, double price, InstrumentSpec spec, InstrumentType type) {
    Instrument instrument = new Instrument(serialNumber, price, spec, type);
    instrumentList.Add(instrument);
    } // 搜索列表,寻找满足SearchSpec参数的乐器
    public List<Instrument> Search(InstrumentSpec searchSpec) {
    List<Instrument>.Enumerator it = instrumentList.GetEnumerator();
    List<Instrument> list = new List<Instrument>(); while (it.MoveNext()) {
    if (it.Current.Spec.Equals(searchSpec))
    list.Add(it.Current);
    }
    return list;
    }
    }
    }