Exemple #1
0
        private static bool ValidateInspection(GoodsStateEntity current, string hospitalId, out string errorCode)
        {
            errorCode = string.Empty;

            var form = InspectionFormRepository.Get(current.FutureFormId);

            if (form == null)
            {
                errorCode = GoodsStateValidateCodes.FutureFormNotExist;
                return(false);
            }

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

            if (!Enum.IsDefined(typeof(FormType), current.FutureFormType) ||
                (FormType)current.FutureFormType != FormType.Inspection)
            {
                errorCode = GoodsStateValidateCodes.NotValidState;
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static bool CanFormValidate(string formId, FormType formType, string hospitalId, out string errorCode)
        {
            errorCode = string.Empty;
            if (string.IsNullOrEmpty(formId))
            {
                errorCode = GoodsStateValidateCodes.NotValidState;
                return(false);
            }

            bool   noForm;
            string formHospitalId;

            switch (formType)
            {
            case FormType.Receive:
                var receive = ReceiveFormRepository.Get(formId);
                noForm         = receive == null;
                formHospitalId = noForm ? string.Empty : receive.HospitalId;
                break;

            case FormType.Inspection:
                var inspection = InspectionFormRepository.Get(formId);
                noForm         = inspection == null;
                formHospitalId = noForm ? string.Empty : inspection.HospitalId;
                break;

            case FormType.Incoming:
                var incoming = IncomingFormRepository.Get(formId);
                noForm         = incoming == null;
                formHospitalId = noForm ? string.Empty : incoming.HospitalId;
                break;

            case FormType.Apply:
                var apply = ApplyFormRepository.Get(formId);
                noForm         = apply == null;
                formHospitalId = noForm ? string.Empty : apply.HospitalId;
                break;

            case FormType.Return:
                var @return = ReturnFormRepository.Get(formId);
                noForm         = @return == null;
                formHospitalId = noForm ? string.Empty : @return.HospitalId;
                break;

            default:
                errorCode      = GoodsStateValidateCodes.NotValidState;
                noForm         = true;
                formHospitalId = string.Empty;
                break;
            }

            if (!string.IsNullOrEmpty(errorCode))
            {
                return(false);
            }

            if (noForm)
            {
                errorCode = GoodsStateValidateCodes.FutureFormNotExist;
                return(false);
            }

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

            return(true);
        }