예제 #1
0
        public void AddIntervention(LocalIntervention localIntervention)
        {
            int year  = localIntervention.DateHourDetail.Date.Year;
            int month = localIntervention.DateHourDetail.Date.Month;

            if (InterventionsDictionary.ContainsKey(year))
            {
                if (InterventionsDictionary[year].ContainsKey(month))
                {
                    InterventionsDictionary[year][month].Add(localIntervention);
                }
                else
                {
                    InterventionsDictionary[year].Add(month, new List <LocalIntervention>()
                    {
                        localIntervention
                    });
                }
            }
            else
            {
                InterventionsDictionary.Add(year, new Dictionary <int, List <LocalIntervention> >());
                InterventionsDictionary[year].Add(month, new List <LocalIntervention>()
                {
                    localIntervention
                });
            }
        }
        public static List <LocalPatient> ExcelToPatient(this Dictionary <String, List <string> > excelResult)
        {
            List <LocalPatient> patients = new List <LocalPatient>();

            excelResult.Remove(excelResult.Keys.Last());
            foreach (var key in excelResult.Keys)
            {
                LocalPatient patient = new LocalPatient();
                patient.Name = excelResult[key][3];
                LocalIntervention Intervention = new LocalIntervention();

                Intervention.Area = new LocalArea()
                {
                    Name = excelResult[key][7]
                };
                Intervention.DateHourDetail = new LocalDateHourDetail()
                {
                    StartHour  = DateTime.FromOADate(float.Parse(excelResult[key][9])),
                    EndingHour = DateTime.FromOADate(float.Parse(excelResult[key][10])),
                    Date       = Convert.ToDateTime(excelResult[key][2])
                };
                Intervention.Location = new LocalLocation()
                {
                    Name = excelResult[key][4]
                };
                Intervention.Material = new LocalMaterial()
                {
                    Name = excelResult[key][6]
                };
                Intervention.Observation = excelResult[key][8];
                Intervention.Revenue     = new LocalRevenue()
                {
                    Amount = Convert.ToDecimal(excelResult[key][12])
                };
                Intervention.Lucrare = new LocalWork()
                {
                    Name = excelResult[key][5]
                };
                //patient.Intervention = Intervention;
                var currPatient = patients.FirstOrDefault(item => item.Name == patient.Name);
                if (currPatient != null)
                {
                    currPatient.Interventions.Add(Intervention);
                }
                else
                {
                    patient.Interventions = new List <LocalIntervention>();
                    patient.Interventions.Add(Intervention);
                    patients.Add(patient);
                }
            }

            return(patients);
        }
예제 #3
0
        private void ChangeTotalInfo(LocalIntervention intervention, bool wasDeleted)
        {
            if (wasDeleted)
            {
                eventAggregator.GetEvent <TotalsModifiedEvent>().Publish(TotalInfoSelectedEl);
            }

            eventAggregator.GetEvent <TotalsModifiedEvent>().Publish(new TotalsIfo
            {
                TotalHours         = intervention.DateHourDetail.Duration,
                TotalInverventions = 1,
                TotalRevenue       = intervention.Revenue,
                TotalProfit        = intervention.Percent
            });
        }
예제 #4
0
        private void SetNewIntervenionDetails(LocalIntervention intervention)
        {
            var addedInterventionDetails = intervention.ToInterventionDetails();

            addedInterventionDetails.NewlyAdded = true;
            addedInterventionDetails.Brush      = BackgroundColors.BackgroundFilled;
            if (IsInEditMode)
            {
                Parent.YearListViewModel.RemoveInterventionFromYear(SelectedInterventionDetails);
            }
            Parent.YearListViewModel.AddYear(addedInterventionDetails);
            if (LastaddedInteventiondetails != null)
            {
                LastaddedInteventiondetails.Brush = BackgroundColors.GridInterventionRowColor;
            }
            LastaddedInteventiondetails = addedInterventionDetails;
        }
