Exemplo n.º 1
0
        private static MBaseModel findObject(MBaseModel m, IList colls, String fldName)
        {
            if (m == null)
            {
                return(null);
            }

            if (fldName == null)
            {
                return(null);
            }

            if (colls == null)
            {
                return(null);
            }

            String id = (String)m.GetType().GetProperty(fldName).GetValue(m, null);

            foreach (MBaseModel o in colls)
            {
                String searchID = (String)o.GetType().GetProperty(fldName).GetValue(o, null);

                if (id.Equals(searchID))
                {
                    return(o);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private MBaseModel createObject(Range row)
        {
            int       colCnt = row.Columns.Count;
            Hashtable hash   = new Hashtable();

            for (int column = 1; column <= colCnt; column++)
            {
                Range  cell = row.Columns[column];
                String data = "";
                if (cell.Value2 != null)
                {
                    data = cell.Value2.ToString();
                }

                String propertyName = (String)colNames[column - 1];
                hash[propertyName] = data.Trim();
            }

            MBaseModel en = createModel();

            foreach (PropertyInfo prop in en.GetType().GetProperties())
            {
                String propertyName = prop.Name;
                if (hash.ContainsKey(propertyName))
                {
                    String value = (String)hash[propertyName];
                    prop.SetValue(en, value, null);
                }
            }

            return(en);
        }
Exemplo n.º 3
0
        private double getItemHeight(double maxWidth, MBaseModel m, String fieldName)
        {
            Boolean wrappFlag = rptCfg.GetConfigValue("WrapFlag").Equals("Y");

            if (!wrappFlag || maxWidth <= 0)
            {
                double rh = CUtil.StringToDouble(rptCfg.GetConfigValue("ItemRowHeight"));
                if (rh <= 0)
                {
                    rh = 30; //Default value
                }

                return(rh);
            }

            String itemDesc = " ";

            if (!fieldName.Equals(""))
            {
                itemDesc = (String)m.GetType().GetProperty(fieldName).GetValue(m, null);
            }

            String fontName = rptCfg.GetConfigValue("FontName");
            double fontSize = CUtil.StringToDouble(rptCfg.GetConfigValue("FontSize"));

            TextBlock tb = new TextBlock();

            tb.Text                = itemDesc;
            tb.TextWrapping        = TextWrapping.Wrap;
            tb.FontFamily          = new FontFamily(fontName);;
            tb.FontSize            = fontSize;
            tb.HorizontalAlignment = HorizontalAlignment.Left;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            tb.FontWeight          = FontWeights.Bold;
            tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            tb.Arrange(new Rect(0, 0, maxWidth, 1000));

            double h1      = tb.ActualHeight;
            int    lineCnt = (int)Math.Ceiling(tb.ActualWidth / maxWidth);

            double h = (lineCnt * h1) + 10; //Margin top and bottom, ONLY applicable to 5pt margin top and bottom

            tb = null;

            return(h);
        }