/// <summary> /// 更新一条数据 /// </summary> public bool Update(ReceiptDetailModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update ReceiptDetail set "); strSql.Append(" ReceiptDetailId = @ReceiptDetailId , "); strSql.Append(" ReceiptId = @ReceiptId , "); strSql.Append(" Quatity = @Quatity , "); strSql.Append(" ReceiptMemo = @ReceiptMemo , "); strSql.Append(" StockId = @StockId "); strSql.Append(" where ReceiptDetailId=@ReceiptDetailId "); SqlParameter[] parameters = { new SqlParameter("@ReceiptDetailId", SqlDbType.VarChar, 60), new SqlParameter("@ReceiptId", SqlDbType.VarChar, 50), new SqlParameter("@Quatity", SqlDbType.Decimal, 9), new SqlParameter("@ReceiptMemo", SqlDbType.VarChar, 500), new SqlParameter("@StockId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.ReceiptDetailId; parameters[1].Value = model.ReceiptId; parameters[2].Value = model.Quatity; parameters[3].Value = model.ReceiptMemo; parameters[4].Value = model.StockId; 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(ReceiptDetailModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ReceiptDetail("); strSql.Append("ReceiptDetailId,ReceiptId,Quatity,ReceiptMemo,StockId"); strSql.Append(") values ("); strSql.Append("@ReceiptDetailId,@ReceiptId,@Quatity,@ReceiptMemo,@StockId"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@ReceiptDetailId", SqlDbType.VarChar, 60), new SqlParameter("@ReceiptId", SqlDbType.VarChar, 50), new SqlParameter("@Quatity", SqlDbType.Decimal, 9), new SqlParameter("@ReceiptMemo", SqlDbType.VarChar, 500), new SqlParameter("@StockId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.ReceiptDetailId; parameters[1].Value = model.ReceiptId; parameters[2].Value = model.Quatity; parameters[3].Value = model.ReceiptMemo; parameters[4].Value = model.StockId; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }