Beispiel #1
0
        private async Task <bool> UpdateFirstAidData(BasicFirstAid tempFirstAid)
        {
            docKitName.Text = tempFirstAid.Name;
            docKitFirstAidDescription.Text = "\n" + tempFirstAid.FirstAid;
            docKitFirstAidImage.Source     = await ImageMethods.Base64StringToBitmap(tempFirstAid.Image);

            docKitFirstAidSymptoms.Text = "\n" + tempFirstAid.DoNot;
            return(true);
        }
Beispiel #2
0
        private async void docKitDelItem(object sender, RoutedEventArgs e)
        {
            docKitCmdbar.IsOpen = false;

            //Find the instance of the item which is selected from the DB, then delete it using that instance.
            if (docKitListBox.SelectedItem != null)
            {
                var messageDialog = new MessageDialog("Are you sure you want to delete details for this disease?", "Confirmation");
                messageDialog.Commands.Add(new Windows.UI.Popups.UICommand("Yes", null));
                messageDialog.Commands.Add(new Windows.UI.Popups.UICommand("No", null));
                var dialogResult = await messageDialog.ShowAsync();

                if (dialogResult.Label.Equals("Yes"))
                {
                    if (isDiseaseSelected)
                    {
                        BasicDiseases tempDisease = await diseaseMethods.FindSingleDisease(this.ocString[docKitListBox.SelectedIndex].ToString());

                        await diseaseMethods.DeleteDisease(tempDisease);
                    }
                    else
                    {
                        BasicFirstAid tempDisease = await firstAidMethods.FindSingleFirstAid(this.ocString[docKitListBox.SelectedIndex].ToString());

                        await firstAidMethods.DeleteFirstAid(tempDisease);
                    }
                    this.ocString.RemoveAt(docKitListBox.SelectedIndex);
                    if (this.ocString.Count() > 0)
                    {
                        docKitListBox.SelectedIndex = 0;
                    }
                    else
                    {
                        docKitDelBut.IsEnabled  = false;
                        docKitEditBut.IsEnabled = false;
                        this.hideDiseaseItems();
                        this.hideFirstAidItems();
                    }
                }
            }
        }
Beispiel #3
0
        private async void docKitEditItem(object sender, RoutedEventArgs e)
        {
            docKitCmdbar.IsOpen = false;
            countEnter          = 0;
            if (docKitListBox.SelectedItem != null)
            {
                //Load all the values from the DB. Assertion: Value exist in DB since loaded from list.Also set PK to ReadOnly.
                if (isDiseaseSelected)
                {
                    docKitDialog.IsOpen = true;
                    BasicDiseases tempDisease = await diseaseMethods.FindSingleDisease(this.ocString[docKitListBox.SelectedIndex].ToString());

                    docKitDName.Text        = tempDisease.Name;
                    docKitDDescription.Text = tempDisease.Description;
                    docKitDSymptoms.Text    = tempDisease.Symptoms;
                    docKitDImage.Text       = tempDisease.Name + ".jpg";
                    decodedImage            = tempDisease.Image;
                    isUpdating             = true;
                    docKitDName.IsReadOnly = true;
                    docKitCustomDialogAnimation.Begin();
                }
                else
                {
                    docKitDialogFirstAid.IsOpen = true;
                    BasicFirstAid tempFirstAid = await firstAidMethods.FindSingleFirstAid(this.ocString[docKitListBox.SelectedIndex].ToString());

                    docKitFAName.Text        = tempFirstAid.Name;
                    docKitFADescription.Text = tempFirstAid.FirstAid;
                    docKitFASymptoms.Text    = tempFirstAid.DoNot;
                    docKitFAImage.Text       = tempFirstAid.Name + ".jpg";
                    decodedImage             = tempFirstAid.Image;
                    isUpdating = true;
                    docKitFAName.IsReadOnly = true;
                    docKitCustomDialogAnimationFA.Begin();
                }
            }
        }
