private void SaveMedicineClick(object sender, RoutedEventArgs e)
        {
            var medicine = new Medicine(_medicine == null ? Guid.Empty : _medicine.Id)
            {
                Name        = productName.Text,
                Description = productDescription.Text,
                Image       = Utils.Utils.BitmapImageToBitmap(productImage.Source as BitmapImage),
                Type        = medicineType.SelectionBoxItem as MedicineType,
                Price       = int.Parse(productPrice.Text),
                Ingredients = _selectedIngredients
            };

            if (_isEditMode)
            {
                MedicineManager.Update(medicine);
                this.Close();
                return;
            }


            MedicineManager.Insert(medicine);

            productName.Text           = null;
            productDescription.Text    = null;
            medicineType.SelectedIndex = -1;
            productPrice.Text          = null;
            ingredientsTextBlock.Text  = null;
            productImage.Source        = null;
            ingredientFilter.Text      = null;
            _selectedIngredients.Clear();
        }
        public IActionResult updateMedicineInfo([FromForm] MedicineDTO medicine)
        {
            if (medicine == null)
            {
                return(BadRequest(new JsonCreate()
                {
                    message = Utils.ConstMessage.BAD_REQUEST, data = false
                }));
            }
            MedicineManager medicineManager = new MedicineManager();
            bool            judge           = medicineManager.updateMedicineInfo(medicine);

            if (judge)
            {
                return(Ok(new JsonCreate()
                {
                    message = Utils.ConstMessage.UPDATE_SUCCESS, data = true
                }));
            }
            else
            {
                return(Conflict(new JsonCreate()
                {
                    message = Utils.ConstMessage.CONFILICT, data = false
                }));
            }
        }
Example #3
0
        private void ButtonDeleteMedicine_OnClick(object sender, RoutedEventArgs e)
        {
            if (productsGrid.SelectedCells.Count <= 0)
            {
                return;
            }

            foreach (var medicineRow in productsGrid.SelectedCells)
            {
                if (!(medicineRow.Item is Medicine))
                {
                    return;
                }

                var medicine = (Medicine)medicineRow.Item;

                MedicineManager.Delete(medicine);
            }

            DetailsGrid.Visibility = Visibility.Hidden;
            medicineImage.Source   = null;
            medicineName.Content   = null;
            medicineType.Content   = null;

            medicineDescription.Document.Blocks.Clear();
            medicineIngredients.ItemsSource = null;

            productsGrid.ItemsSource = GetGridData();
        }
Example #4
0
    private void loadMedicine()
    {
        ddlMedicine.Items.Clear();
        ListItem li = new ListItem("New Medicine", "0");

        ddlMedicine.Items.Add(li);

        List <Medicine> medicines = new List <Medicine>();

        medicines = MedicineManager.GetAllMedicines();
        foreach (Medicine medicine in medicines)
        {
            bool isDuplicate = false;
            foreach (ListItem itemddl in ddlMedicine.Items)
            {
                if (itemddl.Text == medicine.MedicineName)
                {
                    isDuplicate = true;
                    break;
                }
            }

            if (!isDuplicate)
            {
                ListItem item = new ListItem(medicine.MedicineName.ToString(), medicine.MedicineID.ToString());
                ddlMedicine.Items.Add(item);
            }
        }
    }
Example #5
0
    private void showMedicineData()
    {
        Medicine medicine = new Medicine();

        medicine = MedicineManager.GetMedicineByID(Int32.Parse(Request.QueryString["medicineID"]));

        txtMedicineName.Text = medicine.MedicineName;
    }
