Exemplo n.º 1
0
        // Saves when the form closes
        private void employeeAdd_FormClosed(object sender, FormClosedEventArgs e)
        {
            Form1.currentStaff = original;
            SaveToFile.serializeAll();

            if (action == 1 && Form1.currentStaff.Count > 0)
            {
                employeeSelect eS = new employeeSelect();
                eS.ShowDialog();
            }
        }
Exemplo n.º 2
0
        // When form is closing
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (Form1.currentStaff.Count == 0)
            {
                File.Delete(filepath + "\\Employees.xml");
            }

            SaveToFile.serializeAll();

            // Perform backup if necessary
            backupFunction.performBackup(filepath);
        }
Exemplo n.º 3
0
        // Sets the filepath for the program and populates the directories
        private void setFilepath()
        {
            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }

            // If the file does not already exist, create it, otherwise, deserialize
            if (!File.Exists(filepath + "\\InstrumentData.xml"))
            {
                File.Create(filepath + "\\InstrumentData.xml").Close();
            }
            else
            {
                SaveToFile.deserialize(0);
                instrumentList.DataSource = allInstruments;
            }

            // If the file does not already exist, create it, otherwise, deserialize
            if (!File.Exists(filepath + "\\StudentData.xml"))
            {
                File.Create(filepath + "\\StudentData.xml").Close();
            }
            else
            {
                SaveToFile.deserialize(1);
            }

            // If the file does not already exist, create it, otherwise, deserialize
            if (!File.Exists(filepath + "\\Employees.xml"))
            {
                File.Create(filepath + "\\Employees.xml").Close();

                // Add employee dialoge
                employeeAdd eA = new employeeAdd(0);
                eA.ShowDialog();
            }
            else
            {
                SaveToFile.deserialize(2);
            }

            Refresh();
        }
Exemplo n.º 4
0
        // Import backup
        private void importButton_Click(object sender, EventArgs e)
        {
            // If there employee isn't empty and if they have admin permissions
            if (currentEmployee != null && currentEmployee.password != null)
            {
                // File explorer
                string         fullPath = "";
                OpenFileDialog ofd      = new OpenFileDialog();

                // filter out filetypes
                ofd.Filter = "Backup Files|*.icrb";

                // Create filepath
                string sfdname = ofd.FileName;
                ofd.InitialDirectory = filepath + "\\LibraryData\\Backups";

                // If ok is clicked, backup
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    Path.GetFullPath(ofd.FileName);

                    // Warn the user that their information will be overwritten and there will be no way to undo it
                    askBackupForm aBF = new askBackupForm();
                    aBF.ShowDialog();

                    fullPath = Path.GetFullPath(ofd.FileName);

                    SaveToFile.populateBackup(fullPath);
                    Refresh();
                }
            }
            else
            {
                adminForm();
            }
        }
Exemplo n.º 5
0
 // Saves to a file
 private void saveButton_Click(object sender, EventArgs e)
 {
     SaveToFile.serializeAll();
 }