Ejemplo n.º 1
0
        public SelectMSCRMEntity(IOrganizationService Service, String SearchStr, String Title, Boolean ShowAllAtStart, String Entity, String NameAttribute, String IDAttribute, Boolean AutoAcceptOneResult)
        {
            InitializeComponent();

            _Service = Service;

            _SearchResult = new DataTable("searchresult");
            _SearchResult.Columns.Add("id", typeof(String));
            _SearchResult.Columns.Add("name", typeof(String));

            SearchGrid.ItemsSource = _SearchResult;

            SearchGrid.IsFilterEnabled = true;
            SearchGrid.RefreshData();

            foreach (DevExpress.Xpf.Grid.GridColumn _gc in SearchGrid.Columns)
            {
                _gc.AllowAutoFilter     = true;
                _gc.AutoFilterCondition = DevExpress.Xpf.Grid.AutoFilterCondition.Contains;
                _gc.AllowEditing        = DevExpress.Utils.DefaultBoolean.False;
            }

            // SearchGrid.GroupBy(SearchGrid.Columns["gctype"], DevExpress.Data.ColumnSortOrder.Ascending);
            // SearchGrid.ExpandAllGroups();

            _Entity        = Entity;
            _NameAttribute = NameAttribute;
            _IDAttribute   = IDAttribute;

            if (SearchStr != "")
            {
                tbEntitySearch.Text = SearchStr.Trim();
            }

            if (ShowAllAtStart && tbEntitySearch.Text != "")
            {
                Int32 _count = GetSearchList(_Service, tbEntitySearch.Text.Trim(), _Entity, _NameAttribute, _IDAttribute);
                if (_count == 1 && AutoAcceptOneResult)
                {
                    Accept();
                }
            }

            if (Title != "")
            {
                this.Title = Title;
            }

            tbEntitySearch.Focus();
        }
Ejemplo n.º 2
0
        public Int32 GetSearchList(IOrganizationService _Service, String sSearchString, String sEntity, String sNameAttribute, String sIDAttribute)
        {
            Int32 rV = 0;

            this.Cursor = Cursors.Wait;

            btnAccept.IsEnabled = false;
            btnClose.IsEnabled  = false;

            if (_Service != null)
            {
                if (sSearchString.IndexOf("%") == -1)
                {
                    sSearchString = "%" + sSearchString + "%";
                }

                FilterExpression    filterExpression = new FilterExpression();
                ConditionExpression condition        = new ConditionExpression(sNameAttribute, ConditionOperator.Like, sSearchString);
                ConditionExpression condition2       = new ConditionExpression("isdisabled", ConditionOperator.Equal, "false");

                filterExpression.FilterOperator = LogicalOperator.And;

                if (sEntity == SystemUser.EntityLogicalName)
                {
                    filterExpression.AddCondition(condition);
                    filterExpression.AddCondition(condition2);
                }
                else
                {
                    filterExpression.AddCondition(condition);
                }

                QueryExpression query = new QueryExpression()
                {
                    EntityName = sEntity,
                    ColumnSet  = new ColumnSet(new String[] { sNameAttribute, sIDAttribute }),
                    Criteria   = filterExpression,
                    Distinct   = false,
                    NoLock     = true
                };

                RetrieveMultipleRequest multipleRequest = new RetrieveMultipleRequest();
                multipleRequest.Query = query;

                _SearchResult.Rows.Clear();

                RetrieveMultipleResponse response = (RetrieveMultipleResponse)_Service.Execute(multipleRequest);

                foreach (Entity _e in response.EntityCollection.Entities)
                {
                    rV++;

                    if (_e.Attributes[sNameAttribute] != null && _e.Attributes[sIDAttribute] != null)
                    {
                        DataRow _dr = null;
                        if ((_dr = _SearchResult.NewRow()) != null)
                        {
                            _dr["id"]   = _e.Attributes[sIDAttribute].ToString();
                            _dr["name"] = _e.Attributes[sNameAttribute].ToString();
                            _SearchResult.Rows.Add(_dr);
                        }
                    }
                }

                SearchGrid.RefreshData();
            }

            btnAccept.IsEnabled = true;
            btnClose.IsEnabled  = true;

            this.Cursor = Cursors.Arrow;

            return(rV);
        }
