deleteRow() 공개 정적인 메소드

public static deleteRow ( Row temp ) : void
temp Row
리턴 void
예제 #1
0
        private void Delete_Click(object sender, EventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure?", "Delete", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                Table.Remove(Edit_Query[0]);
                DB_Helper.deleteRow(Edit_Query[0]);
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
예제 #2
0
        private void SaveLocation_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            user_feedback.VibrateOnItemSelected();
            String temp_Radius     = "0";
            String temp_Note       = "";
            String temp_RingTones  = "";
            String temp_icon_light = "";
            String temp_icon_dark  = "";
            String error           = "";

            if (Title.Text == "" && error == "")
            {
                error = "Title";
            }

            // check if radius contains more than one "."
            int count = 0;

            if (Radius.Visibility == Visibility.Visible && error == "")
            {
                for (int i = 0; i < Radius.Text.Count(); i++)
                {
                    if (Radius.Text.ElementAt(i).Equals('.'))
                    {
                        count++;
                    }
                }
                if (count > 1)
                {
                    error = "Radius";
                }
                else if (Radius.Text == "." || Radius.Text == "")
                {
                    error = "Radius";
                }
                else if (Convert.ToDouble(Radius.Text) > 0)
                {
                    // do nothing, radius is greater than 0
                }
                else
                {
                    error = "Radius";
                }
            }

            if (Radius.Visibility == Visibility.Visible && (Radius.Text == "" || Radius.Text == "0" || Radius.Text == "." || Radius.Text == "0.0" || Radius.Text == "0." || Radius.Text == ".0") && error == "")
            {
                error = "Radius";
            }
            if (Note.Visibility == Visibility.Visible && Note.Text == "" && error == "")
            {
                error = "Note";
            }
            if (Location.Visibility == Visibility.Visible)
            {
                if (Location.Text == "" && error == "")
                {
                    error = "Location";
                }
            }

            if (error != "")
            {
                if (error != "Radius")
                {
                    MessageBox.Show(error + " cannot be empty ", "", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show(error + " cannot be empty or 0", "", MessageBoxButton.OK);
                }
            }
            else
            {
                if (Radius.Visibility == Visibility.Visible)
                {
                    temp_Radius = Radius.Text;
                }
                if (Ring_Tones.Visibility == Visibility.Visible)
                {
                    temp_RingTones = (String)Ring_Tones.SelectedItem;
                }
                if (Note.Visibility == Visibility.Visible)
                {
                    temp_Note = Note.Text;
                }
                switch ((String)Type.SelectedItem)
                {
                case "Alarm":
                    temp_icon_dark  = "/Images/Mode.png/";
                    temp_icon_light = "/Images/Mode_Dark.png/";
                    break;

                case "Car Locator":
                    temp_icon_dark  = "/Images/PushpinCar.png/";
                    temp_icon_light = "/Images/PushpinCar_Dark.png/";
                    break;

                case "Ring Tones":
                    temp_icon_dark  = "/Images/Location.png/";
                    temp_icon_light = "/Images/Location_Dark.png/";
                    break;

                default:
                    temp_icon_dark  = "/Images/PushpinCar.png/";
                    temp_icon_light = "/Images/PushpinCar_Dark.png/";
                    break;
                }
                if (!new_page)//Edit Page
                {
                    if ((old_title != Title.Text) || (old_radius != temp_Radius) || (old_ringtones != temp_RingTones) || (old_type != (String)Type.SelectedItem) || (old_note != temp_Note))
                    {
                        Table.Remove(Edit_Query[0]);
                        DB_Helper.deleteRow(Edit_Query[0]);

                        // Create a new to-do item based on the text box.
                        Row newRow = new Row {
                            Title = Title.Text, longitude = longitude, latitude = latitude, Radius = Double.Parse(temp_Radius), Ring_Tones = temp_RingTones, Type = (String)Type.SelectedItem, Note = temp_Note, Icon_Source_Dark = temp_icon_dark, Icon_Source_Light = temp_icon_light
                        };

                        // Add a to-do item to the observable collection.
                        Table.Add(newRow);

                        DB_Helper.insertRow(newRow);
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                    else
                    {
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                }
                else// New Page
                {
                    if (DB_Helper.getRowsbyTitle(Title.Text).Count != 0)
                    {
                        MessageBox.Show("The title is already used ", "", MessageBoxButton.OK);
                    }
                    else
                    {
                        Row newRow = new Row {
                            Title = Title.Text, longitude = longitude, latitude = latitude, Radius = Double.Parse(temp_Radius), Ring_Tones = temp_RingTones, Type = (String)Type.SelectedItem, Note = temp_Note, Icon_Source_Dark = temp_icon_dark, Icon_Source_Light = temp_icon_light
                        };

                        Table.Add(newRow);
                        DB_Helper.insertRow(newRow);

                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                }
            }

            user_feedback.Speak("Location Saved");
            avoiddouble = true;
        }