Example #1
0
        public void ReaderRow(HtmlTextWriter writer, Model.Model model)
        {
            var propertys = Source.ModelType.GetProperties();

            if (ShowCheckBox)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, "checkbox_item");
                writer.AddAttribute(HtmlTextWriterAttribute.Value, model.Property(model.getIdentifyFiled()).ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.Input);
                writer.RenderEndTag();
                writer.RenderEndTag();
            }
            foreach (var p in propertys)
            {
                if (p.GetCustomAttributes(typeof(GirdHiddenAttribute), false).Length > 0) continue;
                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                var value = p.GetValue(model, null);
                string result = string.Format("{0}", value);
                if (Source.DataFormatter.ContainsKey(p.Name))
                {
                    result = Source.DataFormatter[p.Name].Invoke(value, model);
                }

                writer.Write(result);
                writer.RenderEndTag();
            }

            List<string> links = new List<string>();
            foreach (var kv in Source.ActionLinks)
            {
                string url = FormatFromModel(kv.Value, model);
                links.Add(string.Format("<a href=\"{1}\">{0}</a>", kv.Key, url));
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(string.Join("|", links.ToArray()));
            writer.RenderEndTag();
        }
Example #2
0
        private string FormatFromModel(string tempString, Model.Model model)
        {
            var propertys = model.GetType().GetProperties();
            Regex r = new Regex("{[A-Z|a-z|0-9]*}");
            return r.Replace(tempString, (m) =>
            {
                var value =model.Property(m.Value.Trim('{','}'));
                if (value == null) return "";
                return value.ToString();

            });
        }
Example #3
0
        /// <summary>
        /// 获取sql参数
        /// </summary>
        /// <returns></returns>
        public virtual IDataParameter[] GetParameters(Model.Model model)
        {
            var propertys = model.GetType().GetProperties();

            List<IDataParameter> listSQLParamter = new List<IDataParameter>();
            foreach (var p in propertys)
            {
                listSQLParamter.Add(new SqlParameter() { ParameterName = p.Name, Value = model.Property(p.Name) });
            }
            return listSQLParamter.ToArray();
        }