コード例 #1
0
ファイル: FollowUpBL.cs プロジェクト: ester9894/finalProject
        /// <summary>
        /// הגדרת תדירות למוצר ועדכונה כל קניה
        /// </summary>
        /// <param name="follow"></param>
        public static void SetFrequency(FollowUpList follow)

        {
            using (ProjectDBEntities db = new ProjectDBEntities())
            {
                int    daysbefore = 0, daysafter = 0;
                double rangeDates = 0;
                //lastbuys שולף את כל הפעמים שנקנה המוצר וממין מהתאריך קנייה האחרון ומטה
                List <ProductToList> lastBuys = db.ProductToLists.
                                                Where(p => p.DateOfBuy != null && p.ProductId == follow.ProductId && p.List.TypesList.AccountId == follow.AccountId).
                                                OrderByDescending(p => p.DateOfBuy).ToList();
                //אם מעודכן תדירות כבר למוצר, מחשב את הזמנים שאפשר לחרוג בקניית המוצר
                if (follow.Frequency != null)
                {
                    daysbefore = follow.Frequency.NumDays - follow.Frequency.Exception; // חריגה לפני
                    daysafter  = follow.Frequency.NumDays + follow.Frequency.Exception; //חריגה אחרי
                }
                // אם קנה מוצר זה יותר מפעמיים אז מחשב את הפרש זמן הקנייה מהקנייה העכשוית לקניה הקודמת לה
                if (lastBuys.Count >= 2)
                {
                    rangeDates = (lastBuys[0].DateOfBuy - lastBuys[1].DateOfBuy).Value.TotalDays;
                }
                // אם תקין- קיימת תדירות ויש יותר וקנה את המוצר יותר מ 3 םעמים וגם קניית המוצר עכשיו היא עדיין בטווח החריגה או שבכלל אין לו על מה לעבוד עדיין כי אין לו כמות מספקת בשביל החישוב
                if ((follow.Frequency != null && lastBuys.Count >= 3 && rangeDates >= daysbefore && rangeDates <= daysafter) ||
                    lastBuys.Count < 3)
                {
                    return;
                }
                // מחשב הפרשי קנייה של 3 הפעמים האחרונות שקנה את המוצר
                int[] differences = new int[2];
                for (int i = 0; i < 2; i++)
                {
                    differences[i] = (int)(lastBuys[i].DateOfBuy - lastBuys[i + 1].DateOfBuy).Value.TotalDays;//הפרש בין התאריכים האחרונים
                }
                // בודק אם ההפרשים נמצאים באחד מהטווחים הנתונים כבר
                foreach (var frequency in db.Frequencies)
                {
                    int i = 0;
                    for (; i < 2; i++)
                    {
                        if (!(IsNumberInFreequencyRange(differences[i], frequency)))
                        {
                            break;
                        }
                    }
                    if (i < 2)
                    {
                        continue;
                    }
                    // אם כל ההפרשים מקיימים את אחד מהטווחים מעדכן את התדירות למוצר זה
                    db.FollowUpLists.FirstOrDefault(f => f.FollowUpListId == follow.FollowUpListId).FrequencyId = frequency.FrequencyId;
                    //frequency.FrequencyId;
                    break;
                }
                db.SaveChanges();
            }
        }
コード例 #2
0
 async void Handle_ClientSelected(object sender, SelectionChangedEventArgs e)
 {
     if (e.CurrentSelection != null)
     {
         FollowUpList followupList = (FollowUpList)e.CurrentSelection.FirstOrDefault();
         await Shell.Current.GoToAsync($"{nameof(FollowupDetailPage)}?{nameof(FollowupViewModel.OpdNumber)}={followupList.OPDNumber}");
     }
     else
     {
         return;
     }
 }
コード例 #3
0
 public static FollowUpListDTO ConvertFollowUpListToDTO(FollowUpList f)
 {
     return(new FollowUpListDTO
     {
         Amount = f.Amount,
         FollowUpListId = f.FollowUpListId,
         FrequencyId = f.FrequencyId,
         ProductId = f.ProductId,
         AccountId = f.AccountId,
         ProductName = f.Product.ProductName
     });
 }