예제 #5
0
        public static InterventionDetails ToInterventionDetails(this LocalIntervention localIntervention)
        {
            int minutes = 0;
            int hours   = 0;

            if (localIntervention.DateHourDetail != null)
            {
                hours   = localIntervention.DateHourDetail.Duration.Hours;
                minutes = localIntervention.DateHourDetail.Duration.Minutes;
//                minutes = minutes + localIntervention.DateHourDetail.Duration.Seconds > 50 ? 1 : 0;
            }


            return(new InterventionDetails()
            {
                Area = localIntervention.Area != null ? localIntervention.Area.Name : null,
                EndH = localIntervention.DateHourDetail.EndingHour,
                StartH = localIntervention.DateHourDetail.StartHour,
                Location = localIntervention.Location != null ? localIntervention.Location.Name : null,
                Observations = localIntervention.Observation,
                Material = localIntervention.Material != null ? localIntervention.Material.Name : null,
                MaterialType = localIntervention.MaterialTYpe != null ? localIntervention.MaterialTYpe.Name : null,
                Work = localIntervention.Lucrare != null ? localIntervention.Lucrare.Name : null,
                WorkType = localIntervention.WorkType != null ? localIntervention.WorkType.Name : null,
                DateString = localIntervention.DateHourDetail != null?localIntervention.DateHourDetail.Date.ToShortDateString() : "",
                                 Date = localIntervention.DateHourDetail.Date,
                                 Mili = localIntervention.DateHourDetail.Mili,
                                 Revenue = localIntervention.Revenue,
                                 Durata = new TimeSpan(hours, minutes, 0),// localIntervention.DateHourDetail != null ? localIntervention.DateHourDetail.Duration : new TimeSpan(0, 0, 0, 0),
                                 //new TimeSpan(hours, minutes, 0),//
                                 WasPayedByDental = localIntervention.WasPayedByDental,
                                 //if i put PacientName after was payed i can test smth look in wasPyed setter
                                 PacientName = localIntervention.PatientName,
                                 Percent = localIntervention.Percent,
                                 Id = localIntervention.Id,
                                 LocalIntervention = localIntervention,
                                 Brush = localIntervention.WasPayedByDental ? BackgroundColors.GridInterventionRowColor : BackgroundColors.GridNotPayedColor,
//                Brush = localIntervention.DateHourDetail.StartHour > LocalCache.Instance.ProgramInfo.SetAsNewStartDate ? BackgroundColors.BackgroundPending : localIntervention.WasPayedByDental ? BackgroundColors.GridInterventionRowColor : BackgroundColors.GridNotPayedColor,
                                 MaterialCost = localIntervention.MaterialCost,
                                 TechnicianId = localIntervention.TechnicianId,
                                 TechnicianName = localIntervention.Technician != null ? localIntervention.Technician.Name : ""
            });
        }
