예제 #1
0
        private void Button_Save_Configuration_Click(object sender, RoutedEventArgs e)
        {
            SaveDialog dialog = new SaveDialog();

            dialog.ShowDialog();
            string SaveName = dialog.TextBox_Save_Name.Text;

            if (!string.IsNullOrEmpty(SaveName))
            {
                SaveConfigModel model = new SaveConfigModel()
                {
                    Name                 = SaveName,
                    Address              = TextBox_IP.Text,
                    Username             = TextBox_Username.Text,
                    Password             = TextBox_Password.Text,
                    CurrentConnectorType = ComboBox_SqlType.SelectedItem.ToString(),
                };

                Saves.Add(model);

                var result = JsonMethod <SaveConfigModel> .AddData(Saves);

                JsonMethod <SaveConfigModel> .WriteDataJson(Path, result);

                UpdateComboBox_Saves(Saves);
            }
        }
        private void Button_Validate_Click(object sender, RoutedEventArgs e)
        {
            List <SaveConfigModel> saves = JsonMethod <SaveConfigModel> .ReadAllDataJson(Path);

            SaveConfigModel save = saves.Where(x => x.Name == ComboBox_Configuration_Save.SelectedItem.ToString()).FirstOrDefault();

            saves.Remove(save);

            JsonMethod <SaveConfigModel> .WriteDataJson(Path, JsonMethod <SaveConfigModel> .AddData(saves));

            NewSaveConfig = saves;

            this.Close();
        }