コード例 #4
0
ファイル: Database.cs プロジェクト: ShiZoe/Mwense.Malaria.App
        /*public async Task<List<LabResults>> GetFollowupPatientsAsync()
         * {
         *  //Get all Registered Patients.
         *  //return _database.Table<Patients>().ToListAsync();
         *  return await _database.Table<LabResults>().ToListAsync();
         *
         * }*/

        public async Task <bool> SubmitFollowupAsync(FollowUpList followUpList)
        {
            //var Submit = await _database.InsertAsync(Labresult);
            if (followUpList.OPDNumber != 0)
            {
                await _database.InsertAsync(followUpList);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
ファイル: FollowUpBL.cs プロジェクト: ester9894/finalProject
 /// <summary>
 /// מחיקת מוצר מרשימת המעקב
 /// </summary>
 /// <param name="idSelectedProducts"></param>
 /// <param name="accountId"></param>
 public static void removeProductsFromFollowUp(int[] idSelectedProducts, int accountId)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {
         foreach (int item in idSelectedProducts)
         {
             FollowUpList f = new FollowUpList();
             if (db.FollowUpLists.Any(a => a.AccountId == accountId && a.ProductId == item))
             {
                 f = db.FollowUpLists.FirstOrDefault(a => a.AccountId == accountId && a.ProductId == item);
                 db.FollowUpLists.Remove(f);
             }
         }
         db.SaveChanges();
     }
 }
コード例 #6
0
ファイル: RFQSubHeader.cs プロジェクト: Osama91/CCWFM
 private void AddFollowUp()
 {
     if (FollowUpList.Any(x => x.IsRejected))
     {
         return;
     }
     if (FollowUpItem != null)
     {
         if ((FollowUpList.IndexOf(FollowUpItem)) != (FollowUpList.Count - 1))
         {
             return;
         }
         if (FollowUpList[FollowUpList.Count - 1].ObjStatus.IsEmpty)
         {
             return;
         }
         FollowUpList.Add(new RFQFollowUpViewModel {
             Style = Style, ParentID = SubHeaderSerial
         });
         FollowUpItem = FollowUpList[FollowUpList.Count - 1];
         FollowUpItem.ObjStatus.IsEmpty = true;
         FollowUpItem.ObjStatus.IsNew   = true;
         FollowUpItem.SizesCollection.Clear();
         foreach (var size in RFQGlobalLkps.StatisSizesCollection.Where(x => x.StyleCode == Style))
         {
             FollowUpItem.SizesCollection.Add(size);
         }
     }
     else
     {
         FollowUpList.Add(new RFQFollowUpViewModel {
             Style = Style, ParentID = SubHeaderSerial
         });
         FollowUpItem = FollowUpList[FollowUpList.Count - 1];
         FollowUpItem.ObjStatus.IsEmpty = true;
         FollowUpItem.ObjStatus.IsNew   = true;
         FollowUpItem.SizesCollection.Clear();
         foreach (var size in RFQGlobalLkps.StatisSizesCollection.Where(x => x.StyleCode == Style))
         {
             FollowUpItem.SizesCollection.Add(size);
         }
     }
 }
コード例 #7
0
        public async void LoadPatientId(int opdNumber)
        {
            try
            {
                //int opdnum = Convert.ToInt32(opdNumber);
                //
                FollowUpList person = await App.Database.GetFollowupAsync(opdNumber, reviewDate);

                ID          = person.ID;
                OPDNumber   = person.OPDNumber;
                FirstName   = person.FirstName;
                LastName    = person.LastName;
                Village     = person.Village;
                PhoneNumber = person.PhoneNumber;
                TestDate    = person.TestDate.ToString("dd/MM/yyyy");
            }
            catch (Exception)
            {
                Debug.WriteLine("Failed to Load Item");
            }
        }
コード例 #8
0
        private async void OnSubmitClicked(object obj)
        {
            ActivityRunning();
            var model = new LabResults
            {
                OPDNumber      = Opdnumber,
                MalariaResults = Malariaresults,
                TestDate       = DateTime.Today
            };


            if (Opdnumber != 0 & Malariaresults != null)
            {
                var check = await App.Database.CheckClientAsync(Opdnumber);

                if (check)
                {
                    var client = await App.Database.GetPatientAsync(Opdnumber);

                    var followupmodel = new FollowUpList
                    {
                        OPDNumber      = client.OPDNumber,
                        FirstName      = client.FirstName,
                        LastName       = client.LastName,
                        DateOfBirth    = client.DateOfBirth,
                        Village        = client.Village,
                        HouseNumber    = client.HouseNumber,
                        PhoneNumber    = client.PhoneNumber,
                        MalariaResults = Malariaresults,
                        TestDate       = DateTime.Today,
                        IsReviewed     = false
                    };



                    //var responce = await _apiServices.LoginAsync(Username, Password);
                    // Prefixing with `//` switches to a different navigation stack instead of pushing to the active one
                    var responce = await App.Database.SubmitResultsAsync(model);

                    var follows = await App.Database.SubmitFollowupAsync(followupmodel);


                    if (responce && follows)
                    {
                        // popupLoadingView.IsVisible = false;
                        ActivityStopped();
                        DisplaySaveSucessPrompt();
                        Clear();
                        //await Shell.Current.GoToAsync($"//{nameof(LabResultsPage)}");
                        //await Shell.Current.GoToAsync(nameof(LabResultsPage));
                    }
                    else
                    {
                        ActivityStopped();
                        DisplaySaveFailedPrompt();
                        Clear();
                        return;
                    }
                    //popupLoadingView.IsVisible = false;
                    //DisplayInvalidLoginPrompt();
                }
                else
                {
                    ActivityStopped();
                    Clear();
                    DisplayPatientNotRegisteredPrompt();
                    await Shell.Current.GoToAsync($"//{nameof(PatientsPage)}");

                    return;
                }
            }
            else
            {
                ActivityStopped();
                DisplayRequiredFieldsPrompt();
                return;
            }

            //await Shell.Current.GoToAsync($"//{nameof(PatientsListPage)}");
        }