Exemplo n.º 1
0
        private void cmdRaport_Click(object sender, EventArgs e)
        {
            RaportSelect rs = new RaportSelect();

            if (rs.ShowDialog() == DialogResult.OK)
            {
                SavingState = SavingStates.Saving;

                string file = Path.GetFullPath(PresenterSettings.raportFolder);
                if (!file.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    file += Path.DirectorySeparatorChar.ToString();
                }
                file += "Raport " + rs.raportDate.Value.ToString("yyyy.MM.dd") + ".xlsx";
                if (File.Exists(file))
                {
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.InitialDirectory = file.Substring(0, file.IndexOf(Path.GetFileName(file)));
                    ofd.Multiselect      = false;
                    ofd.FileName         = file.Substring(file.IndexOf(Path.GetFileName(file)));
                    ofd.Filter           = "Microsoft Excel 2010 File|*.xlsx";
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        file = ofd.FileName;
                    }
                }

                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += Bw_DoWork;
                bw.RunWorkerAsync(400);

                CreateRaport(rs.raportDate.Value, file);
                SavingState = SavingStates.Saved;
            }
            rs.Dispose();
        }
Exemplo n.º 2
0
        private void cmdRaport_Click(object sender, EventArgs e)
        {
            RaportSelect rs = new RaportSelect();
            if (rs.ShowDialog() == DialogResult.OK) {
                SavingState = SavingStates.Saving;

                string file = Path.GetFullPath(PresenterSettings.raportFolder);
                if (!file.EndsWith(Path.DirectorySeparatorChar.ToString())) file += Path.DirectorySeparatorChar.ToString();
                file += "Raport " + rs.raportDate.Value.ToString("yyyy.MM.dd") + ".xlsx";
                if (File.Exists(file)) {
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.InitialDirectory = file.Substring(0, file.IndexOf(Path.GetFileName(file)));
                    ofd.Multiselect = false;
                    ofd.FileName = file.Substring(file.IndexOf(Path.GetFileName(file)));
                    ofd.Filter = "Microsoft Excel 2010 File|*.xlsx";
                    if (ofd.ShowDialog() == DialogResult.OK)
                        file = ofd.FileName;
                }

                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += Bw_DoWork;
                bw.RunWorkerAsync(400);

                CreateRaport(rs.raportDate.Value, file);
                SavingState = SavingStates.Saved;
            }
            rs.Dispose();
        }