Exemple #1
0
        /// <summary>
        /// Set Attribute Instance
        /// </summary>
        /// <param name="M_AttributeSetInstance_ID">value</param>
        /// <param name="value">id</param>
        public void SetMAttributeInstance(int M_AttributeSetInstance_ID, MAttributeValue value)
        {
            MAttributeInstance instance = GetMAttributeInstance(M_AttributeSetInstance_ID);

            if (instance == null)
            {
                if (value != null)
                {
                    instance = new MAttributeInstance(GetCtx(), GetM_Attribute_ID(),
                                                      M_AttributeSetInstance_ID, value.GetM_AttributeValue_ID(),
                                                      value.GetName(), Get_TrxName());  //	Cached !!
                }
                else
                {
                    instance = new MAttributeInstance(GetCtx(), GetM_Attribute_ID(),
                                                      M_AttributeSetInstance_ID, 0, null, Get_TrxName());
                }
            }
            else
            {
                if (value != null)
                {
                    instance.SetM_AttributeValue_ID(value.GetM_AttributeValue_ID());
                    instance.SetValue(value.GetName());         //	Cached !!
                }
                else
                {
                    instance.SetM_AttributeValue_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 MAttributeValue[] GetMAttributeValues()
        {
            if (m_values == null && ATTRIBUTEVALUETYPE_List.Equals(GetAttributeValueType()))
            {
                List <MAttributeValue> list = new List <MAttributeValue>();
                MAttributeValue        val  = null;
                if (!IsMandatory())
                {
                    list.Add(val);
                }
                //
                String sql = "SELECT * FROM M_AttributeValue "
                             + "WHERE M_Attribute_ID=" + GetM_Attribute_ID()
                             + "ORDER BY Value";
                DataSet ds = null;
                try
                {
                    ds = ExecuteQuery.ExecuteDataset(sql, null);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = ds.Tables[0].Rows[i];
                        list.Add(new MAttributeValue(GetCtx(), dr, null));
                    }
                    ds = null;
                }
                catch (Exception ex)
                {
                    log.Log(Level.SEVERE, sql, ex);
                }

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