protected override void LoadObjectFromScreen(MyNotificationsEO baseEO) { foreach (HtmlTableRow tr in tblNotifications.Rows) { //Cell one has the checkbox and the id for the notification. var notificationType = (ENTNotificationEO.NotificationType)((int.Parse(tr.Cells[0].Attributes["NotificationId"].ToString()))); //Try to find this in the object. var myNotification = baseEO.UserNotifications.Get(notificationType); bool isChecked = ((CheckBox)tr.Cells[0].Controls[0]).Checked; if (myNotification == null) { if (isChecked) { myNotification = new ENTNotificationENTUserAccountEO(); myNotification.ENTNotificationId = (int)notificationType; myNotification.ENTUserAccountId = CurrentUser.ID; baseEO.UserNotifications.Add(myNotification); } } else { if (isChecked == false) { myNotification.DBAction = ENTBaseEO.DBActionEnum.Delete; } } if ((isChecked) && (notificationType == ENTNotificationEO.NotificationType.IssueIOwnedGoesToState)) { myNotification.NotificationStates.Clear(); var lstState = (ListBox)tr.Cells[1].Controls[0]; foreach (ListItem li in lstState.Items) { if (li.Selected == true) { myNotification.NotificationStates.Add(new ENTNotificationENTWFStateEO { ENTNotificationENTUserAccountId = myNotification.ID, ENTWFStateId = int.Parse(li.Value) }); } } } } }
protected override void LoadScreenFromObject(MyNotificationsEO baseEO) { foreach (HtmlTableRow tr in tblNotifications.Rows) { //Cell one has the checkbox and the id for the notification. var notificationType = (ENTNotificationEO.NotificationType) int.Parse(tr.Cells[0].Attributes["NotificationId"].ToString()); //Try to find this in the object. ENTNotificationENTUserAccountEO myNotification = baseEO.UserNotifications.Get(notificationType); if (myNotification != null) { //Check the box ((CheckBox)tr.Cells[0].Controls[0]).Checked = true; if (notificationType == ENTNotificationEO.NotificationType.IssueIOwnedGoesToState) { var lstStates = (ListBox)tr.Cells[1].Controls[0]; //Highlight each state in the list box. foreach (ENTNotificationENTWFStateEO state in myNotification.NotificationStates) { //Find this item in the list box. foreach (ListItem li in lstStates.Items) { if (li.Value == state.ENTWFStateId.ToString()) { //Set it to selected. li.Selected = true; break; } } } } } } ViewState[VIEW_STATE_KEY_MYNOTIFICATIONS] = baseEO; }