Esempio n. 1
0
        /// <summary>
        /// データベース登録
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int ctlCount = frm.pnlMain.Controls.Count;

            if (txtName.Text == "" || txtURL.Text == "" || txtPath.Text == "")
            {
                MessageBox.Show(this, "入力に誤りがあります", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /*------------------------
             登録
            ------------------------*/
            using (global.conn = new SQLiteConnection(global.gDataSource))
            {
                try
                {
                    global.conn.Open();

                    global.sql = "insert into Settings (name, url, path) values ( " +
                                 "'" + txtName.Text + "'," +
                                 "'" + txtURL.Text + "'," +
                                 "'" + txtPath.Text + "'" +
                                 ")";

                    global.command = new SQLiteCommand(global.sql, global.conn);
                    global.command.ExecuteNonQuery();

                    /*------------------------
                     データベースのexamを更新
                    ------------------------*/
                    frm.pnlMain.Controls.Clear();

                    try
                    {
                        global.sql = "select * from Settings";

                        global.command = new SQLiteCommand(global.sql, global.conn);
                        global.rd = global.command.ExecuteReader();

                        while (global.rd.Read())
                        {
                            try
                            {
                                global.sql = "update Settings set exam = 'InfoAdd" + int.Parse((ctlCount + global.rd.GetValue(global.ID).ToString())).ToString() + "' where no = " + global.rd.GetValue(global.ID).ToString();
                                global.command = new SQLiteCommand(global.sql, global.conn);
                                global.command.ExecuteNonQuery();
                            }
                            catch (Exception) { }
                        }
                    }
                    catch (Exception){ }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error : " + ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Notify.SendMailError(DateTime.Now, ex.Message, "frmAdd - 64~101");
                }
                finally
                {
                    global.conn.Close();
                    frm.Dispose();
                    this.Close();
                }

                MessageBox.Show(this, "登録が完了しました", "お知らせ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 設定の読み込み
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMain_Load(object sender, EventArgs e)
        {
            int ctlCount = pnlMain.Controls.Count;

            menuSettings.Enabled = false;

            /*------------------------
            *  起動時に一回だけ実行
            *  ------------------------*/
            if (!global.FirstRun_flg)
            {
                ShowInTaskbar = false;
                Hide();
                menuSettings.Enabled = true;

                notifyIcon1.ShowBalloonTip(5000, "お知らせ", "AutoDownloader へようこそ!\r\n講義の登録はこちらから行えます", ToolTipIcon.Info);

                Update_Check(0);    //アップデート確認

                //.oldファイル削除
                if (File.Exists("AutoDownloader.old"))
                {
                    File.Delete("AutoDownloader.old");
                }

                RefreshInterval.Enabled = true;
                global.FirstRun_flg     = true;
            }

            /*------------------------
            *  データベースを元にフォームへ追加
            *  ------------------------*/
            pnlMain.Controls.Clear();

            using (global.conn = new SQLiteConnection(global.gDataSource))
            {
                try
                {
                    global.conn.Open();

                    global.sql = "select * from Settings";

                    global.command = new SQLiteCommand(global.sql, global.conn);
                    global.rd      = global.command.ExecuteReader();

                    while (global.rd.Read())
                    {
                        try
                        {
                            Info = new InfoAdd();

                            Info.Name         = "InfoAdd" + int.Parse((ctlCount + global.rd.GetValue(global.ID).ToString())).ToString();
                            Info.lblName.Text = global.rd.GetValue(global.NAME).ToString();
                            Info.lblUrl.Text  = global.rd.GetValue(global.URL).ToString();
                            Info.lblPath.Text = global.rd.GetValue(global.PATH).ToString();

                            pnlMain.Controls.Add(Info);
                        }
                        catch (Exception) { }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error : " + ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Notify.SendMailError(DateTime.Now, ex.Message, "frmMain - 147~171");
                }
                finally
                {
                    global.conn.Close();
                }
            }

            /*------------------------
            *  タイマセット
            *  ------------------------*/
            if (System.IO.File.Exists(@"settings.ini")) //INIファイルが存在する
            {
                switch (ini.getValueString("Interval", "time"))
                {
                case "5 分":
                    RefreshInterval.Interval = 300000;
                    break;

                case "10 分":
                    RefreshInterval.Interval = 600000;
                    break;

                case "30 分":
                    RefreshInterval.Interval = 1800000;
                    break;

                case "1 時間":
                    RefreshInterval.Interval = 3600000;
                    break;

                case "6 時間":
                    RefreshInterval.Interval = 21600000;
                    break;

                case "12 時間":
                    RefreshInterval.Interval = 43200000;
                    break;

                case "1 日":
                    RefreshInterval.Interval = 86400000;
                    break;

                default:
                    break;
                }
            }
            else
            {
                RefreshInterval.Interval = 3600000;
            }

            //RefreshInterval.Interval = 60000; //デバッグ用
            RefreshInterval.Enabled = true;

            ShowInTaskbar = false;
            Hide();

            menuSettings.Enabled = true;
        }