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