/// <summary>
        /// Init drugs and chart
        /// </summary>
        private void InitDrugsAndChart()
        {
            _pharmacyDomainContext.Load(_pharmacyDomainContext.GetLiecivoQuery(), true).Completed +=
                (sender, args) =>
                {
                    DrugNames.Clear();
                    var drugs = ((LoadOperation<Liecivo>)sender).Entities;

                    foreach (var drug in drugs)
                    {
                        DrugNameCount dnc = new DrugNameCount();

                        dnc.DrugName = (drug.na_predpis == "0") ? "Na predpis" : "Bez predpisu";

                        _drugNameCountList.Add(dnc);
                    }

                    for (int i = 0; i < _drugNameCountList.GetDrugNameList().Count; i++)
                    {
                        var drugNameCount = new DrugNameCount();
                        drugNameCount.DrugName = _drugNameCountList.GetDrugNameList().ElementAt(i).DrugName;
                        drugNameCount.Count = _drugNameCountList.GetDrugNameList().ElementAt(i).Count;
                        DrugNames.Add(drugNameCount);
                    }

            };
        }
        /// <summary>
        /// Init drugs and chart
        /// </summary>
        private void InitDrugsAndChart()
        {
            _pharmacyDomainContext.Load(_pharmacyDomainContext.GetNazov_liecivaQuery(), true).Completed += (a, e) =>
            {
                _pharmacyDomainContext.Load(_pharmacyDomainContext.GetSoldDrugsStatisticsQuery(), true).Completed +=
                    (sender, args) =>
                    {
                        DrugNames.Clear();
                        var drugs = ((LoadOperation<Liecivo>) sender).Entities;

                        foreach (var drug in drugs)
                        {
                            DrugNameCount dnc = new DrugNameCount();
                            dnc.DrugName = drug.Nazov_lieciva.nazov_lieciva1;
                            _drugNameCountList.Add(dnc);
                        }

                        for (int i = 0; i < _drugNameCountList.GetDrugNameList().Count; i++)
                        {
                            var drugNameCount = new DrugNameCount();
                            drugNameCount.DrugName = _drugNameCountList.GetDrugNameList().ElementAt(i).DrugName;
                            drugNameCount.Count = _drugNameCountList.GetDrugNameList().ElementAt(i).Count;
                            DrugNames.Add(drugNameCount);
                        }

                    };
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Add drug if not exists.. If exists then only count add
        /// </summary>
        /// <param name="drug"></param>
        public void Add(DrugNameCount drug)
        {
            bool added = false;
            //pre-iterate array if exists
            for (int i = 0; i < _drugList.Count; i++)
            {
                var drugTemp = _drugList.ElementAt(i);
                if (drugTemp.DrugName == drug.DrugName)
                {
                    drugTemp.Count++;
                    added = true;
                }
            }

            if (!added)
            {
                drug.Count = 1;
                _drugList.Add(drug);
            }
                
        }