Example #6
0
        private void BindMedicineNameDropDown()
        {
            MedicineManager medicineManager = new MedicineManager();

            ddlMedicine.DataSource = medicineManager.GetAll();
            ddlMedicine.DataBind();
            ddlMedicine.Items.Insert(0, new ListItem("--Select--"));
        }
        async void DoneClicked(object sender, EventArgs e)
        {
            MedicineManager medicineManager = MedicineManager.DefaultManager;
            await medicineManager.SaveTaskAsync(currentMedicine, isNewItem);

            App.contentChanged = true;
            await Navigation.PopAsync();
        }
        public IActionResult getMedicinInfoById(String medicineId, String batchId)
        {
            MedicineManager medicineManager = new MedicineManager();
            object          result          = medicineManager.getMedicineInfoById(medicineId, batchId);

            return(Ok(new JsonCreate {
                message = ConstMessage.GET_SUCCESS, data = result
            }));
        }
    protected void lbDelete_Click(object sender, EventArgs e)
    {
        LinkButton linkButton = new LinkButton();

        linkButton = (LinkButton)sender;
        bool result = MedicineManager.DeleteMedicine(Convert.ToInt32(linkButton.CommandArgument));

        showMedicineGrid();
    }
        public IActionResult getMedicineInfoAll()
        {
            MedicineManager medicineManager = new MedicineManager();
            object          result          = medicineManager.getMedicineInfoAll();

            return(Ok(new JsonCreate {
                message = ConstMessage.GET_SUCCESS, data = result
            }));
        }
Example #11
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Medicine medicine = new Medicine();

        medicine.MedicineName = txtMedicineName.Text;
        int resutl = MedicineManager.InsertMedicine(medicine);

        Response.Redirect("AdminMedicineDisplay.aspx");
    }
Example #12
0
 public MedicinePage()
 {
     InitializeComponent();
     medicineManager        = MedicineManager.DefaultManager;
     reminderManager        = ReminderManager.DefaultManager;
     medicineHistoryManager = MedicineHistoryManager.DefaultManager;
     Init();
     ReminderClicked();
     currentView = 0;
 }
        public IActionResult getMedicineListByKeyword(String keyword)
        {
            MedicineManager medicineManager          = new MedicineManager();
            List <MedicineSearchResultDTO> medicines = medicineManager.getMedicineListByKeyword(keyword);

            return(Ok(new JsonCreate
            {
                message = medicines != null && medicines.Count > 0 ?ConstMessage.GET_SUCCESS:ConstMessage.NOT_FOUND,
                data = medicines
            }));
        }
Example #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CenterId"] == null)
            {
                Response.Redirect("CenterLoginUI.aspx");
            }
            MedicineManager aMedicineManager = new MedicineManager();

            showMedicineGridView.DataSource = aMedicineManager.GetMedicine(Convert.ToInt32(Session["CenterId"]));
            showMedicineGridView.DataBind();
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            MedicineManager aMedicineManager = new MedicineManager();
            Medicine        aMedicine        = new Medicine();

            aMedicine.Name  = nameTextBox.Text;
            aMedicine.Power = Convert.ToInt32(powerTextBox.Text);
            aMedicine.Type  = mgMlDropDownList.SelectedItem.ToString();

            string msg = aMedicineManager.SaveMedicine(aMedicine);

            msgLabel.Text = msg;
        }
Example #16
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Medicine medicine = new Medicine();

        medicine = MedicineManager.GetMedicineByID(Int32.Parse(Request.QueryString["medicineID"]));
        Medicine tempMedicine = new Medicine();

        tempMedicine.MedicineID = medicine.MedicineID;

        tempMedicine.MedicineName = txtMedicineName.Text;
        bool result = MedicineManager.UpdateMedicine(tempMedicine);

        Response.Redirect("AdminMedicineDisplay.aspx");
    }
    private void loadMedicine()
    {
        ListItem li = new ListItem("Select Medicine...", "0");

        ddlMedicine.Items.Add(li);

        List <Medicine> medicines = new List <Medicine>();

        medicines = MedicineManager.GetAllMedicines();
        foreach (Medicine medicine in medicines)
        {
            ListItem item = new ListItem(medicine.MedicineName.ToString(), medicine.MedicineID.ToString());
            ddlMedicine.Items.Add(item);
        }
    }
