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