Exemple #1
0
        public bool ExecuteUnitChange()
        {
            if (_selectedChangeReason == null)
            {
                MessageBox.Show("Favor selecionar o motivo de saída de serviço da AM.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else if (string.IsNullOrEmpty(_selectedTargetUnitId))
            {
                MessageBox.Show("Favor selecionar a AM que entrará em serviço.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                try
                {
                    TargetUnitForceMap = new UnitForceMapModel()
                    {
                        UnitId = _selectedTargetUnitId
                    };

                    return(UnitForceMapBusiness.ExchangeUnit(_currentUnitForceMap, TargetUnitForceMap, _selectedChangeReason));
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception)
                {
                    MessageBox.Show("Não foi possível substituir a AM.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }

            return(false);
        }
Exemple #2
0
        private UnitForceMapModel CopyUnit(UnitForceMapModel unit)
        {
            var copy = new UnitForceMapModel();

            copy.Avl              = unit.Avl;
            copy.Category         = unit.Category;
            copy.CellPhone        = unit.CellPhone;
            copy.CurrentWorkShift = unit.CurrentWorkShift;
            copy.DispatchedTimes  = unit.DispatchedTimes;
            copy.Doctor           = unit.Doctor;
            copy.Driver           = unit.Driver;
            copy.FirstAuxiliar    = unit.FirstAuxiliar;
            copy.HT             = unit.HT;
            copy.Nurse          = unit.Nurse;
            copy.Radio          = unit.Radio;
            copy.Remarks        = unit.Remarks;
            copy.SecondAuxiliar = unit.SecondAuxiliar;
            copy.ThirdAuxiliar  = unit.ThirdAuxiliar;
            copy.ShiftDate      = unit.ShiftDate;
            if (unit.Station != null)
            {
                copy.Station               = new CadStationModel();
                copy.Station.StationId     = unit.Station.StationId;
                copy.Station.Station       = unit.Station.Station;
                copy.Station.DispatchGroup = unit.Station.DispatchGroup;
                copy.Station.Phone         = unit.Station.Phone;
                copy.Station.Address       = unit.Station.Address;
            }
            copy.Status           = unit.Status;
            copy.UnitId           = unit.UnitId;
            copy.WorkShiftStarted = unit.WorkShiftStarted;
            return(copy);
        }
Exemple #3
0
 public UnitCrewMemberVM(CrewMemberTypeEnum crewMemberType, UnitForceMapModel currentUnit, WorkShiftModel.ShiftTime currentShiftTime)
 {
     this._crewMemberType = crewMemberType;
     this._currentUnitId  = currentUnit.UnitId;
     this._shiftTime      = currentShiftTime;
     this._shiftDate      = currentUnit.ShiftDate;
     this._workShift      = currentUnit.CurrentWorkShift;
 }
Exemple #4
0
        public ChangeUnitWindowVM(UnitForceMapModel UnitForceMap)
        {
            CurrentUnitForceMap = UnitForceMap;

            string agencyId = "SAMU";

            LoadOutServiceTypeList(agencyId);
            this.LoadReserveUnitList(agencyId);
        }
Exemple #5
0
        private void LoginSelectedUnit()
        {
            if (!CadBusiness.UnitInService(SelectedTargetUnitId, RemarkText))
            {
                throw new Exception();
            }

            UnitForceMapModel unit = UnitForceMapBusiness.GetCurrentUnitForceMap(SelectedTargetUnitId);

            if (UnitForceMapBusiness.UpdateUnitForceMap(unit) == null)
            {
                throw new Exception();
            }
        }
Exemple #6
0
        public EditUnitVM(UnitForceMapModel unit, WorkShiftModel.ShiftTime currentShiftTime)
        {
            //UnitForceMapModel currentUnit = UnitForceMapBusiness.GetCurrentUnitForceMap(unit.UnitId);

            BackupUnit = CopyUnit(unit);// (UnitForceMapModel)unit.Clone();

            _currentShiftTime = currentShiftTime;

            HeaderText    = new string[3];
            HeaderText[0] = "Você está editando as informações de uma AM em seu";
            HeaderText[1] = "TURNO " + (_currentShiftTime == WorkShiftModel.ShiftTime.Actual ? "ATUAL" : "FUTURO");
            HeaderText[2] = unit.ShiftDate.ToString("dd/MM/yyyy") + " das " + unit.CurrentWorkShift.ToString();

            LoadData();
        }
Exemple #7
0
        public bool LoginOutServiceUnit()
        {
            try
            {
                if (string.IsNullOrEmpty(SelectedTargetUnitId))
                {
                    MessageBox.Show("Favor selecionar a AM que entrará em serviço.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                else
                {
                    //VERIFICAR SE A UNIDADE POSSUI CNES, NÃO É POSSÍVEL LOGAR UMA VIATURA QUE NÃO POSSUA CNES CADASTRADO.
                    string currentUnitCnes = UnitForceMapBusiness.GetUnitCnes(SelectedTargetUnitId);

                    if (string.IsNullOrEmpty(currentUnitCnes))
                    {
                        MessageBox.Show("Não foi possível logar a AM pois nao existe um CNES cadastrado para a mesma.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                        return(false);
                    }

                    string substituteUnitId = UnitForceMapBusiness.GetSubstituteUnitId(SelectedTargetUnitId);
                    if (!string.IsNullOrEmpty(substituteUnitId))
                    {
                        //A UNIDADE SELECTIONADA POSSUI CNES, PORÉM ESTÁ SENDO SUBSTITUÍDA NO MOMENTO POR UMA OUTRA VIATURA,
                        //PRECISA VERIFICAR SE ESSA OUTRA VIATURA TAMBÉM POSSUI CNES ANTES DE PERGUNTAR SOBRE A RETIRADA DO VÍNCULO.
                        string substituteUnitCnes = UnitForceMapBusiness.GetUnitCnes(substituteUnitId);

                        if (string.IsNullOrEmpty(substituteUnitCnes))
                        {
                            MessageBox.Show(string.Format("A unidade {0} está atuando como reserva da selecionada, {1}." +
                                                          Environment.NewLine + "Não é possível colocar a viatura {1} em operação, pois sua reserva {0} não possui um CNES cadastrado." +
                                                          Environment.NewLine + "Substitua a viatura reserva pela oficial caso deseje o retorno da viatura {1} de volta em operação.",
                                                          substituteUnitId, SelectedTargetUnitId), "Viatura possui unidade reserva em operação", MessageBoxButton.OK);

                            return(false);
                        }


                        if (UnitBusiness.IsAssigned(substituteUnitId))
                        {
                            MessageBox.Show(string.Format("A unidade {0}, que está substituindo a selecionada, está EMPENHADA." +
                                                          Environment.NewLine + "Não é possível colocá-la em serviço.",
                                                          substituteUnitId), "Viatura possui reserva empenhada", MessageBoxButton.OK);

                            return(false);
                        }



                        MessageBoxResult msgBoxResult = MessageBox.Show(string.Format("A unidade {0} está atuando como reserva da selecionada, {1}." +
                                                                                      Environment.NewLine + "Deseja remover o vínculo entre elas e manter as duas em operação?",
                                                                                      substituteUnitId, SelectedTargetUnitId), "Viatura possui unidade reserva em operação",
                                                                        MessageBoxButton.OKCancel);
                        if (msgBoxResult == MessageBoxResult.OK)
                        {//string _outServiceTypeId
                            UnitForceMapModel     unitForceTarget  = UnitForceMapBusiness.GetCurrentUnitForceMap(SelectedTargetUnitId);
                            UnitForceMapModel     unitForceCurrent = UnitForceMapBusiness.GetCurrentUnitForceMap(substituteUnitId);
                            OutOfServiceTypeModel outOfServiceType = UnitForceMapBusiness.GetOutOfServiceType(OutOfServiceTypeModel.OUT_TYPE_RESERVA_TECNICA_ID, "SAMU");
                            UnitForceMapBusiness.ExchangeUnit(unitForceCurrent, unitForceTarget, outOfServiceType);


                            //UnitForceMapBusiness.RemoveSubstituteUnit(SelectedTargetUnitId);
                            //LoginSelectedUnit();
                            return(true);
                        }
                    }
                    else
                    {
                        LoginSelectedUnit();
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                ShowErrorMessage();
            }

            return(false);
        }
Exemple #8
0
 public UnitVM(UnitForceMapModel unitModel, string rowColor)
 {
     this.UnitModel = unitModel;
     this.RowColor  = rowColor;
 }