Пример #1
0
        private void buCreate_Click(object sender, RoutedEventArgs e)
        {
            string result = "";

            switch (cbReportType.SelectedIndex)
            {
            case 0: if (lbTurns.SelectedItem != null)
                {
                    result = CreateReport0();
                }
                else
                {
                    MessageBox.Show("Выберите направление");
                } break;

            case 1: try { int.Parse(tbWindowId.Text); result = CreateReport1(); } catch (Exception ex) { MessageBox.Show(ex.Message); } break;
            }
            if (result != "")
            {
                System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                sfd.InitialDirectory = InitialDirectory;
                sfd.Filter           = "Report for Excel|*.xml";
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK && sfd.FileName != "")
                {
                    System.IO.StreamWriter w = new System.IO.StreamWriter(sfd.OpenFile(), Encoding.UTF8);
                    w.Write(result);
                    w.Close();
                    PropertiesFile props = new PropertiesFile(AppDomain.CurrentDomain.BaseDirectory + "properties.properties");
                    props.set("InitialDirectory", System.IO.Path.GetFullPath(sfd.FileName));
                    props.Save();
                }
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            turns = new ObservableCollection <CTurn>();
            PropertiesFile props = new PropertiesFile(AppDomain.CurrentDomain.BaseDirectory + "properties.properties");

            DBHost           = props.get("DBHost", "127.0.0.1");
            DBPort           = props.get("DBPort", "5432");
            DBUser           = props.get("DBUser", "postgres");
            DBPass           = props.get("DBPass", "post");
            DBName           = props.get("DBName", "turnlive2");
            InitialDirectory = props.get("InitialDirectory", "C:\\");
            DBGetTurns();
        }