예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public override void OnAccountChanged()
        {
            Oltp.AccountRow value = Window.CurrentAccount;

            //..............................
            // Segments
            _tabSegmentsInitialized = false;
            _segmentValueTables     = new Dictionary <Oltp.SegmentRow, Oltp.SegmentValueDataTable>();

            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    _segmentTable = proxy.Service.Segment_Get(value.ID, false);
                    foreach (Oltp.SegmentRow segment in _segmentTable.Rows)
                    {
                        Oltp.SegmentValueDataTable values = proxy.Service.SegmentValue_Get(value.ID, segment.SegmentID);
                        Oltp.SegmentValueRow defaultRow   = values.NewSegmentValueRow();
                        defaultRow.AccountID = value.ID;
                        defaultRow.SegmentID = segment.SegmentID;
                        defaultRow.ValueID   = -1;
                        defaultRow.Value     = "(none)";
                        values.Rows.InsertAt(defaultRow, 0);
                        values.AcceptChanges();
                        _segmentValueTables.Add(segment, values);
                    }
                }
            },
                                  delegate()
            {
                GetCreatives(value, null, false);
            });
        }
        public ActionResult AddNewSegmentValue(int segmentID, string newValue)
        {
            int newValueID = 0;

            using (var client = OltpLogicClient.Open(AppState.SessionID))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                Oltp.SegmentValueDataTable t = client.Service.SegmentValue_Get(acc_id, segmentID);
                Oltp.SegmentValueRow       r = t.NewSegmentValueRow();
                r.AccountID = acc_id;
                r.SegmentID = segmentID;
                r.Value     = newValue;
                t.AddSegmentValueRow(r);

                Oltp.SegmentValueDataTable t2 = client.Service.SegmentValue_Save(t);

                Dictionary <int, string> oldcollection = t.ToDictionary(z => z.ValueID, z => z.Value);
                Dictionary <int, string> newcollection = t2.ToDictionary(z => z.ValueID, z => z.Value);

                newValueID = newcollection.Where(n => !oldcollection.ContainsKey(n.Key)).First().Key;
            }

            return(Content(newValueID.ToString()));
        }
        /// <summary>
        ///
        /// </summary>
        private void SegmentValue_Add(object sender, RoutedEventArgs e)
        {
            string valueText = _segmentValueTextbox.Text.Trim();

            if (valueText.Length < 1)
            {
                return;
            }

            if (_segmentValuesTable.Select(String.Format("{0} = '{1}'",
                                                         _segmentValuesTable.ValueColumn.ColumnName,
                                                         valueText.Replace("'", "''"))).Length > 0)
            {
                MessageBoxError("This value is already defined.", null);
                return;
            }

            ObservableCollection <DataRow> source = _segmentValuesListTable.ListView.ItemsSource as ObservableCollection <DataRow>;

            Oltp.SegmentValueRow segmentValueRow = _segmentValuesTable.NewSegmentValueRow();
            segmentValueRow.AccountID = Window.CurrentAccount.ID;
            segmentValueRow.SegmentID = (Segment_dialog.TargetContent as Oltp.SegmentRow).SegmentID;
            segmentValueRow.Value     = valueText;
            _segmentValuesTable.Rows.Add(segmentValueRow);

            source.Add(segmentValueRow);
            _segmentValuesListTable.ListView.SelectedItem = segmentValueRow;
            _segmentValuesListTable.ListView.ScrollIntoView(segmentValueRow);

            // Deselect whatever
            _segmentValueTextbox.Text = String.Empty;
            _segmentValueTextbox.Focus();
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        private void SegmentValue_Add(object sender, RoutedEventArgs e)
        {
            string valueText = _segmentValueTextbox.Text;

            foreach (ValidationRule rule in _segmentAddValidation.ValidationRules)
            {
                ValidationResult result = rule.Validate(valueText, null);

                if (!result.IsValid)
                {
                    MainWindow.MessageBoxError(
                        result.ErrorContent == null ?
                        "Invalid value." :
                        result.ErrorContent as string,
                        null
                        );

                    return;
                }
            }

            ObservableCollection <DataRow> source = _segmentValuesListTable.ListView.ItemsSource as ObservableCollection <DataRow>;

            Oltp.SegmentValueRow segmentValueRow = _segmentValuesTable.NewSegmentValueRow();
            segmentValueRow.AccountID = Window.CurrentAccount.ID;
            segmentValueRow.SegmentID = (Segment_dialog.TargetContent as Oltp.SegmentRow).SegmentID;
            segmentValueRow.Value     = valueText;
            _segmentValuesTable.Rows.Add(segmentValueRow);

            source.Add(segmentValueRow);
            _segmentValuesListTable.ListView.SelectedItem = segmentValueRow;
            _segmentValuesListTable.ListView.ScrollIntoView(segmentValueRow);

            // Deselect whatever
            _segmentValueTextbox.Text = String.Empty;
            _segmentValueTextbox.Focus();
        }