partial void BudgetButton(NSObject sender) { Match matchBudget = RegexClass.rgxSalary.Match(BudgetTextField.StringValue); if (matchBudget.Success) { currentCompany.Budget = BudgetTextField.IntValue; BudgetLabel.StringValue = "Budget left: " + currentCompany.GetBudgetLeft().ToString(); } else { AddFuncs.AlertFunc("Please enter a valid budget!"); } }
partial void AddEmployeeButton(NSObject sender) { if (EmployeePosition.TitleOfSelectedItem == "Manager") { Match matchName = RegexClass.rgxName.Match(NameTextField.StringValue); Match matchSalary = RegexClass.rgxSalary.Match(SalaryTextField.StringValue); if (matchName.Success && matchSalary.Success) { if (LevelTextField.StringValue == "") { Manager manager = new Manager(AddFuncs.IDGenerator(), NameTextField.StringValue, Int32.Parse(SalaryTextField.StringValue)); if (currentCompany.Hire(manager) == true) { isAddingSuccessfulLabel.StringValue = "Added successfully - ID : " + manager.Id; BudgetLabel.StringValue = "Budget left: " + currentCompany.GetBudgetLeft().ToString(); } else { isAddingSuccessfulLabel.StringValue = "Not enough budget left!"; AddFuncs.startID--; } } else { Match matchLevel = RegexClass.rgxLevel.Match(LevelTextField.StringValue); if (matchLevel.Success) { Manager manager = new Manager(AddFuncs.IDGenerator(), NameTextField.StringValue, SalaryTextField.IntValue, Int32.Parse(LevelTextField.StringValue)); if (currentCompany.Hire(manager) == true) { isAddingSuccessfulLabel.StringValue = "Added successfully - ID : " + manager.Id; BudgetLabel.StringValue = "Budget left: " + currentCompany.GetBudgetLeft().ToString(); } else { isAddingSuccessfulLabel.StringValue = "Not enough budget left!"; AddFuncs.startID--; }; } else { AddFuncs.AlertFunc("You have entered an invalid level (min. 1, max. 9)"); } } } else { AddFuncs.AlertFunc("You have entered either invalid name or salary, please double-check"); } } else if (EmployeePosition.TitleOfSelectedItem == "Employee") { Match matchName = RegexClass.rgxName.Match(NameTextField.StringValue); Match matchSalary = RegexClass.rgxSalary.Match(SalaryTextField.StringValue); if (matchName.Success && matchSalary.Success) { Employee employee = new Employee(AddFuncs.IDGenerator(), NameTextField.StringValue, Int32.Parse(SalaryTextField.StringValue)); if (currentCompany.Hire(employee) == true) { isAddingSuccessfulLabel.StringValue = "Added successfully - ID : " + employee.Id; BudgetLabel.StringValue = "Budget left: " + currentCompany.GetBudgetLeft().ToString(); } else { isAddingSuccessfulLabel.StringValue = "Not enough budget left!"; AddFuncs.startID--; } } else { AddFuncs.AlertFunc("You have entered either invalid name or salary, please double-check"); } } else if (EmployeePosition.TitleOfSelectedItem == "Intern") { Match matchName = RegexClass.rgxName.Match(NameTextField.StringValue); if (matchName.Success) { Intern intern = new Intern(AddFuncs.IDGenerator(), NameTextField.StringValue); currentCompany.Hire(intern); isAddingSuccessfulLabel.StringValue = "Added successfully - ID : " + intern.Id; BudgetLabel.StringValue = "Budget left: " + currentCompany.GetBudgetLeft().ToString(); } else { AddFuncs.AlertFunc("Please enter a valid name!"); } } }