예제 #6
0
        public void Save()
        {
            if (SelectedPatient != null && SelectedPatient.NewlyAdded)
            {
                PatientsList.Add(SelectedPatient);
                SelectedPatient.NewlyAdded = false;
            }
            try
            {
                bool   shouldDisplayMessage;
                double cost             = MaterialCost.HasValue ? MaterialCost.Value : 0;
                var    itemsNotSelected = GetNotAddedInformation(out shouldDisplayMessage);
                if (shouldDisplayMessage)
                {
                    MessageBox.Show("Inainte de a salva adaugati :" + itemsNotSelected);
                    return;
                }
                var duration = TimeSpan.FromMinutes(Convert.ToDouble(Durata));
                EndTIme = StartingHour.Add(duration);
                double percentage = SelectedPercentage != null
                    ? SelectedPercentage.Percentage / 100
                    : (SelectedWork != null && SelectedWork.Percent != 0 ? SelectedWork.Percent / 100 : 1);

                var intervention = new LocalIntervention()
                {
                    Id       = Id,
                    Area     = SelectedArea != null ? (SelectedArea.SettingTOarea()) : null,
                    Location = SelectedLocation != null?SelectedLocation.SettingToLocation() : null,
                                   DateHourDetail = new LocalDateHourDetail()
                    {
                        Date       = Date,
                        StartHour  = StartingHour,
                        Mili       = Convert.ToInt64(DateTime.Now.TimeOfDay.TotalMilliseconds),
                        EndingHour = EndTIme,
                        Duration   = duration
                    },
                    Lucrare          = SelectedWork,
                    PatientName      = SelectedPatient.AllName,
                    Material         = SelectedMaterial,
                    Observation      = Observation,
                    Revenue          = Revenue.HasValue ? Revenue.Value : 0,
                    PatientId        = SelectedPatient.Id,
                    Percent          = Convert.ToDouble((Revenue - cost) * percentage),
                    WasPayedByDental = WasPayedByDental,
                    TechnicianId     = SelectedTechnician != null ? SelectedTechnician.Id : (int?)null,
                    MaterialCost     = MaterialCost,
                    Technician       = SelectedTechnician
                };

                ChangeTotalInfo(intervention, IsInEditMode);
                intervention.Id = DatabaseHandler.Instance.AddIntervention(intervention, LocalCache.Instance.CurrentUser.Id);
                if (IsInEditMode)
                {
                    LocalIntervention = intervention;
                }
                else
                {
                    LocalCache.Instance.AddIntervention(intervention);
                    var patient = LocalCache.Instance.PatientsRepository.Patients.FirstOrDefault(item => item.Id == SelectedPatient.Id);
                    if (patient != null)
                    {
                        patient.Interventions.Add(intervention);
                    }
                }
                SetNewIntervenionDetails(intervention);
                IsPatientComboFocused = false;
                IsPatientComboFocused = true;
                InitData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("A intervenit o eroare la salvare.");
                Log.Error("Error inserting intervention --> Save");
            }
        }
예제 #7
0
        public static List <LocalPatient> ExcelToPatient(this Dictionary <String, List <string> > excelResult)
        {
            List <LocalPatient> patients = new List <LocalPatient>();

            excelResult.Remove(excelResult.Keys.Last());
            foreach (var key in excelResult.Keys)
            {
                LocalPatient patient = new LocalPatient();
                patient.Name    = excelResult[key][3];
                patient.Surname = "";
                LocalIntervention Intervention = new LocalIntervention();

                Intervention.Area = new LocalArea()
                {
                    Name = excelResult[key][7]
                };
                try
                {
                    Intervention.DateHourDetail = new LocalDateHourDetail()
                    {
                        StartHour  = DateTime.FromOADate(float.Parse(excelResult[key][9])),
                        EndingHour = DateTime.FromOADate(float.Parse(excelResult[key][10])),
                        Date       = Convert.ToDateTime(excelResult[key][2])
                    };
                }
                catch (Exception e)
                {
                    Log.Error(string.Format("Patient Name: {0}.Start Date Or Enddate Wrong", patient.Name), e);
                }
                Intervention.Location = new LocalLocation()
                {
                    Name = excelResult[key][4]
                };
                Intervention.Material = new LocalMaterial()
                {
                    Name = excelResult[key][6]
                };
                Intervention.Observation = excelResult[key][8];
                try
                {
                    Intervention.Revenue = Convert.ToDouble(excelResult[key][12]);
                }
                catch (Exception e)
                {
                    Log.Error(string.Format("Patient Name: {0} .Revenue Wrong", patient.Name), e);
                }
                Intervention.Lucrare = new LocalWork()
                {
                    Name = excelResult[key][5]
                };
                var t = excelResult[key][14];
                if (!string.IsNullOrEmpty(t))
                {
                    try
                    {
                        Intervention.Percent = Convert.ToDouble(excelResult[key][14]);
                    }
                    catch (Exception e)
                    {
                        Log.Error(string.Format("Patient Name: {0} .Percent Wrong", patient.Name), e);
                    }
                }
                //patient.Intervention = Intervention;
                var currPatient = patients.FirstOrDefault(item => item.Name == patient.Name);
                if (currPatient != null)
                {
                    currPatient.Interventions.Add(Intervention);
                }
                else
                {
                    patient.Interventions = new List <LocalIntervention>();
                    patient.Interventions.Add(Intervention);
                    patients.Add(patient);
                }
            }

            return(patients);
        }