/// <summary> /// 得到一个对象实体 /// </summary> public HTNResp.Model.SpecialPatientProcess DataRowToModel(DataRow row) { HTNResp.Model.SpecialPatientProcess model = new HTNResp.Model.SpecialPatientProcess(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["DecisionRule"] != null) { model.DecisionRule = row["DecisionRule"].ToString(); } if (row["SymptomName"] != null) { model.SymptomName = row["SymptomName"].ToString(); } if (row["Contents"] != null) { model.Contents = row["Contents"].ToString(); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["EvalGuidId"] != null && row["EvalGuidId"].ToString() != "") { model.EvalGuidId = int.Parse(row["EvalGuidId"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HTNResp.Model.SpecialPatientProcess model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SpecialPatientProcess("); strSql.Append("DecisionRule,SymptomName,Contents,Status,EvalGuidId)"); strSql.Append(" values ("); strSql.Append("@DecisionRule,@SymptomName,@Contents,@Status,@EvalGuidId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DecisionRule", SqlDbType.NVarChar, 255), new SqlParameter("@SymptomName", SqlDbType.NVarChar, 255), new SqlParameter("@Contents", SqlDbType.NVarChar, -1), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@EvalGuidId", SqlDbType.Int, 4) }; parameters[0].Value = model.DecisionRule; parameters[1].Value = model.SymptomName; parameters[2].Value = model.Contents; parameters[3].Value = model.Status; parameters[4].Value = model.EvalGuidId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(HTNResp.Model.SpecialPatientProcess model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SpecialPatientProcess set "); strSql.Append("DecisionRule=@DecisionRule,"); strSql.Append("SymptomName=@SymptomName,"); strSql.Append("Contents=@Contents,"); strSql.Append("Status=@Status,"); strSql.Append("EvalGuidId=@EvalGuidId"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@DecisionRule", SqlDbType.NVarChar, 255), new SqlParameter("@SymptomName", SqlDbType.NVarChar, 255), new SqlParameter("@Contents", SqlDbType.NVarChar, -1), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@EvalGuidId", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.DecisionRule; parameters[1].Value = model.SymptomName; parameters[2].Value = model.Contents; parameters[3].Value = model.Status; parameters[4].Value = model.EvalGuidId; parameters[5].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public HTNResp.Model.SpecialPatientProcess GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,DecisionRule,SymptomName,Contents,Status,EvalGuidId from SpecialPatientProcess "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; HTNResp.Model.SpecialPatientProcess model = new HTNResp.Model.SpecialPatientProcess(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }