Пример #1
0
        private static IncomingFormEntity Get(string id, Database db, DbTransaction trans)
        {
            var sql = string.Format("select {0} from incoming_form {1} where id=@p_id", COLUMN_SQL, TransHelper.UpdateLock(trans));

            if (db == null)
            {
                db = DatabaseFactory.CreateDatabase();
            }

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_id", DbType.String, id);

            IncomingFormEntity entity = null;

            using (var reader = (trans == null ? db.ExecuteReader(dc) : db.ExecuteReader(dc, trans)))
            {
                while (reader.Read())
                {
                    entity = new IncomingFormEntity();
                    entity.Init(reader);

                    break;
                }
            }

            return(entity);
        }
Пример #2
0
        private static bool Exist(string productId, string hospitalId, Database db, DbTransaction trans)
        {
            var sql = string.Format("select count(*) from goods_inventory {0} where product_id=@p_product_id and hospital_id=@p_hospital_id", TransHelper.UpdateLock(trans));

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_product_id", DbType.String, productId);
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);

            using (var reader = db.ExecuteReader(dc, trans))
            {
                reader.Read();

                return(reader.GetInt32(0) > 0);
            }
        }
Пример #3
0
        public static int CountValid(string futureFormId, FormType futureFormType, Database db, DbTransaction trans)
        {
            var sql = string.Format(@"select count(id) from goods_state {0} where future_form_id=@p_future_form_id and future_form_type=@p_future_form_type and future_valid=1", TransHelper.UpdateLock(trans));

            if (db == null)
            {
                db = DatabaseFactory.CreateDatabase();
            }

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_future_form_id", DbType.String, futureFormId);
            db.AddInParameter(dc, "p_future_form_type", DbType.Int32, (int)futureFormType);

            if (trans == null)
            {
                using (var reader = db.ExecuteReader(dc))
                {
                    reader.Read();

                    return((int)reader.GetValue(0));
                }
            }
            else
            {
                using (var reader = db.ExecuteReader(dc, trans))
                {
                    reader.Read();

                    return((int)reader.GetValue(0));
                }
            }
        }
Пример #4
0
        public static IList <GoodsInventoryEntity> Get(IList <string> productIds, string hospitalId, Database db, DbTransaction trans)
        {
            var sql = string.Format("select {0} from goods_inventory {2} where product_id in ('{1}') and hospital_id=@p_hospital_id", COLUMN_SQL, string.Join("','", productIds), TransHelper.UpdateLock(trans));

            if (db == null)
            {
                db = DatabaseFactory.CreateDatabase();
            }
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);

            var list   = new List <GoodsInventoryEntity>();
            var reader = trans == null?db.ExecuteReader(dc) : db.ExecuteReader(dc, trans);

            try
            {
                while (reader.Read())
                {
                    var entity = new GoodsInventoryEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }
            finally
            {
                reader.Close();
            }

            return(list);
        }