Ejemplo n.º 1
0
        public bool CheckDatabaseConnection()
        {
            if (File.Exists(databasePath) && Path.GetExtension(databasePath) == ".s3db")
            {
                try
                {
                    toolStripStatusLabel1.Text = "Database OK";

                    comboBox1.Items.Clear();
                    comboBox2.Items.Clear();
                    foreach (string item in General.GetActivities(databasePath))
                    {
                        comboBox1.Items.Add(item);
                    }
                    foreach (string item in General.GetMentors(databasePath))
                    {
                        comboBox2.Items.Add(item);
                    }
                    General.GetAttendaceSummaryReports(databasePath);
                    return(true);
                }
                catch
                {
                    toolStripStatusLabel1.Text = "ERROR, database cannot be loaded, try again";
                    return(false);
                }
            }
            else
            {
                toolStripStatusLabel1.Text = "ERROR, database cannot be loaded, try again";
            }
            return(false);
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            databasePath = Application.ExecutablePath.Replace("StudentProfileScanner.EXE", "") + "StudentProfileDatabase.s3db";
            if (CheckDatabaseConnection())
            {
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                foreach (string item in General.GetActivities(databasePath))
                {
                    comboBox1.Items.Add(item);
                }
                foreach (string item in General.GetMentors(databasePath))
                {
                    comboBox2.Items.Add(item);
                }

                button8.Text = "Submit Database Data [" + General.GetNumberOfReports(databasePath) + "]";
            }
            else
            {
                MessageBox.Show("There is no database file in the same directory as this application, select the database file using 'Open database' button", "Database loading failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }