Example #1
0
File: Field.cs Project: jjg0519/OA
 public static void Save <ET, PT>(ListBase <Field> listField, ET entityObj)
 {
     {
         MethodInfo saveMethod = typeof(PT).GetMethod("Save", new Type[] { typeof(ET) });
         saveMethod.Invoke(null, new object[] { entityObj });
     }
 }
Example #2
0
File: Field.cs Project: jjg0519/OA
        public static void CreateTable(HtmlTable tableCtrl, ListBase <Field> listField, Button btnQuery, string name)
        {
            tableCtrl.Rows.Clear();
            HtmlTableRow  tr         = new HtmlTableRow();
            HtmlTableCell cellBottom = new HtmlTableCell();

            foreach (Field field in listField)
            {
                HtmlTableCell td1 = new HtmlTableCell();
                td1.Controls.Add(field.CaptionControl);
                td1.Visible = field.IsVisible;
                td1.Style.Add("padding-left", "20px");
                HtmlTableCell td2 = new HtmlTableCell();
                for (int n = 0; n < field.MainControl.Count; n++)
                {
                    td2.Controls.Add((Control)field.MainControl[n]);
                }
                td2.Controls.Add(field.DescriptionControl);
                td2.Visible = field.IsVisible;

                tr.Cells.Add(td1);
                tr.Cells.Add(td2);
            }
            btnQuery.ID       = name + "btnQuery";
            btnQuery.Text     = "查 询";
            btnQuery.CssClass = "button";
            cellBottom.Controls.Add(btnQuery);
            tr.Cells.Add(cellBottom);
            tableCtrl.Rows.Add(tr);
        }
Example #3
0
File: Field.cs Project: jjg0519/OA
 /// <summary>
 /// 根据实体设置控件的值
 /// </summary>
 public static void SetControlValue <ET>(ListBase <Field> listField, object entity)
 {
     foreach (PropertyInfo pif in typeof(ET).GetProperties())
     {
         if (listField[pif.Name] != null)
         {
             listField[pif.Name].Value = pif.GetValue(entity, null);
         }
     }
 }
Example #4
0
File: Field.cs Project: jjg0519/OA
        public static ListBase <Field> GetListField <ET>(string preFix)
        {
            ListBase <Field> _listMemberSetField = new ListBase <Field>("FieldName");

            PropertyInfo[] piEntity;
            piEntity = typeof(ET).GetProperties();
            int i = 0;

            foreach (PropertyInfo pif in piEntity)
            {
                {
                    Field field = new Field();
                    field.FieldName   = pif.Name;
                    field.Prefix      = preFix;
                    field.CaptionName = pif.Name;
                    field.OrderNo     = i * 10;
                    //根据实体属性字段的数据类型,生成对应的控件
                    field.TypeFullName = pif.PropertyType.FullName;

                    if (pif.PropertyType.FullName.IndexOf("System.String") != -1)
                    {
                        field.ControlType = Constant.CtrlType.TextBox;
                    }
                    else if (pif.PropertyType.FullName.IndexOf("System.Boolean") != -1)
                    {
                        field.ControlType = Constant.CtrlType.CheckBox;
                    }
                    else if (pif.PropertyType.FullName.IndexOf("System.DateTime") != -1)
                    {
                        field.ControlType = Constant.CtrlType.DateTextBox;
                    }
                    else if (pif.PropertyType.FullName.IndexOf("System.Int32") != -1)
                    {
                        field.ControlType = Constant.CtrlType.IntTextBox;
                    }
                    else if (pif.PropertyType.FullName.IndexOf("System.Double") != -1)
                    {
                        field.ControlType = Constant.CtrlType.DoubleTextBox;
                    }
                    else if (pif.PropertyType.FullName.IndexOf("System.Decimal") != -1)
                    {
                        field.ControlType = Constant.CtrlType.DecimalTextBox;
                    }
                    _listMemberSetField.Add(field);
                    i++;
                }
            }
            _listMemberSetField.Sort("OrderNo", true);
            _listMemberSetField.Remove(_listMemberSetField["EntityState"]);
            _listMemberSetField.Remove(_listMemberSetField["TableName"]);
            _listMemberSetField.Remove(_listMemberSetField["PrimaryKeyField"]);
            return(_listMemberSetField);
        }
