private void FillGrid()
        {
            //Get all conn group attaches because we will be using all of them in order to show counts.
            List <ConnGroupAttach> listConnGroupAttaches = ConnGroupAttaches.GetAll();

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lans.g(this, "Group Name"), 280);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lans.g(this, "Conns"), 0);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            foreach (ConnectionGroup connGroup in _listCentralConnGroups)
            {
                row = new ODGridRow();
                row.Cells.Add(connGroup.Description);
                row.Cells.Add(listConnGroupAttaches.FindAll(x => x.ConnectionGroupNum == connGroup.ConnectionGroupNum).Count.ToString());
                row.Tag = connGroup;              //Not really used currently, but we may want to add filtering later.
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Example #2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //Sync groupattaches for this group prior to leaving this window.  Updating the ConnectionGroup list in parent window is taken care of there.
            if (textDescription.Text == "")
            {
                MessageBox.Show(Lans.g(this, "Please enter something for the description."));
                return;
            }
            ConnectionGroupCur.Description = textDescription.Text;
            //Find all connections in our current list that do not have a corresponding conn group attach entry.
            List <CentralConnection> listConnsToAdd = _listConnsCur.FindAll(x => !_listConnGroupAttaches.Exists(y => y.CentralConnectionNum == x.CentralConnectionNum));

            //Add a conn group attach for each connection found.
            foreach (CentralConnection conn in listConnsToAdd)
            {
                ConnGroupAttach connGA = new ConnGroupAttach();
                connGA.CentralConnectionNum = conn.CentralConnectionNum;
                connGA.ConnectionGroupNum   = ConnectionGroupCur.ConnectionGroupNum;
                _listConnGroupAttaches.Add(connGA);
            }
            //Make sure that we only keep all conn group attaches that have a valid match.
            //Removing any orphaned conn group attaches from our in-memory list will cause the sync to remove the entries from the db correctly.
            _listConnGroupAttaches = _listConnGroupAttaches.FindAll(x => _listConnsCur.Exists(y => y.CentralConnectionNum == x.CentralConnectionNum));
            //_listConnGroupAttaches now directly reflects what is shown in the UI, without creating duplicates.
            ConnGroupAttaches.Sync(_listConnGroupAttaches, ConnectionGroupCur.ConnectionGroupNum);
            DialogResult = DialogResult.OK;
        }
Example #3
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, Lans.g(this, "Delete this entire connection group?"), "", MessageBoxButtons.YesNo) == DialogResult.No)
     {
         return;
     }
     ConnGroupAttaches.DeleteForGroup(ConnectionGroupCur.ConnectionGroupNum);
     ConnectionGroups.Delete(ConnectionGroupCur.ConnectionGroupNum);
     DialogResult = DialogResult.OK;
 }
Example #4
0
 private void FormCentralConnectionGroupEdit_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         return;
     }
     if (ConnectionGroupCur.IsNew)
     {
         ConnGroupAttaches.DeleteForGroup(ConnectionGroupCur.ConnectionGroupNum);
         ConnectionGroups.Delete(ConnectionGroupCur.ConnectionGroupNum);
     }
 }
Example #5
0
 private void butAdd_Click(object sender, EventArgs e)
 {
     if (gridAvail.SelectedIndices.Length == 0)
     {
         MessageBox.Show(Lans.g(this, "Please select connections first."));
         return;
     }
     for (int i = 0; i < gridAvail.SelectedIndices.Length; i++)
     {
         ConnGroupAttaches.Attach(_listConnectionsAvail[gridAvail.SelectedIndices[i]].CentralConnectionNum, ConnectionGroupCur.ConnectionGroupNum);
     }
     FillGrid();
     FillGridAvail();
 }
Example #6
0
 private void FormCentralConnectionGroupEdit_Load(object sender, EventArgs e)
 {
     _listConns    = CentralConnections.GetConnections();
     _listConnsCur = new List <CentralConnection>();
     if (IsNew)
     {
         _listConnGroupAttaches = new List <ConnGroupAttach>();
     }
     else              //Take full list and filter out
     {
         _listConnGroupAttaches = ConnGroupAttaches.GetForGroup(ConnectionGroupCur.ConnectionGroupNum);
         //Grab all the connections associated to the corresponding connection group from the list of all connections.
         _listConnsCur = _listConns.FindAll(x => _listConnGroupAttaches.Exists(y => y.CentralConnectionNum == x.CentralConnectionNum));
     }
     textDescription.Text = ConnectionGroupCur.Description;
     FillGrid();
 }
Example #7
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)             //Do nothing
     {
         DialogResult = DialogResult.Cancel;
     }
     //Deletion is permanent.  Remove all groupattaches for this group then Set ConnectionGroupCur to null so parent form knows to remove it.
     if (MessageBox.Show(this, Lans.g(this, "Delete this entire connection group?"), "", MessageBoxButtons.YesNo) == DialogResult.No)
     {
         return;
     }
     for (int i = 0; i < _listConnGroupAttaches.Count; i++)
     {
         ConnGroupAttaches.Delete(_listConnGroupAttaches[i].ConnGroupAttachNum);
     }
     ConnectionGroupCur = null;
     DialogResult       = DialogResult.OK;
 }
Example #8
0
        private void FillGrid()
        {
            _listCentralConnGroups = ConnectionGroups.GetAll();
            //Get all conn group attaches because we will be using all of them in order to show counts.
            List <ConnGroupAttach> listConnGroupAttaches = ConnGroupAttaches.GetAll();
            //always fills combo, too, since it's the same list
            long defaultConnGroupNum = PrefC.GetLong(PrefName.ConnGroupCEMT);

            comboConnectionGroup.Items.Clear();
            comboConnectionGroup.Items.Add(Lan.g(this, "All"));
            comboConnectionGroup.SelectedIndex = 0;          //Select all by default.
            //Fill in the list of conn groups and update the selected index of the combo box if needed.
            for (int i = 0; i < _listCentralConnGroups.Count; i++)
            {
                comboConnectionGroup.Items.Add(_listCentralConnGroups[i].Description);
                if (_listCentralConnGroups[i].ConnectionGroupNum == defaultConnGroupNum)
                {
                    comboConnectionGroup.SelectedIndex = i + 1;
                }
            }
            //grid-----------------------------------------------------------------------------------------------------
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lans.g(this, "Group Name"), 280);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lans.g(this, "Conns"), 0);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            for (int i = 0; i < _listCentralConnGroups.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(_listCentralConnGroups[i].Description);
                row.Cells.Add(listConnGroupAttaches.FindAll(x => x.ConnectionGroupNum == _listCentralConnGroups[i].ConnectionGroupNum).Count.ToString());
                //row.Tag=connGroup;//Not really used currently, but we may want to add filtering later.
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }