Example #1
0
        public void UpdateAddressesData()
        {
            List <TerritoryAddress> addresses = new List <TerritoryAddress>();

            if (allAddresses != null)
            {
                foreach (DataRow row in allAddresses.Rows)
                {
                    string logement = row["Logement"].ToString();

                    string type = row["Type de territoire"].ToString();
                    if (logement != null && logement.Length > 0 && !type.Equals("P") && !type.Equals("C"))
                    //if (logement != null && logement.Length > 0)
                    {
                        TerritoryAddress add = new TerritoryAddress();
                        add.TerritoryNumber = row["Numéro de territoire"].ToString();
                        add.Address         = row["Adresse"].ToString();
                        add.Details         = row["Logement"].ToString();

                        string status = row["Statut"].ToString();
                        add.Language = row["Langue"].ToString();
                        add.Remark   = row["Notes"].ToString();
                        add.Status   = status; // "Ne voulant Plus être Visité"

                        addresses.Add(add);
                    }
                }
            }

            allAddressesData.FilteredItemsSource = addresses;
        }
Example #2
0
        private void TerritoriesData_SelectedCellsChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid dataGrid = sender as DataGrid;

            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                // find row for the first selected item
                DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]);
                if (row != null)
                {
                    DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);
                    // find grid cell object for the cell with index 0
                    DataGridCell cellTerritoryNumber = presenter.ItemContainerGenerator.ContainerFromIndex(1) as DataGridCell;

                    // Trying to get the mail (third column)
                    string territoryNumber            = ((TextBlock)cellTerritoryNumber.Content).Text;
                    List <TerritoryAddress> addresses = new List <TerritoryAddress>();
                    if (allAddresses != null)
                    {
                        foreach (DataRow row2 in allAddresses.Rows)
                        {
                            string currentRowTerritoryNumber = row2["Numéro de territoire"].ToString();
                            string logement = row2["Logement"].ToString();
                            if (currentRowTerritoryNumber == territoryNumber && logement != null && logement.Length > 0)
                            {
                                TerritoryAddress add = new TerritoryAddress();
                                add.TerritoryNumber = territoryNumber;
                                add.Address         = row2["Adresse"].ToString();
                                add.Details         = row2["Logement"].ToString();
                                add.Status          = row2["Statut"].ToString();
                                add.Language        = row2["Langue"].ToString();
                                add.Remark          = row2["Notes"].ToString();

                                addresses.Add(add);
                            }
                        }
                    }

                    territoryAddressesData.FilteredItemsSource = addresses;
                }
            }
        }