Пример #1
0
        protected void savePublicOptionChangeButton_Click( object sender, EventArgs e )
        {
            TrackerDataSetTableAdapters.GroupTableAdapter adapter = new TrackerDataSetTableAdapters.GroupTableAdapter( );

              string newIsPublicValueStr = this.publicOptionRadioButtonList.SelectedValue;
              bool newIsPublicValue;
              if ( newIsPublicValueStr == "public" )
              {
            newIsPublicValue = true;
              }
              else if ( newIsPublicValueStr == "unlisted" )
              {
            newIsPublicValue = false;
              }
              else
              {
            throw new InvalidOperationException( string.Format( "Unknown public option value '{0}'", newIsPublicValueStr ) );
              }

              this.groupTable[0].IsPublic = newIsPublicValue;
              adapter.Update( this.groupTable );
              this.publicOptionMultiView.SetActiveView( this.dispayPublicOptionView );
        }
Пример #2
0
        protected void assignGroupsButton_Click(object sender, EventArgs e)
        {
            if (groupsPanelMultiView.GetActiveView() == defaultGroupPanelView)
              {
            groupsPanelMultiView.SetActiveView(expandedGroupPanelView);
              }

              if (assignedTaskMultiView.GetActiveView() != assignedTaskEditView)
              {
            assignedTaskMultiView.SetActiveView(assignedTaskEditView);

            // If "default Event controls" was in edit mode, cancel any changes and return it to the read mode:
            defaultEventControlsMultiView.SetActiveView(defaultEventReadView);
              }
              else
              {
            bool isChanged = false;
            if (sender == assignGroupsSaveButton)
            {
              TrackerDataSetTableAdapters.GroupTableAdapter groupTableAdapter = new TrackerDataSetTableAdapters.GroupTableAdapter();
              TrackerDataSet.GroupDataTable userGroups = groupTableAdapter.GetDataByUserId(Global.UserId);

              int tempAssignedGroupsCount = 0;
              foreach (ListItem li in assignedGroupsCheckBoxList.Items)
              {
            int groupId = int.Parse(li.Value);
            TrackerDataSet.GroupRow groupRow = userGroups.FindById(groupId);

            // Note that the content of assignedGroupsCheckBoxList came from the ViewState, and the group
            // can be actually deleted by that time (or replaced in ViewState by another user's group). So check
            // if it's valid group to prevent NullReferenceExcpetion:
            if (groupRow == null)
              continue;

            if (li.Selected)
            {
              tempAssignedGroupsCount++;
              if (groupRow.IsEventIdNull() ||
                   groupRow.EventId != EventId)
                groupRow.EventId = EventId;
            }
            else
            {
              if (!groupRow.IsEventIdNull() &&
                   groupRow.EventId == EventId)
              {
                groupRow.SetEventIdNull();
              }
            }
              }

              int updatedRecords = groupTableAdapter.Update(userGroups);
              _assignedGroupsCount = tempAssignedGroupsCount;
              isChanged = updatedRecords > 0;
              if (isChanged)
              {
            TrackerDataSetTableAdapters.ProcsAdapter procsAdapter = new TrackerDataSetTableAdapters.ProcsAdapter();
            procsAdapter.SetEventAsDefault(EventId);

            // We just set event as default in the DB - now we need to update this.IsEventDefault that is used in the markup
            IsEventDefault = true;
              }
            }

            SetAssignedGroupsReadView();
            SetNoGroupWarningVisibility();
            if (isChanged)
            {
              assignedGroupsGridView.DataBind();
            }
              }
        }