/// <summary>
        /// Set Attribute Instance
        /// </summary>
        /// <param name="M_AttributeSetInstance_ID">value</param>
        /// <param name="value">id</param>
        public void SetCGenAttributeInstance(int M_AttributeSetInstance_ID, MGenAttributeValue value)
        {
            MGenAttributeInstance instance = GetCGenAttributeInstance(M_AttributeSetInstance_ID);

            if (instance == null)
            {
                if (value != null)
                {
                    instance = new MGenAttributeInstance(GetCtx(), GetC_GenAttribute_ID(),
                                                         M_AttributeSetInstance_ID, value.GetC_GenAttributeValue_ID(),
                                                         value.GetName(), Get_TrxName()); //	Cached !!
                }
                else
                {
                    instance = new MGenAttributeInstance(GetCtx(), GetC_GenAttribute_ID(),
                                                         M_AttributeSetInstance_ID, 0, null, Get_TrxName());
                }
            }
            else
            {
                if (value != null)
                {
                    instance.SetC_GenAttributeValue_ID(value.GetC_GenAttributeValue_ID());
                    instance.SetValue(value.GetName());         //	Cached !!
                }
                else
                {
                    instance.SetC_GenAttributeValue_ID(0);
                    instance.SetValue(null);
                }
            }
            instance.Save();
        }
Exemple #2
0
        /// <summary>
        /// Get Values if List
        /// </summary>
        /// <returns>Values or null if not list</returns>
        public MGenAttributeValue[] GetMAttributeValues()
        {
            if (m_values == null && ATTRIBUTEVALUETYPE_List.Equals(GetAttributeValueType()))
            {
                List <MGenAttributeValue> list = new List <MGenAttributeValue>();
                MGenAttributeValue        val  = null;
                if (!IsMandatory())
                {
                    list.Add(val);
                }
                //
                String sql = "SELECT * FROM C_GenAttributeValue "
                             + "WHERE C_GenAttribute_ID=" + GetC_GenAttribute_ID()
                             + " ORDER BY Value";
                sql = MRole.GetDefault(GetCtx()).AddAccessSQL(sql, "C_GenAttributeValue", true, false);

                DataSet ds = null;
                try
                {
                    ds = DB.ExecuteDataset(sql, null);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = ds.Tables[0].Rows[i];
                        list.Add(new MGenAttributeValue(GetCtx(), dr, null));
                    }
                    ds = null;
                }
                catch (Exception ex)
                {
                    log.Log(Level.SEVERE, sql, ex);
                }

                ds       = null;
                m_values = new MGenAttributeValue[list.Count];
                m_values = list.ToArray();
            }
            return(m_values);
        }