Example #18
0
        private List <Medicine> GetGridData()
        {
            var medicines = MedicineManager.GetAllMedicines();
            int priceFrom;
            int priceTo;

            medicines = medicines.Where(med => !int.TryParse(filterMedicinePriceFrom.Text, out priceFrom) || med.Price >= priceFrom)
                        .Where(med => !int.TryParse(filterMedicinePriceFrom.Text, out priceTo) || med.Price <= priceTo)
                        .Where(med => filterMedicineType.SelectedItem == null || med.Type.Id == ((MedicineType)filterMedicineType.SelectedItem).Id)
                        .Where(med => string.IsNullOrEmpty(filterMedicineName.Text) || med.Name.ToLower().Contains(filterMedicineName.Text.ToLower()))
                        .Where(med => _neededIngredients.Count <= 0 || med.Ingredients.Any(ingr => _neededIngredients.All(needIngr => ingr.Id == needIngr.Id)))
                        .Where(med => _blockedIngredients.Count <= 0 || med.Ingredients.All(ingr => _blockedIngredients.All(needIngr => ingr.Id != needIngr.Id)))
                        .ToList();


            return(medicines);
        }
Example #19
0
        protected void grvMedicineQuantity_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (grvMedicineQuantity.EditIndex == e.Row.RowIndex)
                {
                    DropDownList ddlMedicineName = (DropDownList)e.Row.FindControl("ddlGridMedicineName");

                    MedicineManager medicineManager = new MedicineManager();
                    ddlMedicineName.DataSource = medicineManager.GetAll();
                    ddlMedicineName.DataBind();

                    var medicineName = (e.Row.FindControl("lblMedicineName") as Label).Text;
                    var selectedItem = ddlMedicineName.Items.FindByValue(medicineName);
                    selectedItem.Selected = true;
                }
            }
        }
Example #20
0
        async void DeleteClicked(object sender, System.EventArgs e)
        {
            ReminderManager reminderManager = ReminderManager.DefaultManager;
            var             temp            = await reminderManager.GetReminderAsync();

            foreach (var t in temp)
            {
                if (t.MedicineId == currentMedicine.Id)
                {
                    await reminderManager.DeleteTaskAsync(t);

                    DeleteNotification(t);
                }
            }
            MedicineManager medicineManager = MedicineManager.DefaultManager;
            await medicineManager.DeleteTaskAsync(currentMedicine);

            App.contentChanged = true;
            await Navigation.PopAsync();
        }
        public IActionResult getMedicineInstanceById(String mId)
        {
            MedicineManager medicineManager = new MedicineManager();
            var             r = medicineManager.getMedicineInstanceById(mId);

            if (r != null && r.Count != 0)
            {
                return(Ok(new JsonCreate()
                {
                    message = Utils.ConstMessage.GET_SUCCESS, data = r
                }));
            }
            else
            {
                return(Ok(new JsonCreate()
                {
                    message = Utils.ConstMessage.NOT_FOUND, data = null
                }));
            }
        }
        public IActionResult getAllMedicineWithSupplier()
        {
            MedicineManager medicineManager = new MedicineManager();
            var             r = medicineManager.getAllMedicineWithSupplier();

            if (r != null && r.Count != 0)
            {
                return(Ok(new JsonCreate()
                {
                    message = Utils.ConstMessage.GET_SUCCESS, data = r
                }));
            }
            else
            {
                return(Ok(new JsonCreate()
                {
                    message = Utils.ConstMessage.NOT_FOUND, data = null
                }));
            }
        }
