public NcManagementPage(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            InitializeComponent();

            // create pages instances
            QualityPage     = new NonConformityListPage(this, false);
            HsePage         = new NonConformityListPage(this, true);
            imageViewerPage = new ImageViewerPage(this);

            // set pages to their frames\
            QualityFrame.Content = QualityPage;
            HseFrame.Content     = HsePage;
            //SecondFrame.Content = imageViewerPage;

            focussedNcListPage = QualityPage;
        }
        public void ShowNcDetailForm(NonConformityListPage nonConformityListPage)//, int index)
        {
            // Get focussed NcCase (NOT OPTIMAL)

            /*int currentId = 0;
             * int ix = 0;
             * while (ix < focussedNcListPage.NcCaseList.Count) // && focussedNcListPage.NcCaseList[ix].id != ((NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex]).id)
             * //for(int i=0;i< focussedNcListPage.NcCaseList.Count;i++)
             * {
             *  if(focussedNcListPage.NcCaseList[ix].id == ((NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex]).id)
             *  {
             *      currentId = ix;
             *      ix = focussedNcListPage.NcCaseList.Count; // to exit the loop
             *  }
             *  ix++;
             * }*/
            // ---------------------------------



            NcFile ncCase = (NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex];//focussedNcListPage.NcCaseList[currentId];// focussedNcListPage.NcCaseDataGrid.SelectedIndex];

            Nullable <NcFileDetails> ncFileDetail = mainWindow.sqlTools.GetNcFileDetailSQL(ncCase.id, mainWindow);

            if (ncFileDetail.HasValue)
            {
                // get Bitmap images from server
                ncCaseBitmapImageList.Clear();
                ncCaseBitmapImageList.AddRange(mainWindow.sqlTools.GetImageListSQL(ncCase.id, mainWindow));


                if (ncCase.estimated_start_date != "")
                {
                    Nullable <NcFileFix> ncFileFix = mainWindow.sqlTools.GetNcFileFixSQL(ncCase.id, mainWindow);
                    ncFullDetailPage        = new NcFullDetailPage(this, ncCase, ncFileDetail.Value, ncFileFix.Value);
                    NcFileFormFrame.Content = ncFullDetailPage;
                }
                else
                {
                    ncDetailPage            = new NcDetailPage(this, ncCase, ncFileDetail.Value);
                    NcFileFormFrame.Content = ncDetailPage;
                }
                NewFormDialog.IsOpen = true;
            }
        }