/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProAttrItemModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.ProAttrItem set "); strSql.Append(" ProAttrItemId = @ProAttrItemId , "); strSql.Append(" ProAttrId = @ProAttrId , "); strSql.Append(" BgIntKey = @BgIntKey , "); strSql.Append(" EndIntKey = @EndIntKey , "); strSql.Append(" StrKey = @StrKey , "); strSql.Append(" OrderNo = @OrderNo "); strSql.Append(" where ProAttrItemId=@ProAttrItemId "); SqlParameter[] parameters = { new SqlParameter("@ProAttrItemId", SqlDbType.Decimal, 9), new SqlParameter("@ProAttrId", SqlDbType.NChar, 10), new SqlParameter("@BgIntKey", SqlDbType.Decimal, 9), new SqlParameter("@EndIntKey", SqlDbType.Decimal, 9), new SqlParameter("@StrKey", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.ProAttrItemId; parameters[1].Value = model.ProAttrId; parameters[2].Value = model.BgIntKey; parameters[3].Value = model.EndIntKey; parameters[4].Value = model.StrKey; parameters[5].Value = model.OrderNo; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 得到一个对象实体 /// </summary> public ProAttrItemModel GetModel(decimal ProAttrItemId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ProAttrItemId, ProAttrId, BgIntKey, EndIntKey, StrKey, OrderNo "); strSql.Append(" from CORE.dbo.ProAttrItem "); strSql.Append(" where ProAttrItemId=@ProAttrItemId "); SqlParameter[] parameters = { new SqlParameter("@ProAttrItemId", SqlDbType.Decimal, 9) }; parameters[0].Value = ProAttrItemId; ProAttrItemModel model = new ProAttrItemModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ProAttrItemId"].ToString() != "") { model.ProAttrItemId = decimal.Parse(ds.Tables[0].Rows[0]["ProAttrItemId"].ToString()); } model.ProAttrId = ds.Tables[0].Rows[0]["ProAttrId"].ToString(); if (ds.Tables[0].Rows[0]["BgIntKey"].ToString() != "") { model.BgIntKey = decimal.Parse(ds.Tables[0].Rows[0]["BgIntKey"].ToString()); } if (ds.Tables[0].Rows[0]["EndIntKey"].ToString() != "") { model.EndIntKey = decimal.Parse(ds.Tables[0].Rows[0]["EndIntKey"].ToString()); } model.StrKey = ds.Tables[0].Rows[0]["StrKey"].ToString(); if (ds.Tables[0].Rows[0]["OrderNo"].ToString() != "") { model.OrderNo = int.Parse(ds.Tables[0].Rows[0]["OrderNo"].ToString()); } return(model); } else { return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ProAttrItemModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.ProAttrItem ("); strSql.Append("ProAttrItemId,ProAttrId,BgIntKey,EndIntKey,StrKey,OrderNo"); strSql.Append(") values ("); strSql.Append("@ProAttrItemId,@ProAttrId,@BgIntKey,@EndIntKey,@StrKey,@OrderNo"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@ProAttrItemId", SqlDbType.Decimal, 9), new SqlParameter("@ProAttrId", SqlDbType.NChar, 10), new SqlParameter("@BgIntKey", SqlDbType.Decimal, 9), new SqlParameter("@EndIntKey", SqlDbType.Decimal, 9), new SqlParameter("@StrKey", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.ProAttrItemId; parameters[1].Value = model.ProAttrId; parameters[2].Value = model.BgIntKey; parameters[3].Value = model.EndIntKey; parameters[4].Value = model.StrKey; parameters[5].Value = model.OrderNo; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }