/// <summary>
        /// 添加数据
        /// </summary>
        public int Add(Plan_Beginwork_Flow model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TAB_Plan_Beginwork_Flow");
            strSql.Append("(strTrainPlanGUID,strUserName,strUserNumber,dtConfirmTime,nConfirmType,strConfirmBrief,nFlowState,dtCreateTime,dtBeginTime,dtEndTime,nExecLength)");
            strSql.Append("values(@strTrainPlanGUID,@strUserName,@strUserNumber,@dtConfirmTime,@nConfirmType,@strConfirmBrief,@nFlowState,@dtCreateTime,@dtBeginTime,@dtEndTime,@nExecLength)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strTrainPlanGUID", model.strTrainPlanGUID),
                new SqlParameter("@strUserName",      model.strUserName),
                new SqlParameter("@strUserNumber",    model.strUserNumber),
                new SqlParameter("@dtConfirmTime",    model.dtConfirmTime),
                new SqlParameter("@nConfirmType",     model.nConfirmType),
                new SqlParameter("@strConfirmBrief",  model.strConfirmBrief),
                new SqlParameter("@nFlowState",       model.nFlowState),
                new SqlParameter("@dtCreateTime",     model.dtCreateTime),
                new SqlParameter("@dtBeginTime",      model.dtBeginTime),
                new SqlParameter("@dtEndTime",        model.dtEndTime),
                new SqlParameter("@nExecLength",      model.nExecLength)
            };

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters)));
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        public bool Update(Plan_Beginwork_Flow model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Update TAB_Plan_Beginwork_Flow set ");
            strSql.Append(" strTrainPlanGUID = @strTrainPlanGUID, ");
            strSql.Append(" strUserName = @strUserName, ");
            strSql.Append(" strUserNumber = @strUserNumber, ");
            strSql.Append(" dtConfirmTime = @dtConfirmTime, ");
            strSql.Append(" nConfirmType = @nConfirmType, ");
            strSql.Append(" strConfirmBrief = @strConfirmBrief, ");
            strSql.Append(" nFlowState = @nFlowState, ");
            strSql.Append(" dtCreateTime = @dtCreateTime, ");
            strSql.Append(" dtBeginTime = @dtBeginTime, ");
            strSql.Append(" dtEndTime = @dtEndTime, ");
            strSql.Append(" nExecLength = @nExecLength ");
            strSql.Append(" where nID = @nID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@strTrainPlanGUID", model.strTrainPlanGUID),
                new SqlParameter("@strUserName",      model.strUserName),
                new SqlParameter("@strUserNumber",    model.strUserNumber),
                new SqlParameter("@dtConfirmTime",    model.dtConfirmTime),
                new SqlParameter("@nConfirmType",     model.nConfirmType),
                new SqlParameter("@strConfirmBrief",  model.strConfirmBrief),
                new SqlParameter("@nFlowState",       model.nFlowState),
                new SqlParameter("@dtCreateTime",     model.dtCreateTime),
                new SqlParameter("@dtBeginTime",      model.dtBeginTime),
                new SqlParameter("@dtEndTime",        model.dtEndTime),
                new SqlParameter("@nExecLength",      model.nExecLength)
            };

            return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters) > 0);
        }
        /// <summary>
        /// 检查数据是否存在
        /// </summary>
        public bool Exists(Plan_Beginwork_Flow _Plan_Beginwork_Flow)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(*) from TAB_Plan_Beginwork_Flow where nID=@nID");
            SqlParameter[] parameters =
            {
                new SqlParameter("nID", _Plan_Beginwork_Flow.nID)
            };

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters)) > 0);
        }
 /// <summary>
 /// 读取DataRow数据到Model中
 /// </summary>
 private void DataRowToModel(Plan_Beginwork_Flow model, DataRow dr)
 {
     model.nID = ObjectConvertClass.static_ext_int(dr["nID"]);
     model.strTrainPlanGUID = ObjectConvertClass.static_ext_string(dr["strTrainPlanGUID"]);
     model.strUserName      = ObjectConvertClass.static_ext_string(dr["strUserName"]);
     model.strUserNumber    = ObjectConvertClass.static_ext_string(dr["strUserNumber"]);
     model.dtConfirmTime    = ObjectConvertClass.static_ext_date(dr["dtConfirmTime"]);
     model.nConfirmType     = ObjectConvertClass.static_ext_int(dr["nConfirmType"]);
     model.strConfirmBrief  = ObjectConvertClass.static_ext_string(dr["strConfirmBrief"]);
     model.nFlowState       = ObjectConvertClass.static_ext_int(dr["nFlowState"]);
     model.dtCreateTime     = ObjectConvertClass.static_ext_date(dr["dtCreateTime"]);
     model.dtBeginTime      = ObjectConvertClass.static_ext_date(dr["dtBeginTime"]);
     model.dtEndTime        = ObjectConvertClass.static_ext_date(dr["dtEndTime"]);
     model.nExecLength      = ObjectConvertClass.static_ext_int(dr["nExecLength"]);
 }
        /// <summary>
        /// 获得一个实体对象
        /// </summary>
        public Plan_Beginwork_Flow GetModel(Plan_Beginwork_FlowQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

            QueryCondition.OutPut(out strSqlOption, out sqlParams);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * ");
            strSql.Append(" FROM TAB_Plan_Beginwork_Flow where 1=1 " + strSqlOption.ToString());
            DataTable           dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0];
            Plan_Beginwork_Flow _Plan_Beginwork_Flow = null;

            if (dt.Rows.Count > 0)
            {
                _Plan_Beginwork_Flow = new Plan_Beginwork_Flow();
                DataRowToModel(_Plan_Beginwork_Flow, dt.Rows[0]);
            }
            return(_Plan_Beginwork_Flow);
        }