Example #23
0
    protected void lbEdit_Click(object sender, EventArgs e)
    {
        ImageButton linkButton = new ImageButton();

        linkButton = (ImageButton)sender;
        int id;

        id = Convert.ToInt32(linkButton.CommandArgument);

        MedicationTime medicationTime = MedicationTimeManager.GetMedicationTimeByID(id);

        hfMedicationTimeID.Value = medicationTime.MedicationTimeID.ToString();
        txtTakingTime.Text       = medicationTime.TakingTime == "PRN" ? "" : medicationTime.TakingTime;
        chkPRN.Checked           = medicationTime.TakingTime == "PRN" ? true : false;
        string medicationName = MedicineManager.GetMedicineByID(medicationTime.MedicineID).MedicineName;
        int    medicaitonID   = 0;

        foreach (ListItem item in ddlMedicine.Items)
        {
            if (item.Text == medicationName)
            {
                medicaitonID = int.Parse(item.Value);
            }
        }

        ddlMedicine.SelectedValue = medicaitonID.ToString();


        txtQuantity.Text              = medicationTime.Quantity;
        txtQuality.Text               = medicationTime.Quality;
        txtFrequency.Text             = medicationTime.Frequency;
        txtEXNo.Text                  = medicationTime.ExtraField1;
        ddlRouteOfAdmin.SelectedValue = medicationTime.ExtraField2;
        txtAmount.Text                = medicationTime.ExtraField3;
        txtpharmacyName.Text          = medicationTime.ExtraField4;
        ddlStatus.SelectedValue       = medicationTime.ExtraField6 != null ? medicationTime.ExtraField6 : "Active";
        //chkAddDischargeRecord.Checked=bool.Parse(medicationTime.ExtraField5);
    }
