Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void thresholdValidation(int column_number)
- {
- var cells = MPD_Page.Columns[column_number].ExistingCells.ToArray();
- string indice = "";
- string[] thresholdValues = new string[cells.Length];
- var TC = INTERVAL_Page.Columns[9].ExistingCells.ToArray();
- var TC1 = INTERVAL_Page.Columns[11].ExistingCells.ToArray();
- var TC2 = INTERVAL_Page.Columns[12].ExistingCells.ToArray();
- var CHK = CHECK_Page.Columns[1].ExistingCells.ToArray();
- string[] trackingCodeValues = new string[TC.Length-1];
- string[] checkValues = new string[CHK.Length - 1];
- int[] minValues = new int[TC.Length - 1];
- int[] maxValues = new int[TC.Length - 1];
- for (int i = 0; i < TC.Length-1; i++)
- {
- trackingCodeValues[i] = TC[i+1].Value.ToString();
- minValues[i] = Int32.Parse(TC1[i + 1].Value.ToString());
- maxValues[i] = Int32.Parse(TC2[i + 1].Value.ToString());
- }
- for (int i = 0; i < CHK.Length - 1; i++)
- {
- checkValues[i] = CHK[i + 1].Value.ToString();
- }
- for (int i = 0; i < cells.Length; i++)
- {
- thresholdValues[i] = cells[i].Value.ToString();
- }
- for (int i = 1; i < thresholdValues.Length; i++)
- {
- indice = "K" + (i + 1).ToString();
- string[] text ;
- if (thresholdValues[i] != "")
- {
- // MPD_Page.Cells[indice].FillColor = Color.Red;
- text = thresholdValues[i].Split(new string[] { "OR" }, StringSplitOptions.None);
- switch (text.Length)
- {
- case 1:
- if (!testInterval(text[0],-1)) {
- MPD_Page.Cells[indice].FillColor = Color.Red;
- }
- break;
- case 2:
- if (!testInterval(text[0], 0) || !testInterval(text[1], 2))
- {
- MPD_Page.Cells[indice].FillColor = Color.Red;
- }
- break;
- default:
- if (!testInterval(text[0], 0))
- {
- MPD_Page.Cells[indice].FillColor = Color.Red;
- }
- for (int j = 1; j < text.Length-1; j++)
- {
- if (!testInterval(text[j], 1))
- {
- MPD_Page.Cells[indice].FillColor = Color.Red;
- }
- }
- if (!testInterval(text[text.Length-1], 2))
- {
- MPD_Page.Cells[indice].FillColor = Color.Red;
- }
- break;
- }
- bool testInterval(string v1, int v2)
- {
- string value;
- if (v2 == -1)
- {
- if (v1.IndexOf('\n')>=0)
- {
- return false;
- } else
- {
- value = v1;
- }
- }
- else if (v2 == 0)
- {
- if (v1[v1.Length - 1] != '\n')
- {
- return false;
- } else
- {
- value = v1.Split('\n')[0];
- }
- }
- else if (v2 == 1)
- {
- if (v1[0] != '\n' || v1[v1.Length - 1] != '\n' )
- {
- return false;
- } else
- {
- value = v1.Split('\n')[1];
- }
- }
- else
- {
- if (v1[0] != '\n')
- {
- return false;
- } else
- {
- value = v1.Split('\n')[1];
- }
- }
- if (value.IndexOf(' ')<0)
- {
- if (Array.IndexOf(thresholdValues, value) < 0)
- return false;
- }
- else
- {
- int part1 = Int32.Parse(value.Split(' ')[0]);
- string part2 = value.Split(' ')[1];
- int index = Array.IndexOf(trackingCodeValues, part2);
- if (index < 0 || (part1 < minValues[index] || part1 > maxValues[index]))
- {
- return false;
- }
- }
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement