Exemplo n.º 1
0
        public static GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string vendorId, string hospitalId)
        {
            var sql = string.Format(@"select {0} from goods_flow 
where 1=1 and barcode=@p_barcode {1}", COLUMN_SQL, GetValidTypeSql(validType));

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

            if (validType == GoodsFlowValidType.Dispatch)
            {
                db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId);
            }
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);
            db.AddInParameter(dc, "p_barcode", DbType.String, barcode);

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

                    return(entity);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public static IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string vendorId, string hospitalId)
        {
            var sql = string.Format(@"select top 30 {0} from goods_flow 
where 1=1 {1} order by barcode", COLUMN_SQL, GetFormNoSql(validType, true));

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

            db.AddInParameter(dc, "p_form_no", DbType.Int32, formNo);
            if (validType == GoodsFlowValidType.Dispatch)
            {
                db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId);
            }
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);
            AddValidValue(db, dc, validType, isValid);

            var list = new List <GoodsFlowEntity>();

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

                    list.Add(entity);
                }
            }

            return(list);
        }
Exemplo n.º 3
0
        private static string GetSumWhere(GoodsFlowValidType validType)
        {
            string sql;

            switch (validType)
            {
            case GoodsFlowValidType.Incoming:
                sql = " and incoming_valid=1 and incoming_form=@p_form";
                break;

            case GoodsFlowValidType.Inspection:
                sql = " and inspection_valid=1 and inspection_form=@p_form";
                break;

            case GoodsFlowValidType.Receive:
                sql = " and receive_valid=1 and receive_form=@p_form";
                break;

            default:
                sql = " and dispatch_valid=1 and dispatch_form=@p_form";
                break;
            }

            return(sql);
        }
Exemplo n.º 4
0
        public static void BatchCancelValid(GoodsFlowValidType validType, string formId, string userId)
        {
            var sql = string.Format("update goods_flow set {0} where 1=1 {1}", GetUpdateValidSql(validType), GetFormIdWhere(validType));
            var db  = DatabaseFactory.CreateDatabase();
            var dc  = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_is_valid", DbType.Boolean, false);
            db.AddInParameter(dc, "p_user", DbType.String, userId);
            db.AddInParameter(dc, "p_datetime", DbType.DateTime, DateTime.Now);
            db.AddInParameter(dc, "p_form_id", DbType.String, formId);

            db.ExecuteNonQuery(dc);
        }
Exemplo n.º 5
0
        private static string GetUpdateValidSql(GoodsFlowValidType validType)
        {
            var sql = string.Empty;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                sql = "receive_valid=@p_is_valid, receive_user=@p_user, receive_time=@p_datetime";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                sql = "dispatch_valid=@p_is_valid, dispatch_user=@p_user, dispatch_time=@p_datetime";
                break;
            }

            return(sql);
        }
Exemplo n.º 6
0
        private static string GetFormIdWhere(GoodsFlowValidType validType)
        {
            var sql = string.Empty;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                sql = " and receive_form = @p_form_id";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                sql = " and dispatch_form = @p_form_id";
                break;
            }

            return(sql);
        }
Exemplo n.º 7
0
        private static string GetValidTypeSql(GoodsFlowValidType validType)
        {
            var sql = string.Empty;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                sql = " and dispatch_valid=1 and receive_form in (select id from receive_form where hospital_id=@p_hospital_id and scan_over=0)";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                sql = " and dispatch_form in (select id from dispatch_form where vendor_id=@p_vendor_id and hospital_id=@p_hospital_id and scan_over=0)";
                break;
            }

            return(sql);
        }
Exemplo n.º 8
0
        private static void AddValidValue(Database db, DbCommand dc, GoodsFlowValidType validType, bool isValid)
        {
            string name;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                name = "p_receive_valid";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                name = "p_dispatch_valid";
                break;
            }

            db.AddInParameter(dc, name, DbType.Boolean, isValid);
        }