Example #5
0
File: Field.cs Project: jjg0519/OA
 /// <summary>
 /// 获取控件的值并赋给实体
 /// </summary>
 public static void GetControlValue <ET>(ListBase <Field> listField, object entity)
 {
     foreach (PropertyInfo pif in typeof(ET).GetProperties())
     {
         if (listField[pif.Name] != null)
         {
             if (listField[pif.Name].ControlType != Constant.CtrlType.Label && listField[pif.Name].FieldType == 1 && listField[pif.Name].IsVisible)
             {
                 try
                 {
                     if (pif.PropertyType == typeof(System.Boolean?) && (listField[pif.Name].Value is string))
                     {
                         pif.SetValue(entity, Convert.ToBoolean(Convert.ToInt32(listField[pif.Name].Value)), null);
                     }
                     else if (pif.PropertyType == typeof(Int32) && (listField[pif.Name].Value is string))
                     {
                         pif.SetValue(entity, Convert.ToInt32(Functions.IsNotNull(listField[pif.Name].Value.ToString()) ? listField[pif.Name].Value : "0"), null);
                     }
                     else if (pif.PropertyType == typeof(DateTime?) && (listField[pif.Name].Value is string))
                     {
                         pif.SetValue(entity, Convert.ToDateTime(listField[pif.Name].Value), null);
                     }
                     else if (pif.PropertyType == typeof(Double?) && (listField[pif.Name].Value is string))
                     {
                         pif.SetValue(entity, Convert.ToDouble(Functions.IsNotNull(listField[pif.Name].Value.ToString()) ? listField[pif.Name].Value : "0.00"), null);
                     }
                     else
                     {
                         pif.SetValue(entity, listField[pif.Name].Value, null);
                     }
                 }
                 catch (System.ArgumentException ex)
                 {
                     //碰到DropDownList SeleledValue 是INT型,做类型转换
                     SMT.SaaS.Common.ErrorLog.Log("获取控件值时出错:" + ex.ToString());
                     pif.SetValue(entity, Convert.ToInt32(Functions.IsNotNull(listField[pif.Name].Value.ToString()) ? listField[pif.Name].Value : "0"), null);
                 }
             }
         }
     }
 }
Example #6
0
File: Field.cs Project: jjg0519/OA
        public static void CreateTable(HtmlTable tableCtrl, ListBase <Field> listField, int colsCount, string name)
        {
            //先清除所有行
            tableCtrl.Rows.Clear();

            int          i            = 0;
            HtmlTableRow tr           = null;
            int          visibleCount = 0;

            foreach (Field field in listField)
            {
                if (field.IsVisible)
                {
                    visibleCount++;
                }
            }
            int j = 0;

            foreach (Field field in listField)
            {
                if (field.IsVisible)
                {
                    if (j == visibleCount - 1)
                    {
                        field.Colspan = (colsCount - 1 - i % colsCount) + 1;
                    }
                    if (i % colsCount == 0)
                    {
                        tr    = new HtmlTableRow();
                        tr.ID = name + "tr" + i;
                    }

                    HtmlTableCell td1 = new HtmlTableCell();
                    td1.Width = (100 / (colsCount * 4)) + "%";
                    td1.Attributes.Add("align", "right");
                    td1.Attributes.Add("class", "cell_l");
                    td1.Controls.Add(field.CaptionControl);
                    td1.Visible = field.IsVisible;

                    HtmlTableCell td2 = new HtmlTableCell();
                    td2.ColSpan = (field.Colspan - 1) * 2 + 1;
                    td2.Width   = (((100 / (colsCount * 4)) * 3) + (100 / (colsCount * 4)) * (field.Colspan - 1)) + "%";;
                    td2.Attributes.Add("class", "cell_r");
                    for (int n = 0; n < field.MainControl.Count; n++)
                    {
                        td2.Controls.Add((Control)field.MainControl[n]);
                    }
                    td2.Controls.Add(field.DescriptionControl);
                    td2.Visible = field.IsVisible;

                    tr.Controls.Add(td1);
                    tr.Controls.Add(td2);
                    tableCtrl.Rows.Add(tr);


                    i = i + field.Colspan;
                    j++;
                }
                else
                {
                    HtmlTableCell td2 = new HtmlTableCell();
                    td2.ColSpan = (field.Colspan - 1) * 2 + 1;
                    td2.Width   = (((100 / (colsCount * 4)) * 3) + (100 / (colsCount * 4)) * (field.Colspan - 1)) + "%";;
                    td2.Attributes.Add("class", "cell_r");
                    for (int n = 0; n < field.MainControl.Count; n++)
                    {
                        td2.Controls.Add((Control)field.MainControl[n]);
                    }
                    td2.Controls.Add(field.DescriptionControl);
                    td2.Visible = field.IsVisible;

                    HtmlTableRow trhidden = new HtmlTableRow();
                    trhidden.Controls.Add(td2);
                    trhidden.Visible = false;
                    tableCtrl.Rows.Add(trhidden);
                }
            }
        }