Ejemplo n.º 1
0
        private void butDuplicate_Click(object sender, EventArgs e)
        {
            if (gridCustom.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an custom alert category from the list first.");
                return;
            }
            List <AlertCategory> listNewAlertCategories = _listInternalAlertCategory.Select(x => x.Copy()).ToList();
            AlertCategory        alertCat = _listCustomAlertCategory[gridCustom.GetSelectedIndex()].Copy();

            alertCat.Description += Lan.g(this, "(Copy)");
            listNewAlertCategories.Add(alertCat);
            //alertCat.AlertCategoryNum reflects the original pre-copied PK. After sync this will be a new PK for the new row.
            List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum);

            if (AlertCategories.Sync(listNewAlertCategories, _listInternalAlertCategory))
            {
                //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks
                listAlertCategoryType.ForEach(x => {
                    x.AlertCategoryNum = alertCat.AlertCategoryNum;
                    AlertCategoryLinks.Insert(x);
                });
                DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks);
                FillGrids(selectedCustomKey: alertCat.AlertCategoryNum);
            }
        }
Ejemplo n.º 2
0
 private void FormAlertCategoryEdit_Load(object sender, EventArgs e)
 {
     textDesc.Text       = _categoryCur.Description;
     listShownAlertTypes = Enum.GetValues(typeof(AlertType)).OfType <AlertType>().ToList();
     listShownAlertTypes.RemoveAll(x => !PrefC.IsODHQ && x.IsODHQ());
     if (_categoryCur.IsHQCategory)
     {
         textDesc.Enabled  = false;
         butDelete.Enabled = false;
         butOK.Enabled     = false;
     }
     listOldAlertCategoryLinks = AlertCategoryLinks.GetForCategory(_categoryCur.AlertCategoryNum);
     InitAlertTypeSelections();
 }
Ejemplo n.º 3
0
        private void InsertCopyAlertCategory(AlertCategory alertCat)
        {
            alertCat.IsHQCategory = false;
            alertCat.Description += Lan.g(this, "(Copy)");
            //alertCat.AlertCategoryNum reflects the original pre-copied PK. After Insert this will be a new PK for the new row.
            List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum);

            alertCat.AlertCategoryNum = AlertCategories.Insert(alertCat);
            //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks
            listAlertCategoryType.ForEach(x => {
                x.AlertCategoryNum = alertCat.AlertCategoryNum;
                AlertCategoryLinks.Insert(x);
            });
            DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks);
            FillGrids();
        }