Example #24
0
        async void StartClicked(object sender, EventArgs e)
        {
            if (!ValidCheck())
            {
                await DisplayAlert("Notice!", "Please fill name, The cycle of medication, Frequency and Basic unit", "Sure");

                return;
            }
            if (currentMedicine.IsTaking)
            {
                await DisplayAlert("Notice:", "Please end this medication first!", "Ok");

                return;
            }
            var result = await DisplayAlert("Notices", "Your new reminders starts from " + currentMedicine.StartTime.ToString("dd/MMM/yyyy dddd")
                                            + " with " + currentMedicine.TimesPerDay + " times per day. Are you sure to activate?", "Sure", "Cancel");

            if (result)
            {
                currentMedicine.IsTaking = true;
                if (currentMedicine.TimesPerDay >= 1)
                {
                    Reminder reminder = new Reminder
                    {
                        Id           = Guid.NewGuid().ToString(),
                        UserId       = App.email,
                        MedicineId   = currentMedicine.Id,
                        MedicineName = currentMedicine.MedicineName,
                        Unit         = currentMedicine.Unit,
                        Checked      = false
                    };
                    ReminderManager reminderManager = ReminderManager.DefaultManager;
                    reminder.Time = timePicker1.Time;
                    reminder.SetTimeToDisplay();
                    reminder.SetUnChecked();
                    await reminderManager.SaveTaskAsync(reminder, true);

                    SetNotification(reminder);
                    if (currentMedicine.TimesPerDay >= 2)
                    {
                        reminder = new Reminder
                        {
                            Id           = Guid.NewGuid().ToString(),
                            UserId       = App.email,
                            MedicineId   = currentMedicine.Id,
                            MedicineName = currentMedicine.MedicineName,
                            Unit         = currentMedicine.Unit,
                            Checked      = false
                        };
                        reminder.Time = timePicker2.Time;
                        reminder.SetTimeToDisplay();
                        reminder.SetUnChecked();
                        await reminderManager.SaveTaskAsync(reminder, true);

                        SetNotification(reminder);
                        if (currentMedicine.TimesPerDay >= 3)
                        {
                            reminder = new Reminder
                            {
                                Id           = Guid.NewGuid().ToString(),
                                UserId       = App.email,
                                MedicineId   = currentMedicine.Id,
                                MedicineName = currentMedicine.MedicineName,
                                Unit         = currentMedicine.Unit,
                                Checked      = false
                            };
                            reminder.Time = timePicker3.Time;
                            reminder.SetTimeToDisplay();
                            reminder.SetUnChecked();
                            await reminderManager.SaveTaskAsync(reminder, true);

                            SetNotification(reminder);
                            if (currentMedicine.TimesPerDay >= 4)
                            {
                                reminder = new Reminder
                                {
                                    Id           = Guid.NewGuid().ToString(),
                                    UserId       = App.email,
                                    MedicineId   = currentMedicine.Id,
                                    MedicineName = currentMedicine.MedicineName,
                                    Unit         = currentMedicine.Unit,
                                    Checked      = false
                                };
                                reminder.Time = timePicker4.Time;
                                reminder.SetTimeToDisplay();
                                reminder.SetUnChecked();
                                await reminderManager.SaveTaskAsync(reminder, true);

                                SetNotification(reminder);
                                if (currentMedicine.TimesPerDay >= 5)
                                {
                                    reminder = new Reminder
                                    {
                                        Id           = Guid.NewGuid().ToString(),
                                        UserId       = App.email,
                                        MedicineId   = currentMedicine.Id,
                                        MedicineName = currentMedicine.MedicineName,
                                        Unit         = currentMedicine.Unit,
                                        Checked      = false
                                    };
                                    reminder.Time = timePicker5.Time;
                                    reminder.SetTimeToDisplay();
                                    reminder.SetUnChecked();
                                    await reminderManager.SaveTaskAsync(reminder, true);

                                    SetNotification(reminder);
                                    if (currentMedicine.TimesPerDay >= 6)
                                    {
                                        reminder = new Reminder
                                        {
                                            Id           = Guid.NewGuid().ToString(),
                                            UserId       = App.email,
                                            MedicineId   = currentMedicine.Id,
                                            MedicineName = currentMedicine.MedicineName,
                                            Unit         = currentMedicine.Unit,
                                            Checked      = false
                                        };
                                        reminder.Time = timePicker6.Time;
                                        reminder.SetTimeToDisplay();
                                        reminder.SetUnChecked();
                                        await reminderManager.SaveTaskAsync(reminder, true);

                                        SetNotification(reminder);
                                    }
                                }
                            }
                        }
                    }
                }

                currentMedicine.Max = int.Parse(currentMedicine.Duration);
                MedicineManager medicineManager = MedicineManager.DefaultManager;
                await medicineManager.SaveTaskAsync(currentMedicine, isNewItem);

                App.contentChanged = true;
                await Navigation.PopAsync();
            }
        }
 private void showMedicineGrid()
 {
     gvMedicine.DataSource = MedicineManager.GetAllMedicines();
     gvMedicine.DataBind();
 }
