Exemplo n.º 1
0
        private void EditPerformance()
        {
            if (listViewCompliance.SelectedItems.Count == 0 ||
                !(listViewCompliance.SelectedItems[0].Tag is EventTypeRiskLevelChangeRecord))
            {
                return;
            }

            CAAEventTypeRiskLevelChangeRecord changeRecord =
                listViewCompliance.SelectedItems[0].Tag as CAAEventTypeRiskLevelChangeRecord;
            CommonEditorForm form = new CommonEditorForm(changeRecord);

            if (form.ShowDialog() == DialogResult.OK)
            {
                listViewCompliance.Items[listViewCompliance.Items.IndexOf(listViewCompliance.SelectedItems[0])] =
                    new ListViewItem(GetListViewSubItems(changeRecord), null)
                {
                    Tag = changeRecord
                };
            }
        }
Exemplo n.º 2
0
        private ListViewItem.ListViewSubItem[] GetListViewSubItems(CAAEventTypeRiskLevelChangeRecord item)
        {
            List <PropertyInfo> properties = GetTypeProperties();

            ListViewItem.ListViewSubItem[] subItems = new ListViewItem.ListViewSubItem[properties.Count];
            for (int i = 0; i < properties.Count; i++)
            {
                object value = properties[i].GetValue(item, null);
                if (value != null)
                {
                    string valueString;
                    if (value is DateTime)
                    {
                        valueString = SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)value);
                    }
                    else
                    {
                        valueString = value.ToString();
                    }


                    subItems[i] = new ListViewItem.ListViewSubItem
                    {
                        Text = valueString,
                        Tag  = value
                    };
                }
                else
                {
                    subItems[i] = new ListViewItem.ListViewSubItem
                    {
                        Text = "",
                        Tag  = ""
                    };
                }
            }
            return(subItems);
        }
Exemplo n.º 3
0
        private void AddPerformance()
        {
            try
            {
                var newRecord =
                    new CAAEventTypeRiskLevelChangeRecord {
                    ParentEventType = _smsEventType
                };
                CommonEditorForm form = new CommonEditorForm(newRecord);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    listViewCompliance.Items.Add(new ListViewItem(GetListViewSubItems(newRecord), null)
                    {
                        Tag = newRecord
                    });
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while building new object", ex);
                return;
            }
        }