internal static void CreateRuntime(GoodsInventoryRuntimeEntity entity, Database db, DbTransaction trans) { var sql = @"insert into goods_inventory_runtime(id,hospital_id,apply_id,product_id,apply_count,granted_count) values(@p_id,@p_hospital_id,@p_apply_id,@p_product_id,@p_apply_count,@p_granted_count)"; entity.Id = Guid.NewGuid().ToString(); var cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "p_id", DbType.String, entity.Id); db.AddInParameter(cmd, "p_hospital_id", DbType.String, entity.HospitalId); db.AddInParameter(cmd, "p_apply_id", DbType.String, entity.ApplyId); db.AddInParameter(cmd, "p_product_id", DbType.String, entity.ProductId); db.AddInParameter(cmd, "p_apply_count", DbType.Int32, entity.ApplyCount); db.AddInParameter(cmd, "p_granted_count", DbType.Int32, entity.GrantedCount); db.ExecuteNonQuery(cmd, trans); }
public static GoodsInventoryRuntimeEntity GetRuntime(string applyId, string hospitalId, string productId, Database db, DbTransaction dbTrans) { var sql = "select id,hospital_id,apply_id,product_id,apply_count,granted_count from goods_inventory_runtime where apply_id=@p_apply_id and hospital_id=@p_hospital_id and product_id=@p_product_id"; var cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "p_apply_id", DbType.String, applyId); db.AddInParameter(cmd, "p_hospital_id", DbType.String, hospitalId); db.AddInParameter(cmd, "p_product_id", DbType.String, productId); using (var reader = db.ExecuteReader(cmd, dbTrans)) { while (reader.Read()) { var entity = new GoodsInventoryRuntimeEntity(); entity.Init(reader); return(entity); } } return(null); }
public static IList <GoodsInventoryRuntimeEntity> GetRuntime(string applyId, string hospitalId) { var sql = "select id,hospital_id,apply_id,product_id,apply_count,granted_count from goods_inventory_runtime where apply_id=@p_apply_id and hospital_id=@p_hospital_id"; var list = new List <GoodsInventoryRuntimeEntity>(); var db = DatabaseFactory.CreateDatabase(); var cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "p_apply_id", DbType.String, applyId); db.AddInParameter(cmd, "p_hospital_id", DbType.String, hospitalId); using (var reader = db.ExecuteReader(cmd)) { while (reader.Read()) { var entity = new GoodsInventoryRuntimeEntity(); entity.Init(reader); list.Add(entity); } } return(list); }