/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreDomain model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreDomain set "); strSql.Append(" Name = @Name , "); strSql.Append(" Remark = @Remark "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.Remark; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.StoreDomain GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Name, Remark "); strSql.Append(" from StoreDomain "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DTcms.Model.StoreDomain model = new DTcms.Model.StoreDomain(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DTcms.Model.StoreDomain model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreDomain("); strSql.Append("Name,Remark"); strSql.Append(") values ("); strSql.Append("@Name,@Remark"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Name; parameters[1].Value = model.Remark; return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0); }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.StoreDomain GetModel(int Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select Id, Name, Remark "); strSql.Append(" from StoreDomain "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; DTcms.Model.StoreDomain model=new DTcms.Model.StoreDomain(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["Id"].ToString()!="") { model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name= ds.Tables[0].Rows[0]["Name"].ToString(); model.Remark= ds.Tables[0].Rows[0]["Remark"].ToString(); return model; } else { return null; } }