/// <summary> /// 更新一条数据 /// </summary> public bool Update(HTNResp.Model.DiagnoseList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DiagnoseList set "); strSql.Append("DecisionRule=@DecisionRule,"); strSql.Append("Name=@Name,"); strSql.Append("Sex=@Sex,"); strSql.Append("Description=@Description,"); strSql.Append("Status=@Status,"); strSql.Append("EvalGuidId=@EvalGuidId"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@DecisionRule", SqlDbType.NVarChar, -1), new SqlParameter("@Name", SqlDbType.NVarChar, 255), new SqlParameter("@Sex", SqlDbType.NVarChar, 255), new SqlParameter("@Description", SqlDbType.NVarChar, 255), 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.Name; parameters[2].Value = model.Sex; parameters[3].Value = model.Description; 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.DiagnoseList DataRowToModel(DataRow row) { HTNResp.Model.DiagnoseList model = new HTNResp.Model.DiagnoseList(); 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["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Sex"] != null) { model.Sex = row["Sex"].ToString(); } if (row["Description"] != null) { model.Description = row["Description"].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.DiagnoseList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DiagnoseList("); strSql.Append("DecisionRule,Name,Sex,Description,Status,EvalGuidId)"); strSql.Append(" values ("); strSql.Append("@DecisionRule,@Name,@Sex,@Description,@Status,@EvalGuidId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DecisionRule", SqlDbType.NVarChar, -1), new SqlParameter("@Name", SqlDbType.NVarChar, 255), new SqlParameter("@Sex", SqlDbType.NVarChar, 255), new SqlParameter("@Description", SqlDbType.NVarChar, 255), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@EvalGuidId", SqlDbType.Int, 4) }; parameters[0].Value = model.DecisionRule; parameters[1].Value = model.Name; parameters[2].Value = model.Sex; parameters[3].Value = model.Description; 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.DiagnoseList GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,DecisionRule,Name,Sex,Description,Status,EvalGuidId from DiagnoseList "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; HTNResp.Model.DiagnoseList model = new HTNResp.Model.DiagnoseList(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }