Advertisement
lilos404

validation zone

Apr 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. static void accessValidation()
  2.         {
  3.             var accessListe = ACCESS_Page.Columns[0].ExistingCells.ToArray();
  4.             var cells = MPD_Page.Columns[4].ExistingCells.ToArray();
  5.             var zonesListes = MPD_Page.Columns[6].ExistingCells.ToArray();
  6.             string[] accessValue = new string[accessListe.Length];
  7.  
  8.             for (int i = 0; i < accessListe.Length; i++)
  9.             {
  10.                 accessValue[i] = accessListe[i].Value.ToString();
  11.          
  12.             }
  13.  
  14.  
  15.             string indice = "";
  16.  
  17.             for (int i = 1; i < cells.Length; i++)
  18.             {
  19.                 indice = "E" + (i + 1).ToString();
  20.                 bool notFound = false;
  21.                 string[] ligneAccess , zones ;
  22.                 string[] access;
  23.                 string[] cellAccessValues , cellAccessValuesReversed;
  24.  
  25.                 if (cells[i].Value.ToString() == "")
  26.                 {
  27.                     continue;
  28.                 }
  29.  
  30.                 zones = zonesListes[i].Value.ToString().Split('\n');
  31.                 ligneAccess = cells[i].Value.ToString().Split('\n');
  32.  
  33.                 if (zones.Length < ligneAccess.Length)
  34.                 {
  35.                     MPD_Page.Cells[indice].FillColor = Color.Red;
  36.                     continue;
  37.  
  38.                 }
  39.                 cellAccessValues = cells[i].Value.ToString().Replace('\n', ';').Split(';');
  40.                 cellAccessValuesReversed = cells[i].Value.ToString().Replace('\n', ';').Split(';');
  41.                 Array.Reverse(cellAccessValuesReversed);
  42.                
  43.  
  44.                 foreach (var itemligne in ligneAccess)
  45.                 {
  46.                    
  47.                     if (itemligne != "") {
  48.                     access = itemligne.Split(';');
  49.                     foreach (var itemaccess in access)
  50.                     {
  51.                        
  52.                        if (Array.IndexOf(accessValue, itemaccess)== -1 || (Array.IndexOf(cellAccessValues, itemaccess) != (cellAccessValues.Length - Array.IndexOf(cellAccessValuesReversed, itemaccess)) - 1))
  53.                         {
  54.                             notFound = true;
  55.                             MPD_Page.Cells[indice].FillColor = Color.Red;
  56.                             break;
  57.                         }
  58.                     }
  59.                     if (notFound)
  60.                     {
  61.                         break;
  62.                     }
  63.                 }
  64.  
  65.  
  66.  
  67.                 }
  68.  
  69.  
  70.  
  71.             }
  72.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement