Example #1
0
        // Добавляем данные
        void btnAddData_Click(object sender, RoutedEventArgs e)
        {
            var win = new NewDataWindow {
                Owner = this
            };

            if (win.ShowDialog() != true || string.IsNullOrEmpty(win.FinalUrl))
            {
                return;
            }

            var sIcon = "";

            if (!string.IsNullOrWhiteSpace(win.FinalIconName))
            {
                sIcon = win.FinalIconName;
            }

            var data = new DBData {
                Url = win.FinalUrl, Description = win.FinalDescription, Icon = sIcon
            };

            var eMessage = "";

            if (!SQLManager.TryAddData(data, currentSessionPassword, out eMessage))
            {
                MessageBox.Show(eMessage, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            values.Add(data);
            listDB.SelectedItem = data;
        }
Example #2
0
        // редактировать данные
        void btnEditData_Click(object sender, RoutedEventArgs e)
        {
            var data = listDB.SelectedItem as DBData;

            if (data == null)
            {
                return;
            }

            var win = new NewDataWindow {
                Owner = this, FinalDescription = data.Description, FinalUrl = data.Url, FinalIconName = data.Icon
            };

            if (win.ShowDialog() != true || string.IsNullOrEmpty(win.FinalUrl))
            {
                return;
            }

            var sIcon = "";

            if (!string.IsNullOrWhiteSpace(win.FinalIconName))
            {
                sIcon = win.FinalIconName;
            }

            var tmp = new DBData
            {
                Id          = data.Id,
                Url         = win.FinalUrl,
                Description = win.FinalDescription,
                Icon        = sIcon,
            };

            var eMessage = "";

            if (!SQLManager.TrUpdateData(tmp, currentSessionPassword, out eMessage))
            {
                MessageBox.Show(eMessage, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            data.Url         = tmp.Url;
            data.Description = tmp.Description;
            data.Icon        = tmp.Icon;
        }