Пример #1
0
        private void ExportData(FileTypeEnum storageEnum, bool selected = false, bool all = false)
        {
            var    players      = FilePath.GetBasketballPlayers();
            var    teams        = FilePath.GetTeams();
            var    selectedTeam = lvTeamsOutput.SelectedItem as Teams;
            var    refer        = new ImpExpDB();
            string path;

            refer.DataStorage = storageEnum;
            if (players.Count > 0 && storageEnum.ToString().Contains("player", StringComparison.OrdinalIgnoreCase))
            {
                if (all)
                {
                    refer.ExportPlayerDataFromDB(players.ToArray());
                }
                if (selected)
                {
                    refer.ExportPlayerDataFromDB(selectedTeam.BasketballPlayers.ToArray());
                }
                ToLog("Basketball players data was inserted from database", MessageBoxImage.Information);
                path = refer.GetFilePath();
                ShowFileDialog(path);
                return;
            }
            if (teams.Count > 0 && storageEnum.ToString().Contains("team", StringComparison.OrdinalIgnoreCase))
            {
                if (all)
                {
                    refer.ExportTeamDataFromDB(teams.ToArray());
                }
                if (selected)
                {
                    refer.ExportTeamDataFromDB(selectedTeam);
                }
                ToLog("Team data was inserted from database", MessageBoxImage.Information);
                path = refer.GetFilePath();
                ShowFileDialog(path);
                return;
            }
            else
            {
                ToLog("Database is empty", MessageBoxImage.Error);
            }
        }
Пример #2
0
        private void miImportTeams_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog opnfldlg = new OpenFileDialog();

            opnfldlg.Filter = "Storage Files(*.TXT;*.CSV;*.JSON;*.XML;*.XLSX)|*.TXT;*.CSV;*.JSON;*.XML;*.XLSX";

            string filePath = null;
            var    result   = opnfldlg.ShowDialog();

            if (result == true)
            {
                filePath = opnfldlg.FileName;
            }
            if (string.IsNullOrEmpty(filePath))
            {
                ToLog("You haven't chosen a file", MessageBoxImage.Error);
                return;
            }
            var refer = new ImpExpDB(filePath, false);

            refer.StorageTeamsEmptinessCheck();
            refer.ImportTeamDataToDB();
        }
Пример #3
0
        private void miImportPlayers_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog opnfldlg = new OpenFileDialog();

            opnfldlg.Filter = "Storage Files(*.TXT;*.CSV;*.JSON;*.XML;*.XLSX)|*.TXT;*.CSV;*.JSON;*.XML;*.XLSX";

            string filePath = null;
            var    result   = opnfldlg.ShowDialog();

            if (result == true)
            {
                filePath = opnfldlg.FileName;
            }
            if (string.IsNullOrEmpty(filePath))
            {
                ToLog("You haven't chosen a file", MessageBoxImage.Error);
                return;
            }


            var refer = new ImpExpDB(filePath, true);
            var cont  = (Control)sender;

            refer.StoragePlayersEmptinessCheck();
            if (cont.Name.Contains("all", StringComparison.OrdinalIgnoreCase))
            {
                refer.ImportPlayerDataToDB();
                UpdateInterface();
            }
            if (cont.Name.Contains("selected", StringComparison.OrdinalIgnoreCase))
            {
                var team = lvTeamsOutput.SelectedItem as Teams;
                refer.ImportPlayerDataToDB(true, team);
                UpdateInterface();
            }
        }