Beispiel #4
0
        //////////////////////This methods are for Buttons click events in Dialog Box opened.
        private async void docKitDialogSave(object sender, RoutedEventArgs e)
        {
            if (isDiseaseSelected)
            {
                if (docKitDName.Text.Equals("") || docKitDSymptoms.Text.Equals("") || docKitDDescription.Text.Equals("") || docKitDImage.Text.Equals(""))
                {
                    docKitErrorDescription.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
                else
                {
                    if (decodedImage != null)
                    {
                        if (isUpdating == true)
                        {
                            //Find that object's instance and change its values
                            if (docKitListBox.SelectedItem != null)
                            {
                                BasicDiseases tempDisease = await diseaseMethods.FindSingleDisease(this.ocString[docKitListBox.SelectedIndex].ToString());

                                tempDisease.Name        = docKitDName.Text;
                                tempDisease.Description = docKitDDescription.Text;
                                tempDisease.Image       = decodedImage;
                                tempDisease.Symptoms    = docKitDSymptoms.Text;

                                docKitDSymptoms.Text = ExtraModules.RemoveExtraCommas(docKitDSymptoms.Text);
                                tempDisease.Symptoms = docKitDSymptoms.Text;

                                await diseaseMethods.UpdateDisease(tempDisease);

                                isUpdating             = false;
                                docKitDName.IsReadOnly = false;
                                await this.UpdateDiseaseData(tempDisease);
                            }
                        }
                        else
                        {
                            await diseaseMethods.InsertDisease(new BasicDiseases()
                            {
                                Name = docKitDName.Text, Description = docKitDDescription.Text, Symptoms = ExtraModules.RemoveExtraCommas(docKitDSymptoms.Text), Image = decodedImage
                            });

                            this.ocString.Add(docKitDName.Text);
                            docKitListBox.SelectedIndex = this.ocString.IndexOf(docKitDName.Text);
                            if (ocString.Count() == 1)
                            {
                                this.showDiseaseItems();
                                await this.UpdateDiseaseData(new BasicDiseases()
                                {
                                    Name = docKitDName.Text, Description = docKitDDescription.Text, Symptoms = ExtraModules.RemoveExtraCommas(docKitDSymptoms.Text), Image = decodedImage
                                });

                                docKitDelBut.IsEnabled  = true;
                                docKitEditBut.IsEnabled = true;
                            }
                        }
                        docKitDialog.IsOpen = false;
                        //After everything is stored/Updated in database we need to reset all the fields.
                        this.ClearFormFields();
                    }
                }
            }
            else
            {
                if (docKitFAName.Text.Equals("") || docKitFASymptoms.Text.Equals("") || docKitFADescription.Text.Equals("") || docKitFAImage.Text.Equals(""))
                {
                    docKitFAErrorDescription.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
                else
                {
                    if (isUpdating == true)
                    {
                        if (docKitListBox.SelectedItem != null)
                        {
                            //Find that object's instance and change its values
                            BasicFirstAid tempFirstAid = await firstAidMethods.FindSingleFirstAid(this.ocString[docKitListBox.SelectedIndex].ToString());

                            tempFirstAid.Name     = docKitFAName.Text;
                            tempFirstAid.FirstAid = docKitFADescription.Text;
                            tempFirstAid.Image    = decodedImage;
                            tempFirstAid.DoNot    = docKitFASymptoms.Text;

                            await firstAidMethods.UpdateFirstAid(tempFirstAid);

                            isUpdating = false;
                            docKitFAName.IsReadOnly = false;
                            await this.UpdateFirstAidData(tempFirstAid);
                        }
                    }
                    else
                    {
                        await firstAidMethods.InsertFirstAid(new BasicFirstAid()
                        {
                            Name = docKitFAName.Text, FirstAid = docKitFADescription.Text, DoNot = docKitFASymptoms.Text, Image = decodedImage
                        });

                        this.ocString.Add(docKitFAName.Text);
                        docKitListBox.SelectedIndex = this.ocString.IndexOf(docKitFAName.Text);
                        if (ocString.Count() == 1)
                        {
                            this.showFirstAidItems();
                            await this.UpdateFirstAidData(new BasicFirstAid()
                            {
                                Name = docKitFAName.Text, FirstAid = docKitFADescription.Text, DoNot = docKitFASymptoms.Text, Image = decodedImage
                            });

                            docKitDelBut.IsEnabled  = true;
                            docKitEditBut.IsEnabled = true;
                        }
                    }
                    docKitDialogFirstAid.IsOpen = false;
                    //After everything is stored/Updated in database we need to reset all the fields.
                    this.ClearFormFields();
                }
            }
        }
Beispiel #5
0
 public async Task DeleteFirstAid(BasicFirstAid firstAid)
 {
     await conn.DeleteAsync(firstAid);
 }
Beispiel #6
0
 public async Task UpdateFirstAid(BasicFirstAid firstAid)
 {
     await conn.UpdateAsync(firstAid);
 }
Beispiel #7
0
 public async Task InsertFirstAid(BasicFirstAid firstAid)
 {
     await conn.InsertAsync(firstAid);
 }