/// <summary> /// 得到一个对象实体 /// </summary> public ProClassVsPinPaiModel GetModel(decimal ProClassId, decimal PinPaiId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ProClassId, PinPaiId, OrderNo, VsType "); strSql.Append(" from CORE.dbo.ProClassVsPinPai "); strSql.Append(" where ProClassId=@ProClassId and PinPaiId=@PinPaiId "); SqlParameter[] parameters = { new SqlParameter("@ProClassId", SqlDbType.Decimal, 9), new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9) }; parameters[0].Value = ProClassId; parameters[1].Value = PinPaiId; ProClassVsPinPaiModel model = new ProClassVsPinPaiModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ProClassId"].ToString() != "") { model.ProClassId = decimal.Parse(ds.Tables[0].Rows[0]["ProClassId"].ToString()); } if (ds.Tables[0].Rows[0]["PinPaiId"].ToString() != "") { model.PinPaiId = decimal.Parse(ds.Tables[0].Rows[0]["PinPaiId"].ToString()); } if (ds.Tables[0].Rows[0]["OrderNo"].ToString() != "") { model.OrderNo = int.Parse(ds.Tables[0].Rows[0]["OrderNo"].ToString()); } model.VsType = ds.Tables[0].Rows[0]["VsType"].ToString(); return(model); } else { return(model); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProClassVsPinPaiModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.ProClassVsPinPai set "); strSql.Append(" ProClassId = @ProClassId , "); strSql.Append(" PinPaiId = @PinPaiId , "); strSql.Append(" OrderNo = @OrderNo , "); strSql.Append(" VsType = @VsType "); strSql.Append(" where ProClassId=@ProClassId and PinPaiId=@PinPaiId "); SqlParameter[] parameters = { new SqlParameter("@ProClassId", SqlDbType.Decimal, 9), new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@OrderNo", SqlDbType.Int, 4), new SqlParameter("@VsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.ProClassId; parameters[1].Value = model.PinPaiId; parameters[2].Value = model.OrderNo; parameters[3].Value = model.VsType; 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 bool Add(ProClassVsPinPaiModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.ProClassVsPinPai ("); strSql.Append("ProClassId,PinPaiId,OrderNo,VsType"); strSql.Append(") values ("); strSql.Append("@ProClassId,@PinPaiId,@OrderNo,@VsType"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@ProClassId", SqlDbType.Decimal, 9), new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@OrderNo", SqlDbType.Int, 4), new SqlParameter("@VsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.ProClassId; parameters[1].Value = model.PinPaiId; parameters[2].Value = model.OrderNo; parameters[3].Value = model.VsType; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }