protected override void OnInit(EventArgs e) { base.OnInit(e); pickerPhoto.FolderPath = UniversityConfig.Instance.EmployeePhoto.DefaultPath; pickerPhoto.FileFilter = Globals.glbImageFileTypes; pickerAltPhoto.FolderPath = UniversityConfig.Instance.EmployeePhoto.DefaultPath; pickerAltPhoto.FileFilter = Globals.glbImageFileTypes; checkShowBarcode.Checked = true; // add default item to user list comboUsers.Items.Add(new ListItem(LocalizeString("NotSelected.Text"), Null.NullInteger.ToString())); // init working hours WorkingHoursLogic.Init(this, comboWorkingHours); var achievementTypes = new FlatQuery <AchievementTypeInfo> (ModelContext).List(); var achievements = new FlatQuery <AchievementInfo> (ModelContext).List(); var positions = new FlatQuery <PositionInfo> (ModelContext).ListOrderBy(p => p.Title); var divisions = new FlatQuery <DivisionInfo> (ModelContext).ListOrderBy(d => d.Title); formEditAchievements.OnInit(this, achievementTypes, achievements); formEditDisciplines.OnInit(this); formEditPositions.OnInit(this, positions, divisions); }
protected override void UpdateItem(EmployeeInfo item) { // update working hours item.WorkingHours = WorkingHoursLogic.Update( comboWorkingHours, textWorkingHours.Text, checkAddToVocabulary.Checked ); // update audit info item.LastModifiedByUserId = UserId; item.LastModifiedOnDate = DateTime.Now; // update employee ModelContext.Update(item); new UpdateOccupiedPositionsCommand(ModelContext) .Update(formEditPositions.GetModifiedData(), item.EmployeeID); new UpdateEmployeeAchievementsCommand(ModelContext) .UpdateEmployeeAchievements(formEditAchievements.GetModifiedData(), item.EmployeeID); new UpdateEmployeeDisciplinesCommand(ModelContext) .Update(formEditDisciplines.GetModifiedData(), item.EmployeeID); ModelContext.SaveChanges(); }
protected override void AddItem(DivisionInfo item) { if (SecurityContext.CanAdd(typeof(DivisionInfo))) { // update working hours item.WorkingHours = WorkingHoursLogic.Update( comboWorkingHours, textWorkingHours.Text, checkAddToVocabulary.Checked ); new AddDivisionCommand(ModelContext, SecurityContext).Add(item, DateTime.Now); ModelContext.SaveChanges(); // then adding new division from Division module, // set calling module to display new division info if (ModuleConfiguration.ModuleDefinition.DefinitionName == "R7_University_Division") { var settingsRepository = new DivisionSettingsRepository(); var settings = settingsRepository.GetSettings(ModuleConfiguration); settings.DivisionID = item.DivisionID; settingsRepository.SaveSettings(ModuleConfiguration, settings); } } }
/// <summary> /// Handles Init event for a control. /// </summary> /// <param name="e">Event args.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); // parse QueryString var itemId = ParseHelper.ParseToNullable <int> (Request.QueryString ["division_id"]); // FIXME: Possible circular dependency as list can still contain childrens of current division parentDivisionSelector.DataSource = new DivisionQuery(ModelContext).ListExcept(itemId).OrderBy(d => d.Title); parentDivisionSelector.DataBind(); // init working hours WorkingHoursLogic.Init(this, comboWorkingHours); // bind positions var positions = new FlatQuery <PositionInfo> (ModelContext).ListOrderBy(p => p.Title); comboHeadPosition.DataSource = positions.Select(p => new { p.PositionID, Title = UniversityFormatHelper.FormatTitleWithShortTitle(p.Title, p.ShortTitle) }); comboHeadPosition.DataBind(); comboHeadPosition.InsertDefaultItem(LocalizeString("NotSelected.Text")); }
protected override void UpdateItem(DivisionInfo item) { // update working hours item.WorkingHours = WorkingHoursLogic.Update( comboWorkingHours, textWorkingHours.Text, checkAddToVocabulary.Checked ); new UpdateDivisionCommand(ModelContext, SecurityContext).Update(item, DateTime.Now); ModelContext.SaveChanges(); }
protected override void LoadItem(DivisionInfo item) { txtTitle.Text = item.Title; txtShortTitle.Text = item.ShortTitle; txtWebSite.Text = item.WebSite; textWebSiteLabel.Text = item.WebSiteLabel; txtEmail.Text = item.Email; txtSecondaryEmail.Text = item.SecondaryEmail; textAddress.Text = item.Address; txtLocation.Text = item.Location; txtPhone.Text = item.Phone; txtFax.Text = item.Fax; datetimeStartDate.SelectedDate = item.StartDate; datetimeEndDate.SelectedDate = item.EndDate; checkIsSingleEntity.Checked = item.IsSingleEntity; checkIsInformal.Checked = item.IsInformal; checkIsGoverning.Checked = item.IsGoverning; comboHeadPosition.SelectByValue(item.HeadPositionID); // load working hours WorkingHoursLogic.Load(comboWorkingHours, textWorkingHours, item.WorkingHours); // select parent division parentDivisionSelector.DivisionId = item.ParentDivisionID; // set HomePage url if (!string.IsNullOrWhiteSpace(item.HomePage)) { urlHomePage.Url = item.HomePage; } else { // or set to "None", if Url is empty urlHomePage.UrlType = "N"; } // set Document url if (!string.IsNullOrWhiteSpace(item.DocumentUrl)) { urlDocumentUrl.Url = item.DocumentUrl; } else { // or set to "None", if url is empty urlDocumentUrl.UrlType = "N"; } ctlAudit.Bind(item); }
protected override void AddItem(EmployeeInfo item) { if (SecurityContext.CanAdd(typeof(EmployeeInfo))) { // update working hours item.WorkingHours = WorkingHoursLogic.Update( comboWorkingHours, textWorkingHours.Text, checkAddToVocabulary.Checked ); // add employeee new AddCommand <EmployeeInfo> (ModelContext, SecurityContext).Add(item); ModelContext.SaveChanges(false); // then adding new employee from Employee or EmployeeDetails modules, // set calling module to display new employee if (ModuleConfiguration.ModuleDefinition.DefinitionName == "R7_University_Employee" || ModuleConfiguration.ModuleDefinition.DefinitionName == "R7_University_EmployeeDetails") { var settingsRepository = new EmployeeSettingsRepository(); var settings = settingsRepository.GetSettings(ModuleConfiguration); settings.EmployeeID = item.EmployeeID; // we adding new employee, so he/she should be displayed in the module settings.ShowCurrentUser = false; settingsRepository.SaveSettings(ModuleConfiguration, settings); } new UpdateOccupiedPositionsCommand(ModelContext) .Update(formEditPositions.GetModifiedData(), item.EmployeeID); new UpdateEmployeeAchievementsCommand(ModelContext) .UpdateEmployeeAchievements(formEditAchievements.GetModifiedData(), item.EmployeeID); new UpdateEmployeeDisciplinesCommand(ModelContext) .Update(formEditDisciplines.GetModifiedData(), item.EmployeeID); ModelContext.SaveChanges(); } }
protected override void LoadItem(EmployeeInfo item) { var employee = GetItemWithDependencies(ItemKey.Value); base.LoadItem(employee); textLastName.Text = employee.LastName; textFirstName.Text = employee.FirstName; textOtherName.Text = employee.OtherName; textPhone.Text = employee.Phone; textCellPhone.Text = employee.CellPhone; textFax.Text = employee.Fax; textEmail.Text = employee.Email; textSecondaryEmail.Text = employee.SecondaryEmail; textWebSite.Text = employee.WebSite; textWebSiteLabel.Text = employee.WebSiteLabel; textMessenger.Text = employee.Messenger; textWorkingPlace.Text = employee.WorkingPlace; textBiography.Text = employee.Biography; checkShowBarcode.Checked = employee.ShowBarcode; txtScienceIndexAuthorId.Text = employee.ScienceIndexAuthorId.ToString(); // load working hours WorkingHoursLogic.Load(comboWorkingHours, textWorkingHours, employee.WorkingHours); if (!Null.IsNull(employee.ExperienceYears)) { textExperienceYears.Text = employee.ExperienceYears.ToString(); } if (!Null.IsNull(employee.ExperienceYearsBySpec)) { textExperienceYearsBySpec.Text = employee.ExperienceYearsBySpec.ToString(); } datetimeStartDate.SelectedDate = employee.StartDate; datetimeEndDate.SelectedDate = employee.EndDate; // set photo if (employee.PhotoFileID != null && !Null.IsNull(employee.PhotoFileID.Value)) { var photo = FileManager.Instance.GetFile(employee.PhotoFileID.Value); if (photo != null) { pickerPhoto.FileID = photo.FileId; } } if (employee.AltPhotoFileId != null && !Null.IsNull(employee.AltPhotoFileId.Value)) { var photo = FileManager.Instance.GetFile(employee.AltPhotoFileId.Value); if (photo != null) { pickerAltPhoto.FileID = photo.FileId; } } if (employee.UserID != null && !Null.IsNull(employee.UserID.Value)) { var user = UserController.GetUserById(PortalId, employee.UserID.Value); if (user != null) { // add previously selected user to user list... comboUsers.Items.Add(new ListItem( user.Username + " / " + user.Email, user.UserID.ToString())); comboUsers.SelectedIndex = 1; } } formEditAchievements.SetData(employee.Achievements.OrderByDescending(ach => ach.YearBegin), employee.EmployeeID); formEditPositions.SetData(employee.Positions, employee.EmployeeID); // apply default ordering var employeeDisciplines = employee.Disciplines .OrderBy(ed => ed.EduProgramProfile.EduProgram.EduLevel.SortIndex) .ThenBy(ed => ed.EduProgramProfile.EduProgram.Code) .ThenBy(ed => ed.EduProgramProfile.EduProgram.Title) .ThenBy(ed => ed.EduProgramProfile.ProfileCode) .ThenBy(ed => ed.EduProgramProfile.ProfileTitle) .ThenBy(ed => ed.EduProgramProfile.EduLevel.SortIndex); formEditDisciplines.SetData(employeeDisciplines, employee.EmployeeID); // setup audit control ctlAudit.Bind(employee, PortalId, LocalizeString("Unknown"));; SetupDivisionSelector(); }
protected override void LoadItem(EmployeeInfo item) { var employee = GetItemWithDependencies(ItemId.Value); textLastName.Text = employee.LastName; textFirstName.Text = employee.FirstName; textOtherName.Text = employee.OtherName; textPhone.Text = employee.Phone; textCellPhone.Text = employee.CellPhone; textFax.Text = employee.Fax; textEmail.Text = employee.Email; textSecondaryEmail.Text = employee.SecondaryEmail; textWebSite.Text = employee.WebSite; textWebSiteLabel.Text = employee.WebSiteLabel; textMessenger.Text = employee.Messenger; textWorkingPlace.Text = employee.WorkingPlace; textBiography.Text = employee.Biography; checkShowBarcode.Checked = employee.ShowBarcode; // load working hours WorkingHoursLogic.Load(comboWorkingHours, textWorkingHours, employee.WorkingHours); if (!Null.IsNull(employee.ExperienceYears)) { textExperienceYears.Text = employee.ExperienceYears.ToString(); } if (!Null.IsNull(employee.ExperienceYearsBySpec)) { textExperienceYearsBySpec.Text = employee.ExperienceYearsBySpec.ToString(); } datetimeStartDate.SelectedDate = employee.StartDate; datetimeEndDate.SelectedDate = employee.EndDate; // set photo if (!TypeUtils.IsNull(employee.PhotoFileID)) { var photo = FileManager.Instance.GetFile(employee.PhotoFileID.Value); if (photo != null) { pickerPhoto.FileID = photo.FileId; } } if (!Null.IsNull(employee.UserID)) { var user = UserController.GetUserById(this.PortalId, employee.UserID.Value); if (user != null) { // add previously selected user to user list... comboUsers.Items.Add(new ListItem( user.Username + " / " + user.Email, user.UserID.ToString())); comboUsers.SelectedIndex = 1; } } // TODO: Sort achievements? formEditAchievements.SetData(employee.Achievements, employee.EmployeeID); formEditPositions.SetData(employee.Positions, employee.EmployeeID); formEditDisciplines.SetData(employee.Disciplines, employee.EmployeeID); // setup audit control ctlAudit.Bind(employee); SetupDivisionSelector(); }