Ejemplo n.º 3
0
        public EntitySearch(DataTable _TimeEntryCache, String _User)
        {
            InitializeComponent();

            searchInfo.Content = "";
            this.Title         = "";
            TimeEntryCache     = _TimeEntryCache;

            SearchResult = new DataTable("favorites");

            SearchResult.Columns.Add("gctype", typeof(String));
            SearchResult.Columns.Add("gcdescription", typeof(String));
            SearchResult.Columns.Add("gcinfo1", typeof(String));
            SearchResult.Columns.Add("gcinfo2", typeof(String));

            SearchGrid.ItemsSource = SearchResult;

            SearchGrid.IsFilterEnabled = true;
            SearchGrid.RefreshData();
            SearchGrid.GroupBy(SearchGrid.Columns["gctype"], DevExpress.Data.ColumnSortOrder.Ascending);

            SearchGrid.ExpandAllGroups();

            //Boolean _check_failed = false;

            //// Check marked time entries
            //Int32 _sync_count = 0;
            //for (int i = 0; i < _parent_tv.SelectedRows.Count; i++)
            //{
            //    System.Data.DataRowView _drv = (System.Data.DataRowView)_parent_tv.SelectedRows[i];
            //    DataRow _dr = _drv.Row;
            //    String _status = "";
            //    String _tekz = "";
            //    try
            //    {
            //        _tekz = _dr["tekz"].ToString().Trim().ToUpper();
            //        _status = _dr["status"].ToString().Trim().ToUpper();
            //    }
            //    catch
            //    {
            //    }

            //    if (_status == "NOSYNC")
            //    {
            //        _sync_count++;
            //        if (Sync_Entity_Type == "")
            //        {
            //            Sync_Entity_Type = _tekz;
            //        }
            //        else
            //        {
            //            if (Sync_Entity_Type != _tekz)
            //            {
            //                MessageBox.Show("Es können nur Zeiteinträge vom gleichen MSCRM Typ (AP, ANF, VC) zugewiesen werden!", "Wichtiger Hinweis", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            //                _check_failed = true;
            //                break;
            //            }
            //        }
            //    }
            //}

            //if (_sync_count == 0)
            //{
            //    MessageBox.Show("Bitte markieren Sie mindestens einen Zeiteintrag für die Übertragung nach MSCRM!", "Wichtiger Hinweis", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            //    _check_failed = true;
            //}

            //if (_check_failed)
            //{
            //    this.Close();
            //} else
            //{
            //    if (Sync_Entity_Type == "AP")
            //    {
            //        if (_sync_count == 1)
            //             this.Title = "Zeiteintrag zu MSCRM Arbeitspaket zuweisen ...";
            //        else this.Title = _sync_count.ToString()+" Zeiteinträge zu MSCRM Arbeitspaket zuweisen ...";
            //    }
            //    else if (Sync_Entity_Type == "ANF")
            //    {
            //        if (_sync_count == 1)
            //             this.Title = "Zeiteintrag zu MSCRM Anfrage zuweisen ...";
            //        else this.Title = _sync_count.ToString()+" Zeiteinträge zu MSCRM Anfrage zuweisen ...";
            //    }
            //    else if (Sync_Entity_Type == "VC")
            //    {
            //        if (_sync_count == 1)
            //            this.Title = "Zeiteintrag zu MSCRM Verkaufschance zuweisen ...";
            //        else this.Title = _sync_count.ToString() + " Zeiteinträge zu MSCRM Verkaufschance zuweisen ...";
            //    }
            //}
        }