Ejemplo n.º 1
0
        private string Referencia(string campo, DOCUMENTO doc, List <DOCUMENTOF> docf, CLIENTE clien)
        {
            string[] cc    = campo.Trim().Split('+');
            string[] indes = new string[cc.Length];
            string   txt   = "";
            int      index = 0;

            PropertyInfo[] ppdf = new PropertyInfo[1];
            PropertyInfo[] ppd  = doc.GetType().GetProperties();
            if (docf.Count > 0)
            {
                ppdf = docf[0].GetType().GetProperties();
            }
            PropertyInfo[] ppdc = clien.GetType().GetProperties();
            try
            {
                foreach (string c in cc)
                {
                    try
                    {
                        txt += ppd.Where(x => x.Name == c).Single().GetValue(doc);
                        //txt += ppd[1].GetValue(doc);
                        indes[index] = "X";
                    }
                    catch (Exception) { }
                    try
                    {
                        if (docf.Count > 0)
                        {
                            if (indes[index] != "X")
                            {
                                for (int i = 0; i < docf.Count; i++)
                                {
                                    txt         += ppdf.Where(x => x.Name == c).Single().GetValue(docf[i]) + ",";
                                    indes[index] = "X";
                                }
                                txt = txt.Substring(0, txt.Length - 1);
                            }
                        }
                    }
                    catch (Exception) { }
                    try
                    {
                        if (indes[index] != "X")
                        {
                            txt         += ppdc.Where(x => x.Name == c).Single().GetValue(clien);
                            indes[index] = "X";
                        }
                    }
                    catch (Exception) { }
                    index++;
                }
            }
            catch (Exception)
            { }
            if (String.IsNullOrEmpty(txt))
            {
                return("");
            }
            else
            {
                return(txt);
            }
        }