private void AddWeekProfile(GXDLMSActivityCalendar target, int index, ListView li)
        {
            GXDLMSWeekProfile item = new GXDLMSWeekProfile();

            GXDLMSWeekProfile[] list;
            GXDLMSDayProfile[]  days;
            if (index == 3)
            {
                list = target.WeekProfileTableActive;
                days = target.DayProfileTableActive;
            }
            else
            {
                list = target.WeekProfileTablePassive;
                days = target.DayProfileTablePassive;
            }

            GXDLMSActivityCalendarWeekProfileDlg dlg = new GXDLMSActivityCalendarWeekProfileDlg(item, days);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                List <GXDLMSWeekProfile> items = new List <GXDLMSWeekProfile>();
                if (list != null)
                {
                    items.AddRange(list);
                }
                items.Add(item);
                if (index == 4)
                {
                    target.WeekProfileTableActive = items.ToArray();
                }
                else
                {
                    target.WeekProfileTablePassive = items.ToArray();
                }
                UpdateWeekProfile(item, null, li);
                errorProvider1.SetError(li, Properties.Resources.ValueChangedTxt);
                target.UpdateDirty(index, list);
            }
        }
        private void EditWeekProfile(GXDLMSActivityCalendar target, GXDLMSWeekProfile[] list, int index, ListViewItem li, ListView lv)
        {
            GXDLMSWeekProfile item = (GXDLMSWeekProfile)li.Tag;

            GXDLMSDayProfile[] days;
            if (index == 3)
            {
                days = target.DayProfileTableActive;
            }
            else
            {
                days = target.DayProfileTablePassive;
            }

            GXDLMSActivityCalendarWeekProfileDlg dlg = new GXDLMSActivityCalendarWeekProfileDlg(item, days);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                UpdateWeekProfile(item, li, lv);
                errorProvider1.SetError(lv, Properties.Resources.ValueChangedTxt);
                Target.UpdateDirty(index, list);
            }
        }