private void PhoneBook_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (sender is Microsoft.Windows.Controls.DataGridCell)
     {
         Microsoft.Windows.Controls.DataGridCell tempcell = sender as Microsoft.Windows.Controls.DataGridCell;
         Microsoft.Windows.Controls.DataGridRow  row      = null;
         var parent = VisualTreeHelper.GetParent(tempcell);
         while (parent != null && parent.GetType() != typeof(Microsoft.Windows.Controls.DataGridRow))
         {
             parent = VisualTreeHelper.GetParent(parent);
             if (parent is Microsoft.Windows.Controls.DataGridRow)
             {
                 row = parent as Microsoft.Windows.Controls.DataGridRow;
                 break;
             }
         }
         if (row != null)
         {
             Pointel.Interactions.Chat.Helpers.Contacts selectedContact = (Pointel.Interactions.Chat.Helpers.Contacts)row.Item;
             dgvContact.SelectedItem        = (Pointel.Interactions.Chat.Helpers.Contacts)row.Item;
             _phoneBookText                 = selectedContact.Number;
             _phoneBookMenu.PlacementTarget = row;
             _phoneBookMenu.IsOpen          = true;
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Handles the RowEditEnding event of the DGAttachData control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs"/> instance containing the event data.</param>
 private void DGAttachData_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
 {
     try
     {
         Microsoft.Windows.Controls.DataGridRow dgRow = e.Row;
         if (dgRow != null)
         {
             var    selectedCallData = dgRow.Item as CallData;
             string key            = selectedCallData.Key.ToString().Trim();
             string value          = selectedCallData.Value.ToString().Trim();
             var    updateCallData = new SoftPhone();
             if (_dataContext.userAttachData.ContainsKey(key))
             {
                 string originalValue = _dataContext.userAttachData[key];
                 if (value != originalValue)
                 {
                     _dataContext.userAttachData.Remove(key);
                     _dataContext.userAttachData.Add(key, value);
                     updateCallData.UpdateUserData(_dataContext.userAttachData);
                 }
             }
             BindGrid();
         }
     }
     catch (Exception ex)
     {
         _logger.Error("Error occurred as " + ex.Message);
     }
 }
 static Microsoft.Windows.Controls.DataGridCell TryToFindGridCell(Microsoft.Windows.Controls.DataGrid grid, Microsoft.Windows.Controls.DataGridCellInfo cellInfo)
 {
     Microsoft.Windows.Controls.DataGridCell result = null;
     Microsoft.Windows.Controls.DataGridRow  row    = null;
     try
     {
         grid.ScrollIntoView(cellInfo.Item);
         grid.UpdateLayout();
         row = (Microsoft.Windows.Controls.DataGridRow)grid.ItemContainerGenerator.ContainerFromItem(cellInfo.Item);
         if (row != null)
         {
             int columnIndex = grid.Columns.IndexOf(cellInfo.Column);
             if (columnIndex > -1)
             {
                 Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter presenter = GetVisualChild <Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter>(row);
                 result = presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex) as Microsoft.Windows.Controls.DataGridCell;
             }
         }
     }
     catch (Exception generalException)
     {
         string error = generalException.Message;
         result = null;
     }
     return(result);
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow         row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            StandardInclusionResource.StandardInclusionPAG s   = (StandardInclusionResource.StandardInclusionPAG)row.Item;
            bool exists = false;

            if (s.PAGID != 0 && s.SIBrandID != 0 && s.SIRegionGroupID != 0)
            {
                if (s.StandardInclusionID == 0)
                {
                    if (!StandardInclusionExists(s))
                    {
                        exists = false;
                    }
                    else
                    {
                        exists = true;
                    }
                }

                if (exists)
                {
                    MessageBox.Show("This inclusion PAG for this brand and region group already exists.");
                }
                else
                {
                    try
                    {
                        sr.SaveStandardInclusions(s);
                        if (row.DetailsVisibility == Visibility.Visible)
                        {
                            row.DetailsVisibility = Visibility.Collapsed;
                        }
                        btnSearch_Click(null, null);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                if (s.PAGID == 0)
                {
                    MessageBox.Show("Please select a PAG.");
                }
                else if (s.SIRegionGroupID == 0)
                {
                    MessageBox.Show("Please select a region group.");
                }
                else if (s.SIBrandID == 0)
                {
                    MessageBox.Show("Please select a Brand.");
                }
            }
        }
Esempio n. 5
0
        private void RowDoubleClick(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow row1 = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            DataRowView dr = (DataRowView)row1.Item;

            ProductID        = dr["productid"].ToString();
            ProductName      = dr["productname"].ToString();
            isStudioMProduct = bool.Parse(dr["isstudiomproduct"].ToString());
            this.Close();
        }
Esempio n. 6
0
 private void RowDoubleClick(object sender, RoutedEventArgs e)
 {
     Microsoft.Windows.Controls.DataGridRow row1 = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
     if (row1.DetailsVisibility == Visibility.Visible)
     {
         row1.DetailsVisibility = Visibility.Collapsed;
     }
     else
     {
         row1.DetailsVisibility = Visibility.Visible;
     }
 }
Esempio n. 7
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            ManagementResource.Answer s = (ManagementResource.Answer)row.Item;
            bool exists = false;

            if (s.QuestionID == null || s.QuestionID < 1)
            {
                MessageBox.Show("Please select a question for the answer.");
            }
            else
            {
                if (s.AnswerText != null && s.AnswerText.Trim() != "")
                {
                    if (s.AnswerID == 0)
                    {
                        if (!AnswerExists(s))
                        {
                            exists = false;
                        }
                        else
                        {
                            exists = true;
                        }
                    }

                    if (exists)
                    {
                        MessageBox.Show("This answer already exists.");
                    }
                    else
                    {
                        try
                        {
                            mr.SaveAnswer(s);
                            if (row.DetailsVisibility == Visibility.Visible)
                            {
                                row.DetailsVisibility = Visibility.Collapsed;
                            }
                            btnSearch_Click(null, null);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please enter an answer text.");
                }
            }
        }
        private void DGCaseDataInfo_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
        {
            var chatMedia = new ChatMedia();

            try
            {
                Microsoft.Windows.Controls.DataGridRow dgRow = e.Row;
                if (dgRow != null)
                {
                    var    selectedCallData = dgRow.Item as ChatCaseData;
                    string key   = selectedCallData.Key.ToString().Trim();
                    string value = selectedCallData.Value.ToString().Trim();
                    if (_chatUtil.UserData.ContainsKey(key))
                    {
                        string originalValue = _chatUtil.UserData[key].ToString();
                        if (value != originalValue)
                        {
                            KeyValueCollection caseData = new KeyValueCollection();
                            caseData.Add(key, value);
                            OutputValues output = chatMedia.DoUpdateCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                            if (output.MessageCode == "200")
                            {
                                _chatUtil.UserData.Remove(key);
                                _chatUtil.UserData.Add(key, value);
                            }
                            caseData.Clear();
                        }
                    }
                    else
                    {
                        KeyValueCollection caseData = new KeyValueCollection();
                        caseData.Add(key, value);
                        OutputValues output = chatMedia.DoAddCaseDataProperties(_interactionID, _chatUtil.ProxyId, caseData);
                        if (output.MessageCode == "200")
                        {
                            _chatUtil.UserData.Add(key, value);
                        }
                        caseData.Clear();
                    }
                    BindGrid();
                }
            }
            catch (Exception commonException)
            {
                _logger.Error("Error occurred while DGCaseDataInfo_RowEditEnding(): " + commonException.ToString());
            }
            finally
            {
                chatMedia = null;
            }
        }
Esempio n. 9
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            ManagementResource.Question            s   = (ManagementResource.Question)row.Item;
            bool exists = false;

            s.QuestionText = RemoveExtraCarriageReturn(s.QuestionText);

            if (s.QuestionText != null && s.QuestionText.Trim() != "")
            {
                if (s.QuestionID == 0)
                {
                    if (!QuestionExists(s))
                    {
                        exists = false;
                    }
                    else
                    {
                        exists = true;
                    }
                }

                if (exists)
                {
                    MessageBox.Show("This question already exists.");
                }
                else
                {
                    try
                    {
                        mr.SaveQuestion(s);
                        if (row.DetailsVisibility == Visibility.Visible)
                        {
                            row.DetailsVisibility = Visibility.Collapsed;
                        }
                        btnSearch_Click(null, null);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter a question text.");
            }
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            RetailClusterSource.RetailCluster      s   = (RetailClusterSource.RetailCluster)row.Item;
            bool exists = false;

            if (s.RetailClusterName != null && s.RetailClusterName.Trim() != "")
            {
                if (s.RetailClusterID == 0)
                {
                    if (!RetailClusterExists(s))
                    {
                        exists = false;
                    }
                    else
                    {
                        exists = true;
                    }
                }

                if (exists)
                {
                    MessageBox.Show("This cluster already exists.");
                }
                else
                {
                    try
                    {
                        rs.SaveRetailCluster(s);
                        if (row.DetailsVisibility == Visibility.Visible)
                        {
                            row.DetailsVisibility = Visibility.Collapsed;
                        }
                        btnSearch_Click(null, null);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter a cluster name.");
            }
        }
Esempio n. 11
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            SupplierBrandResource.SupplierBrand    s   = (SupplierBrandResource.SupplierBrand)row.Item;
            bool exists = false;

            if (s.SupplierBrandName != null && s.SupplierBrandName.Trim() != "")
            {
                if (s.SupplierBrandID == 0)
                {
                    if (!SupplierBrandExists(s))
                    {
                        exists = false;
                    }
                    else
                    {
                        exists = true;
                    }
                }

                if (exists)
                {
                    MessageBox.Show("This brand already exists.");
                }
                else
                {
                    try
                    {
                        br.SaveSupplierBrand(s);
                        if (row.DetailsVisibility == Visibility.Visible)
                        {
                            row.DetailsVisibility = Visibility.Collapsed;
                        }
                        btnSearch_Click(null, null);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter a question text.");
            }
        }
        /// <summary>
        /// Handles the PreparingCellForEdit event of the DGCaseDataInfo control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.Windows.Controls.DataGridPreparingCellForEditEventArgs"/> instance containing the event data.</param>
        private void DGCaseDataInfo_PreparingCellForEdit(object sender, Microsoft.Windows.Controls.DataGridPreparingCellForEditEventArgs e)
        {
            Microsoft.Windows.Controls.DataGridRow dgRow = e.Row;
            dgRow.IsSelected = true;
            var contentPresenter = e.EditingElement as ContentPresenter;
            var editingTemplate  = contentPresenter.ContentTemplate;
            var textBox          = (editingTemplate as DataTemplate).FindName("txtValue", (contentPresenter as ContentPresenter));

            if (textBox == null)
            {
                return;
            }

            if (!(textBox is TextBox))
            {
                return;
            }
            (textBox as TextBox).Focus();
            isEditDone = false;
        }
Esempio n. 13
0
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));

                // change the details visibility
                if (row.DetailsVisibility == Visibility.Collapsed)
                {
                    row.DetailsVisibility = Visibility.Visible;
                }
                else
                {
                    row.DetailsVisibility = Visibility.Collapsed;
                }
                btnSearch_Click(null, null);
            }
            catch (System.Exception)
            {
            }
        }
 /// <summary>
 /// Handles the RowEditEnding event of the DGCaseDataInfo control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs"/> instance containing the event data.</param>
 private void DGCaseDataInfo_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
 {
     try
     {
         Microsoft.Windows.Controls.DataGridRow dgRow = e.Row;
         if (dgRow != null)
         {
             var    selectedCallData = dgRow.Item as EmailCaseData;
             string key   = selectedCallData.Key.ToString().Trim();
             string value = selectedCallData.Value.ToString().Trim();
             if (!isEditDone)
             {
                 isEditDone = true;
                 if (CurrentData.ContainsKey(key))
                 {
                     string originalValue = CurrentData[key].ToString();
                     if (value != originalValue)
                     {
                         KeyValueCollection caseData = new KeyValueCollection();
                         caseData.Add(key, value);
                         InteractionService interactionService = new InteractionService();
                         Pointel.Interactions.Core.Common.OutputValues result = interactionService.UpdateCaseDataProperties(interactionId, EmailDataContext.GetInstance().ProxyClientID, caseData);
                         if (result.MessageCode == "200")
                         {
                             CurrentData[key] = value;
                         }
                         caseData.Clear();
                     }
                 }
                 else
                 {
                     KeyValueCollection caseData = new KeyValueCollection();
                     caseData.Add(key, value);
                     InteractionService interactionService = new InteractionService();
                     Pointel.Interactions.Core.Common.OutputValues result = interactionService.AddCaseDataProperties(interactionId, EmailDataContext.GetInstance().ProxyClientID, caseData);
                     if (result.MessageCode == "200")
                     {
                         CurrentData.Add(key, value);
                     }
                     caseData.Clear();
                 }
                 return;
             }
             else
             {
                 if (CurrentData.ContainsKey(key))
                 {
                     string originalValue = CurrentData[key].ToString();
                     if (value != originalValue)
                     {
                         CurrentData.Remove(key);
                         CurrentData.Add(key, value);
                     }
                 }
                 else
                 {
                     CurrentData.Add(key, value);
                 }
             }
             ConvertUserData();
         }
     }
     catch (Exception ex)
     {
         logger.Error("dgCaseInfo_RowEditEnding: " + ex.Message);
     }
 }
Esempio n. 15
0
        private static void ToolkitGridColumnFastEditOnFocus(Microsoft.Windows.Controls.DataGridCell cell, KeyboardFocusChangedEventArgs e)
        {
            if (cell == null || cell.IsEditing || cell.IsReadOnly)
            {
                return;
            }

            Microsoft.Windows.Controls.DataGrid dataGrid = FindVisualParent <Microsoft.Windows.Controls.DataGrid>(cell);
            if (dataGrid == null)
            {
                return;
            }

            dataGrid.UnselectAll();

            if (dataGrid.SelectionUnit != Microsoft.Windows.Controls.DataGridSelectionUnit.FullRow)
            {
                if (!cell.IsSelected)
                {
                    cell.IsSelected = true;
                }
            }
            else
            {
                Microsoft.Windows.Controls.DataGridRow row = FindVisualParent <Microsoft.Windows.Controls.DataGridRow>(cell);
                if (row != null && !row.IsSelected)
                {
                    row.IsSelected = true;
                }
            }

            String statusmsg = "";

            if (cell.Content is TextBlock)
            {
                TextBlock tb = cell.Content as TextBlock;
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }
            else if (cell.Content is TextBox)
            {
                TextBox tb = cell.Content as TextBox;
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }
            else if (cell.Content is ComboBox)
            {
                ComboBox cb = cell.Content as ComboBox;
                if (cb != null)
                {
                    statusmsg = cb.Text;
                    //DataGrid dataGrid = FindVisualParent<DataGrid>(cell);
                    cell.Dispatcher.Invoke(
                        DispatcherPriority.Background,
                        new Action(delegate { }));
                    cb.IsDropDownOpen = true;
                }
            }
            if (cell.Content is ContentPresenter)
            {
                TextBlock tb = FindVisualChild <TextBlock>(cell);
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }

            StatusMessage.setStatus(statusmsg);
        }
Esempio n. 16
0
        private void ToolkitDataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            Microsoft.Windows.Controls.DataGrid dataGrid = sender as Microsoft.Windows.Controls.DataGrid;
            if (dataGrid == null)
            {
                return;
            }

            if (e.Key == Key.Enter || e.Key == Key.Tab || e.Key == Key.Down || e.Key == Key.Up || e.Key == Key.Right || e.Key == Key.Left)
            {
                if (dataGrid.ItemsSource != null && dataGrid.SelectedIndex == dataGrid.Items.Count - 2)
                {
                    var border = VisualTreeHelper.GetChild(dataGrid, 0) as Decorator;
                    if (border != null)
                    {
                        var scroll = border.Child as ScrollViewer;
                        if (scroll != null)
                        {
                            scroll.ScrollToEnd();
                        }
                    }
                }
            }


            if (e.Key == Key.Enter || e.Key == Key.Tab)
            {
                TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
                request.Wrapped = true;

                Microsoft.Windows.Controls.DataGridRow rowContainer = (Microsoft.Windows.Controls.DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.CurrentItem);
                if (rowContainer != null)
                {
                    int columnIndex = dataGrid.Columns.IndexOf(dataGrid.CurrentColumn);
                    Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter presenter = GetVisualChild <Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer);
                    dataGrid.CommitEdit();
                    Microsoft.Windows.Controls.DataGridCell cell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                    cell.MoveFocus(request);
                    dataGrid.SelectedItem = dataGrid.CurrentItem;
                    e.Handled             = true;
                    dataGrid.UpdateLayout();
                    try
                    {
                        dataGrid.BeginEdit(e);
                    }
                    catch (System.InvalidOperationException)
                    {
                        //Ignore error if it is 'Recursive call to Automation Peer API is not valid.'
                    }
                }
            }
            else if (e.Key == Key.Down || e.Key == Key.Up || e.Key == Key.Right || e.Key == Key.Left)
            {
                int columnIndex = dataGrid.Columns.IndexOf(dataGrid.CurrentColumn);
                Microsoft.Windows.Controls.DataGridRow rowContainer = (Microsoft.Windows.Controls.DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.CurrentItem);
                if (rowContainer != null)
                {
                    Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter presenter = GetVisualChild <Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer);
                    Microsoft.Windows.Controls.DataGridCell currentcell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

                    if (currentcell.Content is ContentPresenter)
                    {
                        DatePickerCus datepicker = FindVisualChild <DatePickerCus>(currentcell);
                        if (datepicker != null && datepicker.IsDropDownOpen)
                        {
                            e.Handled = true;
                            return;
                        }

                        ComboBoxWithSearch combo = FindVisualChild <ComboBoxWithSearch>(currentcell);
                        if (combo != null && combo.IsDropDownOpen)
                        {
                            e.Handled = true;
                            return;
                        }
                    }

                    if (e.Key == Key.Down)
                    {
                        dataGrid.CommitEdit();
                        dataGrid.SelectedIndex++;

                        rowContainer = (Microsoft.Windows.Controls.DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.SelectedItem);
                        if (rowContainer != null)
                        {
                            presenter = GetVisualChild <Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer);
                            Microsoft.Windows.Controls.DataGridCell cell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                            cell.Focus();
                            dataGrid.CurrentItem = dataGrid.SelectedItem;
                            e.Handled            = true;
                            dataGrid.UpdateLayout();
                            try
                            {
                                dataGrid.BeginEdit(e);
                            }
                            catch (System.InvalidOperationException)
                            {
                                //Ignore error if it is 'Recursive call to Automation Peer API is not valid.'
                            }
                        }
                    }
                    else if (e.Key == Key.Up)
                    {
                        if (dataGrid.ItemsSource != null && dataGrid.SelectedIndex == 0)
                        {
                            return;
                        }

                        dataGrid.CommitEdit();
                        dataGrid.SelectedIndex--;

                        rowContainer = (Microsoft.Windows.Controls.DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.SelectedItem);
                        if (rowContainer != null)
                        {
                            presenter = GetVisualChild <Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer);
                            Microsoft.Windows.Controls.DataGridCell cell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                            cell.Focus();
                            dataGrid.CurrentItem = dataGrid.SelectedItem;
                            e.Handled            = true;
                            dataGrid.UpdateLayout();
                            try
                            {
                                dataGrid.BeginEdit(e);
                            }
                            catch (System.InvalidOperationException)
                            {
                                //Ignore error if it is 'Recursive call to Automation Peer API is not valid.'
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="row">The row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <returns></returns>
        public static Microsoft.Windows.Controls.DataGridCell GetCell(Microsoft.Windows.Controls.DataGrid host, Microsoft.Windows.Controls.DataGridRow row, int columnIndex)
        {
            if (row == null)
            {
                return(null);
            }

            var presenter = GetVisualChild <DataGridCellsPresenter>(row);

            if (presenter == null)
            {
                return(null);
            }

            // try to get the cell but it may possibly be virtualized
            var cell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

            if (cell == null)
            {
                // now try to bring into view and retreive the cell
                host.ScrollIntoView(row, host.Columns[columnIndex]);
                cell = (Microsoft.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
            }
            return(cell);
        }
Esempio n. 18
0
 public static Microsoft.Windows.Controls.DataGridCell GetCell(Microsoft.Windows.Controls.DataGrid dataGrid, Microsoft.Windows.Controls.DataGridRow rowContainer, int column)
 {
     if (rowContainer != null)
     {
         DataGridCellsPresenter presenter = FindVisualChild <DataGridCellsPresenter>(rowContainer);
         if (presenter == null)
         {
             /* if the row has been virtualized away, call its ApplyTemplate() method
              * to build its visual tree in order for the DataGridCellsPresenter
              * and the DataGridCells to be created */
             rowContainer.ApplyTemplate();
             presenter = FindVisualChild <DataGridCellsPresenter>(rowContainer);
         }
         if (presenter != null)
         {
             Microsoft.Windows.Controls.DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as Microsoft.Windows.Controls.DataGridCell;
             if (cell == null)
             {
                 /* bring the column into view
                  * in case it has been virtualized away */
                 dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[column]);
                 cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as Microsoft.Windows.Controls.DataGridCell;
             }
             return(cell);
         }
     }
     return(null);
 }
Esempio n. 19
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            int     forregional   = 0;
            int     active        = 0;
            decimal promotioncost = 0;
            decimal capevalue     = 0;
            int     multiplepromotionid;
            bool    ok          = true;
            string  baseproduct = "";
            string  message     = "";


            Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem));
            CommonResource.FullMultiplePromotion   dv  = (CommonResource.FullMultiplePromotion)row.Item;

            if (dv != null)
            {
                if (dv.PromotionName.Trim() == "")
                {
                    message = "Please enter promotion name.";
                    ok      = false;
                }
                if (dv.BaseProduct != null)
                {
                    baseproduct = dv.BaseProduct;
                }
                else
                {
                    message = "Please enter base product.";
                    ok      = false;
                }

                if (dv.DisplayCodeID < 1)
                {
                    message = "Please select a price display code.";
                    ok      = false;
                }

                try
                {
                    promotioncost = decimal.Parse(dv.PromotionCost.ToString());
                }
                catch (Exception ex)
                {
                    message = "Please enter a valid promotion cost.";
                    ok      = false;
                }
                try
                {
                    capevalue = decimal.Parse(dv.CapeVale.ToString());
                }
                catch (Exception ex)
                {
                    message = "Please enter a valid cape value.";
                    ok      = false;
                }
                multiplepromotionid = int.Parse(dv.MultiplePromotionID.ToString());
                if (dv.ForRegional)
                {
                    forregional = 1;
                }

                if (dv.Active)
                {
                    active = 1;
                }

                if (ok)
                {
                    client = new SQSAdminServiceClient();
                    client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint);
                    client.SQSAdmin_Promotion_UpdatePromotion(multiplepromotionid, baseproduct, promotioncost, capevalue, forregional, active, dv.DisplayCodeID, dv.PromotionName);
                    client.Close();

                    SearchPromotion();
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }