• 通用DAL类


    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Reflection;

    namespace MTS2.IDAL {     public class IPublic_Interface : MTS2.DBUtility.MySqlServerHelper     {

            /// <summary>         /// SQL 语句字符文本;         /// </summary>         public String SQL_Str = "";         /// <summary>         /// 表名称公用变量         /// </summary>         public String Table_Name = "";         /// <summary>         /// 控件标签         /// </summary>         public String Controls_Label = "";         /// <summary>         /// 对象属性标签         /// </summary>         public String Property_Label = "";         /// <summary>         /// 对象字段标签         /// </summary>         public String Fields_Label = "";         /// <summary>         /// 控件前缀变量         /// </summary>         public String Controls_Prefix = "";         /// <summary>         /// 对象属性前缀变量         /// </summary>         public String Property_Prefix = "";         /// <summary>         /// 对象字段前缀变量         /// </summary>         public String Fields_Prefix = "";         /// <summary>         /// 类名称前缀变量         /// </summary>         public String Class_Name_Prefix = "";         /// <summary>         /// 前缀变量         /// </summary>         public String Common_Prefix = "";         /// <summary>         /// SQL预留部分字段字符串         /// </summary>         public String SQL_Paras = "";         /// <summary>         /// 用户ID         /// </summary>         public String User_ID = "";         /// <summary>         /// 用户部门名称         /// </summary>         public String User_Depart_Name = "";         /// <summary>         /// 用户部门ID         /// </summary>         public String User_Depart_ID = "";         /// <summary>         /// 用户部门编号         /// </summary>         public String User_CoCode = "";         /// <summary>         /// 部门班次         /// </summary>         public String User_ShiftID = "";         /// <summary>         /// 用户权限名称         /// </summary>         public String USer_Grant_Name = "";         /// <summary>         /// 用户权限ID         /// </summary>         public String User_Grant_ID = "";         /// <summary>         /// 用户添加权限         /// </summary>         public String User_Allowadd = "";         /// <summary>         /// 用户编辑权限         /// </summary>         public String User_Allowedit = "";         /// <summary>         /// 用户权限扩展         /// </summary>         public String User_Allowexp = "";         /// <summary>         /// 用户状态         /// </summary>         public String User_Status = "";         /// <summary>         /// 用户岗位编号LIst         /// </summary>         public String User_GroupID = "";         /// <summary>         /// 公用DATASET变量         /// </summary>         public DataSet DS = new DataSet();         /// <summary>         /// 公用DATATABLE变量         /// </summary>         public DataTable DT = new DataTable();

            public IWeb_Cache webCache = new IWeb_Cache();

            /// <summary>         /// 泛型获取SQL  INSERT字符串         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="md">对象类型参数</param>         /// <returns>返回SQL INSERT语句;调用方法:  </returns>         public String SqlInsertBuilder<T>(T md)         {

                String SQL_STR_INSERT_HEADER = "insert  into mytablename(";             string SQL_STR_INSERT_FIELDS = "";             string SQL_STR_INSERT_VALUES = "";             string SQL_STR = "";             Type type = md.GetType();             String str = type.Name.ToString();             if (Table_Name.ToString().Trim().Length < 2)             {                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                Common_Prefix = Table_Name + "_";             SQL_STR_INSERT_HEADER = SQL_STR_INSERT_HEADER.Replace("mytablename", Table_Name.ToString());

                object obj = Activator.CreateInstance(type);             PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);             foreach (PropertyInfo p in props)             {                 if (p.GetValue(md, null).ToString().Trim().Length > 0)                 {                     SQL_STR_INSERT_FIELDS = SQL_STR_INSERT_FIELDS + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + ",";                     SQL_STR_INSERT_VALUES = SQL_STR_INSERT_VALUES + "', '" + p.GetValue(md, null).ToString().Trim();                 }

                }             if (SQL_STR_INSERT_FIELDS.ToString().Trim().Length > 3)             {                 SQL_STR = SQL_STR_INSERT_HEADER + SQL_STR_INSERT_FIELDS.Substring(0, SQL_STR_INSERT_FIELDS.Length - 1) + ")values(" + SQL_STR_INSERT_VALUES.Substring(2, SQL_STR_INSERT_VALUES.Length - 2) + "')";             }             return SQL_STR.ToUpper();         }

            public String SqlInsertBuilder(DataSet Ds)         {             DataTable dt = new DataTable();             if (Ds != null)             {                 if (Ds.Tables.Count > 0)                 {                     dt = Ds.Tables[0];                 }             }             String SQL_STR_INSERT_HEADER = "insert  into mytablename(";             string SQL_STR_INSERT_FIELDS = "";             string SQL_STR_INSERT_VALUES = "";             string SQL_STR = "";

                if (dt.Rows.Count > 0)             {                 SQL_STR = "";

                    foreach (DataRow dr in dt.Rows)                 {                     SQL_STR_INSERT_HEADER = "insert  into mytablename(";                     SQL_STR_INSERT_HEADER = SQL_STR_INSERT_HEADER.Replace("mytablename", Table_Name.ToString());                     foreach (DataColumn dc in dt.Columns)                     {                         SQL_STR_INSERT_FIELDS = SQL_STR_INSERT_FIELDS + dc.ColumnName.ToLower().ToString() + ",";                         SQL_STR_INSERT_VALUES = SQL_STR_INSERT_VALUES + "', '" + dr[dc.ColumnName].ToString().Trim();                     }                     if (SQL_STR_INSERT_FIELDS.ToString().Trim().Length > 3)                     {                         SQL_STR = SQL_STR + SQL_STR_INSERT_HEADER + SQL_STR_INSERT_FIELDS.Substring(0, SQL_STR_INSERT_FIELDS.Length - 1) + ")values(" + SQL_STR_INSERT_VALUES.Substring(2, SQL_STR_INSERT_VALUES.Length - 2) + "');";                     }                 }

                }             return SQL_STR;         }         public String SqlInsertBuilder(DataTable dt)         {             String SQL_STR_INSERT_HEADER = "insert  into mytablename(";             string SQL_STR_INSERT_FIELDS = "";             string SQL_STR_INSERT_VALUES = "";             string SQL_STR = "";

                if (dt.Rows.Count > 0)             {                 SQL_STR = "";

                    foreach (DataRow dr in dt.Rows)                 {                     SQL_STR_INSERT_HEADER = "insert  into mytablename(";                     SQL_STR_INSERT_HEADER = SQL_STR_INSERT_HEADER.Replace("mytablename", Table_Name.ToString());                     foreach (DataColumn dc in dt.Columns)                     {                         SQL_STR_INSERT_FIELDS = SQL_STR_INSERT_FIELDS + dc.ColumnName.ToLower().ToString() + ",";                         SQL_STR_INSERT_VALUES = SQL_STR_INSERT_VALUES + "', '" + dr[dc.ColumnName].ToString().Trim();                     }                     if (SQL_STR_INSERT_FIELDS.ToString().Trim().Length > 3)                     {                         SQL_STR = SQL_STR + SQL_STR_INSERT_HEADER + SQL_STR_INSERT_FIELDS.Substring(0, SQL_STR_INSERT_FIELDS.Length - 1) + ")values(" + SQL_STR_INSERT_VALUES.Substring(2, SQL_STR_INSERT_VALUES.Length - 2) + "');";                     }                 }

                }             return SQL_STR;         }         public String SqlSelectStrByKeyBuilder<T>(string Keystr)         {             string SQL_STR = "";             Type type = typeof(T).GetType();             Table_Name = typeof(T).Name.ToString();             if (Table_Name.ToString().Trim().Length > 2)             {                 String str = Table_Name.ToString();                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                if (Keystr.ToString().Trim().Length > 0)             {                 SQL_STR = "select * from " + Table_Name.ToString() + "  where   " + Keystr.ToString();

                }             return SQL_STR.ToUpper();         }         /// <summary>         /// 通过泛型动态获取SQL  SELECT字符串         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="md">对象类型实例</param>         /// <returns>返回SQL SELECT语句;调用方法: </returns>         public String SqlStrSelectBuilder<T>(T md)         {             String SQL_STR_INSERT_HEADER = "select  ";             string SQL_STR_INSERT_FIELDS = "";             string SQL_STR_INSERT_VALUES = "";             string SQL_STR = "";             Type type = md.GetType();             if (Table_Name.ToString().Trim().Length < 2)             {                 String str = type.Name.ToString();                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                object obj = Activator.CreateInstance(type);             PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

                Common_Prefix = Table_Name + "_";             foreach (PropertyInfo p in props)             {                 SQL_STR_INSERT_FIELDS = SQL_STR_INSERT_FIELDS + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + "  ,";

                    if (p.GetValue(md, null).ToString().Trim().Length > 0)                 {                     SQL_STR_INSERT_VALUES = SQL_STR_INSERT_VALUES + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + "='" + p.GetValue(md, null).ToString().Trim() + "'  and ";                 }

                }             if (SQL_STR_INSERT_FIELDS.ToString().Trim().Length > 3)             {                 if (SQL_STR_INSERT_VALUES.Length == 0)                 {                     SQL_STR = "";                 }                 else                 {                     SQL_STR = SQL_STR_INSERT_HEADER + SQL_STR_INSERT_FIELDS.Substring(0, SQL_STR_INSERT_FIELDS.Length - 1) + "  from tablename where " + SQL_STR_INSERT_VALUES.Substring(0, SQL_STR_INSERT_VALUES.Length - 4);                 }                 SQL_STR = SQL_STR.Replace("tablename", Table_Name.ToString());             }             return SQL_STR.ToUpper();         }         /// <summary>         /// 根据对象参数所指定条件生成删除数据信息的SQL语句         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="md">对象参数所</param>         /// <returns>返回生成的字符串</returns>         public String SqlStrDeleteBuilder<T>(T md)         {             String SQL_STR_INSERT_HEADER = "Delete    ";             string SQL_STR_INSERT_FIELDS = "";             string SQL_STR_INSERT_VALUES = "";             string SQL_STR = "";             Type type = md.GetType();             if (Table_Name.ToString().Trim().Length < 2)             {                 String str = type.Name.ToString();                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                object obj = Activator.CreateInstance(type);             PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

                Common_Prefix = Table_Name + "_";             foreach (PropertyInfo p in props)             {                 SQL_STR_INSERT_FIELDS = SQL_STR_INSERT_FIELDS + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + "  ,";

                    if (p.GetValue(md, null).ToString().Trim().Length > 0)                 {                     SQL_STR_INSERT_VALUES = SQL_STR_INSERT_VALUES + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + "='" + p.GetValue(md, null).ToString().Trim() + "',";                 }

                }             if (SQL_STR_INSERT_FIELDS.ToString().Trim().Length > 3)             {                 SQL_STR = SQL_STR_INSERT_HEADER + "  from tablename where " + SQL_STR_INSERT_VALUES.Substring(0, SQL_STR_INSERT_VALUES.Length - 1);                 SQL_STR = SQL_STR.Replace("tablename", Table_Name.ToString());             }             return SQL_STR.ToUpper();         }         /// <summary>         /// 通过泛型动态获取SQL  UPDATE字符串         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="md">对象类型实例</param>         /// <param name="SQL_CASE">SQL更新条件</param>         /// <returns>返回SQL UPDATE语句;调用方法:  </returns>         public String SqlStrUpdateBuilder<T>(T md, string SQL_CASE)         {             String SQL_STR_UPDATE_HEADER = "UPDATE  MYTABLENAME  SET   ";             string SQL_STR_UPDATE_FIELDS = "";             string SQL_STR_UPDATE_VALUES = "";             string SQL_STR = "";             SQL_STR_UPDATE_FIELDS = SQL_CASE;             Type type = md.GetType();             String str = type.Name.ToString();             if (Table_Name.ToString().Trim().Length < 2)             {                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                Common_Prefix = Table_Name + "_";             SQL_STR_UPDATE_HEADER = SQL_STR_UPDATE_HEADER.Replace("MYTABLENAME", Table_Name.ToString());

                object obj = Activator.CreateInstance(type);             PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);             foreach (PropertyInfo p in props)             {                 if (p.GetValue(md, null).ToString().Trim().Length > 0)                 {

                        SQL_STR_UPDATE_VALUES = SQL_STR_UPDATE_VALUES + p.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), "") + "='" + p.GetValue(md, null).ToString().Trim() + "',";                 }

                }

                if (SQL_STR_UPDATE_FIELDS.ToString().Trim().Length > 3)             {                 SQL_STR = SQL_STR_UPDATE_HEADER + SQL_STR_UPDATE_VALUES.Substring(0, SQL_STR_UPDATE_VALUES.Length - 1) + "    where " + SQL_STR_UPDATE_FIELDS.ToString();             }             else             {                 SQL_STR = "";             }             return SQL_STR.ToUpper();         }         /// <summary>         /// 通过DATATABLE参数为指定类型对象赋值(为指定类型对象属性赋值)         /// </summary>         /// <typeparam name="T">指定类型</typeparam>         /// <param name="dt">DATATABLE参数</param>         /// <returns>返回已经赋值的指定对象实例;调用方法: </returns>         public T SetPropertyValueForObjectByDt<T>(DataTable dt)         {             System.Type Object_Type = typeof(T);//获取指定名称的类型

                String str = typeof(T).GetType().Name.ToString();             if (Table_Name.ToString().Trim().Length < 2)             {                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                Common_Prefix = Table_Name + "_";             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             PropertyInfo[] fields = Object_Instance.GetType().GetProperties();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (PropertyInfo t in fields)                         {                             if (dc.ColumnName == t.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), ""))                             {                                 t.SetValue(obj, dr[dc.ColumnName].ToString(), null);//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过泛型方法的DATATABLE参数  为指定类型的对象赋值(为指定类型对象属性赋值)         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="dt">数据表</param>         /// <param name="Class_name">对象类型名称</param>         /// <returns>返回指定类型对象;调用方法: </returns>         public T SetPropertyValueForObjectByClassNameAndDt<T>(DataTable dt, string Class_name)         {             System.Type Object_Type = System.Type.GetType(Class_name);//获取指定名称的类型             String str = typeof(T).GetType().Name.ToString();             if (Table_Name.ToString().Trim().Length < 2)             {                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                Common_Prefix = Table_Name + "_";             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             PropertyInfo[] fields = Object_Instance.GetType().GetProperties();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (PropertyInfo t in fields)                         {                             if (dc.ColumnName == t.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), ""))                             {                                 t.SetValue(obj, dr[dc.ColumnName].ToString(), null);//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过DATATABLE和对象实例参数 为对象赋值(为指定类型对象属性赋值)         /// </summary>         /// <typeparam name="T">对象类型</typeparam>         /// <param name="dt">DATATABLE 类型参数</param>         /// <param name="Entry_Object">对象实例</param>         /// <returns>返回指定类型对象实例;调用方法: </returns>         public T SetPropertyValueForObjectByObjectAndDt<T>(DataTable dt, T Entry_Object)         {             Type Object_Type = Entry_Object.GetType();//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             PropertyInfo[] fields = Object_Instance.GetType().GetProperties();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             String str = typeof(T).GetType().Name.ToString();             if (Table_Name.ToString().Trim().Length < 2)             {                 String[] myarr;                 myarr = str.Split('_');                 Table_Name = myarr[myarr.Length - 1].ToString();             }

                Common_Prefix = Table_Name + "_";             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (PropertyInfo t in fields)                         {                             if (dc.ColumnName.ToLower() == t.Name.ToLower().ToString().Replace(Common_Prefix.ToLower().ToString(), ""))                             {                                 t.SetValue(obj, dr[dc.ColumnName].ToString(), null);//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过DATATABLE类型参数为指定类型对象字段赋值         /// </summary>         /// <typeparam name="T">指定类型</typeparam>         /// <param name="dt">DATDTABLE参数</param>         /// <returns>返回指定类型对象;调用方法: </returns>         public T SetFieldinfoValueForObjectByDt<T>(DataTable dt)         {             Type Object_Type = typeof(T);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);

                if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (FieldInfo f in fields)                         {                             if (dc.ColumnName.ToLower() == f.Name.ToLower())                             {                                 f.SetValue(obj, dr[dc.ColumnName.ToString()].ToString());//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过DATATABLE数据返回对象数组         /// </summary>         /// <typeparam name="T">泛型类参数</typeparam>         /// <param name="dt">数据表参数</param>         /// <returns>返回对象LIST数据</returns>         public List<T> SetFieldinfoValueForObjectListByDt<T>(DataTable dt)         {             List<T> list = new List<T>();             //定义T类型的实体             Type Object_Type = typeof(T);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性                     object obj = Activator.CreateInstance(Object_Type, null);

                        foreach (DataColumn dc in dt.Columns)                     {                         foreach (FieldInfo f in fields)                         {

                                if (dc.ColumnName.ToLower() == f.Name.ToLower())                             {                                 f.SetValue(obj, dr[dc.ColumnName.ToString()].ToString());//给对象赋值                                 continue;                             }

                            }

                        }                     list.Add(((T)obj));                 }

                }             return list;         }         /// <summary>         /// 通过DATATABLE数据参数和指定实例类型参数来对实体类型参数赋值(为指定类型对象字段赋值)         /// </summary>         /// <typeparam name="T">指定类型</typeparam>         /// <param name="dt">DATATABLE数据参数</param>         /// <param name="Entry_Object">指定类型参数</param>         /// <returns>返回赋值完毕后的指定类型对象;调用方法: </returns>         public T SetFieldinfoValueForObjectByObjectAndDt<T>(DataTable dt, T Entry_Object)         {             Type Object_Type = Entry_Object.GetType();//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (FieldInfo f in fields)                         {                             if (dc.ColumnName.ToLower() == f.Name.ToLower())                             {                                 f.SetValue(obj, dr[dc.ColumnName].ToString());//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             else             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (FieldInfo f in fields)                         {                             if (dc.ColumnName.ToLower() == f.Name.ToLower())                             {                                 f.SetValue(obj, dr[dc.ColumnName].ToString());//给对象赋值                                 continue;                             }

                            }

                        }                 }             }             return (T)obj;         }         /// <summary>         /// 通过DATATABLE数据参数和指定实例类型名称参数来对实体类型参数赋值(为指定类型对象字段赋值)         /// </summary>         /// <typeparam name="T">指定实例类型</typeparam>         /// <param name="dt">DATATABLE数据参数</param>         /// <param name="Class_Name">指定实例类型名称</param>         /// <returns>返回赋值完毕后的指定类型对象;调用方法: </returns>         public T SetFieldinfoValueForObjectObjectByClassNameAndDt<T>(DataTable dt, String Class_Name)         {             System.Type Object_Type = System.Type.GetType(Class_Name);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (FieldInfo f in fields)                         {                             if (dc.ColumnName.ToLower() == f.Name.ToLower())                             {                                 f.SetValue(obj, dr[dc.ColumnName].ToString());//给对象赋值                                 continue;                             }

                            }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过指定类型对象,为页面容器中的控件(TextBox)赋值;         /// </summary>         /// <typeparam name="T">指定类型</typeparam>         /// <param name="md">指定类型参数</param>         /// <param name="controls_content">容器控件名</param>         public void SetValueForTextBoxByObject<T>(T md, Control controls_content)         {             Type type = md.GetType();             object obj = Activator.CreateInstance(type);             FieldInfo[] props = type.GetFields();             foreach (FieldInfo p in props)             {                 foreach (Control ctrl in controls_content.Controls)                 {                     if (ctrl is TextBox)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToString())                         {

                                ((TextBox)ctrl).Text = p.GetValue(md).ToString();                         }                     }                 }

                }         }         /// <summary>         /// 通过DATATABLE参数和控件容器为空件容器中的TEXTBOX赋值;         /// </summary>         /// <param name="dt">DATATABLE参数</param>         /// <param name="controls_content">容器控件</param>         public void SetValueForTextBoxByDt(DataTable dt, Control controls_content)         {             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (Control ctrl in controls_content.Controls)                         {                             if (ctrl is TextBox)                             {                                 String str = ctrl.ID.ToString();                                 Controls_Prefix = "";                                 String[] myarr;                                 myarr = str.Split('_');                                 Controls_Prefix = myarr[myarr.Length - 1].ToString();

                                    if (dc.ColumnName.ToLower().ToString() == Controls_Prefix.ToLower().ToString())                                 {

                                        ((TextBox)ctrl).Text = dr[dc.ColumnName].ToString();                                     continue;                                 }                             }                         }                     }                 }             }

            }

            public void SetValueForLabelByDt(DataTable dt, Control controls_content)         {             if (dt.Rows.Count == 1)             {                 foreach (DataRow dr in dt.Rows)                 {                     foreach (DataColumn dc in dt.Columns)                     {                         foreach (Control ctrl in controls_content.Controls)                         {                             if (ctrl is Label)                             {                                 String str = ctrl.ID.ToString();                                 Controls_Prefix = "";                                 String[] myarr;                                 myarr = str.Split('_');                                 Controls_Prefix = myarr[myarr.Length - 1].ToString();

                                    if (dc.ColumnName.ToLower().ToString() == Controls_Prefix.ToLower().ToString())                                 {

                                        ((Label)ctrl).Text = dr[dc.ColumnName].ToString();                                     continue;                                 }                             }                         }                     }                 }             }

            }

            public void SetValueForLabelBy_Object<T>(T md, Control controls_content)         {             Type type = md.GetType();             object obj = Activator.CreateInstance(type);             FieldInfo[] props = type.GetFields();             foreach (FieldInfo p in props)             {                 foreach (Control ctrl in controls_content.Controls)                 {                     if (ctrl is Label)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString())                         {

                                ((Label)ctrl).Text = p.GetValue(obj).ToString();                         }                     }                 }

                }         }         /// <summary>         /// 生成类中属性和字段的流代码         /// </summary>         /// <param name="propertyName">字段名称</param>         /// <returns>返回文本字符串;调用方法: </returns>         public String CreateClassPropertyFieldsString(String Prefix, String propertyName)         {             StringBuilder sbProperty = new StringBuilder();             sbProperty.Append(" /*<br>*" + "对应数据库中表“" + Prefix.ToString() + "”中的字段:" + propertyName.ToString() + "<BR>*/<BR>" + "public   String   " + propertyName + "   = \"\";\n<br>");             sbProperty.Append(" /*<br>*" + "对应数据库中表“" + Prefix.ToString() + "”中的字段:" + propertyName.ToString() + "<BR>*/<BR>" + " public   String   " + Prefix.ToString() + propertyName + "\n");             sbProperty.Append(" {<br>\n");             sbProperty.Append("<br> get{ <br>  return   " + propertyName + ";<br>}   \n");             sbProperty.Append("<br> set{ <br>  " + propertyName + "   =   value;  <br> }\n");             sbProperty.Append(" <br>}<br>");             return sbProperty.ToString();         }         /// <summary>         /// 通过页面控件(TextBox)为指定对象类型实例对象赋值         /// </summary>         /// <typeparam name="T">指定对象类型</typeparam>         /// <param name="Entry_Object">实例对象</param>         /// <param name="controls_content">控件容器名称</param>         /// <returns>返回赋值后的指定类型;调用方法: </returns>         public T SetFieldinfoValueForObjectByControls<T>(T Entry_Object, Control controls_content)         {             Type Object_Type = Entry_Object.GetType();//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             foreach (Control ctrl in controls_content.Controls)             {                 foreach (FieldInfo p in fields)                 {

                        if (ctrl is TextBox)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((TextBox)ctrl).Text.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((TextBox)ctrl).Text.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //RadioButtonList                     if (ctrl is RadioButtonList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((RadioButtonList)ctrl).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((RadioButtonList)ctrl).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //DropDownList                     if (ctrl is DropDownList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((DropDownList)ctrl).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((DropDownList)ctrl).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }

                        //CheckBoxList                     if (ctrl is CheckBoxList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            string checkliststr = "";                         for (int i = 0; i < ((CheckBoxList)ctrl).Items.Count; i++)                         {                             if (((CheckBoxList)ctrl).Items[i].Selected == true)                             {                                 checkliststr = checkliststr + ((CheckBoxList)ctrl).SelectedValue.ToString() + ";";                             }                         }

                            checkliststr = checkliststr.Substring(0, checkliststr.Length - 1);                         if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && checkliststr.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, checkliststr.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                 }

                }             return (T)obj;         }         /// <summary>         /// 通过页面控件(TextBox)为指定对象类型实例对象赋值         /// </summary>         /// <typeparam name="T">指定对象类型</typeparam>         /// <param name="controls_content">控件容器名称</param>         /// <returns>返回赋值后的指定对象</returns>         public T SetFieldinfoValueForObjectByControls<T>(Control controls_content)         {             Type Object_Type = typeof(T);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             foreach (Control ctrl in controls_content.Controls)             {                 foreach (FieldInfo p in fields)                 {

                        if (ctrl is TextBox)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((TextBox)ctrl).Text.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((TextBox)ctrl).Text.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //RadioButtonList                     if (ctrl is RadioButtonList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((RadioButtonList)ctrl).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((RadioButtonList)ctrl).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //DropDownList                     if (ctrl is DropDownList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && ((DropDownList)ctrl).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((DropDownList)ctrl).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }

                        //CheckBoxList                     if (ctrl is CheckBoxList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            string checkliststr = "";                         for (int i = 0; i < ((CheckBoxList)ctrl).Items.Count; i++)                         {                             if (((CheckBoxList)ctrl).Items[i].Selected == true)                             {                                 checkliststr = checkliststr + ((CheckBoxList)ctrl).SelectedValue.ToString() + ";";                             }                         }

                            checkliststr = checkliststr.Substring(0, checkliststr.Length - 1);                         if (p.Name.ToLower().ToString() == Controls_Prefix.ToLower().ToString() && checkliststr.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, checkliststr.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                 }

                }             return (T)obj;         }         /*****************************************************************************************************************************          *          * CACHE获取值 开始          *          * ***************************************************************************************************************************/         /// <summary>         /// 通过CACHE来获取页面控件的值         /// </summary>         /// <typeparam name="T">泛型类型参数</typeparam>         /// <param name="controls_content">页面容器参数</param>         /// <returns>返回赋值后的对象</returns>         public T SetFieldinfoValueForObjectByCache<T>(Control controls_content)         {             Type Object_Type = typeof(T);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             String str = Object_Type.Name.ToString().ToUpper();             Controls_Prefix = "";             String[] myarr;             myarr = str.Split('_');             Controls_Prefix = myarr[myarr.Length - 1].ToString();

                foreach (FieldInfo p in fields)             {                 String CID = "";                 CID = "txt_" + Controls_Prefix.ToString().ToUpper() + "_" + p.Name.ToString().ToUpper();                 CID = CID.ToUpper();                 if (controls_content.FindControl(CID) != null)                 {                     Type type = webCache.GetCacheObjectByCachekey(CID.ToUpper()).GetType();                     if (type.Name.ToString().ToUpper() == "TEXTBOX")                     {

                            if (((TextBox)controls_content.FindControl(CID)).Text.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((TextBox)controls_content.FindControl(CID)).Text.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //RadioButtonList                     if (type.Name.ToString().ToUpper() == "RADIOBUTTONLIST")                     {

                            if (((RadioButtonList)controls_content.FindControl(CID)).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((RadioButtonList)controls_content.FindControl(CID)).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                     //DropDownList                     if (type.Name.ToString().ToUpper() == "DROPDOWNLIST")                     {                         if (((DropDownList)controls_content.FindControl(CID)).SelectedValue.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, ((DropDownList)controls_content.FindControl(CID)).SelectedValue.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }

                        //CheckBoxList                     if (type.Name.ToString().ToUpper() == "CHECKBOXLIST")                     {                         string checkliststr = "";                         for (int i = 0; i < ((CheckBoxList)controls_content.FindControl(CID)).Items.Count; i++)                         {                             if (((CheckBoxList)controls_content.FindControl(CID)).Items[i].Selected == true)                             {                                 checkliststr = checkliststr + ((CheckBoxList)controls_content.FindControl(CID)).SelectedValue.ToString() + ";";                             }                         }

                            checkliststr = checkliststr.Substring(0, checkliststr.Length - 1);                         if (checkliststr.ToString().Trim().Length > 0)                         {                             p.SetValue(obj, checkliststr.ToString());//给对象赋值                             continue;  // ((TextBox)ctrl).Text = p.GetValue(md, null).ToString();                         }

                        }                 }                 else                 {                     webCache.AddObjectToCache("ERROR", webCache.GetCacheObjectByCachekey("ERROR") + CID.ToUpper() + "值为空;");                 }             }

                return (T)obj;         }         /*****************************************************************************************************************************          *          * CACHE获取值 结束          *          * ***************************************************************************************************************************/         /// <summary>         /// 为页面控件赋值         /// </summary>         /// <typeparam name="T">泛型类名</typeparam>         /// <param name="md">实体对象参数</param>         /// <param name="controls_content">控件容器</param>         public void SetValueForControlsByObject<T>(T md, Control controls_content)         {

                Type type = md.GetType();             object obj = Activator.CreateInstance(type);

                FieldInfo[] props = type.GetFields();             foreach (FieldInfo p in props)             {                 foreach (Control ctrl in controls_content.Controls)                 {                     if (ctrl is TextBox)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString().ToLower() == Controls_Prefix.ToString().ToLower())                         {                             ((TextBox)ctrl).Text = p.GetValue(md).ToString();                         }                     }                     //RadioButtonList                     if (ctrl is RadioButtonList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString().ToLower() == Controls_Prefix.ToString().ToLower())                         {                             for (int i = 0; i < ((RadioButtonList)ctrl).Items.Count; i++)                             {                                 if (((RadioButtonList)ctrl).Items[i].Value.ToString() == p.GetValue(md).ToString())                                 {                                     ((RadioButtonList)ctrl).Items[i].Selected = true;                                 }                             }

                            }                     }

                        if (ctrl is DropDownList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString().ToLower() == Controls_Prefix.ToString().ToLower())                         {                             for (int i = 0; i < ((DropDownList)ctrl).Items.Count; i++)                             {                                 if (((DropDownList)ctrl).Items[i].Value.ToString() == p.GetValue(md).ToString())                                 {                                     ((DropDownList)ctrl).Items[i].Selected = true;                                 }                             }

                            }                     }

                        if (ctrl is CheckBoxList)                     {                         String str = ctrl.ID.ToString();                         Controls_Prefix = "";                         String[] myarr;                         myarr = str.Split('_');                         Controls_Prefix = myarr[myarr.Length - 1].ToString();

                            if (p.Name.ToLower().ToString().ToLower() == Controls_Prefix.ToString().ToLower())                         {                             string checkliststr = p.GetValue(md).ToString();                             string[] arrays;                             if (checkliststr.IndexOf(';') > 0)                             {                                 arrays = checkliststr.Split(';');

                                    for (int j = 0; j < arrays.Length; j++)                                 {                                     string m = arrays[j].ToString();

                                        for (int i = 0; i < ((CheckBoxList)ctrl).Items.Count; i++)                                     {                                         if (((CheckBoxList)ctrl).Items[i].Value.ToString() == m.ToString())                                         {                                             ((CheckBoxList)ctrl).Items[i].Selected = true;                                         }                                     }                                 }                             }                             else                             {

                                    for (int i = 0; i < ((CheckBoxList)ctrl).Items.Count; i++)                                 {                                     if (((CheckBoxList)ctrl).Items[i].Value.ToString() == p.GetValue(md).ToString())                                     {                                         ((CheckBoxList)ctrl).Items[i].Selected = true;                                     }                                 }                             }

                            }                     }                 }

                }         }         public void SetValueForControlsAutoByObject<T>(T md, Control controls_content)         {             Type type = md.GetType();             object obj = Activator.CreateInstance(type);             String str = type.Name.ToString();             Controls_Prefix = "";             String[] myarr;             myarr = str.Split('_');             Controls_Prefix = myarr[myarr.Length - 1].ToString();

                PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);             foreach (PropertyInfo p in props)             {                 String CID = "TXT_" + p.Name.ToString().ToUpper();

                    Type ctrltype;                 if (controls_content.FindControl(CID.ToUpper()) != null)                 {                     ctrltype = controls_content.FindControl(CID.ToUpper()).GetType();                     if (ctrltype.Name.ToString().ToUpper() == "TEXTBOX")                     {                         ((TextBox)controls_content.FindControl(CID.ToUpper())).Text = p.GetValue(md, null).ToString();

                        }                     //RadioButtonList                     if (ctrltype.Name.ToString().ToUpper() == "RADIOBUTTONLIST")                     {

                            if (p.Name.ToLower().ToString().ToLower() == Controls_Prefix.ToString().ToLower())                         {                             for (int i = 0; i < ((RadioButtonList)controls_content.FindControl(CID.ToUpper())).Items.Count; i++)                             {                                 if (((RadioButtonList)controls_content.FindControl(CID.ToUpper())).Items[i].Value.ToString() == p.GetValue(md, null).ToString().ToString())                                 {                                     ((RadioButtonList)controls_content.FindControl(CID.ToUpper())).Items[i].Selected = true;                                 }                             }

                            }                     }

                        if (ctrltype.Name.ToString().ToUpper() == "DROPDOWNLIST")                     {                         for (int i = 0; i < ((DropDownList)controls_content.FindControl(CID.ToUpper())).Items.Count; i++)                         {                             if (((DropDownList)controls_content.FindControl(CID.ToUpper())).Items[i].Value.ToString() == p.GetValue(md, null).ToString())                             {                                 ((DropDownList)controls_content.FindControl(CID.ToUpper())).Items[i].Selected = true;                             }                         }

                        }

                        if (ctrltype.Name.ToString().ToUpper() == "CHECKBOXLIST")                     {

                            string checkliststr = p.GetValue(md, null).ToString();                         string[] arrays;                         if (checkliststr.IndexOf(';') > 0)                         {                             arrays = checkliststr.Split(';');

                                for (int j = 0; j < arrays.Length; j++)                             {                                 string m = arrays[j].ToString();

                                    for (int i = 0; i < ((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items.Count; i++)                                 {                                     if (((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items[i].Value.ToString() == m.ToString())                                     {                                         ((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items[i].Selected = true;                                     }                                 }                             }                         }                         else                         {

                                for (int i = 0; i < ((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items.Count; i++)                             {                                 if (((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items[i].Value.ToString() == p.GetValue(md, null).ToString())                                 {                                     ((CheckBoxList)controls_content.FindControl(CID.ToUpper())).Items[i].Selected = true;                                 }                             }                         }

                        }

                    }             }         }         /// <summary>

            /*******************************************************************************************          *          *          *          * DAL层泛型数据库添加、修改、删除、更新、获取列表等功能函数          *          *          *          *          *          * *****************************************************************************************/

            /// <summary>         /// 通过MODEL对象参数 向数据库中添加一条信息         /// </summary>         /// <param name="MODEL">对象参数</param>         /// <returns>返回整型,成功返回1否则为0</returns>         public int CommonAdd<T>(T MODEL)         {             String SQL_STR = "";

                SQL_STR = SqlInsertBuilder<T>(MODEL);

                return ExecuteNonQuery(SQL_STR);

            }         public int CommonAdd(DataSet Ds)         {             String SQL_STR = "";

                SQL_STR = SqlInsertBuilder(Ds);

                return ExecuteNonQuery(SQL_STR);

            }         public int CommonAdd(DataTable dt)         {             String SQL_STR = "";

                SQL_STR = SqlInsertBuilder(dt);

                return ExecuteNonQuery(SQL_STR);

            }         /// <summary>         ///通过对象参数获取数据库对象         /// </summary>         /// <param name="MODEL">数据对象参数</param>         /// <returns>返回数据对象信息</returns>         public T CommonGetMember<T>(T MODEL)         {

                String SQL_Str = "";             SQL_Str = SqlStrSelectBuilder<T>(MODEL);             DT.Clear();             DT = ExecuteDataTable(SQL_Str);

                return SetFieldinfoValueForObjectByObjectAndDt<T>(DT, MODEL);

            }

            /// <summary>         /// 通过对象参数更新数据库         /// </summary>         /// <param name="MODEL">对象参数</param>         /// <returns>返回整型数据 0:更新失败;根据对象参数可以批量更新,只要是符合条件 </returns>         public int CommonUpdate<T>(T MODEL, String KeyStr)         {             String SQL_STR = "";

                SQL_STR = SqlStrUpdateBuilder<T>(MODEL, KeyStr);

                return ExecuteNonQuery(SQL_STR);

            }         /// <summary>         /// 通过对象参数删除数据信息         /// </summary>         /// <param name="MODEL">对象参数</param>         /// <returns>返回整型值;0删除失败;根据对象参数可以批量删除,只要是符合条件</returns>         public int CommonDelete<T>(T MODEL)         {

                return ExecuteNonQuery(SqlStrDeleteBuilder<T>(MODEL));

            }         /// <summary>         /// 执行SQL语句返回影响行数         /// </summary>         /// <param name="SQL_STR">SQL语句参数</param>         /// <returns>返回影响行数</returns>         public int CommonExecuteSQLReturnInt(String SQL_STR)         {             int flag = 0;             flag = ExecSqlString(SQL_STR);             return flag;

            }         /// <summary>         /// 通过对象参数,获取DATASET数据表         /// </summary>         /// <param name="MODEL">对象参数</param>         /// <returns>返回DATASET类型变量</returns>         public DataSet CommonGetDataSet<T>(T MODEL)         {             String SQL_Str = "";             SQL_Str = SqlStrSelectBuilder<T>(MODEL);             DS.Clear();             DS = ExecuteDataSet(SQL_Str);             return DS;         }

            /// <summary>         /// 通过对象参数,获取DATATABLE数据表         /// </summary>         /// <param name="MODEL">对象参数</param>         /// <returns>返回DATATABLE类型变量</returns>         public DataTable CommonGetDataTable<T>(T MODEL)         {             String SQL_Str = "";             SQL_Str = SqlStrSelectBuilder<T>(MODEL);             DT.Clear();             DT = ExecuteDataTable(SQL_Str);             return DT;         }

            public DataSet CommonGetDataSetByKeywords<T>(string Keywords)         {             String SQL_Str = "";             SQL_Str = SqlSelectStrByKeyBuilder<T>(Keywords);             DS.Clear();             DS = ExecuteDataSet(SQL_Str);             return DS;         }         public DataSet CommonGetDataSet(String Str_SQL)         {             DS.Clear();             DS = ExecuteDataSet(Str_SQL);             return DS;         }

            public DataSet GetDataSetBySqlstr(String Str_SQL)         {             DS.Clear();                        DS = ExecuteDataSet(Str_SQL);             return DS;         }         public DataTable CommonGetDataTableByKeywords<T>(string Keywords)         {             String SQL_Str = "";             SQL_Str = SqlSelectStrByKeyBuilder<T>(Keywords);             DT.Clear();             DT = ExecuteDataTable(SQL_Str);             return DT;         }         public DataTable CommonGetDataTable(String Str_SQL)         {             DT.Clear();                        DT = ExecuteDataTable(Str_SQL);             return DT;         }         public DataTable GetDataTableByExcuteSql(String Str_SQL)         {             DT.Clear();                        DT = ExecuteDataTable(Str_SQL);             return DT;         }

            public DataTable GetLotNoInfoByLotNo(String Lot_No)         {             String Str_SQL = "";             if (Lot_No.ToString().Trim().Length > 0)             {                 Str_SQL = "Select    CO_CODE, WIP_ID, PROD_PN, FLOW_ID, LOT_NO, PRIORITY, CAT_ID, LN_ID, PROD_SN, ROHS, START_DATE, END_DATE, INPUT_QTY,OUTPUT_QTY, WIP_QTY, WIP_SEQ, WIP_PROC_ID, PROC_ID, NEXT_PROC_ID, PACK_READY, SPLIT_SEQ, PACK_QTY, PACK_NG_QTY,PACK_QC_QTY, SHIPMENT_QTY, SUB_CON, SUB_CON_ID, BOM_VER, FLOW_VER, STATUS, UPD_USR, UPD_TIME  from lot_info  where lot_no='" + Lot_No.ToString() + "'  limit 1";             }             else             {                 Str_SQL = "Select     CO_CODE, WIP_ID, PROD_PN, FLOW_ID, LOT_NO, PRIORITY, CAT_ID, LN_ID, PROD_SN, ROHS, START_DATE, END_DATE, INPUT_QTY,OUTPUT_QTY, WIP_QTY, WIP_SEQ, WIP_PROC_ID, PROC_ID, NEXT_PROC_ID, PACK_READY, SPLIT_SEQ, PACK_QTY, PACK_NG_QTY,PACK_QC_QTY, SHIPMENT_QTY, SUB_CON, SUB_CON_ID, BOM_VER, FLOW_VER, STATUS, UPD_USR, UPD_TIME    from lot_info  where lot_no='13548641qwer32tgw1e65t4s3f216er8f1' limit 1 ";             }             DT.Clear();             DT = ExecuteDataTable(Str_SQL);             return DT;         }         /// <summary>         /// 通过SQL语句绑定DROPDOWNLIST,DROPDOWNLIST可以加入提示信息         /// </summary>         /// <param name="Dropl">需要绑定的DROPDOWNLIST名称</param>         /// <param name="StrSQL">SQL语句参数</param>         /// <param name="DataTextField">DROPDOWNLIST显示TEXT参数栏位名</param>         /// <param name="DataValueField">DROPDOWNLIST选中时值栏位名</param>         public static void BindDropDownListWithMessageBySqlString(DropDownList Dropl, string StrSQL, String DataTextField, string DataValueField, string message)         {             Dropl.Items.Clear();             if (message.Length > 0)             {                 Dropl.AppendDataBoundItems = true;                 Dropl.Items.Add("0");                 Dropl.Items[0].Text = message;                 Dropl.Items[0].Value = "-1";                 Dropl.Items[0].Selected = true;             }             Dropl.DataSourceID = null;

                Dropl.DataSource = GetDataSetByExecuteSQL(StrSQL);             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();

            }

            /// <summary>         ///通过SQL语句来绑定GRIDVIEW         /// </summary>         /// <param name="dgrd">需要绑定数据的GRIDVIEW名称</param>         /// <param name="StrSQL">传入的SQL语句</param>         public static void BindGridviewBySqlString(GridView dgrd, string StrSQL)         {             dgrd.DataSourceID = null;             dgrd.DataSource = GetDataSetByExecuteSQL(StrSQL);             dgrd.DataBind();

            }

            /// <summary>         ///通过SQL语句来绑定DATALIST         /// </summary>         /// <param name="dgrd">需要绑定数据的DATALIST名称</param>         /// <param name="strSql">传入的SQL语句</param>         public static void BindDataListBySqlString(DataList dtl, string StrSQL)         {             dtl.DataSourceID = null;             dtl.DataSource = GetDataSetByExecuteSQL(StrSQL);             dtl.DataBind();         }         /// <summary>         /// 动态绑定DATATABLE到GRIDVIEW         /// </summary>         /// <param name="dgrd">要绑定的GRIDVIEW名称</param>         /// <param name="datablename">DATABLE名称</param>         /// <param name="strDataKey">GRICVIEW中要取的键值</param>         public static void BindGridViewByDatatable(GridView dgrd, DataTable datablename, string strDataKey)         {             dgrd.Columns.Clear();             dgrd.AutoGenerateColumns = false;             dgrd.DataSource = datablename;             dgrd.DataKeyNames = new string[] { strDataKey };             for (int i = 0; i < datablename.Columns.Count; i++)   //绑定普通数据列             {                 BoundField bfColumn = new BoundField();                 bfColumn.DataField = datablename.Columns[i].ColumnName;                 bfColumn.HeaderText = datablename.Columns[i].Caption;                 dgrd.Columns.Add(bfColumn);             }             if (datablename.Rows.Count == 0)//防止无数据表头不显示             {                 DataRow dr = datablename.NewRow();                 datablename.Rows.Add(dr);                 dgrd.DataSource = datablename;             }

                dgrd.DataBind();

            }         /// <summary>         /// 通过SQL语句绑定DROPDOWNLIST         /// </summary>         /// <param name="Dropl">需要绑定的DROPDOWNLIST名称</param>         /// <param name="StrSQL">SQL语句参数</param>         /// <param name="DataTextField">DROPDOWNLIST显示TEXT参数栏位名</param>         /// <param name="DataValueField">DROPDOWNLIST选中时值栏位名</param>         public static void BindDropDownListBySqlString(System.Web.UI.WebControls.DropDownList Dropl, string StrSQL, String DataTextField, string DataValueField)         {             Dropl.Items.Clear();             Dropl.DataSourceID = null;             Dropl.DataSource = GetDataSetByExecuteSQL(StrSQL);             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();         }         /// <summary>         /// 通过SQL语句绑定REDIOBUTTONLIST         /// </summary>         /// <param name="Dropl">需要绑定的REDIOBUTTONLIST名称</param>         /// <param name="StrSQL">SQL语句参数</param>         /// <param name="DataTextField">REDIOBUTTONLIST显示TEXT参数栏位名</param>         /// <param name="DataValueField">REDIOBUTTONLIST选中时值栏位名</param>         public static void BindRadioButtonListBySqlString(System.Web.UI.WebControls.RadioButtonList Dropl, string StrSQL, String DataTextField, String DataValueField)         {             Dropl.Items.Clear();             Dropl.DataSourceID = null;             Dropl.DataSource = GetDataSetByExecuteSQL(StrSQL);             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();         }         public static void BindRadioButtonListByDs(System.Web.UI.WebControls.RadioButtonList Dropl, DataSet Ds, String DataTextField, String DataValueField)         {             Dropl.Items.Clear();             Dropl.DataSourceID = null;             Dropl.DataSource = Ds;             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();         }         /// <summary>         /// 通过SQL语句绑定CheckBoxList         /// </summary>         /// <param name="Dropl">需要绑定的CheckBoxList名称</param>         /// <param name="StrSQL">SQL语句参数</param>         /// <param name="DataTextField">CheckBoxList显示TEXT参数栏位名</param>         /// <param name="DataValueField">CheckBoxList选中时值栏位名</param>         public static void BindCheckBoxListBySqlString(System.Web.UI.WebControls.CheckBoxList Dropl, string StrSQL, String DataTextField, String DataValueField)         {             Dropl.Items.Clear();             Dropl.DataSourceID = null;             Dropl.DataSource = GetDataSetByExecuteSQL(StrSQL);             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();         }         public static void BindCheckBoxListByDs(System.Web.UI.WebControls.CheckBoxList Dropl, DataSet Ds, String DataTextField, String DataValueField)         {             Dropl.Items.Clear();             Dropl.DataSourceID = null;             Dropl.DataSource = Ds;             Dropl.DataTextField = DataTextField;             Dropl.DataValueField = DataValueField;             Dropl.DataBind();         }         /// <summary>         /// 通过数据库表名称判断用户输入数据是否合法         /// </summary>         /// <param name="controls_content">控件集合参数</param>         /// <param name="tablename">数据库表名称</param>         /// <returns>返回字符串(哪些输入非法数据)</returns>         public String CheckInputValidate(Control controls_content, string tablename)         {             String Error = "你所输入信息有如下错误:";             Int32 ErrorNo = 0;

                DataTable dt1 = new DataTable();             DataTable dt = new DataTable();             dt1 = MTS2.DBUtility.MySqlServerHelper.ExecuteDataTable("desc " + tablename);             dt = dt1;

                foreach (Control ctrl in controls_content.Controls)             {                 if (ctrl is TextBox)                 {                     String str = ctrl.ID.ToString();                     String Controls_Prefix = "";                     String[] myarr;                     String Keywords = "";                     myarr = str.Split('_');                     Controls_Prefix = myarr[myarr.Length - 1].ToString();                     string Str = "";                     if (dt1.Select("field='" + Controls_Prefix + "'").Length > 0)                     {                         Str = dt1.Select("field='" + Controls_Prefix + "'")[0]["type"].ToString();                         Keywords = dt.Select("field='" + Controls_Prefix + "'")[0]["Key"].ToString();                     }                     if (((TextBox)ctrl).Text.ToString().Trim().Length == 0 && Keywords.ToString().Trim() == "PRI")                     {                         string MyTEXT = "";                         string lblID = "";                         lblID = ctrl.ID.ToString().Replace("txt", "lbl");                         if (controls_content.FindControl(lblID) != null)                         {                             MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                         }                         ErrorNo = ErrorNo + 1;                         Error = Error + "【" + ErrorNo.ToString() + "】" + "KEY字段" + MyTEXT + "的值不能为空!;";

                        }                     if (Str.IndexOf('(') > 0)                     {                         Str = Str.Substring(Str.IndexOf('(') + 1, Str.IndexOf(')') - Str.IndexOf('(') - 1);                         Int64 MYFLAG = 1;                         String[] myarrs;                         myarrs = Str.Split(',');                         if (myarrs.Length > 1)                         {                             Int64 p = 0;                             p = Convert.ToInt32(myarrs[0]) - Convert.ToInt32(myarrs[1]);                             for (int i = 0; i < p; i++)                             {                                 MYFLAG = MYFLAG * 10;                             }                             if (((TextBox)ctrl).Text.ToString().Trim().Length == 0 || ((TextBox)ctrl).Text.ToString().Trim().Length > 16)                             {                                 p = 0;                             }                             else                             {                                 Double DB = 0;                                 DB = Convert.ToDouble(((TextBox)ctrl).Text.ToString());

                                    if (DB > MYFLAG)                                 {                                     string MyTEXT = "";                                     string lblID = "";                                     lblID = ctrl.ID.ToString().Replace("txt", "lbl");                                     if (controls_content.FindControl(lblID) != null)                                     {                                         MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                                     }                                     ErrorNo = ErrorNo + 1;                                     Error = Error + "【" + ErrorNo.ToString() + "】输入值:" + ((TextBox)ctrl).Text.ToString() + "超出最大值" + MYFLAG.ToString() + "!;";                                 }                             }                         }                         else                         {                             MYFLAG = Convert.ToInt32(myarrs[0]);                             string MyTEXT = "";                             string lblID = "";                             lblID = ctrl.ID.ToString().Replace("txt", "lbl");                             if (controls_content.FindControl(lblID) != null)                             {                                 MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                             }                             if (((TextBox)ctrl).Text.ToString().Length > MYFLAG)                             {                                 ErrorNo = ErrorNo + 1;                                 Error = Error + "【" + ErrorNo.ToString() + "】输入信息:" + ((TextBox)ctrl).Text.ToString() + "超过" + MYFLAG.ToString() + "个字符的存储长度!;";                             }

                            }                     }

                    }             }             return Error;         }         /*************************************************************************************************************          *          * 检查输入信息是否合法开始          *          * ************************************************************************************************************/         public String CheckInputValidate<T>(Control controls_content)         {             String Error = "你所输入信息有如下错误:";             Int32 ErrorNo = 0;             String tablename = "";

                Type Object_Type = typeof(T);//获取指定名称的类型             object Object_Instance = Activator.CreateInstance(Object_Type, null);//创建指定类型实例             FieldInfo[] fields = Object_Instance.GetType().GetFields();//获取指定对象的所有公共属性             object obj = Activator.CreateInstance(Object_Type, null);             String str = Object_Type.Name.ToString().ToUpper();             String Controls_Prefix = "";             String[] myarr;             myarr = str.Split('_');             tablename = myarr[myarr.Length - 1].ToString();             DataTable dt1 = new DataTable();             DataTable dt = new DataTable();             dt1 = MTS2.DBUtility.MySqlServerHelper.ExecuteDataTable("desc " + tablename);             dt = dt1;

                foreach (FieldInfo ps in fields)             {                 Controls_Prefix = ps.Name.ToString().ToUpper();

                    String CID = "";                 CID = "TXT_" + tablename.ToString().ToUpper() + "_" + ps.Name.ToString().ToUpper();                 CID = CID.ToUpper();                 if (controls_content.FindControl(CID) != null)                 {

                        if (controls_content.FindControl(CID) is TextBox)                     {                         String Keywords = "";                         //myarr = str.Split('_');                         //Controls_Prefix = myarr[myarr.Length - 1].ToString();                         string Str = "";                         if (dt1.Select("field='" + Controls_Prefix + "'").Length > 0)                         {                             Str = dt1.Select("field='" + Controls_Prefix + "'")[0]["type"].ToString();                             Keywords = dt.Select("field='" + Controls_Prefix + "'")[0]["Key"].ToString();                         }                         if (((TextBox)controls_content.FindControl(CID)).Text.ToString().Trim().Length == 0 && Keywords.ToString().Trim() == "PRI")                         {                             string MyTEXT = "";                             string lblID = "";                             lblID = controls_content.FindControl(CID).ID.ToString().Replace("txt", "LBL");                             if (controls_content.FindControl(lblID) != null)                             {                                 MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                             }                             ErrorNo = ErrorNo + 1;                             Error = Error + "【" + ErrorNo.ToString() + "】" + "KEY字段" + MyTEXT + "的值不能为空!;";

                            }                         if (Str.IndexOf('(') > 0)                         {                             Str = Str.Substring(Str.IndexOf('(') + 1, Str.IndexOf(')') - Str.IndexOf('(') - 1);                             Int64 MYFLAG = 1;                             String[] myarrs;                             myarrs = Str.Split(',');                             if (myarrs.Length > 1)                             {                                 Int64 p = 0;                                 p = Convert.ToInt32(myarrs[0]) - Convert.ToInt32(myarrs[1]);                                 for (int i = 0; i < p; i++)                                 {                                     MYFLAG = MYFLAG * 10;                                 }                                 if (((TextBox)controls_content.FindControl(CID)).Text.ToString().Trim().Length == 0 || ((TextBox)controls_content.FindControl(CID)).Text.ToString().Trim().Length > 16)                                 {                                     p = 0;                                 }                                 else                                 {                                     Double DB = 0;                                     try                                     {                                         DB = Convert.ToDouble(((TextBox)controls_content.FindControl(CID)).Text.ToString());                                     }                                     catch                                     {                                         DB = -1;                                     }

                                        if (DB > MYFLAG)                                     {                                         string MyTEXT = "";                                         string lblID = "";                                         lblID = controls_content.FindControl(CID).ID.ToString().Replace("txt", "LBL");                                         if (controls_content.FindControl(lblID) != null)                                         {                                             MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                                         }                                         ErrorNo = ErrorNo + 1;                                         Error = Error + "【" + ErrorNo.ToString() + "】输入值:" + ((TextBox)controls_content.FindControl(CID)).Text.ToString() + "超出最大值" + MYFLAG.ToString() + "!;";                                     }                                     if (DB < 0)                                     {                                         string MyTEXT = "";                                         string lblID = "";                                         lblID = controls_content.FindControl(CID).ID.ToString().Replace("txt", "LBL");                                         if (controls_content.FindControl(lblID) != null)                                         {                                             MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                                         }                                         ErrorNo = ErrorNo + 1;                                         Error = Error + "【" + ErrorNo.ToString() + "】输入值:" + ((TextBox)controls_content.FindControl(CID)).Text.ToString() + "非法,不为数值型!;";

                                        }                                 }                             }                             else                             {                                 MYFLAG = Convert.ToInt32(myarrs[0]);                                 string MyTEXT = "";                                 string lblID = "";                                 lblID = controls_content.FindControl(CID).ID.ToString().Replace("txt", "LBL");                                 if (controls_content.FindControl(lblID) != null)                                 {                                     MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                                 }                                 if (((TextBox)controls_content.FindControl(CID)).Text.ToString().Length > MYFLAG)                                 {                                     ErrorNo = ErrorNo + 1;                                     Error = Error + "【" + ErrorNo.ToString() + "】输入信息:" + ((TextBox)controls_content.FindControl(CID)).Text.ToString() + "超过" + MYFLAG.ToString() + "个字符的存储长度!;";                                 }

                                }                         }

                            if (Str.ToLower().IndexOf("nt") > 0)                         {                             Int64 MYFLAG = 0;                             try                             {                                 MYFLAG = Convert.ToInt64(((TextBox)controls_content.FindControl(CID)).Text.ToString());                             }                             catch                             {                                 MYFLAG = -1;                             }                             string MyTEXT = "";                             string lblID = "";                             lblID = controls_content.FindControl(CID).ID.ToString().Replace("txt", "LBL");                             if (controls_content.FindControl(lblID) != null)                             {                                 MyTEXT = ((Label)(controls_content.FindControl(lblID))).Text.ToString();                             }                             if (MYFLAG < 0)                             {                                 ErrorNo = ErrorNo + 1;                                 Error = Error + "【" + ErrorNo.ToString() + "】输入信息:" + ((TextBox)controls_content.FindControl(CID)).Text.ToString() + "非法!;";                             }                             else if (MYFLAG > 1000000000000)                             {                                 ErrorNo = ErrorNo + 1;                                 Error = Error + "【" + ErrorNo.ToString() + "】输入信息:" + ((TextBox)controls_content.FindControl(CID)).Text.ToString() + "超过存储长度!;";

                                }

                            }

                        }                 }             }             return Error;         }         /**************************************************************************************************************          *          * 检查输入是否合法结束          *          * ************************************************************************************************************/         /// <summary>         /// 获得当前页面的名称         /// </summary>         /// <returns>当前页面的名称</returns>         public string GetPageName()         {             string[] urlArr = HttpContext.Current.Request.Url.AbsolutePath.Split('/');             return urlArr[urlArr.Length - 1].ToLower();         }         /// <summary>         /// 根据文件名称获取表名称;文件名称以_分开各部分,其中倒数第二个是相关表名         /// </summary>         /// <returns>返回表名称</returns>         public string GetTableName()         {             string PATH_INFO = HttpContext.Current.Request.ServerVariables["PATH_INFO"].ToString();             string[] myarr;             string webpagestr = "";             myarr = PATH_INFO.Split('/');             if (myarr.Length > 1)             {                 webpagestr = myarr[myarr.Length - 1].ToString();

                    string[] patharr = webpagestr.Split('_');

                    if (patharr.Length > 2)                 {                     webpagestr = patharr[patharr.Length - 2].ToString();                 }

                }             else             {                 webpagestr = PATH_INFO;             }             return webpagestr.ToUpper().ToString().Trim();         }         /// <summary>         /// 向WEB页面中添加隐藏信息         /// </summary>         /// <param name="ctrl_content">容器参数</param>         /// <param name="ctrlid">添加控件ID</param>         public void AddControl2Content(Control ctrl_content, string ctrlid)         {             HiddenField hfctrl = new HiddenField();             hfctrl.ID = ctrlid;             hfctrl.Value = GetTableName();             ctrl_content.Controls.Add(hfctrl);         }         /// <summary>         /// 向WEB页面中添加隐藏信息         /// </summary>         /// <param name="ctrl_content">容器参数</param>         /// <param name="ctrlid">添加控件ID</param>         /// <param name="ctrlvalue">添加控件的值</param>         public void AddControl2Content(Control ctrl_content, string ctrlid, string ctrlvalue)         {             HiddenField hfctrl = new HiddenField();             hfctrl.ID = ctrlid;             hfctrl.Value = ctrlvalue;             ctrl_content.Controls.Add(hfctrl);         }         /***********************************************************************************************************************************          *          *          * WEB页面控件创建开始          *          *          * ********************************************************************************************************************************/         /// <summary>         ///根据配置文件向容器控件中添加控件         /// </summary>         /// <param name="panelself">容器控件参数</param>         /// <param name="xmlpath">配置文件路径</param>         public void CreateControl(Control panelself, string xmlpath)         {

                System.Web.UI.HtmlControls.HtmlContainerControl div1 = new HtmlGenericControl();             div1.ID = "divAutoList";             panelself.Controls.Add(div1);             DataSet ds = new DataSet();             ds.ReadXml(xmlpath);             HtmlGenericControl MYUL = new HtmlGenericControl("UL");//             MYUL.ID = panelself.ID.ToString() + "_UL";

                if (ds.Tables != null)             {                 if (ds.Tables[0].Rows.Count > 0)                 {                     //添加控件开始

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)                     {

                            ///文本框添加                         if (ds.Tables[0].Rows[i]["CTRLTYPE"].ToString().ToUpper() == "TEXTBOX")                         {                             HtmlGenericControl li = new HtmlGenericControl("li");//                             li.ID = "LI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             li.Attributes.Add("class", "lblcs");

                                Label txtbl = new Label();                             txtbl.ID = "LBL_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             txtbl.Text = ds.Tables[0].Rows[i]["CtrlID"].ToString();                             //txtbl.Lang = Lblprefix + ds.Tables[0].Rows[i]["CtrlID"].ToString();                             li.Controls.Add(txtbl);                             MYUL.Controls.Add(li);

                                //添加文本                             HtmlGenericControl txtli = new HtmlGenericControl("li");//                             txtli.ID = "TXTLI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             txtli.Attributes.Add("class", "txtcs");

                                TextBox txtb = new TextBox();                             // txtb.Text = ds.Tables[0].Rows[i]["ctrlvalue"].ToString();                             if (ds.Tables[0].Rows[i]["CtrlValue"].ToString().ToUpper().Length > 6)                             {                                 txtb.ID = ds.Tables[0].Rows[i]["CtrlValue"].ToString().ToUpper().Replace("$AUTO$", "");                             }                             else                             {                                 txtb.ID = "txt_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             }                             txtb.Text = "";

                                try                             {                                 txtb.MaxLength = Convert.ToInt32(ds.Tables[0].Rows[i]["ctrlLength"]);                             }                             catch                             {                                 txtb.MaxLength = 30;

                                }                             String FieldsType = "";                             FieldsType = "SAE" + ds.Tables[0].Rows[i]["fieldtype"].ToString().ToLower();                             CompareValidator compvr = new CompareValidator();                             if (FieldsType.ToString().ToLower().IndexOf("varchar") > 0 || FieldsType.ToString().ToLower().IndexOf("text") > 0)                             {                                 compvr.ID = "COMPVR_" + txtb.ID.ToString().ToUpper();                                 compvr.ControlToValidate = txtb.ID.ToString();                                 compvr.Display = ValidatorDisplay.Dynamic;                                 compvr.ErrorMessage = "请输入字符";                                 compvr.Operator = ValidationCompareOperator.DataTypeCheck;                                 compvr.Type = ValidationDataType.String;                             }                             else                             {                                 if (FieldsType.ToString().ToLower().IndexOf("oub") > 0 || FieldsType.ToString().ToLower().IndexOf("oat") > 0 || FieldsType.ToString().ToLower().IndexOf("dec") > 0)                                 {                                     compvr.ID = "COMPVR_" + txtb.ID.ToString().ToUpper();                                     compvr.ControlToValidate = txtb.ID.ToString();                                     compvr.Display = ValidatorDisplay.Dynamic;                                     compvr.ErrorMessage = "请输入数字";                                     compvr.Operator = ValidationCompareOperator.DataTypeCheck;                                     compvr.Type = ValidationDataType.Double;                                 }                                 else                                 {                                     if (FieldsType.ToString().ToLower().IndexOf("int") > 0 || FieldsType.ToString().ToLower().IndexOf("long") > 0)                                     {                                         compvr.ID = "COMPVR_" + txtb.ID.ToString().ToUpper();                                         compvr.ControlToValidate = txtb.ID.ToString();                                         compvr.Display = ValidatorDisplay.Dynamic;                                         compvr.ErrorMessage = "请输入数字";                                         compvr.Operator = ValidationCompareOperator.DataTypeCheck;                                         compvr.Type = ValidationDataType.Integer;                                     }                                     else                                     {

                                            if (FieldsType.ToString().ToLower().IndexOf("date") > 0 || FieldsType.ToString().ToLower().IndexOf("time") > 0 || FieldsType.ToString().ToLower().IndexOf("dec") > 0)                                         {                                             compvr.ID = "COMPVR_" + txtb.ID.ToString().ToUpper();                                             compvr.ControlToValidate = txtb.ID.ToString();                                             compvr.Display = ValidatorDisplay.Dynamic;                                             compvr.ErrorMessage = "请输入日期";                                             compvr.Operator = ValidationCompareOperator.DataTypeCheck;                                             compvr.Type = ValidationDataType.Date;                                         }                                         else                                         {                                             compvr.ID = "COMPVR_" + txtb.ID.ToString().ToUpper();                                             compvr.ControlToValidate = txtb.ID.ToString();                                             compvr.Display = ValidatorDisplay.Dynamic;                                             compvr.ErrorMessage = "请输入字符";                                             compvr.Operator = ValidationCompareOperator.DataTypeCheck;                                             compvr.Type = ValidationDataType.String;                                         }                                     }                                 }                             }                             txtli.Controls.Add(txtb);                             txtli.Controls.Add(compvr);                             MYUL.Controls.Add(txtli);

                            }                         ///CHECKBOXLIST                         if (ds.Tables[0].Rows[i]["CTRLTYPE"].ToString().ToUpper() == "CHECKBOXLIST")                         {                             HtmlGenericControl li = new HtmlGenericControl("li");//                             li.ID = "LI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             li.Attributes.Add("class", "lblcs");

                                Label txtbl = new Label();                             txtbl.ID = "LBL_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             txtbl.Text = ds.Tables[0].Rows[i]["CtrlID"].ToString();                             // txtbl.Lang = Lblprefix + ds.Tables[0].Rows[i]["CtrlID"].ToString();

                                li.Controls.Add(txtbl);                             MYUL.Controls.Add(li);                             //添加文本                             HtmlGenericControl CBli = new HtmlGenericControl("li");//                             CBli.ID = "CBLI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             CBli.Attributes.Add("class", "txtcs");

                                CheckBoxList txtb = new CheckBoxList();                             txtb.ID = "txt_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             if (ds.Tables[0].Rows[i]["ctrlvalue"].ToString().ToUpper() == "NULL" || ds.Tables[0].Rows[i]["ctrlvalue"] == null)                             {

                                }                             else                             {                                 string[] myarr = ds.Tables[0].Rows[i]["ctrlvalue"].ToString().Split(',');                                 if (myarr.Length > 0)                                 {                                     Int32 k = 0;                                     for (k = 0; k < myarr.Length; k++)                                     {                                         ListItem itm = new ListItem();

                                            itm.Text = myarr[k].ToString();                                         itm.Value = myarr[k].ToString();

                                            txtb.Items.Add(itm);                                     }                                 }                             }                             txtb.RepeatColumns = 2;                             txtb.Visible = true;                             CBli.Controls.Add(txtb);                             webCache.AddObjectToCache(txtb.ID.ToString().ToUpper(), txtbl);                             MYUL.Controls.Add(CBli);                         }                         ///DROPDOWNLIST                         if (ds.Tables[0].Rows[i]["CTRLTYPE"].ToString().ToUpper() == "DROPDOWNLIST")                         {

                                HtmlGenericControl li = new HtmlGenericControl("li");//                             li.ID = "LI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             li.Attributes.Add("class", "lblcs");

                                Label txtbl = new Label();                             // txtbl.Lang = Lblprefix + ds.Tables[0].Rows[i]["CtrlID"].ToString();                             txtbl.ID = "LBL_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             txtbl.Text = ds.Tables[0].Rows[i]["CtrlID"].ToString();

                                li.Controls.Add(txtbl);                             MYUL.Controls.Add(li);                             //添加文本

                                HtmlGenericControl DRli = new HtmlGenericControl("li");//                             DRli.ID = "DRLI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             DRli.Attributes.Add("class", "txtcs");

                                DropDownList txtb = new DropDownList();                             txtb.ID = "txt_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             if (ds.Tables[0].Rows[i]["ctrlvalue"].ToString().ToUpper() == "NULL" || ds.Tables[0].Rows[i]["ctrlvalue"] == null)                             {

                                }                             else                             {                                 string[] myarr = ds.Tables[0].Rows[i]["ctrlvalue"].ToString().Split(',');                                 if (myarr.Length > 0)                                 {                                     Int32 k = 0;                                     for (k = 0; k < myarr.Length; k++)                                     {                                         ListItem itm = new ListItem();

                                            itm.Text = myarr[k].ToString();                                         itm.Value = myarr[k].ToString();

                                            txtb.Items.Add(itm);                                     }                                 }                             }

                                DRli.Controls.Add(txtb);

                                MYUL.Controls.Add(DRli);                         }                         ///REDIOBUTTONLIST                         if (ds.Tables[0].Rows[i]["CTRLTYPE"].ToString().ToUpper() == "RADIOBUTTONLIST")                         {

                                HtmlGenericControl li = new HtmlGenericControl("li");//                             li.ID = "LI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             li.Attributes.Add("class", "lblcs");

                                Label txtbl = new Label();                             txtbl.ID = "LBL_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             txtbl.Text = ds.Tables[0].Rows[i]["CtrlID"].ToString();                             // txtbl.Lang = Lblprefix + ds.Tables[0].Rows[i]["CtrlID"].ToString();                             txtbl.Visible = true;

                                li.Controls.Add(txtbl);                             MYUL.Controls.Add(li);                             //添加文本

                                HtmlGenericControl RDli = new HtmlGenericControl("li");//                             RDli.ID = "RDLI_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             RDli.Attributes.Add("class", "txtcs");

                                RadioButtonList txtb = new RadioButtonList();                             txtb.ID = "txt_" + ds.Tables[0].Rows[i]["PageName"].ToString().ToUpper() + "_" + ds.Tables[0].Rows[i]["CtrlID"].ToString().ToUpper();                             if (ds.Tables[0].Rows[i]["ctrlvalue"].ToString().ToUpper() == "NULL" || ds.Tables[0].Rows[i]["ctrlvalue"] == null)                             {

                                }                             else                             {                                 string[] myarr = ds.Tables[0].Rows[i]["ctrlvalue"].ToString().Split(',');                                 if (myarr.Length > 0)                                 {                                     Int32 k = 0;                                     for (k = 0; k < myarr.Length; k++)                                     {                                         ListItem itm = new ListItem();

                                            itm.Text = myarr[k].ToString();                                         itm.Value = myarr[k].ToString();

                                            txtb.Items.Add(itm);                                     }                                 }                             }                             txtb.RepeatColumns = 2;

                                txtb.Visible = true;                             RDli.Controls.Add(txtb);                             MYUL.Controls.Add(RDli);                         }                     }

                    }             }

                webCache.AddObjectToCache(panelself.ID.ToString(), MYUL);             panelself.Controls.Add(MYUL);

            }

            /// <summary>         /// 页面刷新时,保存控件信息         /// </summary>         /// <param name="panelself">生成控件所在容器参数</param>         /// <param name="xmlpath">页面配置文件路径参数</param>         public void LoadControl(Control panelself, string xmlpath)         {

                if (webCache.GetCacheObjectByCachekey(panelself.ID.ToString()) != null)             {                 Control ctrl = (Control)(webCache.GetCacheObjectByCachekey(panelself.ID.ToString()));                 panelself.Controls.Add(ctrl);

                }             else             {                 CreateControl(panelself, xmlpath);             }         }         public void LoadControl(Control panelself)         {             System.Web.UI.HtmlControls.HtmlContainerControl div1 = new HtmlGenericControl();             div1.ID = "divAutoList";             panelself.Controls.Add(div1);

                if (webCache.GetCacheObjectByCachekey(panelself.ID.ToString()) != null)             {                 Control ctrl = (Control)(webCache.GetCacheObjectByCachekey(panelself.ID.ToString()));                 panelself.Controls.Add(ctrl);

                }

            }

            /***********************************************************************************************************************************          *          *          * WEB页面控件创建结束          *          *          * ********************************************************************************************************************************/     } }

  • 相关阅读:
    【树论】新二叉树
    【贪心】umi的函数
    【模拟】高精度练习之加法
    【模拟】高精度练习之减法
    【贪心】线段覆盖
    【树论】二叉树的序遍历
    【贪心】超级书架
    【动态规划】爱与愁的心痛
    【图论】牛大赛
    【图论】产生数
  • 原文地址:https://www.cnblogs.com/greefsong/p/2874878.html
Copyright © 2020-2023  润新知