public string SaveAttribute(VA005_SaveAttribute value)
        {
            MAttribute obj = new MAttribute(_ctx, value.ID, null);

            obj.SetName(value.name);


            if (value.description != null)
            {
                obj.SetDescription(value.description);
            }
            else
            {
                obj.SetDescription(" ");
            }


            if (value.attributetype != null)
            {
                obj.SetAttributeValueType(value.attributetype);
            }
            else
            {
                obj.SetAttributeValueType("L");
            }

            obj.SetIsMandatory(value.mandatory);
            obj.SetIsActive(value.isactivefield);
            obj.SetIsInstanceAttribute(value.istanceattribute);



            //obj.Save();
            if (obj.Save())
            {
                return(obj.GetM_Attribute_ID().ToString());
            }
            // mattributeid = obj.GetM_Attribute_ID();
            //}
            //if (value.secname != null)
            //{
            //    MAttributeValue objattval = new MAttributeValue(_ctx, 0, null);
            //    objattval.SetName(value.secname);
            //    objattval.SetValue(value.searchkey);
            //    objattval.SetM_Attribute_ID(mattributeid);
            //    if (objattval.Save())
            //    {
            //        return objattval.GetM_AttributeValue_ID().ToString();
            //    }
            //}
            return(Msg.GetMsg(_ctx, "VA005_UnableToSaveAttribute"));
        }
        /// <summary>
        /// Add New Selection List...
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public string AddNewAttribute(VA005_AddNewAttribute values)
        {
            MAttribute ctrl = new MAttribute(_ctx, 0, null);

            ctrl.SetName(values.Name);
            ctrl.SetDescription(values.Description);
            ctrl.SetM_AttributeSearch_ID(values.M_AttributeSearch_ID);
            if (ctrl.Save())
            {
                return(ctrl.GetM_Attribute_ID().ToString());
            }
            return(Msg.GetMsg(_ctx, "VA005_UnableToAddNewAttribute"));
        }