Example #26
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtNewMedicine.Text != "")
        {
            Medicine medicine = new Medicine();

            medicine.MedicineName = txtNewMedicine.Text;
            medicine.MedicineID   = MedicineManager.InsertMedicine(medicine);
            loadMedicine();
            ddlMedicine.SelectedValue = medicine.MedicineID.ToString();
        }
        if (hfMedicationTimeID.Value == "0")
        {
            //if (!txtTakingTime.Text.Contains(","))
            //{
            //    txtTakingTime.Text = txtTakingTime.Text + ",";
            //}

            //foreach (string item in txtTakingTime.Text.Split(','))
            //{
            //    if (item != "")
            //    {
            MedicationTime medicationTime = new MedicationTime();

            medicationTime.TakingTime   = chkPRN.Checked ? "PRN" : txtTakingTime.Text;
            medicationTime.MedicineID   = Int32.Parse(ddlMedicine.SelectedValue);
            medicationTime.ResidentID   = Int32.Parse(Request.QueryString["ResidentID"]);
            medicationTime.Quantity     = txtQuantity.Text;
            medicationTime.Quality      = txtQuality.Text;
            medicationTime.Frequency    = txtFrequency.Text;
            medicationTime.ExtraField1  = txtEXNo.Text;
            medicationTime.ExtraField2  = ddlRouteOfAdmin.SelectedValue;
            medicationTime.ExtraField3  = txtAmount.Text;
            medicationTime.ExtraField4  = txtpharmacyName.Text;
            medicationTime.ExtraField5  = chkAddDischargeRecord.Checked.ToString();
            medicationTime.ExtraField6  = ddlStatus.SelectedValue;
            medicationTime.ExtraField7  = "";
            medicationTime.ExtraField8  = "";
            medicationTime.ExtraField9  = "";
            medicationTime.ExtraField10 = "";
            medicationTime.AddedBy      = getLogin().LoginID;
            medicationTime.AddedDate    = DateTime.Now;
            medicationTime.UpdateBy     = getLogin().LoginID;
            medicationTime.UpdateDate   = DateTime.Now;
            int resutl = MedicationTimeManager.InsertMedicationTime(medicationTime);
            lblNewMedicationAddedSuccessfully.Text = "Added Successfully";

            //    }
            //}
        }
        else
        {
            MedicationTime medicationTime = new MedicationTime();
            medicationTime.MedicationTimeID = int.Parse(hfMedicationTimeID.Value);
            medicationTime.TakingTime       = chkPRN.Checked ? "PRN" : txtTakingTime.Text;
            medicationTime.MedicineID       = Int32.Parse(ddlMedicine.SelectedValue);
            medicationTime.ResidentID       = Int32.Parse(Request.QueryString["ResidentID"]);
            medicationTime.Quantity         = txtQuantity.Text;
            medicationTime.Quality          = txtQuality.Text;
            medicationTime.Frequency        = txtFrequency.Text;
            medicationTime.ExtraField1      = txtEXNo.Text;
            medicationTime.ExtraField2      = ddlRouteOfAdmin.SelectedValue;
            medicationTime.ExtraField3      = txtAmount.Text;
            medicationTime.ExtraField4      = txtpharmacyName.Text;
            medicationTime.ExtraField5      = chkAddDischargeRecord.Checked.ToString();
            medicationTime.ExtraField6      = ddlStatus.SelectedValue;
            medicationTime.ExtraField7      = "";
            medicationTime.ExtraField8      = "";
            medicationTime.ExtraField9      = "";
            medicationTime.ExtraField10     = "";
            medicationTime.AddedBy          = getLogin().LoginID;
            medicationTime.AddedDate        = DateTime.Now;
            medicationTime.UpdateBy         = getLogin().LoginID;
            medicationTime.UpdateDate       = DateTime.Now;

            MedicationTimeManager.UpdateMedicationTime(medicationTime);
            hfMedicationTimeID.Value = "0";
            lblNewMedicationAddedSuccessfully.Text = "Update Successfully";
        }

        lblMsg.Visible = false;
        lblNewMedicationAddedSuccessfully.Visible = true;
        //ddlMedicine.SelectedValue = "0";
        //txtTakingTime.Text = "";
        //txtQuality.Text = "";
        //txtQuantity.Text = "";
        //txtFrequency.Text = "";

        loadGrid();
    }
