Beispiel #1
0
        public MainController(ActivityType initialActivity, string dbPath)
        {
            { // init context
                //var setting = new KaikeiSystemBody.models.Setting();
                var db = new KaikeiSystemBody.models.db.KaikeiDatabase(dbPath);
                //try {
                db.Open();
                db.InitTables(false);
                // }
                //catch (Exception e) {
                //    MessageBox.Show(KaikeiSystemBody.Properties.Resources.MSG_DB_OPEN_ERROR + " : " + e.Message);
                //}
                mainContext = new KaikeiSystemBody.models.Context(db);
            }

            /*if (mainContext.KaikeiDatabase.MTKamokuKubun.SetKanjouKamokuIdForAllRow()) {
             *  System.Windows.Forms.MessageBox.Show("set kaikei kamoku id ok!!");
             * }
             * else{
             *  System.Windows.Forms.MessageBox.Show("set kaikei kamoku id NG!!");
             * }*/
            //mainContext.KaikeiDatabase.MTKamokuKubun.SetDislayOrderForAllRow();

            { // init activity
                activityStack = new Stack <AbstractActivity>();
                activityHash  = new Dictionary <ActivityType, AbstractActivity>();
                AbstractActivity activity = GetActivity(initialActivity);
                activityStack.Push(activity);
                activity.ShowForm(100, 100, mainContext, null);
            }

            { // backup db
                helper.DBBackup.ExecutePeriodicDBBackup(mainContext.KaikeiDatabase.DBFilePath, "daily", 7, 1, mainContext.KaikeiDatabase.MTSetting);
                helper.DBBackup.ExecutePeriodicDBBackup(mainContext.KaikeiDatabase.DBFilePath, "weekly", 4, 7, mainContext.KaikeiDatabase.MTSetting);
                helper.DBBackup.ExecutePeriodicDBBackup(mainContext.KaikeiDatabase.DBFilePath, "monthly", 12, 30, mainContext.KaikeiDatabase.MTSetting);
            }

            { // load csv (for test)
              /*
               * models.db.KaikeiDenpyouMeisai tbl = mainContext.KaikeiDatabase.Table(models.db.KaikeiDenpyouMeisai.TABLE_NAME) as models.db.KaikeiDenpyouMeisai;
               * tbl.LoadCSV("denpyou.txt");
               * models.db.MTKamoku tbl = main_context_.KaikeiDatabase.Table(models.db.MTKamoku.TABLE_NAME) as models.db.MTKamoku;
               * tbl.LoadCSV("MTkamoku.txt");
               * models.db.MTKaikeiTanni tbl = main_context_.KaikeiDatabase.Table(models.db.MTKaikeiTanni.TABLE_NAME) as models.db.MTKaikeiTanni;
               * tbl.LoadCSV("MTKaikeiTanni.txt");
               * models.db.MTTorihikiKubun tbl = main_context_.KaikeiDatabase.Table(models.db.MTTorihikiKubun.TABLE_NAME) as models.db.MTTorihikiKubun;
               * tbl.LoadCSV("MTTorihikiKubun.txt");
               * models.db.MTDaikubun tbl = main_context_.KaikeiDatabase.Table(models.db.MTDaikubun.TABLE_NAME) as models.db.MTDaikubun;
               * tbl.LoadCSV("MTDaikubun.txt");
               * models.db.MTHojoKamoku tbl = main_context_.KaikeiDatabase.Table(models.db.MTHojoKamoku.TABLE_NAME) as models.db.MTHojoKamoku;
               * tbl.LoadCSV("MTHojoKamoku.txt");
               * models.db.MTHoujinShisetsu tbl = main_context_.KaikeiDatabase.Table(models.db.MTHoujinShisetsu.TABLE_NAME) as models.db.MTHoujinShisetsu;
               * tbl.LoadCSV("MTHoujinShisetsu.txt");
               * models.db.MTSetting tbl = main_context_.KaikeiDatabase.Table(models.db.MTSetting.TABLE_NAME) as models.db.MTSetting;
               * tbl.LoadCSV("MTSetting.txt");
               * models.db.MTIkkatsuSyori tbl = main_context_.KaikeiDatabase.MTIkkatsuSyori;
               * tbl.LoadCSV("MTIkkatsuSyori.txt");
               * models.db.ZenkiKurikoshiKamoku tbl = mainContext.KaikeiDatabase.ZenkiKurikoshiKamoku;
               * tbl.LoadCSV("ZenkiKurikoshiKamoku.txt");
               * models.db.ZenkiKurikoshiHojoKamoku tbl = mainContext.KaikeiDatabase.ZenkiKurikoshiHojoKamoku;
               * tbl.LoadCSV("ZenkiKurikoshiHojoKamoku.txt");
               * for (int year = 2008; year <= 2010; year++) {
               *  models.db.KaikeiDenpyouMeisai denpyou = mainContext.KaikeiDatabase.BackupTable<models.db.KaikeiDenpyouMeisai>(
               *      models.db.KaikeiDenpyouMeisai.TABLE_NAME, year, true);
               *  denpyou.LoadCSV(year.ToString() + "_denpyou_meisai.txt");
               *
               *  models.db.ZenkiKurikoshiKamoku kamoku = mainContext.KaikeiDatabase.BackupTable<models.db.ZenkiKurikoshiKamoku>(
               *      models.db.ZenkiKurikoshiKamoku.TABLE_NAME, year, true);
               *  kamoku.LoadCSV(year.ToString() + "_kurikoshi_kamoku.txt");
               *
               *  models.db.ZenkiKurikoshiHojoKamoku hojo = mainContext.KaikeiDatabase.BackupTable<models.db.ZenkiKurikoshiHojoKamoku>(
               *      models.db.ZenkiKurikoshiHojoKamoku.TABLE_NAME, year, true);
               *  hojo.LoadCSV(year.ToString() + "_kurikoshi_hojo.txt");
               * }
               * models.db.MTShikinSyuushiKoumoku tbl = mainContext.KaikeiDatabase.MTShikinSyuushiKoumoku;
               * tbl.LoadCSV("MTShikinSyuushiKoumoku.txt");
               * models.db.MTJigyouKatsudouSyuushiKoumoku tbl = mainContext.KaikeiDatabase.MTJigyouKatsudouSyuushiKoumoku;
               * tbl.LoadCSV("MTJigyouKatsudouSyuushiKoumoku.txt");
               * models.db.TaisyakuTaisyouhyouTyuuki tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouTyuuki;
               * tbl.LoadCSV("TaisyakuTaisyouhyouTyuuki.txt");
               * models.db.TaisyakuTaisyouhyouTyuuki1 tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouTyuuki1;
               * tbl.LoadCSV("TaisyakuTaisyouhyouTyuuki1.txt");
               * models.db.TaisyakuTaisyouhyouTyuuki3 tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouTyuuki3;
               * tbl.LoadCSV("TaisyakuTaisyouhyouTyuuki3.txt");
               * models.db.TaisyakuTaisyouhyouTyuuki4 tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouTyuuki4;
               * tbl.LoadCSV("TaisyakuTaisyouhyouTyuuki4.txt");
               * models.db.TaisyakuTaisyouhyouTyuuki5 tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouTyuuki5;
               * tbl.LoadCSV("TaisyakuTaisyouhyouTyuuki5.txt");
               * models.db.TaisyakuTaisyouhyouKyakutyuu tbl = mainContext.KaikeiDatabase.TaisyakuTaisyouhyouKyakutyuu;
               * tbl.LoadCSV("TaisyakuTaisyouhyouKyakutyuu.txt");
               * models.db.MTYosanKubun tbl = mainContext.KaikeiDatabase.MTYosanKubun;
               * tbl.LoadCSV("MTYosanKubun.txt");
               * models.db.tables.YosanKamoku tbl = mainContext.KaikeiDatabase.YosanKamoku;
               * tbl.LoadCSV("YosanKamoku.txt");
               * models.db.tables.YosanHojokamoku tbl3 = mainContext.KaikeiDatabase.YosanHojokamoku;
               * tbl3.LoadCSV("YosanHojokamoku.txt");
               * models.db.tables.YosanDaikubun tbl4 = mainContext.KaikeiDatabase.YosanDaikubun;
               * tbl4.LoadCSV("YosanDaikubun.txt");
               * models.db.tables.YosanYobihi tbl2 = mainContext.KaikeiDatabase.YosanYobihi;
               * tbl2.LoadCSV("YosanYobihi.txt");
               * models.db.mtables.MTSyoukyakuKahi tbl = mainContext.KaikeiDatabase.MTSyoukyakuKahi;
               * tbl.LoadCSV("MTSyoukyakuKahi.txt");
               * models.db.mtables.MTSyoukyakuKubun tbl = mainContext.KaikeiDatabase.MTSyoukyakuKubun;
               * tbl.LoadCSV("MTSyoukyakuKubun.txt");
               * models.db.mtables.MTSyoukyakuHouhou tbl = mainContext.KaikeiDatabase.MTSyoukyakuHouhou;
               * tbl.LoadCSV("MTSyoukyakuHouhou.txt");
               * models.db.mtables.MTZoukaJiyuu tbl = mainContext.KaikeiDatabase.MTZoukaJiyuu;
               * tbl.LoadCSV("MTZoukaJiyuu.txt");
               * models.db.mtables.MTTaiyouNennsuu tbl = mainContext.KaikeiDatabase.MTTaiyouNennsuu;
               * tbl.LoadCSV("MTTaiyouNennsuu.txt");
               * models.db.mtables.MTKoteiShisan tbl = mainContext.KaikeiDatabase.MTKoteiShisan;
               * tbl.LoadCSV("MTKoteiShisan.txt");
               * models.db.mtables.MTKeijouHouhou tbl = mainContext.KaikeiDatabase.MTKeijouHouhou;
               * tbl.LoadCSV("MTKeijouHouhou.txt");
               * models.db.mtables.MTGensyouJiyuu tbl = mainContext.KaikeiDatabase.MTGensyouJiyuu;
               * tbl.LoadCSV("MTGensyouJiyuu.txt");
               * models.db.tables.GenkaSyoukyakuMeisai tbl = mainContext.KaikeiDatabase.GenkaSyoukyakuMeisai;
               * tbl.LoadCSV("GenkaSyoukyakuMeisai.txt");
               * models.db.mtables.MTKanrisya tbl = mainContext.KaikeiDatabase.MTKanrisya;
               * tbl.LoadCSV("MTKanrisya.txt");
               * models.db.mtables.MTTaisyakuTaisyouKoumoku tbl = mainContext.KaikeiDatabase.MTTaisyakuTaisyouKoumoku;
               * tbl.LoadCSV("MTTaisyakuTaisyouKoumoku.txt");
               * models.db.mtables.MTTekiyou tbl = mainContext.KaikeiDatabase.Table(models.db.mtables.MTTekiyou.TABLE_NAME) as models.db.mtables.MTTekiyou;
               * tbl.LoadCSV("MTTekiyou.txt");
               * models.db.mtables.MTHoujinDantai tbl = mainContext.KaikeiDatabase.MTHoujinDantai;
               * tbl.LoadCSV("MTHoujinDantai.txt");
               * models.db.mtables.MTTaisyakuKubun tbl = mainContext.KaikeiDatabase.MTTaisyakuKubun;
               * tbl.LoadCSV("MTTaisyakuKubun.txt");
               */
            }
        }
Beispiel #2
0
        public bool SwitchActivity(ActivityType activity_type, ActivitySwitchMethod method, KaikeiSystemBody.models.Context context, object option = null)
        {
            var next_activity = GetActivity(activity_type);
            var form_x        = CurrentActivity.Form.Left;
            var form_y        = CurrentActivity.Form.Top;
            var form_w        = CurrentActivity.Form.Width;
            var form_h        = CurrentActivity.Form.Height;

            switch (method)
            {
            case ActivitySwitchMethod.Change:
                CurrentActivity.HideForm();
                activityStack.Pop();
                activityStack.Push(next_activity);
                CurrentActivity.ShowForm(form_x, form_y, context, option);
                break;

            case ActivitySwitchMethod.Push:
                CurrentActivity.HideForm();
                activityStack.Push(next_activity);
                CurrentActivity.ShowForm(form_x, form_y, context, option);
                break;

            case ActivitySwitchMethod.PushModal:
                activityStack.Push(next_activity);
                CurrentActivity.ShowFormModal(form_x + form_w / 2, form_y + form_h / 2, context, option);
                break;
            }

            return(true);
        }