Exemplo n.º 9
0
        private static string GetValidColumn(GoodsFlowValidType validType)
        {
            var name = string.Empty;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                name = "receive_valid";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                name = "dispatch_valid";
                break;
            }

            return(name);
        }
Exemplo n.º 10
0
        public static void Valid(GoodsFlowValidType validType, string barcode, string userId, string vendorId, string hospitalId)
        {
            var sql = string.Format("update goods_flow set {0} where barcode=@p_barcode {1}",
                                    GetUpdateValidSql(validType), GetValidTypeSql(validType));
            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_barcode", DbType.String, barcode);
            db.AddInParameter(dc, "p_is_valid", DbType.Boolean, true);
            db.AddInParameter(dc, "p_user", DbType.String, userId);
            db.AddInParameter(dc, "p_datetime", DbType.DateTime, DateTime.Now);
            if (validType == GoodsFlowValidType.Dispatch)
            {
                db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId);
            }
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);

            db.ExecuteNonQuery(dc);
        }
Exemplo n.º 11
0
        private static string GetFormNoSql(GoodsFlowValidType validType, bool includeFormNo)
        {
            var sql = string.Empty;

            switch (validType)
            {
            case GoodsFlowValidType.Receive:
                sql = " and dispatch_valid=1 and receive_valid=@p_receive_valid and receive_form in (select id from receive_form where 1=1 {0} and hospital_id=@p_hospital_id and scan_over=0)";
                break;

            case GoodsFlowValidType.Dispatch:
            default:
                sql = " and dispatch_valid=@p_dispatch_valid and dispatch_form in (select id from dispatch_form where 1=1 {0} and vendor_id=@p_vendor_id and hospital_id=@p_hospital_id and scan_over=0)";
                break;
            }

            sql = string.Format(sql, includeFormNo ? " and order_form_no = @p_form_no " : "");

            return(sql);
        }
Exemplo n.º 12
0
        public static int SumValid(GoodsFlowValidType validType, string validFormId)
        {
            var sql = "select count(*) from goods_flow where 1=1 " + GetSumWhere(validType);
            var db  = DatabaseFactory.CreateDatabase();
            var dc  = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_form", DbType.String, validFormId);

            int count = 0;

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    count = Convert.ToInt32(reader[0]);
                    break;
                }
            }

            return(count);
        }
Exemplo n.º 13
0
 public void BatchCancelValid(GoodsFlowValidType validType, string id, string userId)
 {
     GoodsFlowRepository.BatchCancelValid(validType, id, userId);
 }
Exemplo n.º 14
0
 public GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string vendorId, string hospitalId)
 {
     return(GoodsFlowRepository.GetByBarcode(validType, barcode, vendorId, hospitalId));
 }
Exemplo n.º 15
0
 public GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string hospitalId)
 {
     return(this.GetByBarcode(validType, barcode, null, hospitalId));
 }
Exemplo n.º 16
0
 public int SumValid(GoodsFlowValidType validType, string formId)
 {
     return(GoodsFlowRepository.SumValid(validType, formId));
 }
Exemplo n.º 17
0
 public void Valid(GoodsFlowValidType validType, string barcode, string userId, string vendorId, string hospitalId)
 {
     GoodsFlowRepository.Valid(validType, barcode, userId, vendorId, hospitalId);
 }
Exemplo n.º 18
0
 public void CancelValid(GoodsFlowValidType validType, string barcode, string userId, string hospitalId)
 {
     this.CancelValid(validType, barcode, userId, null, hospitalId);
 }
Exemplo n.º 19
0
 public IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string vendorId, string hospitalId)
 {
     return(GoodsFlowRepository.QueryWaitingValid(validType, formNo, isValid, vendorId, hospitalId));
 }
Exemplo n.º 20
0
 public IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string hospitalId)
 {
     return(this.QueryWaitingValid(validType, formNo, isValid, "", hospitalId));
 }