Example #27
0
        async void EndClicked(object sender, EventArgs e)
        {
            var startday = new DateTime(currentMedicine.StartTime.Year, currentMedicine.StartTime.Month, currentMedicine.StartTime.Day);
            var diff     = DateTime.Now - startday;

            var difff = diff.Days + 1;

            if (difff < int.Parse(currentMedicine.Duration))
            {
                var res = await DisplayAlert("Notice!", "You haven't finished this medication. Are you sure to terminate it early? ", "Yes", "No");

                if (res)
                {
                    //delete related reminders
                    ReminderManager reminderManager = ReminderManager.DefaultManager;
                    var             temp            = await reminderManager.GetReminderAsync();

                    foreach (var t in temp)
                    {
                        if (t.MedicineId == currentMedicine.Id)
                        {
                            await reminderManager.DeleteTaskAsync(t);

                            DeleteNotification(t);
                        }
                    }
                    //delete thie medicine

                    MedicineManager medicineManager = MedicineManager.DefaultManager;
                    await medicineManager.DeleteTaskAsync(currentMedicine);

                    App.contentChanged = true;

                    //set a new medicine history
                    MedicineHistory medicineHistory = new MedicineHistory
                    {
                        Id                  = Guid.NewGuid().ToString(),
                        UserId              = App.email,
                        MedicineName        = currentMedicine.MedicineName,
                        Directions          = currentMedicine.Directions,
                        TimeToDisplay       = currentMedicine.StartTime.ToString("dd/MMM/yyyy ddd") + " - " + DateTime.Now.ToString("dd/MMM/yyyy ddd"),
                        Description         = currentMedicine.Description,
                        Duration            = currentMedicine.Duration,
                        TimesPerDay         = currentMedicine.TimesPerDay,
                        Unit                = currentMedicine.Unit,
                        StartTime           = currentMedicine.StartTime,
                        DirectionsToDisplay = currentMedicine.TimesPerDay + " times a day, " + currentMedicine.Unit + " each time",
                        IsDone              = false,
                        IsUnDone            = true
                    };
                    if (currentMedicine.TimesPerDay == 1)
                    {
                        medicineHistory.DirectionsToDisplay = "Once a day, " + currentMedicine.Unit + " each time";
                    }

                    medicineHistory.Duration = difff.ToString();
                    MedicineHistoryManager medicineHistoryManager = MedicineHistoryManager.DefaultManager;
                    await medicineHistoryManager.SaveTaskAsync(medicineHistory, true);
                    await DisplayAlert("Notice:", "You have ended this medicine!", "OK");
                }
            }
            else
            {
                //delete related reminders
                ReminderManager reminderManager = ReminderManager.DefaultManager;
                var             temp            = await reminderManager.GetReminderAsync();

                foreach (var t in temp)
                {
                    if (t.MedicineId == currentMedicine.Id)
                    {
                        await reminderManager.DeleteTaskAsync(t);

                        DeleteNotification(t);
                    }
                }
                //delete thie medicine
                MedicineManager medicineManager = MedicineManager.DefaultManager;
                await medicineManager.DeleteTaskAsync(currentMedicine);

                App.contentChanged = true;


                //set a new medicine history
                MedicineHistory medicineHistory = new MedicineHistory
                {
                    Id                  = Guid.NewGuid().ToString(),
                    UserId              = App.email,
                    MedicineName        = currentMedicine.MedicineName,
                    Directions          = currentMedicine.Directions,
                    TimeToDisplay       = currentMedicine.StartTime.ToString("dd/MMM/yyyy ddd") + " - " + DateTime.Now.ToString("dd/MMM/yyyy ddd"),
                    Description         = currentMedicine.Description,
                    Duration            = currentMedicine.Duration,
                    TimesPerDay         = currentMedicine.TimesPerDay,
                    Unit                = currentMedicine.Unit,
                    StartTime           = currentMedicine.StartTime,
                    DirectionsToDisplay = currentMedicine.TimesPerDay + " times a day, " + currentMedicine.Unit + " each time",
                    IsDone              = true,
                    IsUnDone            = false
                };
                if (currentMedicine.TimesPerDay == 1)
                {
                    medicineHistory.DirectionsToDisplay = "Once a day, " + currentMedicine.Unit + " each time";
                }

                medicineHistory.Duration = difff.ToString();
                MedicineHistoryManager medicineHistoryManager = MedicineHistoryManager.DefaultManager;
                await medicineHistoryManager.SaveTaskAsync(medicineHistory, true);
                await DisplayAlert("Notice:", "You have ended this medicine!", "OK");
            }

            await Navigation.PopAsync();
        }