Пример #3
0
        static String generate(MAttribute attribute)
        {
            return($@"
    private {generate(attribute.Type)} {attribute.Name.FirstCharToLower()};

    public {generate(attribute.Type)} get{attribute.Name.FirstCharToUpper()}() {{
        return this.{attribute.Name.FirstCharToLower()};
    }}

    public void set{attribute.Name.FirstCharToUpper()}({generateParameter(attribute)}) {{
{generateAssignment(attribute)}
    }}
");
        }
        //public string DeleteAttributeSetValue(VA005_DeleteAttributeSetValue value)
        //{
        //    //MAttributeValue obj = new MAttributeValue(_ctx, value.attributesetdelID, null);
        //    MAttributeSet obj = new MAttributeSet(_ctx, value.attributesetdelID, null);
        //    int attvalid = obj.GetM_AttributeSet_ID();
        //    bool _result = false;
        //    try
        //    {
        //        _result = obj.Delete(true);
        //    }
        //    catch (Exception e)
        //    {
        //        return e.Message;
        //    }
        //    if (_result)
        //    {
        //        //return Msg.GetMsg(_ctx,"VA005_Deleted");
        //        return attvalid.ToString();
        //    }
        //    else
        //    {
        //        return Msg.GetMsg(_ctx, "VA005_NotDeleted");
        //    }
        //}

        public string DeleteAttributeSetValue(List <Int32> value)
        {
            string _result = "";

            for (int i = 0; i < value.Count; i++)
            {
                MAttribute obj      = new MAttribute(_ctx, value[i], null);
                int        attvalid = obj.GetM_Attribute_ID();
                try
                {
                    if (!obj.Delete(true))
                    {
                        ValueNamePair pp = VLogger.RetrieveError();
                        _result += pp.ToString() + "/n";
                    }
                }
                catch (Exception e)
                {
                }
            }
            return(_result);
        }
Пример #5
0
        /// <summary>
        /// Table line structure
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="product"></param>
        /// <param name="readOnly"></param>
        private string AddAttributeLine(MAttribute attribute, int M_AttributeSetInstance_ID, bool product, bool readOnly, int windowNo, AttributesObjects obj, int count)
        {
            log.Fine(attribute + ", Product=" + product + ", R/O=" + readOnly);
            //Column 1
            obj.tableStucture += "<td>";
            if (product)
            {
                obj.tableStucture += "<label style=' font-weight:bold; padding-bottom: 10px; padding-right: 5px;' class='VIS_Pref_Label_Font' id=" + attribute.GetName().Replace(" ", "") + "_" + windowNo + ">" + attribute.GetName() + "</label>";
            }
            else
            {
                obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' class='VIS_Pref_Label_Font' id=" + attribute.GetName().Replace(" ", "") + "_" + windowNo + "  >" + attribute.GetName() + "</label>";
            }
            obj.tableStucture += "</td>";

            MAttributeInstance instance = attribute.GetMAttributeInstance(M_AttributeSetInstance_ID);

            if (MAttribute.ATTRIBUTEVALUETYPE_List.Equals(attribute.GetAttributeValueType()))
            {
                MAttributeValue[] values = attribute.GetMAttributeValues();
                //Column 2
                obj.tableStucture += "<td>";
                if (readOnly)
                {
                    obj.tableStucture += "<select style='width: 100%;margin-bottom: 10px;'  readonly id='cmb_" + count + "_" + windowNo + "'>";
                }
                else
                {
                    obj.tableStucture += "<select style='width: 100%;margin-bottom: 10px;;'  id='cmb_" + count + "_" + windowNo + "'>";
                }
                obj.ControlList += "cmb_" + count + "_" + windowNo + ",";
                bool found = false;

                for (int i = 0; i < values.Length; i++)
                {
                    //Set first value default empty
                    if (values[i] == null && i == 0)
                    {
                        obj.tableStucture += " <option value='0' > </option>";
                    }
                    else if (values[i] != null)
                    {
                        if (instance != null)
                        {
                            if (values[i].GetM_AttributeValue_ID() == instance.GetM_AttributeValue_ID())
                            {
                                obj.tableStucture += " <option selected value='" + values[i].GetM_AttributeValue_ID() + "' >" + values[i].GetName() + "</option>";
                            }
                            else
                            {
                                obj.tableStucture += " <option value='" + values[i].GetM_AttributeValue_ID() + "' >" + values[i].GetName() + "</option>";
                            }
                        }
                        else
                        {
                            obj.tableStucture += " <option value='" + values[i].GetM_AttributeValue_ID() + "' >" + values[i].GetName() + "</option>";
                        }
                    }
                }

                obj.tableStucture += "</select>";
                obj.tableStucture += "</td>";

                if (found)
                {
                    log.Fine("Attribute=" + attribute.GetName() + " #" + values.Length + " - found: " + instance);
                }
                else
                {
                    log.Warning("Attribute=" + attribute.GetName() + " #" + values.Length + " - NOT found: " + instance);
                }

                if (instance != null)
                {
                }
                else
                {
                    log.Fine("Attribute=" + attribute.GetName() + " #" + values.Length + " no instance");
                }
            }
            else if (MAttribute.ATTRIBUTEVALUETYPE_Number.Equals(attribute.GetAttributeValueType()))
            {
                string value = null;
                if (instance != null)
                {
                    value = instance.GetValue();
                }
                //Column 2
                obj.tableStucture += "<td>";
                if (readOnly)
                {
                    obj.tableStucture += "<input style='width: 100%;' class='VIS_Pref_pass' readonly id='txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + "' value='" + value + "' class='' type='number'>";
                }
                else
                {
                    string addclass = "VIS_Pref_pass";
                    if (attribute.IsMandatory())
                    {
                        addclass += " vis-gc-vpanel-table-mandatory ";
                    }

                    obj.tableStucture += "<input style='width: 100% ;' maxlength='40' class='" + addclass + "' id='txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + "' value='" + value + "' class='' type='number'>";
                }
                obj.ControlList   += "txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + ",";
                obj.tableStucture += "</td>";
            }
            else        //	Text Field
            {
                string value = null;
                if (instance != null)
                {
                    value = instance.GetValue();
                }

                //Column 2
                obj.tableStucture += "<td>";
                if (readOnly)
                {
                    obj.tableStucture += "<input style='width: 100%;' class='VIS_Pref_pass' readonly id='txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + "' value='" + value + "' class='' type='text'>";
                }
                else
                {
                    string addclass = "VIS_Pref_pass";
                    if (attribute.IsMandatory())
                    {
                        addclass += " vis-gc-vpanel-table-mandatory ";
                    }

                    obj.tableStucture += "<input style='width: 100%;' maxlength='40' class='" + addclass + "' id='txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + "' value='" + value + "' class='' type='text'>";
                }
                obj.ControlList   += "txt" + attribute.GetName().Replace(" ", "") + "_" + windowNo + ",";
                obj.tableStucture += "</td>";
            }

            obj.tableStucture += "</tr>";
            //Row Add
            obj.tableStucture += "<tr>";
            return(obj.tableStucture);
        }
Пример #6
0
 static String generateAssignment(MAttribute attribute)
 {
     return($@"
 this.{attribute.Name.FirstCharToLower()} = {attribute.Name.FirstCharToLower()};");
 }
Пример #7
0
 static String generateParameter(MAttribute attribute)
 {
     return($@"{generate(attribute.Type)} {attribute.Name.FirstCharToLower()}");
 }
Пример #8
0
        private static string GetAttributeText(DObject obj, IReadOnlyDictionary <string, DValue> attributes, MAttribute attr)
        {
            DValue value;

            attributes.TryGetValue(attr.Name, out value);
            var strValue = value?.Value?.ToString();

            if (attr.Type == MAttrType.Numerator)
            {
                try
                {
                    return(GetNumeratorAttributeText(obj, strValue, attr.ParsedConfiguration().CounterDescriptions));
                }
                catch (FormatException)
                {
                    return(string.Empty);
                }
            }
            return(strValue);
        }