public static GoodsSerialEntity GetByBarcode(string barcode)
        {
            var sql = @"select 
	a.id,a.serial_no,a.parent_id,a.product_id,a.dispatched_count,a.hospital_id,a.vendor_id,a.need_audit,a.need_check,a.need_split,
    a.split_copies,a.split_unit,a.valid_days,a.batch_no,a.expired_date,a.split_capacity,a.split_package_count,
	a.logistics_code,a.logistics_content,a.is_closed,a.created_id,a.created_time,a.updated_id,a.updated_time 
from goods_serial a join goods_serial_barcodes b on a.id=b.serial_id and b.out=@p_out where b.barcode=@p_barcode";

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

            db.AddInParameter(cmd, "p_barcode", DbType.String, barcode);
            db.AddInParameter(cmd, "p_out", DbType.Boolean, false);

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

                    return(entity);
                }

                return(null);
            }
        }
        public static GoodsSerialEntity Get(string serialId, Database db, DbTransaction trans)
        {
            var sql = string.Format("select {0} from goods_serial where id=@p_id", COLUMNS);

            var cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "p_id", DbType.String, serialId);

            using (var reader = db.ExecuteReader(cmd, trans))
            {
                if (reader.Read())
                {
                    var entity = new GoodsSerialEntity();
                    entity.Init(reader);

                    return(entity);
                }
            }

            return(null);
        }
        public static IList <GoodsSerialEntity> GetSplitSerials(IList <string> serialIds)
        {
            var list = new List <GoodsSerialEntity>();

            if (serialIds == null || serialIds.Count == 0)
            {
                return(list);
            }

            IList <string> names;
            string         namesSql;

            StringHelper.GenerInParameters("p_id", serialIds.Count, out names, out namesSql);

            var sql = string.Format("select {0} from goods_serial where id in ({1}) and need_split=@p_need_split", COLUMNS, namesSql);

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

            db.AddInParameter(cmd, "p_need_split", DbType.Boolean, true);
            for (var i = 0; i < serialIds.Count; i++)
            {
                db.AddInParameter(cmd, names[i], DbType.String, serialIds[i]);
            }

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

                    list.Add(entity);
                }
            }

            return(list);
        }
        private static IList <GoodsSerialEntity> GetSubSerials(string parentId)
        {
            var sql = string.Format("select {0} from goods_serial where parent_id=@p_parent_id", COLUMNS);

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

            db.AddInParameter(cmd, "p_parent_id", DbType.String, parentId);

            var list = new List <GoodsSerialEntity>();

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

                    list.Add(entity);
                }
            }

            return(list);
        }