Ejemplo n.º 1
0
        private void DataGridCompetition_P_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var indexSeletected = DataGridCompetition_P.SelectedIndex;

            var id = (int)_columnIds2[indexSeletected];

            var competition = new CompetitionDto {
                ID = id
            };

            var service = new CompetitionService();

            bytes = service.GetRules(competition);

            if (bytes != null)
            {
                using (var fbd = new FolderBrowserDialog()) {
                    var result = fbd.ShowDialog();

                    if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                    {
                        var path     = fbd.SelectedPath;
                        var service1 = new CompetitionService();
                        var nombre   = service1.SearchCompetitionById(competition).Name;
                        var filename = $"Reglamento de {nombre}.pdf";

                        var absolutePath = Path.Combine(path, filename);
                        for (var count = 1; File.Exists(absolutePath); count++)
                        {
                            filename     = $"Reglamento de {nombre} (Copia {count}).pdf";
                            absolutePath = Path.Combine(path, filename);
                        }

                        var writer = new BinaryWriter(File.Open(absolutePath, FileMode.CreateNew));

                        writer.Write(bytes);

                        writer.Close();

                        Process.Start(absolutePath);
                    }
                }
            }
        }