private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            ButtonPressed = true;

            /// delete from database and update list

            if (fromControl == (int)ControlTypes.UserPanel)
            {
                UserControl uc = ((((this.Parent as Grid).Parent as Grid).Parent as Grid).Parent as UserControl);
                UserPanel   up = (uc as UserPanel);

                CustomMessageBox cmb = new CustomMessageBox((int)MessageBoxColorTypes.yellow, "Sunteti sigur ca doriti sa stergeti acest anunt?", up, MessageBoxButton.YesNo);


                if (cmb.ShowDialog() == true)
                {
                    if (ad.DeleteFromDataBase())
                    {
                        up.ads.RemoveAt(up.ads.FindIndex(x => x == adID));
                        up.ResetAds();

                        DeleteImages();

                        cmb = new CustomMessageBox((int)MessageBoxColorTypes.green, "Anuntul a fost sters cu succes!", up, MessageBoxButton.OK);
                        cmb.ShowDialog();
                    }
                    else
                    {
                        cmb = new CustomMessageBox((int)MessageBoxColorTypes.red, "A aparut o eroare, daca problema persista va rugam sa contactati un administrator!", up, MessageBoxButton.OK);
                        cmb.ShowDialog();
                    }
                }
            }
            else if (fromControl == (int)ControlTypes.AdvertisementsPage)
            {
                UserControl        uc = (((this.Parent as Grid).Parent as Grid).Parent as UserControl);
                AdvertisementsPage ac = (uc as AdvertisementsPage);

                CustomMessageBox cmb = new CustomMessageBox((int)MessageBoxColorTypes.yellow, "Sunteti sigur ca doriti sa stergeti acest anunt?", ac, MessageBoxButton.YesNo);

                if (cmb.ShowDialog() == true)
                {
                    if (ad.DeleteFromDataBase())
                    {
                        ac.adIds.RemoveAt(ac.adIds.FindIndex(x => x == adID));
                        ac.ResetAds();

                        DeleteImages();

                        cmb = new CustomMessageBox((int)MessageBoxColorTypes.green, "Anuntul a fost sters cu succes!", uc, MessageBoxButton.OK);
                        cmb.ShowDialog();
                    }
                    else
                    {
                        cmb = new CustomMessageBox((int)MessageBoxColorTypes.red, "A aparut o eroare, daca problema persista va rugam sa contactati un administrator!", uc, MessageBoxButton.OK);
                        cmb.ShowDialog();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnDeleteAdd_Click(object sender, RoutedEventArgs e)
        {
            /// delete add from data base and mark the report as verified
            ad.DeleteFromDataBase();
            MarkAsVerified();

            DeleteImages();

            CustomMessageBox cmb = new CustomMessageBox((int)MessageBoxColorTypes.green, "Anuntul a fost sters cu succes!", this, MessageBoxButton.OK);

            cmb.ShowDialog();
            this.Content = new SettingsControl(true, 1);
        }