public static Staff CreateStaff(StaffType staffType) { switch (staffType) { case StaffType.teachingStaff: TeachingStaff teachingStaff = new TeachingStaff(); AskCommonDetails(teachingStaff); teachingStaff.Subject = InputStaffProperties.AskSubject(); teachingStaff.AssignedClass = InputStaffProperties.AskClass(); return(teachingStaff); case StaffType.administrativeStaff: AdminstrativeStaff adminStaff = new AdminstrativeStaff(); AskCommonDetails(adminStaff); adminStaff.Post = InputStaffProperties.AskPost(); return(adminStaff); case StaffType.supportStaff: SupportStaff supportStaff = new SupportStaff(); AskCommonDetails(supportStaff); supportStaff.Post = InputStaffProperties.AskPost(); return(supportStaff); default: return(null); } }
private static void InsertRow(DataTable dataTable) { DataRow dataRow = dataTable.NewRow(); StaffType staffType = InputStaffProperties.AskStaffType(); dataRow["StaffName"] = InputStaffProperties.AskName(); dataRow["PhoneNumber"] = InputStaffProperties.AskPhoneNumber(); dataRow["Salary"] = InputStaffProperties.AskSalary(); Address address = InputStaffProperties.AskAddress(); dataRow["HouseName"] = address.HouseName; dataRow["City"] = address.City; dataRow["State"] = address.State; dataRow["PinCode"] = address.Pin; dataRow["StaffType"] = (int)staffType; string specificData; int classAssigned = 0; if (staffType == StaffType.teachingStaff) { specificData = InputStaffProperties.AskSubject(); classAssigned = Convert.ToInt32(InputStaffProperties.AskClass()); } else { specificData = InputStaffProperties.AskPost(); } dataRow["SpecificData"] = specificData; dataRow["ClassAssigned"] = classAssigned; dataTable.Rows.Add(dataRow); Console.WriteLine("\nInsertion Successfull\nDo you want to add more Staff?(y/n)\n"); char choice = Convert.ToChar(Console.ReadLine()); if (choice == 'y') { InsertRow(dataTable); } }