コード例 #1
0
        private void MakeFresh()
        {
            lstvClient.ItemsSource = null;

            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    var dataClient = from c in contextDB.RequestList
                                     select new
                    {
                        c.id_request,
                        c.famil,
                        c.f_name,
                        c.s_name
                    };
                    listsRLC = new List <RequestListC>();
                    foreach (var itemC in dataClient)
                    {
                        RequestListC rlc = new RequestListC();
                        rlc.IdItem = itemC.id_request;
                        rlc.Client = itemC.famil + " " + itemC.f_name + " " + itemC.s_name;
                        listsRLC.Add(rlc);
                    }
                    lstvClient.ItemsSource       = listsRLC.OrderBy(n => n.Number);
                    lstvClient.SelectedValuePath = "IdItem";
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #2
0
        private void txtBNameClient_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (txtBNameClient.Text != "")
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        var dataClientSearch = from c in contextDB.RequestList
                                               where c.famil.ToLower()
                                               .Contains(txtBNameClient.Text
                                                         .ToLower())
                                               select new
                        {
                            c.id_request,
                            c.famil,
                            c.f_name,
                            c.s_name
                        };
                        listsRLC = new List <RequestListC>();
                        foreach (var item in dataClientSearch)
                        {
                            RequestListC sRequest = new RequestListC();
                            sRequest.IdItem = item.id_request;
                            sRequest.Client = item.famil + " " + item.f_name + " " + item.s_name;



                            listsRLC.Add(sRequest);
                        }

                        lstvClient.ItemsSource       = listsRLC.OrderBy(s => s.Client);
                        lstvClient.SelectedValuePath = "IdItem";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MakeFresh();
            }
        }