Example #1
0
        internal static IList <GoodsRuntimeEntity> FindRuntimes(string applyId, string productId)
        {
            var sql = @"select id,hospital_id,apply_id,serial_id,barcode,count,product_id from goods_runtime where apply_id=@p_apply_id and product_id=@p_product_id";

            var db  = DatabaseFactory.CreateDatabase();
            var cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "p_apply_id", DbType.String, applyId);
            db.AddInParameter(cmd, "p_product_id", DbType.String, productId);

            var list = new List <GoodsRuntimeEntity>();

            using (var reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    var entity = new GoodsRuntimeEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }

            return(list);
        }
Example #2
0
        internal static void CreateRuntime(GoodsRuntimeEntity entity, Database db, DbTransaction trans)
        {
            var sql = @"insert into goods_runtime(id,hospital_id,apply_id,serial_id,barcode,count,product_id)
values(@p_id,@p_hospital_id,@p_apply_id,@p_serial_id,@p_barcode,@p_count,@p_product_id)";

            var cmd = db.GetSqlStringCommand(sql);

            entity.Id = Guid.NewGuid().ToString();

            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_serial_id", DbType.String, entity.SerialId);
            db.AddInParameter(cmd, "p_barcode", DbType.String, entity.Barcode);
            db.AddInParameter(cmd, "p_count", DbType.String, entity.Count);
            db.AddInParameter(cmd, "p_product_id", DbType.String, entity.ProductId);

            db.ExecuteNonQuery(cmd, trans);
        }
Example #3
0
        public static GoodsRuntimeEntity GetRuntime(string barcode, string hospitalId)
        {
            var sql = @"select id,hospital_id,apply_id,serial_id,barcode,count,product_id from goods_runtime where barcode=@p_barcode and hospital_id=@p_hospital_id";

            var db  = DatabaseFactory.CreateDatabase();
            var cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "p_barcode", DbType.String, barcode);
            db.AddInParameter(cmd, "p_hospital_id", DbType.String, hospitalId);

            using (var reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    var entity = new GoodsRuntimeEntity();
                    entity.Init(reader);

                    return(entity);
                }
            }

            return(null);
        }
Example #4
0
        public static GoodsRuntimeEntity SaveRuntime(GoodsRuntimeEntity entity, Database db, DbTransaction dbTrans)
        {
            var sql = string.Empty;

            if (string.IsNullOrEmpty(entity.Id))
            {
                sql = @"insert into goods_runtime(id,hospital_id,apply_id,serial_id,barcode,count,product_id)
values(@p_id,@p_hospital_id,@p_apply_id,@p_serial_id,@p_barcode,@p_count,@p_product_id)";

                entity.Id = Guid.NewGuid().ToString();
            }
            else
            {
                sql = @"update goods_runtime set
hospital_id=@p_hospital_id
,apply_id=@p_apply_id
,serial_id=@p_serial_id
,barcode=@p_barcode
,count=@p_count
,product_id=@p_product_id
where id=@p_id";
            }

            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_serial_id", DbType.String, entity.SerialId);
            db.AddInParameter(cmd, "p_barcode", DbType.String, entity.Barcode);
            db.AddInParameter(cmd, "p_count", DbType.Int32, entity.Count);
            db.AddInParameter(cmd, "p_product_id", DbType.String, entity.ProductId);

            db.ExecuteNonQuery(cmd, dbTrans);

            return(entity);
        }