Exemplo n.º 1
0
 private void ContentView_SelectTable(object sender, EventArgs e)
 {
     if (e is SelectTableEventArgs)
     {
         SelectTableEventArgs selectTableEventArgs = e as SelectTableEventArgs;
         ContentView          contentView          = (ContentView)GetViewByName("contentView");
         Dictionary <int, Dictionary <string, object> > tableData = null;
         string tableName = null;
         for (int i = 0; i < Database.TableList.Count; i++)
         {
             if (selectTableEventArgs.TableAttribute == (string)Database.TableList[i]["attribute"])
             {
                 tableName = (string)Database.TableList[i]["tableName"];
                 break;
             }
         }
         HydroController hydroController = (HydroController)GetControllerByName("hydroController");
         tableData = hydroController.GetTableDataByTableName(tableName);
         if (null == tableData)
         {
             Console.WriteLine(databaseDriver.LastError);
             Console.WriteLine(databaseDriver.LastQuery);
             lastError = ErrorMessage.GetDataFailed;
             int errorLevel = ErrorLevel.ErrorLevelWarning;
             ErrorMessageView errorMessageView = new ErrorMessageView(lastError, errorLevel);
             errorMessageView.ShowDialog();
         }
         else
         {
             contentView.RefreshTable(tableName, tableData, isAdmin);
         }
     }
 }
Exemplo n.º 2
0
        private Controller GetControllerByName(string controllerName)
        {
            if (controllers.ContainsKey(controllerName))
            {
                return(controllers[controllerName]);
            }

            switch (controllerName)
            {
            case "accountController":
                AccountController accountController = new AccountController(ref databaseDriver);
                controllers.Add(controllerName, accountController);
                return(controllers[controllerName]);

            case "hydroController":
                HydroController hydroController = new HydroController(ref databaseDriver);
                controllers.Add(controllerName, hydroController);
                return(controllers[controllerName]);

            default:
                return(null);
            }
        }