/// <summary> /// 获得数据List /// </summary> public Plan_Beginwork_StepResultList GetDataList(string strTrainPlanGUID, int nWorkTypeID, string strWorkShopGUID) { StringBuilder strSql = new StringBuilder(); //strSql.Append("select * "); //strSql.Append(" FROM TAB_Plan_Beginwork_StepResult where 1=1 "); strSql.Append(" select a.strStepName,b.* from TAB_Plan_Beginwork_StepDef a left join TAB_Plan_Beginwork_StepResult b "); strSql.Append(" on b.strStepName=a.strStepID and b.strTrainPlanGUID='" + strTrainPlanGUID + "' and b.nWorkTypeID=" + nWorkTypeID + " "); strSql.Append(" where a.strWorkShopGUID='" + strWorkShopGUID + "' and a.nWorkTypeID=" + nWorkTypeID + ""); //if (!string.IsNullOrEmpty(strTrainPlanGUID)) // strSql.Append(" and strTrainPlanGUID='" + strTrainPlanGUID + "' "); DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString()).Tables[0]; Plan_Beginwork_StepResultList list = new Plan_Beginwork_StepResultList(); foreach (DataRow dr in dt.Rows) { Plan_Beginwork_StepResult _Plan_Beginwork_StepResult = new Plan_Beginwork_StepResult(); DataRowToModel(_Plan_Beginwork_StepResult, dr); list.Add(_Plan_Beginwork_StepResult); } return(list); }
/// <summary> /// 更新数据 /// </summary> public bool Update(Plan_Beginwork_StepResult model) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update TAB_Plan_Beginwork_StepResult set "); strSql.Append(" strTrainPlanGUID = @strTrainPlanGUID, "); strSql.Append(" strStepName = @strStepName, "); strSql.Append(" nStepResult = @nStepResult, "); strSql.Append(" dtBeginTime = @dtBeginTime, "); strSql.Append(" dtEndTime = @dtEndTime, "); strSql.Append(" strStepBrief = @strStepBrief, "); strSql.Append(" dtCreateTime = @dtCreateTime, "); strSql.Append(" nStepIndex = @nStepIndex "); strSql.Append(" where nID = @nID "); SqlParameter[] parameters = { new SqlParameter("@strTrainPlanGUID", model.strTrainPlanGUID), new SqlParameter("@strStepName", model.strStepName), new SqlParameter("@nStepResult", model.nStepResult), new SqlParameter("@dtBeginTime", model.dtBeginTime), new SqlParameter("@dtEndTime", model.dtEndTime), new SqlParameter("@strStepBrief", model.strStepBrief), new SqlParameter("@dtCreateTime", model.dtCreateTime), new SqlParameter("@nStepIndex", model.nStepIndex) }; return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 检查数据是否存在 /// </summary> public bool Exists(Plan_Beginwork_StepResult _Plan_Beginwork_StepResult) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) from TAB_Plan_Beginwork_StepResult where nID=@nID"); SqlParameter[] parameters = { new SqlParameter("nID", _Plan_Beginwork_StepResult.nID) }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters)) > 0); }
/// <summary> /// 读取DataRow数据到Model中 /// </summary> private void DataRowToModel(Plan_Beginwork_StepResult model, DataRow dr) { model.nID = ObjectConvertClass.static_ext_int(dr["nID"]); model.strTrainPlanGUID = ObjectConvertClass.static_ext_string(dr["strTrainPlanGUID"]); model.strStepName = ObjectConvertClass.static_ext_string(dr["strStepName"]); model.nStepResult = ObjectConvertClass.static_ext_int(dr["nStepResult"]); model.dtBeginTime = ObjectConvertClass.static_ext_date(dr["dtBeginTime"]); model.dtEndTime = ObjectConvertClass.static_ext_date(dr["dtEndTime"]); model.strStepBrief = ObjectConvertClass.static_ext_string(dr["strStepBrief"]); model.dtCreateTime = ObjectConvertClass.static_ext_date(dr["dtCreateTime"]); model.nStepIndex = ObjectConvertClass.static_ext_int(dr["nStepIndex"]); model.strTrainmanName = ObjectConvertClass.static_ext_string(dr["strTrainmanName"]); model.strTrainmanNumber = ObjectConvertClass.static_ext_string(dr["strTrainmanNumber"]); }
public List <Plan_Beginwork_StepResult> getStepResult(string strTrainPlanGUID, int nWorkTypeID) { string sql = "select * from TAB_Plan_Beginwork_StepResult where strTrainPlanGUID='" + strTrainPlanGUID + "' and nWorkTypeID='" + nWorkTypeID + "'"; DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql).Tables[0]; Plan_Beginwork_StepResultList list = new Plan_Beginwork_StepResultList(); foreach (DataRow dr in dt.Rows) { Plan_Beginwork_StepResult _Plan_Beginwork_StepResult = new Plan_Beginwork_StepResult(); DataRowToModel(_Plan_Beginwork_StepResult, dr); list.Add(_Plan_Beginwork_StepResult); } return(list); // return dt; }
/// <summary> /// 获得一个实体对象 /// </summary> public Plan_Beginwork_StepResult GetModel(Plan_Beginwork_StepResultQueryCondition 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_StepResult where 1=1 " + strSqlOption.ToString()); DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; Plan_Beginwork_StepResult _Plan_Beginwork_StepResult = null; if (dt.Rows.Count > 0) { _Plan_Beginwork_StepResult = new Plan_Beginwork_StepResult(); DataRowToModel(_Plan_Beginwork_StepResult, dt.Rows[0]); } return(_Plan_Beginwork_StepResult); }
/// <summary> /// 添加数据 /// </summary> public int Add(Plan_Beginwork_StepResult model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TAB_Plan_Beginwork_StepResult"); strSql.Append("(strTrainPlanGUID,strStepName,nStepResult,dtBeginTime,dtEndTime,strStepBrief,dtCreateTime,nStepIndex)"); strSql.Append("values(@strTrainPlanGUID,@strStepName,@nStepResult,@dtBeginTime,@dtEndTime,@strStepBrief,@dtCreateTime,@nStepIndex)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@strTrainPlanGUID", model.strTrainPlanGUID), new SqlParameter("@strStepName", model.strStepName), new SqlParameter("@nStepResult", model.nStepResult), new SqlParameter("@dtBeginTime", model.dtBeginTime), new SqlParameter("@dtEndTime", model.dtEndTime), new SqlParameter("@strStepBrief", model.strStepBrief), new SqlParameter("@dtCreateTime", model.dtCreateTime), new SqlParameter("@nStepIndex", model.nStepIndex) }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters))); }