Пример #1
0
        private static bool ValidateReturn(GoodsStateEntity current, string hospitalId, string vendorId, out string errorCode)
        {
            errorCode = string.Empty;
            var orderForm = OrderFormRepository.Get(current.OrderFormId);

            if (string.Compare(orderForm.HospitalId, hospitalId, false) != 0)
            {
                errorCode = GoodsStateValidateCodes.HospitalNoFutureForm;
                return(false);
            }

            if (!string.IsNullOrEmpty(current.FormId) &&
                (current.FormType == FormType.Dispatch ||
                 current.FormType == FormType.Receive ||
                 current.FormType == FormType.Inspection ||
                 current.FormType == FormType.Incoming))
            {
                return(true);
            }

            if (string.Compare(orderForm.VendorId, vendorId, true) != 0)
            {
                errorCode = GoodsStateValidateCodes.VendorNoFutureForm;
                return(false);
            }

            errorCode = GoodsStateValidateCodes.NotValidState;
            return(false);
        }
Пример #2
0
        private static void UpdateOrderStatus(string orderItemId, bool needAudit, Database db, DbTransaction trans)
        {
            var sql = "select sum(inspection_count) from inspection_form where order_detail_id=@p_order_detail_id";
            var dc  = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_order_detail_id", DbType.String, orderItemId);

            var count = 0;

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

                count = Convert.ToInt32(reader[0]);
            }

            var detailEntity = OrderFormRepository.GetItem(orderItemId);

            if (detailEntity != null && detailEntity.Count == count)
            {
                if (needAudit)
                {
                    OrderFormRepository.UpdateItemStatus(orderItemId, OrderFormItemStatus.Auditing, db, trans);
                }
                else
                {
                    OrderFormRepository.UpdateItemStatus(orderItemId, OrderFormItemStatus.Dispatching, db, trans);
                }
            }
        }
Пример #3
0
        public static void Confirm(string id, string userId)
        {
            var db = DatabaseFactory.CreateDatabase();

            using (var conn = db.CreateConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        var entity = Get(id, db, trans);
                        if (entity == null)
                        {
                            throw new Exception("The inspection form does not exist.");
                        }

                        var scanCount = GoodsStateRepository.CountValid(id, FormType.Inspection, db, trans);

                        UpdateConfirmStatus(id, scanCount, userId, db, trans);

                        var needAudit = OrderFormRepository.GetItem(entity.OrderDetailId).NeedAudit;

                        string   formId;
                        FormType formType;
                        if (needAudit)
                        {
                            formId   = CreateInspectionAudit();
                            formType = FormType.InspectionAudit;
                        }
                        else
                        {
                            formId   = SaveIncomingForm(entity, scanCount, userId, db, trans);
                            formType = FormType.Incoming;
                        }

                        GoodsStateRepository.ChangeState(id, FormType.Inspection, formId, formType, userId, db, trans);

                        //UpdateOrderStatus(entity.OrderDetailId, needAudit, db, trans);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
        }
Пример #4
0
        private static string DispatchGoods(DispatchFormEntity form, DispatchFormItemEntity formItem, Database db, DbTransaction trans)
        {
            var orderDetail = OrderFormRepository.GetItem(form.OrderDetailId);

            var goodsSerial = new GoodsSerialEntity
            {
                ProductId         = form.ProductId,
                DispatchedCount   = formItem.Count,
                HospitalId        = form.HospitalId,
                VendorId          = form.VendorId,
                NeedAudit         = orderDetail.NeedAudit,
                NeedCheck         = orderDetail.NeedCheck,
                NeedSplit         = orderDetail.NeedSplit,
                SplitCopies       = orderDetail.SplitCopies,
                SplitUnit         = orderDetail.SplitUnit,
                SplitCapacity     = orderDetail.SplitCapacity,
                SplitPackageCount = orderDetail.SplitPackageCount,
                ValidDays         = orderDetail.ValidDays,
                BatchNo           = formItem.BatchNo,
                ExpiredDate       = formItem.ExpiredDate,
                IsClosed          = false,
                CreatedId         = form.CreatedId,
                CreatedTime       = DateTime.Now,
                UpdatedId         = form.CreatedId,
                UpdatedTime       = DateTime.Now
            };

            GoodsSerialRepository.Create(goodsSerial, db, trans);

            GoodsSerialFormRepository.Create(new GoodsSerialFormEntity
            {
                SerialId    = goodsSerial.Id,
                FormId      = form.Id,
                FormKind    = FormKind.DispatchItem,
                CreatedId   = form.CreatedId,
                CreatedTime = DateTime.Now,
            }, new GoodsSerialFormEntity
            {
                SerialId    = goodsSerial.Id,
                FormId      = form.OrderDetailId,
                FormKind    = FormKind.OrderDetail,
                CreatedId   = form.CreatedId,
                CreatedTime = DateTime.Now,
            }, db, trans);

            return(goodsSerial.Id);
        }
Пример #5
0
        private static bool ValidateMovein(GoodsStateEntity current, string hospitalId, out string errorCode)
        {
            errorCode = string.Empty;

            if (!string.IsNullOrEmpty(current.FormId) &&
                (current.FormType == FormType.MoveOut))
            {
                return(true);
            }

            var orderForm = OrderFormRepository.Get(current.OrderFormId);

            if (string.Compare(orderForm.HospitalId, hospitalId, false) != 0)
            {
                errorCode = GoodsStateValidateCodes.HospitalNoFutureForm;
                return(false);
            }

            errorCode = GoodsStateValidateCodes.NotValidState;
            return(false);
        }
Пример #6
0
 private static void UpdateOrderStatus(DispatchFormEntity form, Database db, DbTransaction trans)
 {
     OrderFormRepository.UpdateStatus(form.OrderId, form.OrderDetailId, OrderFormItemStatus.Dispatching, db, trans);
 }