فهرست منبع

【软件版本】
V-3.0.6.3,状态:未发布!
【模块名称】
G客户NTF功能
【问题原因】

【修改描述】
新增MSSQL数据库模块功能。
【测试结果】

sat23 3 سال پیش
والد
کامیت
d2bc970236

+ 1748 - 0
SCBC Factory Tools/DAL/BaseDAL.cs

@@ -0,0 +1,1748 @@
+using MOKA_Factory_Tools.Database;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Dynamic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.DAL
+{
+    public abstract class BaseDAL
+    {
+        #region 属性
+        /// <summary>
+        /// 数据表模型对象
+        /// </summary>
+        public abstract object ObjModel { get; }
+
+        /// <summary>
+        /// 数据表名
+        /// </summary>
+        public abstract string TableName { get; set; }
+
+        /// <summary>
+        /// 过期属性请不要使用 数据表字段名字符串,字段名以“,”号分隔
+        /// </summary>
+        public abstract string TableFieldNameString { get; set; }
+        string _TableFieldNameStr = "";
+
+        /// <summary>
+        /// 数据表字段名字符串,字段名以“,”号分隔
+        /// </summary>
+        public string TableFieldNameStr
+        {
+            get
+            {
+                if (this._TableFieldNameStr.Trim() == "")
+                {
+                    for (int i = 0; i < this.TableFieldNames.Length; i++)
+                    {
+                        if (this._TableFieldNameStr.Trim() == "")
+                        {
+                            this._TableFieldNameStr += "[" + this.TableFieldNames[i] + "]";
+                        }
+                        else
+                        {
+                            this._TableFieldNameStr += ",[" + this.TableFieldNames[i] + "]";
+                        }
+                    }
+                }
+                if (this._TableFieldNameStr.Trim() == "")
+                {
+                    this._TableFieldNameStr = "*";
+                }
+                return this._TableFieldNameStr;
+            }
+
+            set { this._TableFieldNameStr = value; }
+        }
+
+        /// <summary>
+        /// 数据表字段名数组
+        /// </summary>
+        public string[] TableFieldNames
+        {
+            get
+            {
+                System.Reflection.PropertyInfo[] propertyInfos = this.PropertyInfos;
+                string[] fieldNames = new string[propertyInfos.Length];
+                for (int i = 0; i < propertyInfos.Length; i++)
+                {
+                    if (!propertyInfos[i].IsSpecialName)
+                    {
+                        System.Reflection.PropertyInfo propertyInfo = propertyInfos[i];
+                        fieldNames[i] = propertyInfo.Name;
+                    }
+                }
+                // System.Reflection.PropertyInfo propertyInfo = ObjModel.GetType().GetProperty(propertyInfos[0].Name);
+
+                return fieldNames;//this.TableFieldNameString.Replace("[", "").Replace("]", "").Replace(" ", "").Split(',');
+            }
+        }
+
+        public ConnectionParameters cps = new ConnectionParameters();
+
+        /// <summary>
+        /// 获取要查询的当前表的字段集合字符串 用","号分隔
+        /// </summary>
+        /// <param name="filters"></param>
+        /// <param name="isContain">如果为true 表示只返回 filters 集合中的字段 如果为false 表示返回排除 filters 集合中的字段以外的所有字段</param>
+        /// <returns></returns>
+        public string GetQueryTableFieldNames(string[] filters = null, bool isContain = false)
+        {
+            List<string> tempFilters = new List<string>();
+            if (filters != null)
+            {
+                tempFilters.AddRange(filters);
+            }
+            System.Reflection.PropertyInfo[] propertyInfos = this.PropertyInfos;
+            string fieldNames = "";
+            for (int i = 0; i < propertyInfos.Length; i++)
+            {
+                if (!propertyInfos[i].IsSpecialName)
+                {
+                    System.Reflection.PropertyInfo propertyInfo = propertyInfos[i];
+                    if ((!tempFilters.Contains(propertyInfo.Name) && !isContain) || (tempFilters.Contains(propertyInfo.Name) && isContain))
+                    {
+                        if (fieldNames.Trim().Length <= 0)
+                        {
+                            fieldNames = "[" + propertyInfo.Name + "]";
+                        }
+                        else
+                        {
+                            fieldNames += ",[" + propertyInfo.Name + "]";
+                        }
+                    }
+                }
+            }
+            return fieldNames;
+        }
+
+        /// <summary>
+        /// 获取属性集合
+        /// </summary>
+        public System.Reflection.PropertyInfo[] PropertyInfos
+        {
+            get
+            {
+                List<System.Reflection.PropertyInfo> list = new List<System.Reflection.PropertyInfo>();
+                System.Reflection.PropertyInfo[] infos = ObjModel.GetType().GetProperties();
+                foreach (System.Reflection.PropertyInfo info in infos)
+                {
+                    if (info.CanWrite)
+                    {
+                        list.Add(info);
+                    }
+                }
+                return list.ToArray();
+            }
+        }
+        #endregion
+
+        #region 检查记录
+        /// <summary>
+        /// 是否存在该记录
+        /// </summary>
+        public bool Exists(long id)
+        {
+            return this.Exists("ID", id);
+        }
+
+        /// <summary>
+        /// 是否存在该记录
+        /// </summary>
+        public bool Exists(int id)
+        {
+            return this.Exists("ID", id);
+        }
+
+        /// <summary>
+        /// 根据筛选条件判断是否存在该记录
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="filterValue">筛选值</param>
+        /// <returns></returns>
+        public bool Exists(string filterFieldName, object filterValue)
+        {
+            if (filterFieldName != "" && filterValue != null)
+            {
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("select count(1) from " + this.TableName + " ");
+                strSql.Append(" where 1=1 and " + filterFieldName + "=@" + filterFieldName);
+                SqlParameter[] parameters = { new SqlParameter("@" + filterFieldName, filterValue) };
+
+                return DbHelper.Exists(cps.ConnectionString, strSql.ToString(), parameters);
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 根据筛选条件判断是否存在该记录
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="filterValue">筛选值</param>
+        /// <returns></returns>
+        public bool Exists(string whereString)
+        {
+            if (whereString.Trim().Length > 0)
+            {
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("select count(1) from " + this.TableName + " ");
+                strSql.Append(" where " + whereString);
+
+                return DbHelper.Exists(cps.ConnectionString, strSql.ToString());
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 判断是否存某个字段
+        /// </summary>
+        /// <param name="columnName">列名称</param>
+        /// <returns>是否存在</returns>
+        public bool ColumnExists(string columnName)
+        {
+            return DbHelper.IsColumnExists(cps.ConnectionString, this.TableName, columnName);
+        }
+        #endregion
+
+        #region 公共方法
+        /// <summary>
+        /// 获取最大ID()
+        /// </summary>
+        /// <returns></returns>
+        public int GetMaxID()
+        {
+            return this.GetMaxID("ID");
+        }
+
+        /// <summary>
+        /// 获取某字段最大值(获取字段必须为数字类型)
+        /// </summary>
+        /// <param name="FieldName">字段名</param>
+        /// <returns></returns>
+        public int GetMaxID(string FieldName)
+        {
+            return DbHelper.GetMaxID(cps.ConnectionString, FieldName, this.TableName);
+        }
+
+        /// <summary>
+        /// 检查CLR功能是否开启
+        /// </summary>
+        /// <returns></returns>
+        public bool CheckingCLR()
+        {
+            try
+            {
+                DataSet cds = DbHelper.Query(cps.ConnectionString, "select top 1  CONVERT(nvarchar(200), dbo.FunTrim(dbo.AggregateString(GM_CustomerID + '{$$}/{where}' +[GM_CustomerID] + '{$$}={$$}' + GM_RelatedPersonID + '{$$}s') + '/' + dbo.AggregateString(GM_CustomerID + '{$$}/{where}' +[GM_CustomerID] + '{$$}<>{$$}' + GM_RelatedPersonID + '{$$}s'), '/')) as CustomerID from[dbo].[tb_ErpCustomerGroupMembers]    group by GM_CustomerGroupID");
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        public void ExecuteSql(string sql)
+        {
+            DbHelper.ExecuteSQL(cps.ConnectionString, sql);
+        }
+        #endregion
+
+        #region 判断方法
+        /// <summary>
+        /// 获取是否为忽略字段 返回 true 表示忽略 false 不忽略
+        /// </summary>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <param name="fieldName">要判断的字段名</param>
+        /// <returns></returns>
+        public bool IsOverlookFiel(string overlookFieldList, string fieldName)
+        {
+            bool bl = false;
+            string[] tempOverlookFieldList = overlookFieldList.Split(',');
+            for (int i = 0; i < tempOverlookFieldList.Length; i++)
+            {
+                if (tempOverlookFieldList[i].Trim().ToLower() == fieldName.Trim().ToLower())
+                {
+                    bl = true;
+                    break;
+                }
+            }
+            return bl;
+        }
+        #endregion
+
+        #region 增加数据
+        /// <summary>
+        /// 增加一条数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Add(object model, string overlookFieldList = "ID")
+        {
+            CommandInfo comdInfo = this.GetAddCommandInfo(model, overlookFieldList);
+            int rows = DbHelper.ExecuteSQL(cps.ConnectionString, comdInfo.CommandText, (SqlParameter[])comdInfo.Parameters);
+            if (rows > 0)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 获取插入数CommandInfo对象
+        /// </summary>
+        /// <param name="model"></param>
+        /// <param name="overlookFieldList">要忽略的字段集合 多个字段名有“,”号分隔</param>
+        /// <returns></returns>
+        public object GetAddCommandInfoObject(object model, string overlookFieldList = "ID")
+        {
+            return this.GetAddCommandInfo(model, overlookFieldList);
+        }
+
+        /// <summary>
+        /// 获取插入数CommandInfo对象
+        /// </summary>
+        /// <param name="model"></param>
+        /// <param name="overlookFieldList">要忽略的字段集合 多个字段名有“,”号分隔</param>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public CommandInfo GetAddCommandInfo(object model, string overlookFieldList = "ID", EffentNextType type = EffentNextType.None)
+        {
+            StringBuilder strSql = new StringBuilder();
+            StringBuilder tempFieldNameString = new StringBuilder();
+            StringBuilder tempValueVariable = new StringBuilder();
+            List<SqlParameter> parameterlist = new List<SqlParameter>();
+
+            for (int i = 0; i < PropertyInfos.Length; i++)
+            {
+                try
+                {
+                    System.Reflection.PropertyInfo propertyInfo = PropertyInfos[i];
+                    string tempFieldName = propertyInfo.Name;
+                    object tempValue = propertyInfo.GetValue(model, null);
+                    Type tempType = propertyInfo.PropertyType;
+                    if (!IsOverlookFiel(overlookFieldList, tempFieldName) || (tempFieldName.ToLower() == "id" && tempType == typeof(long)))
+                    {
+                        try
+                        {
+                            if (tempType.Name == "DateTime")
+                            {
+                                if (tempValue.ToString().Contains("0001"))
+                                {
+                                    tempValue = null;
+                                }
+                                try
+                                {
+                                    DateTime tempTime;
+                                    if (!DateTime.TryParse(tempValue.ToString(), out tempTime))
+                                    {
+                                        tempValue = null;
+                                    }
+                                    else if (tempTime <= Convert.ToDateTime("1900-01-01"))
+                                    {
+                                        tempValue = null;
+                                    }
+                                }
+                                catch
+                                {
+                                    tempValue = null;
+                                }
+                            }
+                            else if (tempFieldName.ToLower() == "id" && tempType == typeof(long) && (tempValue == null || Convert.ToInt64(tempValue) == 0))
+                            {
+                                byte[] buffer = Guid.NewGuid().ToByteArray();
+                                tempValue = BitConverter.ToInt64(buffer, 0);
+                            }
+                            if (tempValue != null)
+                            {
+                                tempFieldNameString.Append("" + tempFieldName + ",");
+                                tempValueVariable.Append("@" + tempFieldName + ",");
+                                SqlParameter parameter = new SqlParameter("@" + tempFieldName, tempValue);
+                                string classFullName = tempType.ToString();
+                                if (classFullName.ToLower().IndexOf("system.") != 0)
+                                {
+                                    parameter.DbType = DbType.String;
+                                    parameter = new SqlParameter("@" + tempFieldName, tempValue.ToString());
+                                }
+                                parameterlist.Add(parameter);
+                            }
+                        }
+                        catch { }
+                    }
+                }
+                catch { }
+            }
+
+            //去除结尾多余的“,”
+            if (tempFieldNameString.ToString().LastIndexOf(',') == tempFieldNameString.Length - 1)
+            {
+                tempFieldNameString.Remove(tempFieldNameString.Length - 1, 1);
+            }
+            //去除结尾多余的“,”
+            if (tempValueVariable.ToString().LastIndexOf(',') == tempValueVariable.Length - 1)
+            {
+                tempValueVariable.Remove(tempValueVariable.Length - 1, 1);
+            }
+            strSql.Append("insert into " + this.TableName + "(");
+            strSql.Append("" + tempFieldNameString.ToString() + ")");
+            strSql.Append(" values (");
+            strSql.Append("" + tempValueVariable.ToString() + ")");
+            strSql.Append(";select @@IDENTITY");
+
+            SqlParameter[] parameters = parameterlist.ToArray();
+
+            return new CommandInfo(strSql.ToString(), parameters, type);
+        }
+
+        #endregion
+
+        #region 更新数据
+        /// <summary>
+        /// 根据筛选字段和SQL筛选运算符号更新数据(内部方法)
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <param name="whereStr">Wher条件,当指定条件语句时筛选字段设置无效,不包含“where”关键字 不建义使用此参数</param>
+        /// <returns></returns>
+        protected bool InsideUpdate(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null)
+        {
+            CommandInfo comdInfo = GetUpdateCommandInfo(model, filterFieldName, operators, overlookFieldList, whereStr);
+            int rows = DbHelper.ExecuteSQL(cps.ConnectionString, comdInfo.CommandText, (SqlParameter[])comdInfo.Parameters);
+            if (rows > 0)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 获取更新数据的UpdateCommandInfo对象 根据筛选字段和SQL筛选运算符号更新数据(内部方法)
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <param name="whereStr">Wher条件,当指定条件语句时筛选字段设置无效,不包含“where”关键字 不建义使用此参数</param>
+        public object GetUpdateCommandInfoObject(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null)
+        {
+            return this.GetUpdateCommandInfo(model, filterFieldName, operators, overlookFieldList, whereStr);
+        }
+
+        /// <summary>
+        /// 获取更新数据的UpdateCommandInfo对象 根据筛选字段和SQL筛选运算符号更新数据(内部方法)
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <param name="whereStr">Wher条件,当指定条件语句时筛选字段设置无效,不包含“where”关键字 不建义使用此参数</param>
+        /// <param name="type"></param>
+        public CommandInfo GetUpdateCommandInfo(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null, EffentNextType type = EffentNextType.None)
+        {
+            StringBuilder strSql = new StringBuilder();
+            strSql.Append("update " + this.TableName + " set ");
+
+            List<SqlParameter> parameterlist = new List<SqlParameter>();
+            overlookFieldList += "," + filterFieldName;
+            object VerifyTimestamp = null;
+            for (int i = 0; i < PropertyInfos.Length; i++)
+            {
+                try
+                {
+                    System.Reflection.PropertyInfo propertyInfo = PropertyInfos[i];
+                    string tempFieldName = propertyInfo.Name;//字段名
+                    object tempValue = propertyInfo.GetValue(model, null);//对应字段值
+                    //如果字段名不为忽略字段则进行处理
+                    if (!IsOverlookFiel(overlookFieldList, tempFieldName))
+                    {
+                        try
+                        {
+                            if (tempValue.GetType() == typeof(DateTime))
+                            {
+                                DateTime tempTime;
+
+                                try
+                                {
+                                    if (!DateTime.TryParse(tempValue.ToString(), out tempTime))
+                                    {
+                                        tempValue = null;
+                                    }
+                                    else if (tempTime <= Convert.ToDateTime("1900-01-01"))
+                                    {
+                                        tempValue = null;
+                                    }
+                                    else if (tempTime.Year == Convert.ToDateTime("0001-01-01").Year || tempTime.Year == Convert.ToDateTime("1753-01-01").Year)
+                                    {
+                                        tempValue = null;
+                                    }
+                                }
+                                catch { tempValue = null; }
+                            }
+                            else if (tempValue.GetType() == typeof(byte[]))
+                            {
+                                if (tempFieldName.ToLower() == "VerifyTimestamp".ToLower())
+                                {
+                                    VerifyTimestamp = tempValue;
+                                    continue;
+                                }
+                            }
+                        }
+                        catch { }
+                        strSql.Append("" + tempFieldName + "=@" + tempFieldName + ",");
+                        SqlParameter parameter = new SqlParameter("@" + tempFieldName, tempValue);
+                        string classFullName = propertyInfo.PropertyType.ToString();
+                        if (classFullName.ToLower().IndexOf("system.") != 0)
+                        {
+                            parameter.DbType = DbType.String;
+                            parameter = new SqlParameter("@" + tempFieldName, tempValue.ToString());
+                        }
+                        parameterlist.Add(parameter);
+                    }
+                }
+                catch { }
+            }
+
+            //去除结尾多余的“,”
+            if (strSql.ToString().LastIndexOf(',') == strSql.Length - 1)
+            {
+                strSql.Remove(strSql.Length - 1, 1);
+            }
+
+            if (whereStr == null)
+            {
+                if (filterFieldName != "" && operators != "")
+                {
+                    try
+                    {
+                        object FilterFieldValue = DbHelper.GetPropertyValue(model, filterFieldName);// model.GetType().GetProperty(filterFieldName).GetValue(model, null);
+                        if (VerifyTimestamp != null)
+                        {
+                            strSql.Append(" where " + filterFieldName + operators + "@" + filterFieldName + " and VerifyTimestamp=@VerifyTimestamp");
+                            parameterlist.Add(new SqlParameter("@VerifyTimestamp", VerifyTimestamp));
+                        }
+                        else
+                        {
+                            strSql.Append(" where " + filterFieldName + operators + "@" + filterFieldName);
+                        }
+                        parameterlist.Add(new SqlParameter("@" + filterFieldName, FilterFieldValue));
+                    }
+                    catch
+                    {
+
+                    }
+                }
+            }
+            else
+            {
+                if (VerifyTimestamp != null)
+                {
+                    strSql.Append(" where " + filterFieldName + operators + "@" + filterFieldName + " and VerifyTimestamp=@VerifyTimestamp");
+                    parameterlist.Add(new SqlParameter("@VerifyTimestamp", VerifyTimestamp));
+                }
+                else
+                {
+                    strSql.Append(" where 1=1 and (" + whereStr + ")");
+                }
+            }
+            SqlParameter[] parameters = parameterlist.ToArray();
+            return new CommandInfo(strSql.ToString(), parameters, type);
+        }
+
+        /// <summary>
+        /// 根据筛选字段和SQL筛选运算符号更新数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Update(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
+        {
+            return InsideUpdate(model, filterFieldName, operators, overlookFieldList);
+        }
+
+        /// <summary>
+        /// 根据Wher条件更新数据 不建义使用此方法
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Update(object model, string whereStr, string overlookFieldList = "ID")
+        {
+            return InsideUpdate(model, overlookFieldList: overlookFieldList, whereStr: whereStr);
+        }
+        #endregion
+
+        #region 删除数据
+        /// <summary>
+        /// 根据筛选字段或where条件删除数据
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="operators">筛选SQL运算符</param>
+        /// <param name="filterValue">筛选值</param>
+        /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
+        /// <returns></returns>
+        protected bool InsideDelete(string filterFieldName = "ID", string operators = "=", object filterValue = null, string whereStr = null)
+        {
+            CommandInfo comdInfo = GetDeleteCommandInfo(filterFieldName, operators, filterValue, whereStr);
+            int rows = DbHelper.ExecuteSQL(cps.ConnectionString, comdInfo.CommandText, (SqlParameter[])comdInfo.Parameters);
+            if (rows > 0)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 根据筛选字段或where条件删除数据
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="operators">筛选SQL运算符</param>
+        /// <param name="filterValue">筛选值</param>
+        /// <param name="whereStr">Wher条件,传入条件语句时筛选字段无效不建义使用 不包含“where”关键字</param>
+        /// <returns></returns>
+        public object GetDeleteCommandInfoObject(string filterFieldName = "ID", string operators = "=", object filterValue = null, string whereStr = null)
+        {
+            return this.GetDeleteCommandInfo(filterFieldName, operators, filterValue, whereStr);
+        }
+
+        /// <summary>
+        /// 根据筛选字段或where条件删除数据
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="operators">筛选SQL运算符</param>
+        /// <param name="filterValue">筛选值</param>
+        /// <param name="whereStr">Wher条件,传入条件语句时筛选字段无效不建义使用 不包含“where”关键字</param>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public CommandInfo GetDeleteCommandInfo(string filterFieldName = "ID", string operators = "=", object filterValue = null, string whereStr = null, EffentNextType type = EffentNextType.None)
+        {
+            if (filterValue == null) { filterValue = ""; }
+            List<SqlParameter> parameterlist = new List<SqlParameter>();
+            StringBuilder strSql = new StringBuilder();
+            strSql.Append("delete from " + this.TableName + " ");
+            if (whereStr == null)
+            {
+                strSql.Append(" where " + filterFieldName + "" + operators + "@" + filterFieldName + "");
+                parameterlist.Add(new SqlParameter("@" + filterFieldName, filterValue));
+            }
+            else
+            {
+                strSql.Append(" where ID>@ID and (" + whereStr + ")");
+                parameterlist.Add(new SqlParameter("@ID", Convert.ToInt32(0)));
+            }
+            SqlParameter[] parameters = parameterlist.ToArray();
+            return new CommandInfo(strSql.ToString(), parameters, type);
+        }
+
+        /// <summary>
+        /// 删除一条数据
+        /// </summary>
+        /// <param name="ID">id</param>
+        public bool Delete(long ID)
+        {
+            return this.InsideDelete(filterValue: ID);
+        }
+
+        /// <summary>
+        /// 删除一条数据
+        /// </summary>
+        /// <param name="ID">id</param>
+        public bool Delete(int ID)
+        {
+            return this.InsideDelete(filterValue: ID);
+        }
+
+        /// <summary>
+        /// 根据筛选字段删除数据
+        /// </summary>
+        /// <param name="filterValue">筛选值</param>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="operators">筛选SQL运算符</param>
+        /// <returns></returns>
+        public bool Delete(object filterValue, string filterFieldName = "ID", string operators = "=")
+        {
+            return this.InsideDelete(filterFieldName, operators, filterValue);
+        }
+
+        /// <summary>
+        /// 根据where条件删除数据 不建义使用此方法
+        /// </summary>
+        /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
+        /// <returns></returns>
+        public bool Delete(string whereStr)
+        {
+            return this.InsideDelete(whereStr: whereStr);
+        }
+
+        /// <summary>
+        /// 批量删除数据
+        /// </summary>
+        /// <param name="filterFieldName">筛选字段名</param>
+        /// <param name="valueList">值列表,多个值用“,”分隔,字符串值用“'”号包含</param>
+        public bool DeleteList(string filterFieldName, string valueList)
+        {
+            if (filterFieldName != "" && valueList != "")
+            {
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("delete from " + this.TableName + " ");
+                strSql.Append(" where " + filterFieldName + " in (" + valueList + ")  ");
+                int rows = DbHelper.ExecuteSQL(cps.ConnectionString, strSql.ToString());
+
+                if (rows > 0)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 按ID列表批量删除数据
+        /// </summary>
+        /// <param name="idList">ID列表,多个用“,”分隔</param>
+        public bool DeleteList(string idList)
+        {
+            return this.DeleteList("ID", idList);
+        }
+        #endregion
+
+        #region 查询数据
+
+        public T GetDataRowToModelByEntity<T>(DataRow row)
+        {
+            if (row == null)
+            {
+                return Activator.CreateInstance<T>();
+            }
+            Dictionary<string, string> dataInfo = new Dictionary<string, string>();
+            dynamic objmatch = new ExpandoObject();
+            for (int i = 0; i < row.Table.Columns.Count; i++)
+            {
+                string value = "";
+                if (row[row.Table.Columns[i].ColumnName] != null)
+                {
+                    value = row[row.Table.Columns[i].ColumnName].ToString();
+                }
+                if (!string.IsNullOrEmpty(value))
+                {
+                    if (row.Table.Columns[i].DataType.Name.ToLower().IndexOf("DateTime".ToLower()) != -1)
+                    {
+                        dataInfo.Add(row.Table.Columns[i].ColumnName, Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss"));
+                    }
+                    else
+                    {
+                        dataInfo.Add(row.Table.Columns[i].ColumnName, value);
+                    }
+                }
+                else
+                {
+                    if (row.Table.Columns[i].DataType.Name.ToLower().IndexOf("String".ToLower()) != -1)
+                    {
+                        dataInfo.Add(row.Table.Columns[i].ColumnName, value);
+                    }
+                }
+            }
+            objmatch = dataInfo;
+            string json = JsonConvert.SerializeObject((object)objmatch);
+
+            return JsonToModelByEntity<T>(json);
+        }
+        T JsonToModelByEntity<T>(string json)
+        {
+            T t = Activator.CreateInstance<T>();
+            return (T)JsonConvert.DeserializeObject(json, t.GetType());
+        }
+
+        public DataSet GetViewDataSetByCustomer(string strSQL)
+        {
+            return DbHelper.Query(cps.ConnectionString, strSQL);
+        }
+
+        public object DataRowToModel<T>(DataRow dr)
+        {
+            if (dr == null)
+            {
+                return Activator.CreateInstance<T>();
+            }
+            Dictionary<string, string> dataInfo = new Dictionary<string, string>();
+            dynamic objmatch = new ExpandoObject();
+            for (int i = 0; i < dr.Table.Columns.Count; i++)
+            {
+                string value = dr[dr.Table.Columns[i].ColumnName].ToString();
+                if (!string.IsNullOrEmpty(value))
+                {
+                    if (dr.Table.Columns[i].DataType.Name.IndexOf("DateTime") != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss"));
+                    }
+                    else
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, value);
+                    }
+                }
+                else
+                {
+                    if (dr.Table.Columns[i].DataType.Name.ToLower().IndexOf("String".ToLower()) != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, "");
+                    }
+                }
+            }
+            objmatch = dataInfo;
+            string json = JsonConvert.SerializeObject((object)objmatch);
+
+            return DataRowToModelByEntity<T>(json);
+        }
+
+        public object GetModelObjectByEntity<T>(string filterFieldName, object filterValue)
+        {
+            DataRow dr = GetDataRow(filterFieldName, filterValue);
+            Dictionary<string, string> dataInfo = new Dictionary<string, string>();
+            if (dr == null)
+            {
+                return Activator.CreateInstance<T>();
+            }
+            dynamic objmatch = new ExpandoObject();
+            for (int i = 0; i < dr.Table.Columns.Count; i++)
+            {
+                string value = dr[dr.Table.Columns[i].ColumnName].ToString();
+                if (!string.IsNullOrEmpty(value))
+                {
+                    if (dr.Table.Columns[i].DataType.Name.IndexOf("DateTime") != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss"));
+                    }
+                    else
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, value);
+                    }
+                }
+                else
+                {
+                    if (dr.Table.Columns[i].DataType.Name.ToLower().IndexOf("String".ToLower()) != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, value);
+                    }
+                }
+            }
+            objmatch = dataInfo;
+            string json = JsonConvert.SerializeObject((object)objmatch);
+
+            return DataRowToModelByEntity<T>(json);
+        }
+
+        public object DataRowToModelByEntity<T>(int ID)
+        {
+            DataRow dr = GetDataRow(ID);
+            if (dr == null)
+            {
+                return Activator.CreateInstance<T>();
+            }
+            Dictionary<string, string> dataInfo = new Dictionary<string, string>();
+            dynamic objmatch = new ExpandoObject();
+            for (int i = 0; i < dr.Table.Columns.Count; i++)
+            {
+                string value = dr[dr.Table.Columns[i].ColumnName].ToString();
+                if (!string.IsNullOrEmpty(value))
+                {
+                    if (dr.Table.Columns[i].DataType.Name.IndexOf("DateTime") != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss"));
+                    }
+                    else
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, value);
+                    }
+
+                }
+                else
+                {
+                    if (dr.Table.Columns[i].DataType.Name.ToLower().IndexOf("String".ToLower()) != -1)
+                    {
+                        dataInfo.Add(dr.Table.Columns[i].ColumnName, value);
+                    }
+                }
+            }
+            objmatch = dataInfo;
+            IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
+            timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
+            string json = JsonConvert.SerializeObject((object)objmatch, Formatting.Indented, timeFormat);
+
+            return DataRowToModelByEntity<T>(json);
+        }
+        object DataRowToModelByEntity<T>(string json)
+        {
+            T t = Activator.CreateInstance<T>();
+            object obj = JsonConvert.DeserializeObject(json, t.GetType());//CustomPublicMethod.JsonToObject(json, t);
+            return obj;
+        }
+
+        /// <summary>
+        /// 得到一个Object对象实体
+        /// </summary>
+        /// <param name="ID"></param>
+        /// <returns></returns>
+        public object GetModelObject(long ID)
+        {
+            return DataRowToModelObject(GetDataRow(ID));
+        }
+
+        /// <summary>
+        /// 得到一个Object对象实体
+        /// </summary>
+        /// <param name="ID"></param>
+        /// <returns></returns>
+        public object GetModelObject(int ID)
+        {
+            return DataRowToModelObject(GetDataRow(ID));
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据Model对象
+        /// </summary>
+        /// <param name="filterFieldName">筛选条件字段名</param>
+        /// <param name="filterValue">值</param>
+        /// <returns></returns>
+        public object GetModelObject(string filterFieldName, object filterValue)
+        {
+            return DataRowToModelObject(GetDataRow(filterFieldName, filterValue));
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据Model对象
+        /// </summary>
+        /// <param name="filterFieldName">筛选条件字段名</param>
+        /// <param name="filterValue">值</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <returns></returns>
+        public object GetModelObject(string filterFieldName, object filterValue, string operators)
+        {
+            return DataRowToModelObject(GetDataRow(filterFieldName, filterValue, operators));
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据Model对象
+        /// </summary>
+        /// <param name="whereString">筛选条件</param>
+        /// <returns></returns>
+        public object GetModelObject(string whereString)
+        {
+            return DataRowToModelObject(GetDataRow(whereString));
+        }
+
+        /// <summary>
+        ///  得到一个object对象实体
+        /// </summary>
+        /// <param name="row"></param>
+        /// <returns></returns>
+        public object DataRowToModelObject(DataRow row)
+        {
+            return DataRowToModel(row, this.ObjModel);
+        }
+
+        /// <summary>
+        /// 获取一条数据DataRow对象
+        /// </summary>
+        /// <param name="ID">id</param>
+        /// <returns></returns>
+        public DataRow GetDataRow(long id)
+        {
+            return GetDataRow("ID", id);
+        }
+
+        /// <summary>
+        /// 获取一条数据DataRow对象
+        /// </summary>
+        /// <param name="ID">id</param>
+        /// <returns></returns>
+        public DataRow GetDataRow(int id)
+        {
+            return GetDataRow("ID", id);
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据DataRow对象
+        /// </summary>
+        /// <param name="whereString">筛选条件</param>
+        /// <returns></returns>
+        public DataRow GetDataRow(string whereString)
+        {
+            if (whereString.Trim().Length > 0)
+            {
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("select  top 1 " + this.TableFieldNameStr + " from " + this.TableName + " ");
+                strSql.Append(" where  " + whereString);
+
+                DataSet ds = DbHelper.Query(cps.ConnectionString, strSql.ToString());
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    return ds.Tables[0].Rows[0];
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据DataRow对象
+        /// </summary>
+        /// <param name="filterFieldName">筛选条件字段名</param>
+        /// <param name="filterValue">值</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <returns></returns>
+        public DataRow GetDataRow(string filterFieldName, object filterValue, string operators = "=")
+        {
+            if (filterFieldName != "" && filterValue != null)
+            {
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("select  top 1 " + this.TableFieldNameStr + " from " + this.TableName + " ");
+                strSql.Append(" where 1=1 and " + filterFieldName + "" + operators + "@" + filterFieldName + " ");
+                SqlParameter[] parameters = { new SqlParameter("@" + filterFieldName, filterValue) };
+                DataSet ds = DbHelper.Query(cps.ConnectionString, strSql.ToString(), parameters);
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    return ds.Tables[0].Rows[0];
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// 根据筛选条件获取一条数据DataRow对象(运算符是“=”)
+        /// </summary>
+        /// <param name="filterFieldName">筛选条件字段名</param>
+        /// <param name="filterValue">值</param>
+        /// <returns></returns>
+        public DataRow GetDataRow(string filterFieldName, object filterValue)
+        {
+            return GetDataRow(filterFieldName, filterValue, "=");
+        }
+
+        /// <summary>
+        /// 得到一个对象实体
+        /// </summary>
+        public object DataRowToModel(DataRow row, object model)
+        {
+            if (row != null)
+            {
+                for (int i = 0; i < PropertyInfos.Length; i++)
+                {
+                    try
+                    {
+                        System.Reflection.PropertyInfo propertyInfo = PropertyInfos[i];
+                        string tempFieldName = propertyInfo.Name;//字段名
+
+                        if (row[tempFieldName] != null)
+                        {
+                            object tempValue = row[tempFieldName];//对应字段值
+                            DbHelper.SetPropertyValue(model, propertyInfo, tempValue);
+                        }
+                    }
+                    catch
+                    {
+
+                    }
+                }
+            }
+            return model;
+        }
+
+        /// <summary>
+        /// 获得数据列表
+        /// </summary>
+        /// <param name="strWhere">条件语句 不包含 where 关键字</param>
+        /// <param name="filedOrder">SQL排序 如:id desc</param>
+        public DataSet GetList(string strWhere, string filedOrder = "SN desc")
+        {
+            return this.GetList(0, strWhere, filedOrder);
+        }
+
+        /// <summary>
+        /// 获得全部数据列表
+        /// </summary>
+        /// <param name="filedOrder">SQL排序 如:id desc</param>
+        public DataSet GetAllList(string filedOrder = "SN desc")
+        {
+            return this.GetList("", filedOrder);
+        }
+
+        /// <summary>
+        /// 获得前几行数据
+        /// </summary>
+        /// <param name="Top">行数</param>
+        /// <param name="strWhere">条件 不包含 where 关键字</param>
+        /// <param name="filedOrder">SQL排序 如:id asc</param>
+        /// <returns></returns>
+        public DataSet GetList(int Top, string strWhere, string filedOrder = "SN desc")
+        {
+            StringBuilder strSql = new StringBuilder();
+            strSql.Append("select ");
+            if (Top > 0)
+            {
+                strSql.Append(" top " + Top.ToString());
+            }
+            strSql.Append(" " + this.TableFieldNameStr + " from " + this.TableName + " ");
+
+            if (strWhere.Trim() != "")
+            {
+                strSql.Append(" where 1=1 and  (" + strWhere + ")");
+            }
+            strSql.Append(" order by " + filedOrder);
+
+            DataSet ds = DbHelper.Query(cps.ConnectionString, strSql.ToString());
+            ds.Tables[0].TableName = this.TableName;
+            return ds;
+        }
+        #endregion
+
+        #region 数据分页
+        /// <summary>
+        /// 获取记录总数
+        /// </summary>
+        public int GetRecordCount(string strWhere)
+        {
+            StringBuilder strSql = new StringBuilder();
+            strSql.Append("select count(1) FROM " + this.TableName + " ");
+            if (strWhere.Trim() != "")
+            {
+                strSql.Append(" where 1=1 and  (" + strWhere + ")");
+            }
+            object obj = DbHelper.GetSingle(cps.ConnectionString, strSql.ToString());
+            if (obj == null)
+            {
+                return 0;
+            }
+            else
+            {
+                return Convert.ToInt32(obj);
+            }
+        }
+
+        /// <summary>
+        /// 获取分页后总页数
+        /// </summary>
+        /// <param name="strWhere">筛选条件</param>
+        /// <param name="pageSize">页面大小</param>
+        /// <returns></returns>
+        public int GetByPageCount(string strWhere, int pageSize)
+        {
+            int pageCount = 0;
+            if (pageSize > 0)
+            {
+                int allCount = GetRecordCount(strWhere);
+                pageCount = allCount / pageSize;
+                if (pageCount * pageSize < allCount)
+                {
+                    pageCount++;
+                }
+            }
+
+            return pageCount;
+        }
+
+        public int GetByPageCount(string strWhere, int pageSize, ref int totalCount)
+        {
+            int pageCount = 0;
+            if (pageSize > 0)
+            {
+                int allCount = GetRecordCount(strWhere);
+                totalCount = allCount;
+                pageCount = allCount / pageSize;
+                if (pageCount * pageSize < allCount)
+                {
+                    pageCount++;
+                }
+            }
+
+            return pageCount;
+        }
+
+        /// <summary>
+        /// 分页获取数据列表
+        /// </summary>
+        /// <param name="strWhere">筛选条件</param>
+        /// <param name="pageIndex">当前页 不能小于0的整数</param>
+        /// <param name="pageSize">页面大小,每页显示条数 不能小于0的整数</param>
+        /// <param name="orderby">排序</param>
+        /// <returns></returns>
+        public DataSet GetListByPage(string strWhere, int pageIndex, int pageSize, string orderby = "SN desc")
+        {
+            return this.GetListByPage(strWhere, orderby, (pageIndex - 1) * pageSize, pageIndex * pageSize);
+        }
+
+        /// <summary>
+        /// 分页获取数据列表
+        /// </summary>
+        /// <param name="strWhere">筛选条件</param>
+        /// <param name="orderby">排序</param>
+        /// <param name="pageIndex">当前页</param>
+        /// <param name="pageSize">页面大小,每页显示条数</param>
+        /// <param name="pageCount">返回总页数</param>
+        /// <returns></returns>
+        public DataSet GetListByPage(string strWhere, string orderby, int pageIndex, int pageSize, ref int pageCount)
+        {
+            pageCount = GetByPageCount(strWhere, pageSize);
+            return this.GetListByPage(strWhere, orderby, (pageIndex - 1) * pageSize, pageIndex * pageSize);
+        }
+
+        /// <summary>
+        /// 分页获取数据列表
+        /// </summary>
+        /// <param name="strWhere">条件</param>
+        /// <param name="orderby">排序</param>
+        /// <param name="startIndex">开始index</param>
+        /// <param name="endIndex">结束index</param>
+        /// <returns></returns>
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
+        {
+            if (!string.IsNullOrEmpty(strWhere.Trim()))
+            {
+                strWhere = " Where " + strWhere;
+            }
+
+            if (!string.IsNullOrEmpty(orderby.Trim()))
+            {
+                orderby = " Order By " + orderby;
+            }
+
+            StringBuilder strSql = new StringBuilder();
+            strSql.Append("SELECT * FROM " + this.TableName + " Where ID Not IN ");
+            strSql.Append("(Select Top " + startIndex + " ID From  " + this.TableName + " " + strWhere + orderby + ")");
+            strSql.Append(" And ID In ");
+            strSql.Append("(Select Top " + endIndex + " ID From  " + this.TableName + " " + strWhere + orderby + ")");
+            strSql.Append(orderby);
+            DataSet ds = DbHelper.Query(cps.ConnectionString, strSql.ToString());
+            ds.Tables[0].TableName = this.TableName;
+            return ds;
+        }
+        #endregion
+
+        #region 
+        /// <summary>
+        /// Type转Dbtype
+        /// </summary>
+        /// <param name="type">变量的Type类型</param>
+        /// <returns>对应的DbType类型</returns>
+        public static SqlDbType GetDbType(Type type)
+        {
+            SqlDbType result = SqlDbType.NVarChar;
+            if (type.Equals(typeof(Int32)) || type.IsEnum)
+                result = SqlDbType.Int;
+            else if (type.Equals(typeof(Int64)))
+                result = SqlDbType.Int;
+            else if (type.Equals(typeof(Double)) || type.Equals(typeof(Double)))
+                result = SqlDbType.Decimal;
+            else if (type.Equals(typeof(DateTime)))
+                result = SqlDbType.DateTime;
+            else if (type.Equals(typeof(Boolean)))
+                result = SqlDbType.Bit;
+            else if (type.Equals(typeof(String)))
+                result = SqlDbType.NVarChar;
+            else if (type.Equals(typeof(Decimal)))
+                result = SqlDbType.Decimal;
+            else if (type.Equals(typeof(Byte[])))
+                result = SqlDbType.Image;
+            else if (type.Equals(typeof(Guid)))
+                result = SqlDbType.UniqueIdentifier;
+
+            return result;
+        }
+        #endregion
+
+        #region 优化sql新增修改的方法
+
+        /// <summary>
+        /// 通过泛型实体生成更新语句和对象
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="date"></param>
+        /// <param name="filterFieldName"></param>
+        /// <param name="operators"></param>
+        /// <param name="overlookFieldList"></param>
+        /// <param name="whereStr"></param>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public CommandInfo GetUpdateCommandInfoByEntity<T>(T date, string filterFieldName = "ID",
+            string operators = "=", string overlookFieldList = "ID", string whereStr = null,
+            EffentNextType type = EffentNextType.None)
+        {
+            var properties = ReflectionHelper.GetProperties(typeof(T));
+            StringBuilder strSql = new StringBuilder();
+
+            Dictionary<string, PropertyInfo> dicWhereData = new Dictionary<string, PropertyInfo>();
+
+            strSql.Append("update " + this.TableName + " set ");
+            List<SqlParameter> parameterlist = new List<SqlParameter>();
+            var ignorePropertyNames = new HashSet<string>();
+            var filterPropertyNames = new HashSet<string>();
+            ///跳过的字段数据
+            if (!string.IsNullOrEmpty(overlookFieldList))
+            {
+                foreach (var msg in overlookFieldList.Split(','))
+                {
+                    ignorePropertyNames.Add(msg);
+                }
+            }
+            ///用于查询的where条件的数据
+            if (!string.IsNullOrEmpty(filterFieldName))
+            {
+                foreach (var msg in filterFieldName.Split(','))
+                {
+                    filterPropertyNames.Add(msg);
+                }
+            }
+
+            foreach (var property in properties)
+            {
+                var ignoreProperty = ignorePropertyNames.SingleOrDefault(x => x.Equals(property.Value.Name, StringComparison.CurrentCultureIgnoreCase));
+
+                var filterProperty = filterPropertyNames.SingleOrDefault(x => x.Equals(property.Value.Name, StringComparison.CurrentCultureIgnoreCase));
+                if (filterProperty != null)
+                {
+                    dicWhereData.Add(property.Key, property.Value);
+                }
+
+                if (ignoreProperty != null)
+                    continue;
+
+                var propertyType = ReflectionHelper.GetPropertyType(property.Value);
+                if (propertyType.Name.ToLower().IndexOf("list") != -1)
+                {
+                    continue;
+                }
+                var propertyValue = ReflectionHelper.GetPropertyValue(date, property.Value);
+                if (propertyValue == null)
+                {
+                    continue;
+                }
+                else if (propertyValue != null && propertyType.Name.ToLower().Equals("datetime") && propertyValue.ToString().Contains("0001"))
+                {
+                    continue;
+                }
+                else if (propertyValue != null && propertyType.Name.ToLower().Equals("datetime") && Convert.ToDateTime(propertyValue) <= DbHelper.GetNullDateTime())
+                {
+                    continue;
+                }
+
+                //  ColumnAction(property.Value.Name, propertyValue, propertyType, DataTypes.Object, 0);
+                if (propertyValue != null)
+                {
+                    strSql.Append("" + property.Key + "=@" + property.Key + ",");
+                    SqlParameter parameter = new SqlParameter("@" + property.Key, propertyValue);
+                    parameterlist.Add(parameter);
+                }
+            }
+
+            //去除结尾多余的“,”
+            if (strSql.ToString().LastIndexOf(',') == strSql.Length - 1)
+            {
+                strSql.Remove(strSql.Length - 1, 1);
+            }
+
+            if (whereStr == null)
+            {
+                if (filterFieldName != "" && operators != "")
+                {
+                    string strWhere = "";
+                    foreach (var property in dicWhereData)
+                    {
+                        if (!string.IsNullOrEmpty(strWhere))
+                        {
+                            strWhere += " and ";
+                        }
+                        strWhere += property.Key + operators + "@" + property.Key;
+
+                        var propertyValue = ReflectionHelper.GetPropertyValue(date, property.Value);
+                        parameterlist.Add(new SqlParameter("@" + property.Key, propertyValue));
+                    }
+                    strSql.Append(" where " + strWhere);
+                }
+            }
+            else
+            {
+                strSql.Append(" where 1=1 and (" + whereStr + ")");
+            }
+            SqlParameter[] parameters = parameterlist.ToArray();
+            return new CommandInfo(strSql.ToString(), parameters, type);
+        }
+
+        /// <summary>
+        /// 通过泛型方法生成新增对象信息
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="date"></param>
+        /// <param name="overlookFieldList"></param>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public CommandInfo GetAddCommandInfoByEntity<T>(T date, string overlookFieldList = "ID", EffentNextType type = EffentNextType.None)
+        {
+            StringBuilder strSql = new StringBuilder();
+            var properties = ReflectionHelper.GetProperties(typeof(T));
+            StringBuilder tempFieldNameString = new StringBuilder();
+            StringBuilder tempValueVariable = new StringBuilder();
+            List<SqlParameter> parameterlist = new List<SqlParameter>();
+            var ignorePropertyNames = new HashSet<string>();
+
+            if (!string.IsNullOrEmpty(overlookFieldList))
+            {
+                foreach (var msg in overlookFieldList.Split(','))
+                {
+                    ignorePropertyNames.Add(msg);
+                }
+            }
+
+            foreach (var property in properties)
+            {
+                var ignoreProperty = ignorePropertyNames.SingleOrDefault(x => x.Equals(property.Value.Name, StringComparison.CurrentCultureIgnoreCase));
+
+                if (ignoreProperty != null)
+                    continue;
+
+                var propertyType = ReflectionHelper.GetPropertyType(property.Value);
+                if (propertyType.Name.ToLower().IndexOf("list") != -1)
+                {
+                    continue;
+                }
+                var propertyValue = ReflectionHelper.GetPropertyValue(date, property.Value);
+                if (propertyValue == null)
+                {
+                    continue;
+                }
+                if (propertyValue != null && propertyType.Name.ToLower().Equals("datetime") && propertyValue.ToString().Contains("0001"))
+                {
+                    continue;
+                }
+                if (propertyValue != null && propertyType.Name.ToLower().Equals("datetime") && Convert.ToDateTime(propertyValue) <= DbHelper.GetNullDateTime())
+                {
+                    continue;
+                }
+                else if (property.Key.ToLower() == "id" && propertyType == typeof(long) && (propertyValue == null || Convert.ToInt64(propertyValue) == 0))
+                {
+                    propertyValue = DbHelper.GenerateId();
+                }
+                //  ColumnAction(property.Value.Name, propertyValue, propertyType, DataTypes.Object, 0);
+                if (propertyValue != null)
+                {
+                    tempFieldNameString.Append("" + property.Key + ",");
+                    tempValueVariable.Append("@" + property.Key + ",");
+                    SqlParameter parameter = new SqlParameter("@" + property.Key, propertyValue);
+                    parameterlist.Add(parameter);
+                }
+            }
+
+            if (tempFieldNameString.ToString().LastIndexOf(',') == tempFieldNameString.Length - 1)
+            {
+                tempFieldNameString.Remove(tempFieldNameString.Length - 1, 1);
+            }
+            //去除结尾多余的“,”
+            if (tempValueVariable.ToString().LastIndexOf(',') == tempValueVariable.Length - 1)
+            {
+                tempValueVariable.Remove(tempValueVariable.Length - 1, 1);
+            }
+            strSql.Append("insert into " + this.TableName + "(");
+            strSql.Append("" + tempFieldNameString.ToString() + ")");
+            strSql.Append(" values (");
+            strSql.Append("" + tempValueVariable.ToString() + ")");
+            strSql.Append(";select @@IDENTITY");
+
+            SqlParameter[] parameters = parameterlist.ToArray();
+
+            return new CommandInfo(strSql.ToString(), parameters, type);
+
+        }
+
+        public object GetAddCommandInfoByEntity<T>(T date, string overlookFieldList = "ID")
+        {
+            return GetAddCommandInfoByEntity(date, overlookFieldList, EffentNextType.None);
+        }
+
+        public object GetUpdateCommandInfoByEntity<T>(T date, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null)
+        {
+            return GetUpdateCommandInfoByEntity(date, filterFieldName, operators, overlookFieldList, whereStr, EffentNextType.None);
+        }
+
+        #endregion
+
+
+        #region 17-04-20 添加
+        /// <summary>
+        /// 将数据列表转泛型数据
+        /// </summary>
+        /// <typeparam name="T">泛型类型</typeparam>
+        /// <param name="dt">数据表数据</param>
+        /// <returns>数据集</returns>
+        public T GetListToEntity<T>(DataTable dt)
+        {
+            var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
+
+            T entityList = Activator.CreateInstance<T>();
+            entityList = JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(dt), jSetting);
+            return entityList;
+        }
+
+        /// <summary>
+        /// 将sql查询出来的数据转成泛型列表
+        /// </summary>
+        /// <typeparam name="T">泛型类型</typeparam>
+        /// <param name="sql">sql数据查询字符串</param>
+        /// <returns>数据集</returns>
+        public T GetListToEntity<T>(string sql)
+        {
+            DataTable dt = GetViewDataSetByCustomer(sql).Tables[0];
+            return GetListToEntity<T>(dt);
+        }
+        #endregion
+
+        public DataSet GetListByPage(string strWhere, string orderby, int pageIndex, int pageSize, ref int pageCount, ref int Totalcount)
+        {
+            pageCount = GetByPageCount(strWhere, pageSize, ref Totalcount);
+            return this.GetListByPage(strWhere, orderby, (pageIndex - 1) * pageSize, pageIndex * pageSize);
+        }
+
+        /// <summary>
+        /// 获得数据列表
+        /// </summary>
+        /// <param name="dt">DataTable</param>
+        public List<object> GetDataTableToOblList(DataTable dt)
+        {
+            List<object> modelList = new List<object>();
+            int rowsCount = dt.Rows.Count;
+            if (rowsCount > 0)
+            {
+                object modelObj;
+                for (int n = 0; n < rowsCount; n++)
+                {
+                    modelObj = DataRowToModelObject(dt.Rows[n]);
+                    if (modelObj != null)
+                    {
+                        modelList.Add(modelObj);
+                    }
+                }
+            }
+            return modelList;
+        }
+
+        /// <summary>
+        /// 获得数据列表
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="dt"></param>
+        /// <returns></returns>
+        public List<T> GetDataTableToOblList<T>(DataTable dt)
+        {
+            List<T> modelList = new List<T>();
+            int rowsCount = dt.Rows.Count;
+            if (rowsCount > 0)
+            {
+                T modelObj;
+                for (int n = 0; n < rowsCount; n++)
+                {
+                    modelObj = (T)DataRowToModelObject(dt.Rows[n]);
+                    if (modelObj != null)
+                    {
+                        modelList.Add(modelObj);
+                    }
+                }
+            }
+            return modelList;
+        }
+    }
+
+    #region 反射助手,用于泛型实体的反射操作
+    internal static class ReflectionHelper
+    {
+        private static readonly ConcurrentDictionary<Type, Dictionary<string, PropertyInfo>> _cachedProperties = new ConcurrentDictionary<Type, Dictionary<string, PropertyInfo>>();
+        /// <summary>
+        /// 得到实体反射的表达式
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="expression"></param>
+        /// <returns></returns>
+        public static string GetPropertyNameFromExpression<T>(Expression<Func<T, object>> expression)
+        {
+            string propertyPath = null;
+            if (expression.Body is UnaryExpression)
+            {
+                var unaryExpression = (UnaryExpression)expression.Body;
+                if (unaryExpression.NodeType == ExpressionType.Convert)
+                    propertyPath = unaryExpression.Operand.ToString();
+            }
+
+            if (propertyPath == null)
+                propertyPath = expression.Body.ToString();
+
+            propertyPath = propertyPath.Replace(expression.Parameters[0] + ".", string.Empty);
+
+            return propertyPath;
+        }
+
+        public static List<string> GetPropertyNamesFromExpressions<T>(Expression<Func<T, object>>[] expressions)
+        {
+            var propertyNames = new List<string>();
+            foreach (var expression in expressions)
+            {
+                var propertyName = GetPropertyNameFromExpression(expression);
+                propertyNames.Add(propertyName);
+            }
+            return propertyNames;
+        }
+
+        public static object GetPropertyValue(object item, PropertyInfo property)
+        {
+            var value = property.GetValue(item, null);
+
+            return value;
+        }
+
+        public static object GetPropertyValue(object item, string propertyName)
+        {
+            PropertyInfo property;
+            foreach (var part in propertyName.Split('.'))
+            {
+                if (item == null)
+                    return null;
+
+                var type = item.GetType();
+
+                property = type.GetProperty(part);
+                if (property == null)
+                    return null;
+
+                item = GetPropertyValue(item, property);
+            }
+            return item;
+        }
+
+        public static object GetPropertyValueDynamic(object item, string name)
+        {
+            var dictionary = (IDictionary<string, object>)item;
+
+            return dictionary[name];
+        }
+
+        public static Dictionary<string, PropertyInfo> GetProperties(Type type)
+        {
+            var properties = _cachedProperties.GetOrAdd(type, BuildPropertyDictionary);
+
+            return properties;
+        }
+
+        private static Dictionary<string, PropertyInfo> BuildPropertyDictionary(Type type)
+        {
+            var result = new Dictionary<string, PropertyInfo>();
+
+            var properties = type.GetProperties();
+            foreach (var property in properties)
+            {
+                result.Add(property.Name.ToLower(), property);
+            }
+            return result;
+        }
+
+        public static bool IsList(object item)
+        {
+            if (item is ICollection)
+                return true;
+
+            return false;
+        }
+
+        public static bool IsNullable(PropertyInfo property)
+        {
+            if (property.PropertyType.IsGenericType &&
+                property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
+                return true;
+
+            return false;
+        }
+
+        /// <summary>
+        /// Includes a work around for getting the actual type of a Nullable type.
+        /// </summary>
+        public static Type GetPropertyType(PropertyInfo property)
+        {
+            if (IsNullable(property))
+                return property.PropertyType.GetGenericArguments()[0];
+
+            return property.PropertyType;
+        }
+
+        public static object GetDefault(Type type)
+        {
+            if (type.IsValueType)
+                return Activator.CreateInstance(type);
+            return null;
+        }
+
+        public static bool IsBasicClrType(Type type)
+        {
+            if (type.IsEnum
+                || type.IsPrimitive
+                || type.IsValueType
+                || type == typeof(string)
+                || type == typeof(DateTime))
+                return true;
+
+            return false;
+        }
+
+        public static bool IsCustomEntity<T>()
+        {
+            var type = typeof(T);
+            if (type.IsClass && Type.GetTypeCode(type) == TypeCode.Object)
+                return true;
+            return false;
+        }
+    }
+    #endregion
+}

+ 172 - 0
SCBC Factory Tools/DAL/DAL_AMResult.cs

@@ -0,0 +1,172 @@
+using MOKA_Factory_Tools.Models;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.DAL
+{
+    class DAL_AMResult : BaseDAL
+    {
+        public DAL_AMResult()
+        {
+            this.TableFieldNameString = "";
+        }
+
+
+        #region 属性和字段
+
+        string _tableName = "AMResult";
+
+        /// <summary>
+        /// 获取数据表名
+        /// </summary>
+        public override string TableName
+        {
+            get { return _tableName; }
+            set { this._tableName = value; }
+        }
+
+        /// <summary>
+        /// 获取当前新的数据表模型对象
+        /// </summary>
+        public override object ObjModel
+        {
+            get
+            {
+                return this.CurrentModel;
+            }
+        }
+
+        /// <summary>
+        /// 获取当前新的MOdel
+        /// </summary>
+        public AMResult CurrentModel
+        {
+            get { return new AMResult(); }
+        }
+
+
+        string _tableFieldNameString = "";
+        /// <summary>
+        /// 数据表字段名数组
+        /// </summary>
+        public override string TableFieldNameString
+        {
+            get { return this._tableFieldNameString; }
+
+            set { this._tableFieldNameString = value; }
+        }
+
+        #endregion
+
+        #region 检查记录
+        //基类已经实现
+        #endregion
+
+        #region 增加数据
+        /// <summary>
+        /// 增加一条数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <returns></returns>
+        public bool Add(AMResult model)
+        {
+            return base.Add(model);
+        }
+        /// <summary>
+        /// 增加一条数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Add(AMResult model, string overlookFieldList = "ID")
+        {
+            return base.Add(model, overlookFieldList);
+        }
+
+        #endregion
+
+        #region 删除数据
+        /// <summary>
+        /// 删除数据
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public bool Delete(AMResult model)
+        {
+            return base.Delete(string.Format("Station = '{0}' and SN = '{1}' and ReDo = '{2}'", model.Station, model.SN, model.ReDo));
+        }
+        #endregion
+
+        #region 更新数据
+        /// <summary>
+        /// 更新一条数据
+        /// </summary>
+        public bool Update(AMResult model)
+        {
+            return base.Update(model);
+        }
+
+        /// <summary>
+        /// 根据筛选字段和SQL筛选运算符号更新数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Update(AMResult model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
+        {
+            return base.Update(model, filterFieldName, operators, overlookFieldList);
+        }
+        #endregion
+
+        #region 查询数据
+        /// <summary>
+        /// 得到一个对象实体
+        /// </summary>
+        public AMResult GetModel(int ID)
+        {
+            return DataRowToModel(GetDataRow(ID));
+        }
+
+        /// <summary>
+        /// 得到一个对象实体
+        /// </summary>
+        /// <param name="row"></param>
+        /// <returns></returns>
+        public AMResult DataRowToModel(DataRow row)
+        {
+            return DataRowToModelObject(row) as AMResult;
+        }
+
+        /// <summary>
+        /// 获得数据Model列表
+        /// </summary>
+        /// <param name="strWhere">条件 不包含 where 关键字</param>
+        public List<AMResult> GetModelList(string strWhere)
+        {
+            DataSet ds = base.GetList(strWhere);
+            return DataTableToList(ds.Tables[0]);
+        }
+
+        /// <summary>
+        /// 获得数据列表
+        /// </summary>
+        /// <param name="dt">DataTable</param>
+        public List<AMResult> DataTableToList(DataTable dt)
+        {
+            List<AMResult> modelList = new List<AMResult>();
+            List<object> ObjList = base.GetDataTableToOblList(dt);
+            foreach (object obj in ObjList)
+            {
+                modelList.Add((AMResult)obj);
+            }
+            return modelList;
+        }
+        #endregion
+    }
+}

+ 172 - 0
SCBC Factory Tools/DAL/DAL_AMYields.cs

@@ -0,0 +1,172 @@
+using MOKA_Factory_Tools.Models;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.DAL
+{
+    class DAL_AMYields : BaseDAL
+    {
+        public DAL_AMYields()
+        {
+            this.TableFieldNameString = "";
+        }
+
+
+        #region 属性和字段
+
+        string _tableName = "AMResult";
+
+        /// <summary>
+        /// 获取数据表名
+        /// </summary>
+        public override string TableName
+        {
+            get { return _tableName; }
+            set { this._tableName = value; }
+        }
+
+        /// <summary>
+        /// 获取当前新的数据表模型对象
+        /// </summary>
+        public override object ObjModel
+        {
+            get
+            {
+                return this.CurrentModel;
+            }
+        }
+
+        /// <summary>
+        /// 获取当前新的MOdel
+        /// </summary>
+        public AMYields CurrentModel
+        {
+            get { return new AMYields(); }
+        }
+
+
+        string _tableFieldNameString = "";
+        /// <summary>
+        /// 数据表字段名数组
+        /// </summary>
+        public override string TableFieldNameString
+        {
+            get { return this._tableFieldNameString; }
+
+            set { this._tableFieldNameString = value; }
+        }
+
+        #endregion
+
+        #region 检查记录
+        //基类已经实现
+        #endregion
+
+        #region 增加数据
+        /// <summary>
+        /// 增加一条数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <returns></returns>
+        public bool Add(AMYields model)
+        {
+            return base.Add(model);
+        }
+        /// <summary>
+        /// 增加一条数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Add(AMYields model, string overlookFieldList = "ID")
+        {
+            return base.Add(model, overlookFieldList);
+        }
+
+        #endregion
+
+        #region 删除数据
+        /// <summary>
+        /// 删除数据
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public bool Delete(AMYields model)
+        {
+            return base.Delete(model.ID);
+        }
+        #endregion
+
+        #region 更新数据
+        /// <summary>
+        /// 更新一条数据
+        /// </summary>
+        public bool Update(AMYields model)
+        {
+            return base.Update(model);
+        }
+
+        /// <summary>
+        /// 根据筛选字段和SQL筛选运算符号更新数据
+        /// </summary>
+        /// <param name="model">Model对象</param>
+        /// <param name="filterFieldName">筛选字段名称</param>
+        /// <param name="operators">SQL筛选运算符号</param>
+        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
+        /// <returns></returns>
+        public bool Update(AMYields model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
+        {
+            return base.Update(model, filterFieldName, operators, overlookFieldList);
+        }
+        #endregion
+
+        #region 查询数据
+        /// <summary>
+        /// 得到一个对象实体
+        /// </summary>
+        public AMYields GetModel(int ID)
+        {
+            return DataRowToModel(GetDataRow(ID));
+        }
+
+        /// <summary>
+        /// 得到一个对象实体
+        /// </summary>
+        /// <param name="row"></param>
+        /// <returns></returns>
+        public AMYields DataRowToModel(DataRow row)
+        {
+            return DataRowToModelObject(row) as AMYields;
+        }
+
+        /// <summary>
+        /// 获得数据Model列表
+        /// </summary>
+        /// <param name="strWhere">条件 不包含 where 关键字</param>
+        public List<AMYields> GetModelList(string strWhere)
+        {
+            DataSet ds = base.GetList(strWhere);
+            return DataTableToList(ds.Tables[0]);
+        }
+
+        /// <summary>
+        /// 获得数据列表
+        /// </summary>
+        /// <param name="dt">DataTable</param>
+        public List<AMYields> DataTableToList(DataTable dt)
+        {
+            List<AMYields> modelList = new List<AMYields>();
+            List<object> ObjList = base.GetDataTableToOblList(dt);
+            foreach (object obj in ObjList)
+            {
+                modelList.Add((AMYields)obj);
+            }
+            return modelList;
+        }
+        #endregion
+    }
+}

+ 58 - 0
SCBC Factory Tools/Database/CommandInfo.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.Database
+{
+    public enum EffentNextType
+    {
+        /// <summary>
+        /// 对其他语句无任何影响 
+        /// </summary>
+        None,
+        /// <summary>
+        /// 当前语句必须为"select count(1) from .."格式,如果存在则继续执行,不存在回滚事务
+        /// </summary>
+        WhenHaveContine,
+        /// <summary>
+        /// 当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
+        /// </summary>
+        WhenNoHaveContine,
+        /// <summary>
+        /// 当前语句影响到的行数必须大于0,否则回滚事务
+        /// </summary>
+        ExcuteEffectRows,
+        /// <summary>
+        /// 引发事件-当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
+        /// </summary>
+        SolicitationEvent
+    }
+
+    public class CommandInfo
+    {
+        public string CommandText;
+        public System.Data.SqlClient.SqlParameter[] Parameters;
+        public EffentNextType EffentNextType = EffentNextType.None;
+        public CommandInfo()
+        {
+
+        }
+
+        public CommandInfo(string sqlText, SqlParameter[] para)
+        {
+            this.CommandText = sqlText;
+            this.Parameters = para;
+        }
+
+        public CommandInfo(string sqlText, SqlParameter[] para, EffentNextType type)
+        {
+            this.CommandText = sqlText;
+            this.Parameters = para;
+            this.EffentNextType = type;
+
+        }
+    }
+}

+ 142 - 0
SCBC Factory Tools/Database/ConnectionParameters.cs

@@ -0,0 +1,142 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.Database
+{
+    public class ConnectionParameters
+    {
+        #region 连接串
+        // 无端口号;
+        private const string _msdbconnect = "Data Source={0};Initial Catalog={1};User ID={2};Password={3}";
+        // 有端口号;
+        private const string _msdbconnect_port = "Data Source={0},{1};Initial Catalog={2};User ID={3};Password={4}";
+        // windows信任连接;
+        private const string _msdbconnect_trusted_master = "server={0};database=master;Trusted_Connection=SSPI";
+        #endregion
+
+        #region 私有变量;
+        /// <summary>
+        /// 数据库连接串;
+        /// </summary>
+        private string connectionString = "";
+        private string connectionStringTrusted = "";
+        #endregion
+
+        #region 公共属性;
+        /// <summary>
+        /// 数据库服务器;
+        /// </summary>
+        public string DatabaseServer { get; set; } = "10.126.64.131";
+        /// <summary>
+        /// 数据库账号;
+        /// </summary>
+        public string DatabaseAccount { get; set; } = "XMUpdate";
+        /// <summary>
+        /// 数据库密码;
+        /// </summary>
+        public string DatabasePassword { get; set; } = "695Xm@123#";
+        /// <summary>
+        /// 数据库名称;
+        /// </summary>
+        public string DatabaseName { get; set; } = "MESOtherData";
+        /// <summary>
+        /// 数据库端口号;
+        /// </summary>
+        public uint DatabasePortNumber { get; set; } = 0;
+
+        /// <summary>
+        /// 连接超时值;
+        /// </summary>
+        public uint ConnectTimeout { get; set; } = 3000;
+
+        [JsonIgnore]
+        /// <summary>
+        /// 是否设置了数据库连接参数;
+        /// </summary>
+        public bool IsSetParameters { get; private set; } = false;
+
+        [JsonIgnore]
+        /// <summary>
+        /// 数据库连接串;
+        /// </summary>
+        public string ConnectionString
+        {
+            get
+            {
+                if (IsSetParameters)
+                    return connectionString;
+                else
+                {
+                    SetConnectParameters();
+                    return connectionString;
+                }
+            }
+        }
+
+        [JsonIgnore]
+        public string ConnectionStringTrusted
+        {
+            get
+            {
+                if (IsSetParameters)
+                    return connectionStringTrusted;
+                else
+                {
+                    SetConnectParameters();
+                    return connectionStringTrusted;
+                }
+            }
+        }
+        #endregion
+
+        public void SetConnectParameters()
+        {
+            try
+            {
+                // 标记连接参数已设置;
+                IsSetParameters = true;
+
+                // 生成默认的连接串;
+                connectionString = DatabasePortNumber == 0
+                    ? string.Format(_msdbconnect, DatabaseServer, DatabaseName, DatabaseAccount, DatabasePassword)
+                    : string.Format(_msdbconnect_port, DatabaseServer, DatabasePortNumber, DatabaseName, DatabaseAccount, DatabasePassword);
+
+                connectionStringTrusted = string.Format(_msdbconnect_trusted_master, DatabaseServer);
+            }
+            catch
+            {
+                throw;
+            }
+        }
+
+        public void SetConnectParameters(string databaseServer, string databaseName, string databaseAccount, string databasePassword, uint databasePortNumber=0)
+        {
+            DatabaseServer = databaseServer;
+            DatabaseName = databaseName;
+            DatabaseAccount = databaseAccount;
+            DatabasePassword = databasePassword;
+            DatabasePortNumber = databasePortNumber;
+
+            // 标记连接参数已设置;
+            IsSetParameters = true;
+
+            try
+            {
+                // 生成默认的连接串;
+                connectionString = DatabasePortNumber == 0
+                    ? string.Format(_msdbconnect, DatabaseServer, DatabaseName, DatabaseAccount, DatabasePassword)
+                    : string.Format(_msdbconnect_port, DatabaseServer, DatabasePortNumber, DatabaseName, DatabaseAccount, DatabasePassword);
+
+                connectionStringTrusted = string.Format(_msdbconnect_trusted_master, DatabaseServer);
+            }
+            catch
+            {
+                throw;
+            }
+        }
+    }
+}

+ 1236 - 0
SCBC Factory Tools/Database/DbHelper.cs

@@ -0,0 +1,1236 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.Database
+{
+    class DbHelper
+    {
+        #region 公共方法		
+        /// <summary>
+        /// 是否存在该连接对象
+        /// </summary>
+        /// <param name="connectionString"></param>
+        /// <returns></returns>
+        public static bool IsConnectionExists(string connectionString)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                try
+                {
+                    if (connection.State != ConnectionState.Open)
+                        connection.Open();
+
+                    connection.Close();
+                    return true;
+                }
+                catch
+                {
+
+                }
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// 表字段是否存在;
+        /// </summary>
+        /// <param name="tableName"></param>
+        /// <param name="columnName"></param>
+        /// <returns></returns>
+        public static bool IsColumnExists(string connectionString, string tableName, string columnName)
+        {
+            string sql = "select count(1) from syscolumns where [id]=object_id('" + tableName + "') and [name]='" + columnName + "'";
+            object res = GetSingle(sql, connectionString);
+            if (res == null)
+            {
+                return false;
+            }
+            return Convert.ToInt32(res) > 0;
+        }
+
+        /// <summary>
+        /// 表是否存在;
+        /// </summary>
+        /// <param name="tableName"></param>
+        /// <returns></returns>
+        public static bool IsTableExists(string connectionString, string tableName)
+        {
+            string strsql = "select count(*) from sysobjects where id = object_id(N'[" + tableName + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1";
+            object obj = GetSingle(strsql, connectionString);
+            int cmdresult;
+            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+            {
+                cmdresult = 0;
+            }
+            else
+            {
+                cmdresult = int.Parse(obj.ToString());
+            }
+
+            if (cmdresult == 0)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        /// <summary>
+        /// 视图是否存在
+        /// </summary>
+        /// <param name="TableName"></param>
+        /// <returns></returns>
+        public static bool IsViewsExists(string connectionString, string viewsName)
+        {
+            try
+            {
+                string strsql = "SELECT count([object_id]) as objCount FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[" + viewsName + "]')";
+                //string strsql = "SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + TableName + "]') AND type in (N'U')";
+                object obj = GetSingle(strsql, connectionString);
+                int cmdresult;
+                if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                {
+                    cmdresult = 0;
+                }
+                else
+                {
+                    cmdresult = int.Parse(obj.ToString());
+                }
+                if (cmdresult == 0)
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+            catch
+            {
+
+            }
+
+            return false;
+        }
+
+        public static int GetMaxID(string connectionString, string FieldName, string TableName)
+        {
+            string strsql = "select max(" + FieldName + ")+1 from " + TableName;
+            object obj = GetSingle(connectionString, strsql);
+            if (obj == null)
+            {
+                return 1;
+            }
+            else
+            {
+                return int.Parse(obj.ToString());
+            }
+        }
+
+        public static bool Exists(string connectionString, string strSQL)
+        {
+            int cmdresult;
+            object obj = GetSingle(strSQL, connectionString);
+            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+            {
+                cmdresult = 0;
+            }
+            else
+            {
+                cmdresult = int.Parse(obj.ToString());
+            }
+            if (cmdresult == 0)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        public static bool Exists(string connectionString, string strSQL, params SqlParameter[] cmdParms)
+        {
+            object obj = GetSingle(connectionString, strSQL, cmdParms);
+            int cmdresult;
+            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+            {
+                cmdresult = 0;
+            }
+            else
+            {
+                cmdresult = int.Parse(obj.ToString());
+            }
+            if (cmdresult == 0)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        /// <summary>
+        /// 获取时间为"1900-01-01"的日期对象
+        /// </summary>
+        /// <returns></returns>
+        public static DateTime GetNullDateTime()
+        {
+            return Convert.ToDateTime("1900-01-01");
+        }
+
+        /// <summary>
+        /// 全局ID GUID获取19位的唯一数字序列 
+        /// </summary>
+        /// <returns></returns>
+        public static long GenerateId()
+        {
+            byte[] buffer = Guid.NewGuid().ToByteArray();
+            return BitConverter.ToInt64(buffer, 0);
+        }
+
+        /// <summary>
+        /// 返回指定类型是否为允许为null的 Nullable泛型对象
+        /// </summary>
+        /// <param name="_type"></param>
+        /// <returns>是Nullable泛型对象为 true 否则为 false</returns>
+        public static bool IsNullable(Type _type)
+        {
+            bool bl = _type.Name.ToLower().Contains("Nullable".ToLower());
+            return bl;
+        }
+
+        /// <summary>
+        /// 验证一个类的完全限定名中是否以“system.”开头
+        /// </summary>
+        /// <param name="classFullName"></param>
+        /// <returns>以“system.”开头为 true 否则为 false </returns>
+        public static bool VerificationClassFullNameIsSystem(string classFullName)
+        {
+            bool bl = false;
+            if (classFullName.ToLower().IndexOf("system.") == 0)
+            {
+                bl = true;
+            }
+            return bl;
+        }
+
+        /// <summary>
+        /// 获取实例对象属性的值
+        /// </summary>
+        /// <param name="model">实例对象</param>
+        /// <param name="propertyName">属性名</param>
+        /// <returns></returns>
+        public static object GetPropertyValue(object model, string propertyName)
+        {
+            System.Reflection.PropertyInfo propertyInfo = model.GetType().GetProperty(propertyName);
+            if (propertyInfo != null)
+            {
+                object tempValue = propertyInfo.GetValue(model, null);//对应字段值
+
+                return tempValue;
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// 设置实例对象属性的值
+        /// </summary>
+        /// <param name="model">实例对象</param>
+        /// <param name="propertyInfo">属性对象</param>
+        /// <param name="value">要设置的值</param>
+        public static void SetPropertyValue(object model, System.Reflection.PropertyInfo propertyInfo, object value)
+        {
+            if (propertyInfo == null)
+            {
+                return;
+            }
+
+            Type tempType = propertyInfo.PropertyType;
+
+            if (IsNullable(tempType))
+            {
+                tempType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
+            }
+            object tempValue = value;
+            if (tempValue == null)
+            {
+                try
+                {
+                    propertyInfo.SetValue(model, null, null);
+                }
+                catch { }
+            }
+            else
+            {
+
+                switch (tempType.Name)
+                {
+                    //      空引用。
+                    case "Empty":
+                        propertyInfo.SetValue(model, tempValue.ToString(), null);
+                        break;
+
+                    //     常规类型,表示不会由另一个 TypeCode 显式表示的任何引用或值类型。
+                    case "Object":
+                        propertyInfo.SetValue(model, tempValue, null);
+                        break;
+                    //     数据库空(列)值。
+                    case "DBNull":
+                        propertyInfo.SetValue(model, null, null);
+                        break;
+                    //     简单类型,表示 true 或 false 的布尔值。
+                    case "Boolean":
+                        try
+                        {
+                            propertyInfo.SetValue(model, Convert.ToBoolean(tempValue), null);
+                        }
+                        catch
+                        {
+                            propertyInfo.SetValue(model, false, null);
+                        }
+                        break;
+                    //字符
+                    case "Char":
+                        propertyInfo.SetValue(model, Convert.ToChar(tempValue), null);
+                        break;
+                    //     整型,表示值介于 -128 到 127 之间的有符号 8 位整数。
+                    case "SByte":
+                        propertyInfo.SetValue(model, Convert.ToSByte(tempValue), null);
+                        break;
+                    //     0 and 255.
+                    case "Byte":
+                        propertyInfo.SetValue(model, Convert.ToByte(tempValue), null);
+                        break;
+                    //     整型,表示值介于 -32768 到 32767 之间的有符号 16 位整数。
+                    case "Int16":
+                        propertyInfo.SetValue(model, Convert.ToInt16(tempValue), null);
+                        break;
+                    //     整型,表示值介于 0 到 65535 之间的无符号 16 位整数。
+                    case "UInt16":
+                        propertyInfo.SetValue(model, Convert.ToUInt16(tempValue), null);
+                        break;
+                    //     整型,表示值介于 -2147483648 到 2147483647 之间的有符号 32 位整数。
+                    case "Int32":
+                        try
+                        {
+                            propertyInfo.SetValue(model, Convert.ToInt32(tempValue), null);
+                        }
+                        catch
+                        {
+                            propertyInfo.SetValue(model, Convert.ToInt32(0), null);
+                        }
+                        break;
+                    //     整型,表示值介于 0 到 4294967295 之间的无符号 32 位整数。
+                    case "UInt32":
+                        propertyInfo.SetValue(model, Convert.ToUInt32(tempValue), null);
+                        break;
+                    //     整型,表示值介于 -9223372036854775808 到 9223372036854775807 之间的有符号 64 位整数。
+                    case "Int64":
+                        propertyInfo.SetValue(model, Convert.ToInt64(tempValue), null);
+                        break;
+                    //     整型,表示值介于 0 到 18446744073709551615 之间的无符号 64 位整数。
+                    case "UInt64":
+                        propertyInfo.SetValue(model, Convert.ToUInt64(tempValue), null);
+                        break;
+                    //     浮点型,表示从大约 1.5 x 10 -45 到 3.4 x 10 38 且精度为 7 位的值。
+                    case "Single":
+                        propertyInfo.SetValue(model, Convert.ToSingle(tempValue), null);
+                        break;
+                    //     浮点型,表示从大约 5.0 x 10 -324 到 1.7 x 10 308 且精度为 15 到 16 位的值。
+                    case "Double":
+                        try
+                        {
+                            propertyInfo.SetValue(model, Convert.ToDouble(tempValue), null);
+                        }
+                        catch
+                        {
+                            propertyInfo.SetValue(model, 0, null);
+                        }
+                        break;
+                    //     简单类型,表示从 1.0 x 10 -28 到大约 7.9 x 10 28 且有效位数为 28 到 29 位的值。
+                    case "Decimal":
+                        propertyInfo.SetValue(model, Convert.ToDecimal(tempValue), null);
+                        break;
+                    //     表示一个日期和时间值的类型。
+                    case "DateTime":
+                        try
+                        {
+                            if (tempValue != null)
+                            {
+                                propertyInfo.SetValue(model, Convert.ToDateTime(tempValue), null);
+                            }
+                        }
+                        catch
+                        {
+                            //  propertyInfo.SetValue(model, Convert.ToDateTime("1753-01-01"), null);
+                        }
+                        break;
+                    //     密封类类型,表示 Unicode 字符串。
+                    case "String":
+                        propertyInfo.SetValue(model, tempValue.ToString(), null);
+                        break;
+                    default:
+                        string classFullName = tempType.ToString();
+                        if (!VerificationClassFullNameIsSystem(classFullName))
+                        {
+                            try
+                            {
+                                Type valueType = tempType.Module.Assembly.GetType(classFullName);
+                                // object obj = Activator.CreateInstance(type, null);
+                                tempValue = Activator.CreateInstance(valueType, new object[] { tempValue.ToString() });
+                            }
+                            catch { }
+                        }
+                        propertyInfo.SetValue(model, tempValue, null);
+                        break;
+                }
+            }
+        }
+        #endregion
+
+        #region  执行简单SQL语句
+
+        /// <summary>
+        /// 执行SQL语句,返回影响的记录数
+        /// </summary>
+        /// <param name="strSQL">SQL语句</param>
+        /// <returns>影响的记录数</returns>
+        public static int ExecuteSQL(string connectionString, string strSQL)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand(strSQL, connection))
+                {
+                    try
+                    {
+                        connection.Open();
+                        int rows = cmd.ExecuteNonQuery();
+                        return rows;
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行SQL语句,返回影响的记录数
+        /// </summary>
+        /// <param name="strSQL">SQL语句</param>
+        /// <param name="Timeouts">超时值</param>
+        /// <returns></returns>
+        public static int ExecuteSQLByTime(string connectionString, string strSQL, int Timeouts)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand(strSQL, connection))
+                {
+                    try
+                    {
+                        connection.Open();
+                        cmd.CommandTimeout = Timeouts;
+                        int rows = cmd.ExecuteNonQuery();
+                        return rows;
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行多条SQL语句,实现数据库事务。
+        /// </summary>
+        /// <param name="listSQL">多条SQL语句</param>		
+        public static int ExecuteSQLTran(string connectionString, List<String> listSQL)
+        {
+            using (SqlConnection conn = new SqlConnection(connectionString))
+            {
+                conn.Open();
+                SqlCommand cmd = new SqlCommand();
+                cmd.Connection = conn;
+                SqlTransaction tx = conn.BeginTransaction();
+                cmd.Transaction = tx;
+                try
+                {
+                    int count = 0;
+                    for (int n = 0; n < listSQL.Count; n++)
+                    {
+                        string strsql = listSQL[n];
+                        if (strsql.Trim().Length > 1)
+                        {
+                            cmd.CommandText = strsql;
+                            count += cmd.ExecuteNonQuery();
+                        }
+                    }
+                    tx.Commit();
+                    return count;
+                }
+                catch
+                {
+                    tx.Rollback();
+                    return 0;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行带一个存储过程参数的的SQL语句。
+        /// </summary>
+        /// <param name="strSQL">SQL语句</param>
+        /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
+        /// <returns>影响的记录数</returns>
+        public static int ExecuteSQL(string connectionString, string strSQL, string content)
+        {
+            System.Data.SqlClient.SqlParameter myParameter = new System.Data.SqlClient.SqlParameter("@content", SqlDbType.NText);
+            myParameter.Value = content;
+
+            return ExecuteSQL(strSQL, connectionString, new System.Data.SqlClient.SqlParameter[] { myParameter });
+        }
+
+        /// <summary>
+        /// 执行带一个存储过程参数的的SQL语句。
+        /// </summary>
+        /// <param name="strSQL">SQL语句</param>
+        /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
+        /// <returns>影响的记录数</returns>
+        public static object ExecuteSQLGet(string connectionString, string strSQL)
+        {
+            System.Data.SqlClient.SqlParameter myParameter = new System.Data.SqlClient.SqlParameter("@content", SqlDbType.NText);
+            myParameter.Value = connectionString;
+
+            return GetSingle(strSQL, connectionString, new System.Data.SqlClient.SqlParameter[] { myParameter });
+        }
+
+        /// <summary>
+        /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
+        /// </summary>
+        /// <param name="strSQL">SQL语句</param>
+        /// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
+        /// <returns>影响的记录数</returns>
+        public static int ExecuteSQLInsertImg(string connectionString, string strSQL, byte[] fs)
+        {
+            System.Data.SqlClient.SqlParameter myParameter = new System.Data.SqlClient.SqlParameter("@fs", SqlDbType.Image);
+            myParameter.Value = fs;
+            return ExecuteSQL(strSQL, connectionString, new System.Data.SqlClient.SqlParameter[] { myParameter });
+        }
+
+        /// <summary>
+        /// 执行查询语句,返回DataSet
+        /// </summary>
+        /// <param name="strSQL">查询语句</param>
+        /// <returns>DataSet</returns>
+        public static DataSet Query(string connectionString, string strSQL)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                DataSet ds = new DataSet();
+                try
+                {
+                    connection.Open();
+                    SqlDataAdapter command = new SqlDataAdapter(strSQL, connection);
+                    command.Fill(ds, "ds");
+                }
+                catch (System.Data.SqlClient.SqlException ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                return ds;
+            }
+        }
+
+        public static DataSet Query(string connectionString, string strSQL, int Timeout)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                DataSet ds = new DataSet();
+                try
+                {
+                    connection.Open();
+                    SqlDataAdapter command = new SqlDataAdapter(strSQL, connection);
+                    command.SelectCommand.CommandTimeout = Timeout;
+                    command.Fill(ds, "ds");
+                }
+                catch (System.Data.SqlClient.SqlException ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                return ds;
+            }
+        }
+
+        #endregion
+
+        #region 执行带参数的SQL语句
+        /// <summary>
+        /// 获取数据库登录用户状态
+        /// </summary>
+        /// <param name="userName">用户名</param>
+        /// <returns>返回 true 为启用 false 为禁用</returns>
+        public static bool GetDBUserStatus(string connectionString, string userName = "sa")
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand())
+                {
+                    try
+                    {
+                        PrepareCommand(cmd, connection, null, "SELECT is_disabled FROM sys.server_principals WHERE name ='" + userName + "'", null);
+                        object obj = cmd.ExecuteScalar();
+                        cmd.Parameters.Clear();
+                        if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                        {
+                            return false;
+                        }
+                        else
+                        {
+                            return !Convert.ToBoolean(obj);
+                        }
+                    }
+                    catch
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 执行多条SQL语句,实现数据库事务。
+        /// </summary>
+        /// <param name="listSQL">多条SQL语句</param>		
+        /// <param name="msg"></param>
+        /// <param name="backgroundWorker"></param>
+        /// <param name="times"></param>
+        /// <returns></returns>
+        public static int ExecuteSQLTran(string connectionString, List<string> listSQL, ref string msg, System.ComponentModel.BackgroundWorker backgroundWorker = null, int times = -1)
+        {
+            //总计数器
+            float sumCount = listSQL.Count;
+            //当前计数器
+            int currentCount = 0;
+            using (SqlConnection conn = new SqlConnection(connectionString))
+            {
+                conn.Open();
+                SqlCommand cmd = new SqlCommand();
+                cmd.Connection = conn;
+                SqlTransaction tx = conn.BeginTransaction();
+                cmd.Transaction = tx;
+                if (times > 0)
+                {
+                    cmd.CommandTimeout = times;
+                }
+                try
+                {
+                    int count = 0;
+                    if (listSQL.Count > 0)
+                    {
+                        for (int n = 0; n < listSQL.Count; n++)
+                        {
+                            currentCount++;
+                            string strsql = listSQL[n];
+                            if (strsql.Trim().Length > 1)
+                            {
+                                cmd.CommandText = strsql;
+                                count += cmd.ExecuteNonQuery();
+                            }
+
+                            if (backgroundWorker != null)
+                            {
+                                try
+                                {
+                                    int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
+                                    backgroundWorker.ReportProgress(currentProgres);
+                                }
+                                catch { }
+                            }
+                        }
+                        tx.Commit();
+                        msg = "成功!";
+                        return listSQL.Count;
+                    }
+                    else
+                    {
+                        msg = "失败,错误原因:脚本内容为空!";
+                        return 0;
+                    }
+                }
+                catch (System.Data.SqlClient.SqlException ex)
+                {
+                    msg = "失败,错误原因:" + ex.Message;
+                    tx.Rollback();
+                    return 0;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行SQL脚本文件 实现数据库事务。
+        /// </summary>
+        /// <param name="sqlScript">SQL脚本内容</param>
+        /// <param name="msg">返回执行信息</param>
+        /// <returns></returns>
+        public static bool ExecuteSQLScriptTextTran(string connectionString, string sqlScript, ref string msg, System.ComponentModel.BackgroundWorker backgroundWorker = null, int times = -1)
+        {
+            bool bl = false;
+            List<string> SQLStringList = new List<string>();
+            string[] sqlArray = System.Text.RegularExpressions.Regex.Split(sqlScript, "go\r\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+            for (int i = 0; i < sqlArray.Length; i++)
+            {
+                string sql = System.Text.RegularExpressions.Regex.Split(sqlArray[i], "\r\ngo", System.Text.RegularExpressions.RegexOptions.IgnoreCase)[0];
+                if (sql.Trim() != "")
+                {
+                    SQLStringList.Add(sql);
+                }
+
+            }
+            int ret = ExecuteSQLTran(connectionString, SQLStringList, ref msg, backgroundWorker, times);
+            if (ret > 0)
+            {
+                bl = true;
+            }
+            return bl;
+        }
+
+        /// <summary>
+        /// 执行SQL脚本文件 实现数据库事务。
+        /// </summary>
+        /// <param name="sqlScriptFilePath">SQL脚本文件路径</param>
+        /// <param name="msg">返回执行信息</param>
+        /// <returns></returns>
+        public static bool ExecuteSQLScriptFileTran(string connectionString, string sqlScriptFilePath, ref string msg, System.ComponentModel.BackgroundWorker backgroundWorker = null, int times = -1)
+        {
+            if (System.IO.File.Exists(sqlScriptFilePath))
+            {
+                string upgradeDatabaseSql = System.IO.File.ReadAllText(sqlScriptFilePath, System.Text.Encoding.UTF8);
+                return ExecuteSQLScriptTextTran(connectionString, upgradeDatabaseSql, ref msg, backgroundWorker, times);
+            }
+            else
+            {
+                msg = "要执行的SQL脚本文件不存在!";
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 执行SQL脚本文件
+        /// </summary>
+        /// <param name="sqlScript">SQL脚本内容</param>
+        /// <param name="msg">返回执行信息</param>
+        /// <returns></returns>
+        public static bool ExecuteSQLScriptFile(string connectionString, string sqlScript, ref string msg, System.ComponentModel.BackgroundWorker backgroundWorker = null, int times = -1)
+        {
+            bool bl = false;
+            string[] sqlArray = System.Text.RegularExpressions.Regex.Split(sqlScript, "go\r\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+            //总计数器
+            float sumCount = sqlArray.Length;
+            //当前计数器
+            int currentCount = 0;
+            for (int i = 0; i < sqlArray.Length; i++)
+            {
+                currentCount++;
+                string sql = System.Text.RegularExpressions.Regex.Split(sqlArray[i], "\r\ngo", System.Text.RegularExpressions.RegexOptions.IgnoreCase)[0];
+                if (sql.Trim() != "")
+                {
+                    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
+                    try
+                    {
+                        List<System.Data.SqlClient.SqlParameter> parameterlist = new List<System.Data.SqlClient.SqlParameter>();
+                        System.Data.SqlClient.SqlParameter[] parameters = parameterlist.ToArray();
+                        if (times > 0)
+                        {
+                            ExecuteSQL(connectionString, sql, times, parameters);
+                        }
+                        else
+                        {
+                            ExecuteSQL(sql, connectionString, parameters);
+                        }
+                        msg = "成功!";
+                        bl = true;
+                    }
+                    catch (System.Data.SqlClient.SqlException ex)
+                    {
+                        msg = "失败,错误原因:" + ex.Message;
+                        bl = false;
+                        break;
+                    }
+                }
+                if (backgroundWorker != null)
+                {
+                    try
+                    {
+                        int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
+                        backgroundWorker.ReportProgress(currentProgres);
+                    }
+                    catch { }
+                }
+            }
+            return bl;
+        }
+
+        /// <summary>
+        /// 执行SQL语句,返回影响的记录数
+        /// </summary>
+        /// <param name="SQLString">SQL语句</param>
+        /// <returns>影响的记录数</returns>
+        public static int ExecuteSQL(string connectionString, string SQLString, params SqlParameter[] cmdParms)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand())
+                {
+                    try
+                    {
+                        PrepareCommand(cmd, connection, null, SQLString, cmdParms);
+                        int rows = cmd.ExecuteNonQuery();
+                        cmd.Parameters.Clear();
+                        return rows;
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行SQL语句,返回影响的记录数
+        /// </summary>
+        /// <param name="SQLString">SQL语句</param>
+        /// <returns>影响的记录数</returns>
+        public static int ExecuteSQL(string connectionString, string SQLString, int times, params SqlParameter[] cmdParms)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand())
+                {
+                    try
+                    {
+                        PrepareCommand(cmd, connection, null, SQLString, cmdParms);
+                        cmd.CommandTimeout = times;
+                        int rows = cmd.ExecuteNonQuery();
+                        cmd.Parameters.Clear();
+                        return rows;
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行一条计算查询结果语句,返回查询结果(object)。
+        /// </summary>
+        /// <param name="strSQL">计算查询结果语句</param>
+        /// <returns>查询结果(object)</returns>
+        public static Object GetSingle(string connectionString, string strSQL)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand(strSQL, connection))
+                {
+                    try
+                    {
+                        connection.Open();
+                        object obj = cmd.ExecuteScalar();
+                        if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                        {
+                            return null;
+                        }
+                        else
+                        {
+                            return obj;
+                        }
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        public static Object GetSingle(string strSQL, SqlConnection connection)
+        {
+            using (SqlCommand cmd = new SqlCommand(strSQL, connection))
+            {
+                try
+                {
+                    if (connection.State != ConnectionState.Open)
+                        connection.Open();
+                    object obj = cmd.ExecuteScalar();
+                    if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                    {
+                        return null;
+                    }
+                    else
+                    {
+                        return obj;
+                    }
+                }
+                catch (System.Data.SqlClient.SqlException e)
+                {
+                    connection.Close();
+                    throw e;
+                }
+            }
+        }
+
+        public static object GetSingle(string connectionString, string strSQL, params SqlParameter[] cmdParms)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                using (SqlCommand cmd = new SqlCommand())
+                {
+                    try
+                    {
+                        PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                        object obj = cmd.ExecuteScalar();
+                        cmd.Parameters.Clear();
+                        if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                        {
+                            return null;
+                        }
+                        else
+                        {
+                            return obj;
+                        }
+                    }
+                    catch (System.Data.SqlClient.SqlException e)
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+
+        public static object GetSingle(string strSQL, SqlConnection connection, params SqlParameter[] cmdParms)
+        {
+            using (SqlCommand cmd = new SqlCommand())
+            {
+                try
+                {
+                    if (connection.State != ConnectionState.Open) connection.Open();
+                    PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                    object obj = cmd.ExecuteScalar();
+                    cmd.Parameters.Clear();
+                    if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
+                    {
+                        return null;
+                    }
+                    else
+                    {
+                        return obj;
+                    }
+                }
+                catch (System.Data.SqlClient.SqlException e)
+                {
+                    throw e;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 执行查询语句,返回SqlDataReader ( 注意:调用该方法后,一定要对SqlDataReader进行Close )
+        /// </summary>
+        /// <param name="strSQL">查询语句</param>
+        /// <returns>SqlDataReader</returns>
+        public static SqlDataReader ExecuteReader(string connectionString, string strSQL, params SqlParameter[] cmdParms)
+        {
+            SqlConnection connection = new SqlConnection(connectionString);
+            SqlCommand cmd = new SqlCommand();
+            try
+            {
+                PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
+                cmd.Parameters.Clear();
+                return myReader;
+            }
+            catch (System.Data.SqlClient.SqlException e)
+            {
+                throw e;
+            }
+        }
+
+        public static SqlDataReader ExecuteReader(string strSQL, SqlConnection connection, params SqlParameter[] cmdParms)
+        {
+            if (connection.State != ConnectionState.Open) connection.Open();
+            SqlCommand cmd = new SqlCommand();
+            try
+            {
+                PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
+                cmd.Parameters.Clear();
+                return myReader;
+            }
+            catch (System.Data.SqlClient.SqlException e)
+            {
+                throw e;
+            }
+        }
+
+        /// <summary>
+        /// 执行查询语句,返回DataSet
+        /// </summary>
+        /// <param name="strSQL">查询语句</param>
+        /// <returns>DataSet</returns>
+        public static DataSet MasterQuery(string connectionString, string strSQL, params SqlParameter[] cmdParms)
+        {
+            return Query(strSQL, connectionString, cmdParms);
+        }
+
+        /// <summary>
+        /// 执行查询语句,返回DataSet
+        /// </summary>
+        /// <param name="SQLString">查询语句</param>
+        /// <returns>DataSet</returns>
+        public static DataSet Query(string connectionString, string strSQL, params SqlParameter[] cmdParms)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                SqlCommand cmd = new SqlCommand();
+                PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
+                {
+                    DataSet ds = new DataSet();
+                    try
+                    {
+                        da.Fill(ds, "ds");
+                        cmd.Parameters.Clear();
+                    }
+                    catch (System.Data.SqlClient.SqlException ex)
+                    {
+                        throw new Exception(ex.Message);
+                    }
+
+                    return ds;
+                }
+            }
+        }
+
+        public static DataSet Query(SqlConnection connection, string strSQL, params SqlParameter[] cmdParms)
+        {
+            if (connection.State != ConnectionState.Open) connection.Open();
+            SqlCommand cmd = new SqlCommand();
+            PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
+            {
+                DataSet ds = new DataSet();
+                try
+                {
+                    da.Fill(ds, "ds");
+                    cmd.Parameters.Clear();
+                }
+                catch (System.Data.SqlClient.SqlException ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+
+                return ds;
+            }
+        }
+
+        /// <summary>
+        /// 执行查询语句,返回DataSet
+        /// </summary>
+        /// <param name="strSQL">查询语句</param>
+        /// <returns>DataSet</returns>
+        public static DataSet Query(string connectionString, string strSQL, int times, params SqlParameter[] cmdParms)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                SqlCommand cmd = new SqlCommand();
+                cmd.CommandTimeout = times;
+                PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
+                {
+                    DataSet ds = new DataSet();
+                    try
+                    {
+                        da.Fill(ds, "ds");
+                        cmd.Parameters.Clear();
+                    }
+                    catch (System.Data.SqlClient.SqlException ex)
+                    {
+                        throw new Exception(ex.Message);
+                    }
+
+                    return ds;
+                }
+            }
+        }
+
+        public static DataSet Query(string strSQL, int times, SqlConnection connection, params SqlParameter[] cmdParms)
+        {
+            if (connection.State != ConnectionState.Open) connection.Open();
+            SqlCommand cmd = new SqlCommand();
+            cmd.CommandTimeout = times;
+            PrepareCommand(cmd, connection, null, strSQL, cmdParms);
+            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
+            {
+                DataSet ds = new DataSet();
+                try
+                {
+                    da.Fill(ds, "ds");
+                    cmd.Parameters.Clear();
+                }
+                catch (System.Data.SqlClient.SqlException ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+
+                return ds;
+            }
+        }
+
+        public static void PublicPrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, string cmdText, SqlParameter[] cmdParms)
+        {
+            PrepareCommand(cmd, conn, trans, cmdText, cmdParms);
+        }
+
+        private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, string cmdText, SqlParameter[] cmdParms)
+        {
+            if (conn.State != ConnectionState.Open)
+                conn.Open();
+            cmd.Connection = conn;
+            cmd.CommandText = cmdText;
+            if (trans != null)
+                cmd.Transaction = trans;
+            cmd.CommandType = CommandType.Text;//cmdType;
+            if (cmdParms != null)
+            {
+                foreach (SqlParameter parameter in cmdParms)
+                {
+                    if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
+                        (parameter.Value == null))
+                    {
+                        parameter.Value = DBNull.Value;
+                    }
+                    cmd.Parameters.Add(parameter);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 存储过程操作
+        /// <summary>
+        /// 执行存储过程
+        /// </summary>
+        /// <param name="storedProcName">存储过程名</param>
+        /// <param name="parameters">存储过程参数</param>
+        /// <param name="tableName">DataSet结果中的表名</param>
+        /// <returns>DataSet</returns>
+        public static DataSet RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, string tableName)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                DataSet dataSet = new DataSet();
+                connection.Open();
+                SqlDataAdapter sqlDA = new SqlDataAdapter();
+                sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
+                sqlDA.Fill(dataSet, tableName);
+                return dataSet;
+            }
+        }
+
+        public static DataSet RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, string tableName, int Times)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                DataSet dataSet = new DataSet();
+                connection.Open();
+                SqlDataAdapter sqlDA = new SqlDataAdapter();
+                sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
+                sqlDA.SelectCommand.CommandTimeout = Times;
+                sqlDA.Fill(dataSet, tableName);
+                return dataSet;
+            }
+        }
+
+        /// <summary>
+        /// 执行存储过程,返回影响的行数		
+        /// </summary>
+        /// <param name="storedProcName">存储过程名</param>
+        /// <param name="parameters">存储过程参数</param>
+        /// <param name="rowsAffected">影响的行数</param>
+        /// <returns></returns>
+        public static int RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, out int rowsAffected)
+        {
+            using (SqlConnection connection = new SqlConnection(connectionString))
+            {
+                int result;
+                connection.Open();
+                SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);
+                rowsAffected = command.ExecuteNonQuery();
+                result = (int)command.Parameters["ReturnValue"].Value;
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// 创建 SqlCommand 对象实例(用来返回一个整数值)	
+        /// </summary>
+        /// <param name="storedProcName">存储过程名</param>
+        /// <param name="parameters">存储过程参数</param>
+        /// <returns>SqlCommand 对象实例</returns>
+        private static SqlCommand BuildIntCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
+        {
+            SqlCommand command = BuildQueryCommand(connection, storedProcName, parameters);
+            command.Parameters.Add(new SqlParameter("ReturnValue",
+                SqlDbType.Int, 4, ParameterDirection.ReturnValue,
+                false, 0, 0, string.Empty, DataRowVersion.Default, null));
+            return command;
+        }
+
+        /// <summary>
+        /// 构建 SqlCommand 对象(用来返回一个结果集,而不是一个整数值)
+        /// </summary>
+        /// <param name="connection">数据库连接</param>
+        /// <param name="storedProcName">存储过程名</param>
+        /// <param name="parameters">存储过程参数</param>
+        /// <returns>SqlCommand</returns>
+        private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
+        {
+            SqlCommand command = new SqlCommand(storedProcName, connection);
+            command.CommandType = CommandType.StoredProcedure;
+            foreach (SqlParameter parameter in parameters)
+            {
+                if (parameter != null)
+                {
+                    // 检查未分配值的输出参数,将其分配以DBNull.Value.
+                    if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
+                        (parameter.Value == null))
+                    {
+                        parameter.Value = DBNull.Value;
+                    }
+                    command.Parameters.Add(parameter);
+                }
+            }
+
+            return command;
+        }
+        #endregion
+    }
+}

+ 11 - 1
SCBC Factory Tools/MOKA Factory Tools.csproj

@@ -99,6 +99,14 @@
   <ItemGroup>
     <Compile Include="Business\CommonMethod.cs" />
     <Compile Include="Business\Countkey.cs" />
+    <Compile Include="DAL\BaseDAL.cs" />
+    <Compile Include="DAL\DAL_AMResult.cs" />
+    <Compile Include="DAL\DAL_AMYields.cs" />
+    <Compile Include="Database\CommandInfo.cs" />
+    <Compile Include="Database\ConnectionParameters.cs" />
+    <Compile Include="Database\DbHelper.cs" />
+    <Compile Include="Models\AMResult.cs" />
+    <Compile Include="Models\AMYields.cs" />
     <Compile Include="Verify\CRC-CCITT %280xFFFF%29.cs" />
     <Compile Include="Verify\CRCUtils.cs" />
     <Compile Include="Views\CreateDBManually.cs">
@@ -298,7 +306,9 @@
   <ItemGroup>
     <WCFMetadata Include="Connected Services\" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <Folder Include="BLL\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="packages\System.Data.SQLite.Core.1.0.111.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('packages\System.Data.SQLite.Core.1.0.111.0\build\net40\System.Data.SQLite.Core.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 29 - 0
SCBC Factory Tools/Models/AMResult.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.Models
+{
+    class AMResult
+    {
+        public DateTime TestDate { get; set; }   /* 日期班次 */
+        public int TestHour { get; set; }        /* 小时 */
+        public string Line { get; set; }         /* 线体:UI界面或配置文件提供 */
+        public string Station { get; set; }      /* 工站:UI界面或配置文件提供 */
+        public string Model { get; set; }        /* 机型:HTTP接口获取 */
+        public string Dimension { get; set; }    /* 尺寸:HTTP接口获取 */
+        public string TestTime { get; set; }     /* 测试时间 */
+        public string ODF { get; set; }          /* 批次:HTTP接口获取 */
+        public string SN { get; set; }           /* 本次抄写SN */
+        public string ReDo { get; set; }         /* 重流标识 */
+        public string Test01 { get; set; }       /* 首次测试结果 */
+        public string Test02 { get; set; }       /* 第二次测试结果 */
+        public string FinalTest { get; set; }    /* 最终测试结果 */
+        public string ResultType { get; set; }   /* 结果类型:OncePass、NTF、FinalPass、TwiceFail、FinalPass、OnceFail、FinalFail */
+        public string DSN { get; set; }          /* 本次抄写DSN */
+        public string ErrorMsg { get; set; }     /* 抄写失败描述 */
+        public string Remark { get; set; }       /* 备注:一般用于重流标记 */
+    }
+}

+ 33 - 0
SCBC Factory Tools/Models/AMYields.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MOKA_Factory_Tools.Models
+{
+    class AMYields
+    {
+        public int ID { get; set; }                     /* 自增ID */
+        public DateTime TestDate { get; set; }          /* 日期班次 */
+        public int TestHour{ get; set; }                /* 小时 */
+        public string Line{ get; set; }                 /* 线体:UI界面或配置文件提供 */
+        public string Station{ get; set; }              /* 工站:UI界面或配置文件提供 */
+        public string ODF{ get; set; }                  /* 批次:HTTP接口获取 */
+        public string DeviceNum{ get; set; }            /* 机架编号:HTTP接口获取 */
+        public string Model{ get; set; }                /* 机型:HTTP接口获取 */
+        public string Dimension{ get; set; }            /* 尺寸:HTTP接口获取 */
+        public string OncePass{ get; set; }             /* 第一次Pass的数量:抄写一次就成功的整机(注意:GetKeys网络通信失败的不要视为Fail加入统计,进入工厂模式失败的也不要加入Fail) */
+        public string NTF{ get; set; }                  /* 第二次Pass的数量:第一次抄写失败,则进行第二次抄写成功的数量 */
+        public string TwiceFail{ get; set; }            /* 连续2次Fail的数量 */
+        public string RealFail{ get; set; }             /* 实际Fail的数量 */
+        public string Total{ get; set; }                /* 测试产品总数:是否包含回流的? */
+        public string FPY{ get; set; }                  /* 一次测试Pass的合格率:计算方式= OncePass/Total */
+        public string SPY{ get; set; }                  /* 两次以内测试Pass的合格率:计算方式=(OnecPass+NTF)/Total */
+        public string RPY{ get; set; }                  /* 实际合格率:计算方式=1-RealFail/Total */
+        public string YieldRate{ get; set; }            /* 去掉重码实际合格率:计算方式=1- */
+        public string NTF_SN{ get; set; }               /* 记录NTF的FSN号,使用分号分隔 */
+        public string FailDSN{ get; set; }              /* 记录实际Fail的FSN号 */
+        public string Remark{ get; set; }               /* 备注 */
+    }
+}

+ 0 - 2
SCBC Factory Tools/Program.cs

@@ -1,6 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Windows.Forms;
 
 namespace MOKA_Factory_Tools