/// <summary>
        /// 更新数据
        /// </summary>
        public bool Update(Plan_Beginwork_StepIndex model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Update TAB_Plan_Beginwork_StepIndex set ");
            strSql.Append(" strTrainPlanGUID = @strTrainPlanGUID, ");
            strSql.Append(" strTrainmanNumber = @strTrainmanNumber, ");
            strSql.Append(" dtStartTime = @dtStartTime, ");
            strSql.Append(" strFieldName = @strFieldName, ");
            strSql.Append(" nStepData = @nStepData, ");
            strSql.Append(" dtStepData = @dtStepData, ");
            strSql.Append(" strStepData = @strStepData ");
            strSql.Append(" where nID = @nID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@strTrainPlanGUID",  model.strTrainPlanGUID),
                new SqlParameter("@strTrainmanNumber", model.strTrainmanNumber),
                new SqlParameter("@dtStartTime",       model.dtStartTime),
                new SqlParameter("@strFieldName",      model.strFieldName),
                new SqlParameter("@nStepData",         model.nStepData),
                new SqlParameter("@dtStepData",        model.dtStepData),
                new SqlParameter("@strStepData",       model.strStepData)
            };

            return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters) > 0);
        }
        /// <summary>
        /// 获得数据List
        /// </summary>
        public Plan_Beginwork_StepIndexList GetDataList(Plan_Beginwork_StepIndexQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

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

            if (QueryCondition.page == 0)
            {
                strSql.Append("select * ");
                strSql.Append(" FROM TAB_Plan_Beginwork_StepIndex where 1=1 " + strSqlOption.ToString());
            }
            else
            {
                strSql.Append(@"select top " + QueryCondition.rows.ToString() + " * from TAB_Plan_Beginwork_StepIndex where 1 = 1 " +
                              strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows +
                              " nID from TAB_Plan_Beginwork_StepIndex where  1=1 " + strSqlOption.ToString() + " order by nID desc) order by nID desc");
            }
            DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0];
            Plan_Beginwork_StepIndexList list = new Plan_Beginwork_StepIndexList();

            foreach (DataRow dr in dt.Rows)
            {
                Plan_Beginwork_StepIndex _Plan_Beginwork_StepIndex = new Plan_Beginwork_StepIndex();
                DataRowToModel(_Plan_Beginwork_StepIndex, dr);
                list.Add(_Plan_Beginwork_StepIndex);
            }
            return(list);
        }
 /// <summary>
 /// 读取DataRow数据到Model中
 /// </summary>
 private void DataRowToModel(Plan_Beginwork_StepIndex model, DataRow dr)
 {
     model.nID = ObjectConvertClass.static_ext_int(dr["nID"]);
     model.strTrainPlanGUID  = ObjectConvertClass.static_ext_string(dr["strTrainPlanGUID"]);
     model.strTrainmanNumber = ObjectConvertClass.static_ext_string(dr["strTrainmanNumber"]);
     model.dtStartTime       = ObjectConvertClass.static_ext_date(dr["dtStartTime"]);
     model.strFieldName      = ObjectConvertClass.static_ext_string(dr["strFieldName"]);
     model.nStepData         = ObjectConvertClass.static_ext_int(dr["nStepData"]);
     model.dtStepData        = ObjectConvertClass.static_ext_date(dr["dtStepData"]);
     model.strStepData       = ObjectConvertClass.static_ext_string(dr["strStepData"]);
 }
        /// <summary>
        /// 检查数据是否存在
        /// </summary>
        public bool Exists(Plan_Beginwork_StepIndex _Plan_Beginwork_StepIndex)
        {
            StringBuilder strSql = new StringBuilder();

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

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters)) > 0);
        }
        /// <summary>
        /// 获得一个实体对象
        /// </summary>
        public Plan_Beginwork_StepIndex GetModel(Plan_Beginwork_StepIndexQueryCondition 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_StepIndex where 1=1 " + strSqlOption.ToString());
            DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0];
            Plan_Beginwork_StepIndex _Plan_Beginwork_StepIndex = null;

            if (dt.Rows.Count > 0)
            {
                _Plan_Beginwork_StepIndex = new Plan_Beginwork_StepIndex();
                DataRowToModel(_Plan_Beginwork_StepIndex, dt.Rows[0]);
            }
            return(_Plan_Beginwork_StepIndex);
        }
        /// <summary>
        /// 添加数据
        /// </summary>
        public int Add(Plan_Beginwork_StepIndex model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TAB_Plan_Beginwork_StepIndex");
            strSql.Append("(strTrainPlanGUID,strTrainmanNumber,dtStartTime,strFieldName,nStepData,dtStepData,strStepData)");
            strSql.Append("values(@strTrainPlanGUID,@strTrainmanNumber,@dtStartTime,@strFieldName,@nStepData,@dtStepData,@strStepData)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strTrainPlanGUID",  model.strTrainPlanGUID),
                new SqlParameter("@strTrainmanNumber", model.strTrainmanNumber),
                new SqlParameter("@dtStartTime",       model.dtStartTime),
                new SqlParameter("@strFieldName",      model.strFieldName),
                new SqlParameter("@nStepData",         model.nStepData),
                new SqlParameter("@dtStepData",        model.dtStepData),
                new SqlParameter("@strStepData",       model.strStepData)
            };

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters)));
        }