예제 #1
0
        private void åbnSagssystemMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "SagsSystem data (.ssy)|*.ssy|All Files (*.*)|*.*";
            dlg.FilterIndex = 1;
            dlg.FileName    = (string)rk.GetValue("Lastfile");
            if (dlg.FileName == null)
            {
                dlg.FileName = "";
            }
            DialogResult result = dlg.ShowDialog();

            if (result == DialogResult.OK)
            {
                rk.SetValue("Lastfile", dlg.FileName);
                try
                {
                    FileStream      fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read, FileShare.None);
                    BinaryFormatter bf = new BinaryFormatter();
                    detteSagsSystem = (SagSystemClass)bf.Deserialize(fs);
                    fs.Close();
                    alleProjekter = detteSagsSystem.projekter;
                    alleSager     = detteSagsSystem.sager;
                    alleOBSer     = detteSagsSystem.obser;
                    projektTilSkærm(findProjekt(1));
                    lastFile = dlg.FileName;
                    SøgTextBox.Focus();        // Place cursor
                }
                catch (Exception err)
                {
                    MessageBox.Show("Cannot Read File: " + err.ToString(), "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
예제 #2
0
        private void HomeBase_Load(object sender, EventArgs e)
        {
            rk = Microsoft.Win32.Registry.CurrentUser;
            rk = rk.CreateSubKey(@"Projekter\SagsSystem");

            lastFile = (string)rk.GetValue("Lastfile");
            try
            {
                FileStream      fs = new FileStream(lastFile, FileMode.Open, FileAccess.Read, FileShare.None);
                BinaryFormatter bf = new BinaryFormatter();
                detteSagsSystem = (SagSystemClass)bf.Deserialize(fs);
                fs.Close();
                alleProjekter = detteSagsSystem.projekter;
                alleSager     = detteSagsSystem.sager;
                alleOBSer     = detteSagsSystem.obser;
                projektTilSkærm(findProjekt(1));
                SøgTextBox.Focus();        // Place cursor
            }
            catch (Exception err)
            {
                MessageBox.Show("Cannot Read File: " + err.ToString(), "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }