Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
                builder.Add("Provider", Properties.Settings.Default.provider);
                builder.Add("Data Source", Properties.Settings.Default.path);

                string connString = builder.ConnectionString;
                OleDbConnection conn = new OleDbConnection(connString);

                conn.Open();
                conn.Close();

                LoadingScreen splashy = new LoadingScreen();
                splashy.Show();

                Application.Run(new Form1(splashy));

                /*Form1 f = new Form1();
                f.Show();*/

            }
            catch
            {
                Application.Run(new ConnectionDefinition());
                /*ConnectionDefinition c = new ConnectionDefinition();
                c.Show();*/
            }

            //Application.Run(/*new ConnectionDefinition()*/);
        }
        private void btPotvrdi_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(tbPutanja.Text) || (op.CheckPathExists == false || op.CheckFileExists == false))
            {
                MessageBox.Show("Proverite da li ste uneli sve podatke kako treba!", "Greška!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string newConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + tbPutanja.Text;

            OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();

            builder.Add("Provider", "Microsoft.ACE.OLEDB.12.0");
            builder.Add("Data source", tbPutanja.Text);

            Program.ChangeConnectionString(builder.DataSource, builder.Provider);
            Properties.Settings.Default.Save();

            try
            {
                OleDbConnection dbConn = new OleDbConnection(builder.ConnectionString);
                dbConn.Open();
                dbConn.Close();
            }
            catch
            {
                MessageBox.Show("Lokacija baze ili naziv fajla nije ispravan! Moraćete ponovo da je definišete.", "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            LoadingScreen s = new LoadingScreen();
            Form1 f = new Form1(s);
            this.Hide();
            f.Show();
        }
Esempio n. 3
0
        public Form1(LoadingScreen splashy)
        {
            _splashy = splashy;
            InitializeComponent();

            OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
            builder.Add("Provider", Properties.Settings.Default.provider);
            builder.Add("Data Source", Properties.Settings.Default.path);
            connString = builder.ConnectionString;
            try
            {
                dbConn = new OleDbConnection(connString);
                dbConn.Open();
                loadDataGrid(query);
                dbConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            gridPacijenti.Columns[0].ReadOnly = true;
            gridPacijenti.Columns[0].DefaultCellStyle.ForeColor = Color.Gray;
        }