public override Dictionary <string, string> ToRow() { var dict = base.ToRow(); dict.Add("Specialization", Specialization.ToString()); return(dict); }
static String getSpecialization() { Console.WriteLine("Enter the number of the specialization you are looking for:"); long num = long.Parse(Console.ReadLine()); Specialization s = bl.getSpecialization(num); return(s.ToString()); }
public void WriteXml(XmlWriter writer) { if (ChainedAbilities == null) { return; } writer.WriteAttributeString("Name", Name); writer.WriteAttributeString("Specialization", Specialization.ToString()); writer.WriteAttributeString("Hotkey", HotKey.ToString()); writer.WriteAttributeString("Modifier", ModiferKey.ToString()); var serializer = new XmlSerializer(ChainedAbilities.GetType()); serializer.Serialize(writer, ChainedAbilities); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { try { bl.deleteSpecialization(s); MessageBox.Show("Deleted successfully \n\n" + s.ToString()); this.Close(); } catch (FormatException) { MessageBox.Show("Incorrect input"); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { try { bl.addSpecialization(s); MessageBox.Show("Added successfully \n\n" + s.ToString()); s = new Specialization(); this.grid1.DataContext = s; this.Close(); } catch (FormatException) { MessageBox.Show("Incorrect input"); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
public bool addContract(Contract contract) { if (hasEmptyFields(contract, "netWagePerHour")) // netwage calculated below in BL { throw new Exception("please fill out all fields"); } #region check if employee and employer exist in DS if (DAL_Object.getEmployeeList().Count(x => x.ID == contract.EmployeeID) != 1) { throw new Exception("cannot add contract for employee that does not exist"); } if (DAL_Object.getEmployerList().Count(x => x.ID == contract.EmployerID) != 1) { throw new Exception("cannot add contract for employer that does not exist"); } #endregion #region check if company established less than year ago Employer employer = DAL_Object.getEmployerList().Find(x => x.ID == contract.EmployerID); if (DateTime.Today.Year - employer.establishmentDate.Year < 1) // company less than 1 year old { throw new Exception("cannot create contract with company established less than a year ago"); } #endregion #region check if gross wage per hour is within range of employee's specialization min/max wage Employee contract_employee = DAL_Object.getEmployeeList().Find(x => x.ID == contract.EmployeeID); Specialization contract_spec = DAL_Object.getSpecilizationList().Find(s => s.ID == contract_employee.specializationID); if (contract.grossWagePerHour < contract_spec.minWagePerHour || contract.grossWagePerHour > contract_spec.maxWagePerHour) { throw new Exception("gross wage per hour not within range of min/max of " + contract_spec.ToString()); } #endregion #region calculate net wage by subtracting commission from gross wage int existingContractEmployeeCount = (from contr in DAL_Object.getContractList() where contr.EmployeeID == contract.EmployeeID select contr).Count(); // 1st employee job commission = 10% (existingContractEmployerCount = 0) // 2nd employee job commission = 9% (existingContractEmployerCount = 1) // 3rd employee job commission = 8% ... // ... // 8th employee job commission = 3% (existingContractEmployerCount = 7) (minimum commission) // nth employee job commission = 3% // ... double commission; if (existingContractEmployeeCount >= 0 && existingContractEmployeeCount < 8) { commission = 10 - existingContractEmployeeCount; // 10,9,8,7,...,3 } else { commission = 3; } // take commission if company has less than 50 contracts int existingContractEmployerCount = (from contr in DAL_Object.getContractList() where contr.EmployerID == contract.EmployerID select contr).Count(); // only take commission for company if they have less than 50 contracts if (existingContractEmployerCount < 50) { commission += (10 - existingContractEmployerCount * .2); } contract.netWagePerHour = contract.grossWagePerHour - (contract.grossWagePerHour * commission) / 100; #endregion return(DAL_Object.addContract(contract)); }
public static Profession ToProfession(this Specialization value) { return((Profession)Enum.Parse(typeof(Profession), value.ToString())); }