Ejemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string currentDirectory = Directory.GetCurrentDirectory() + "\\Store Files";
            string filename         = null;
            string filepath         = null;

            // Reading from file using open file dialogue
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = currentDirectory;

            // Show only .txt files
            openFile.Filter = "inv files (*.inv)|*.inv|All files (*.*)|*.*";

            // Show actual dialog
            openFile.ShowDialog();

            try
            {
                // Store filename
                filepath = openFile.FileName;
                filename = Path.GetFileNameWithoutExtension(filepath);

                StoreForm storeForm = new StoreForm(filename, filepath);
                storeForm.MdiParent = this;
                storeForm.Show();

                insertToolStripMenuItem.Enabled = true;
                updateToolStripMenuItem.Enabled = true;
                deleteToolStripMenuItem.Enabled = true;
                saveToolStripMenuItem.Enabled   = true;
            }

            catch
            {
                return;
            }
        }
Ejemplo n.º 2
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // create new file and child window then display child window
            string filename = null;

            GetFileName storeNameDialog;

            storeNameDialog = new GetFileName();
            storeNameDialog.ShowDialog();

            filename = storeNameDialog.file_Name1.FilenameVal;

            if (filename != null)
            {
                storeForm           = new StoreForm(filename);
                storeForm.MdiParent = this;
                storeForm.Show();

                insertToolStripMenuItem.Enabled = true;
                updateToolStripMenuItem.Enabled = true;
                deleteToolStripMenuItem.Enabled = true;
                saveToolStripMenuItem.Enabled   = true;
            }
        }