public ShellViewModel() { Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; MySQLLaunchModels = new ObservableCollection <MySQLLaunchModel>(); MySQLInstanceModels = new ObservableCollection <MySQLInstanceModel>(); _viewService = new ViewService(); _launchCfgService = new LaunchConfigService(); _mySQLCfgService = new MySQLConfigService(); _mySQLService = new MySQLService(); _mySQLService.NewInstaceFound += _mySQLService_NewInstaceFound; _mySQLService.InstanceLost += _mySQLService_InstanceLost; _logService = new LogService(); _logService.LogContentChanged += _logService_LogContentChanged; CommandCreateNew = new CommandImpl(OnRequestCreateNewLaunchModel); CommandCopyCurrentLaunchModel = new CommandImpl(OnRequestCopyCurrentLaunchModel); CommandRenameSelectedModel = new CommandImpl(OnRequestRenameSelectedModel); CommandDeleteSelectedLaunchModel = new CommandImpl(OnRequestDeleteSelectedLaunchModel); CommandInitMySQLDataDir = new CommandImpl(OnRequestInitMySQLDataDir); CommandStartMySQL = new CommandImpl(OnRequestStartMySQL, CanStartMySQL); CommandStopMySQL = new CommandImpl(OnRequestStopMySQL, CanStopMySQL); CommandReStartMySQL = new CommandImpl(OnRequestReStartMySQL, CanReStartMySQL); CommandRefreshIni = new CommandImpl(OnRequestRefreshIni); CommandSaveIni = new CommandImpl(OnRequestSaveIni); _ = LoadModels(); }
public LoginViewModel() { this.User = new User(); this.LoginCommand = new DelegateCommand(new Action(LoginExecute)); this.connection = new MySqlConnection( "server=localhost;User Id=admin;password=admin;Database=hr"); this.service = new MySQLService(); }
static void Main(string[] args) { string exePath = @"F:\C_shap\Git\MyORM\trunk\TestApp"; string mySQL_conStr = "Your MySQL connection string"; string sqlServer_conStr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + exePath + @"\TestDataBases\SQLServerDB.mdf" + ";Integrated Security=True;Connect Timeout=30"; string sqlite_conStr = @"Data Source=" + exePath + @"\TestDataBases\SQLiteDB.db"; // step 1 SetConnectionString MySQLService.SetConnection(mySQL_conStr); SQLServerService.SetConnection(sqlServer_conStr); SQLiteService.SetConnection(sqlite_conStr); DataBaseTypesEnum DBType = DataBaseTypesEnum.SQLite; SQLService service = null; switch (DBType) { case DataBaseTypesEnum.MySQL: { //step 2 tell Service that which type of database you want to use in default ModelBase.SetDefaultService(DataBaseTypesEnum.MySQL); //step 3 create a new instance and use it service = new MySQLService(); break; } case DataBaseTypesEnum.SQLServer: { ModelBase.SetDefaultService(DataBaseTypesEnum.SQLServer); service = new SQLServerService(); break; } case DataBaseTypesEnum.SQLite: { ModelBase.SetDefaultService(DataBaseTypesEnum.SQLite); service = new SQLiteService(); break; } } LoadById(service); ReadAll(service); ReadByCondition(service); ReadPageList(service); Update(service); Insert(service); Delete(service); Console.ReadKey(); }
//Initialize public PageViewModel() { this.SelectCommand = new DelegateCommand(new Action(SelectExecute)); this.SubmitCommand = new DelegateCommand(new Action(SubmitExecute)); this.connection = new MySqlConnection( "server=localhost;User Id=admin;password=admin;Database=hr"); this.service = new MySQLService(); this.editedIndexs = new List <int>(); this.statements = new List <string>(); SelectExecute(); }
public MyStaffPageViewModel() { Me = new StaffViewModel(); Me.Username = App.Username; statement = string.Format("select No, Name, Gender, date_format(Birthday, '%Y-%m-%d') as Birthday, Department, Position, date_format(EntryDate, '%Y-%m-%d') as EntryDate," + " date_format(ContractDate, '%Y-%m-%d') as ContractDate, Username, Password, Authority, Status from staff where Username='******'", Me.Username); connection = new MySqlConnection( "server=localhost;User Id=admin;password=admin;Database=hr"); service = new MySQLService(); DataTable table = service.QueryManipulation(statement, connection); Me.No = (int)table.Rows[0]["No"]; Me.Name = (string)table.Rows[0]["Name"]; Me.Gender = (string)table.Rows[0]["Gender"]; Me.Birthday = (string)table.Rows[0]["Birthday"]; Me.Department = (string)table.Rows[0]["Department"]; Me.Position = (string)table.Rows[0]["Position"]; Me.EntryDate = (string)table.Rows[0]["EntryDate"]; Me.ContractDate = (string)table.Rows[0]["ContractDate"]; Me.Status = (string)table.Rows[0]["Status"]; }