public List<tsysattrtplatedtl> GetAttributesByTemplate(string attributeTempalteId,
            MES_AttributeTemplate_UsedBy usedBy)
        {
            List<tsysattrtplatedtl> lstResult = new List<tsysattrtplatedtl>();

            if (attributeTempalteId == null) attributeTempalteId = string.Empty;

            if (attributeTempalteId.Trim() == "*")
            {
                List<MESParameterInfo> lstParams = new List<MESParameterInfo>();
                lstParams.Add(new MESParameterInfo()
                {
                    ParamName = "usedby",
                    ParamValue = usedBy.ToString(),
                    ParamType = "string"
                });

                lstParams.Add(new MESParameterInfo()
                {
                    ParamName = "isdefault",
                    ParamValue = MES_Misc.Y.ToString(),
                    ParamType = "string"
                });

                tsysattrtplate template = GetSingleObject<tsysattrtplate>(lstParams);

                if (template != null)
                {
                    attributeTempalteId = template.attrtplatid;
                }
                else
                {
                    attributeTempalteId = string.Empty;
                }

            }

            if (attributeTempalteId.Trim() != string.Empty)
            {
                List<MESParameterInfo> lstParameters = new List<MESParameterInfo>();
                lstParameters.Add(new MESParameterInfo()
                {
                    ParamName = "attrtplatid",
                    ParamValue = attributeTempalteId,
                    ParamType = "string"
                });

                lstResult = GetSelectedObjects<tsysattrtplatedtl>(lstParameters);
            }

            return lstResult;
        }
Esempio n. 2
0
        public static void InitCMB_AttributeTemplate_All(ComboBox cmb, MES_AttributeTemplate_UsedBy usedBy)
        {
            cmb.Items.Clear();
            cmb.DisplayMember = "DisplayField";
            cmb.ValueMember = "ValueField";

            wsSYS.IwsSYSClient client = new wsSYS.IwsSYSClient();

            try
            {
                List<MESParameterInfo> lstParameters = new List<MESParameterInfo>()
                {
                    new MESParameterInfo()
                    {
                        ParamName="usedby",
                        ParamValue = usedBy.ToString(),
                        ParamType="string"
                    }
                };
                List<tsysattrtplate> lstArrtibueteTemplate = client.GetAttributeTemplateList((new BaseForm()).CurrentContextInfo, lstParameters.ToArray<MESParameterInfo>()).ToList<tsysattrtplate>();

                var q = from p in lstArrtibueteTemplate orderby p.attrtplatname ascending select p;
                for (int i = 0; i < q.Count(); i++)
                {
                    cmb.Items.Add(new ValueInfo()
                    {
                        DisplayField = q.ElementAt(i).attrtplatname,
                        ValueField = q.ElementAt(i).attrtplatid
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                baseForm.CloseWCF(client);
            }
        }