Beispiel #1
0
 public void changeLabel(string message)
 {
     mainMenu.ChangeUpperLabel(message);
 }
Beispiel #2
0
        public void LoadNDTStatus()
        {
            pic_ft.Visible   = false;
            pic_hta.Visible  = false;
            pic_htb.Visible  = false;
            pic_pmi.Visible  = false;
            pic_pt.Visible   = false;
            pic_pwht.Visible = false;
            pic_rt.Visible   = false;

            DataTable rt   = new DataTable("RT");
            DataTable pwht = new DataTable("PWHT");
            DataTable pmi  = new DataTable("PMI");
            DataTable htb  = new DataTable("HTB");
            DataTable hta  = new DataTable("HTA");
            DataTable pt   = new DataTable("PT");
            DataTable ft   = new DataTable("FT");

            mainMenu.ChangeUpperLabel("RT STATUS LOADING...");
            string rtQuery = File.ReadAllText(@"..\NDT Status\Status\RT.sql");

            rt = Utilities.GetDBData(rtQuery);
            Utilities.DTtoDG(CalculateStatus(rt), dgv_RT);

            mainMenu.ChangeUpperLabel("PWHT STATUS LOADING...");
            string pwhtQuery = File.ReadAllText(@"..\NDT Status\Status\PWHT.sql");

            pwht = Utilities.GetDBData(pwhtQuery);

            Utilities.DTtoDG(CalculateStatus(pwht), dgv_pwht);

            mainMenu.ChangeUpperLabel("PMI STATUS LOADING...");
            string pmiQuery = File.ReadAllText(@"..\NDT Status\Status\PMI.sql");

            pmi = Utilities.GetDBData(pmiQuery);

            Utilities.DTtoDG(CalculateStatus(pmi), dgv_pmi);

            mainMenu.ChangeUpperLabel("HTB STATUS LOADING...");
            string htbQuery = File.ReadAllText(@"..\NDT Status\Status\HTB.sql");

            htb = Utilities.GetDBData(htbQuery);

            Utilities.DTtoDG(CalculateStatus(htb), dgv_htb);

            mainMenu.ChangeUpperLabel("HTA STATUS LOADING...");
            string htaQuery = File.ReadAllText(@"..\NDT Status\Status\HTA.sql");

            hta = Utilities.GetDBData(htaQuery);

            Utilities.DTtoDG(CalculateStatus(hta), dgv_hta);

            mainMenu.ChangeUpperLabel("PT STATUS LOADING...");
            string ptQuery = File.ReadAllText(@"..\NDT Status\Status\PT.sql");

            pt = Utilities.GetDBData(ptQuery);

            Utilities.DTtoDG(CalculateStatus(pt), dgv_pt);

            mainMenu.ChangeUpperLabel("FT STATUS LOADING...");
            string ftQuery = File.ReadAllText(@"..\NDT Status\Status\FT.sql");

            ft = Utilities.GetDBData(ftQuery);

            Utilities.DTtoDG(CalculateStatus(ft), dgv_ft);
        }
        private void NDTPerformanceExport()
        {
            DataTable pwht = new DataTable("PWHT");
            DataTable pmi  = new DataTable("PMI");
            DataTable hta  = new DataTable("HTA");
            DataTable pt   = new DataTable("PT");
            DataTable ft   = new DataTable("FT");

            string addUnits = GetCheckedUnits();

            //mainMenu.ChangeUpperLabel("EXTRACTING PWHT");
            string pwhtQuery = File.ReadAllText(@"..\Queries\NDT PERFORMANCE\NDT PERFORMANCE (PWHT).sql");

            pwhtQuery     += addUnits;
            pwht           = Utilities.GetDBData(pwhtQuery);
            pwht.TableName = "PWHT";

            mainMenu.ChangeUpperLabel("EXTRACTING PMI");
            string pmiQuery = File.ReadAllText(@"..\Queries\NDT PERFORMANCE\NDT PERFORMANCE (PMI).sql");

            pmiQuery     += addUnits;
            pmi           = Utilities.GetDBData(pmiQuery);
            pmi.TableName = "PMI";

            mainMenu.ChangeUpperLabel("EXTRACTING HTA");
            string htaQuery = File.ReadAllText(@"..\Queries\NDT PERFORMANCE\NDT PERFORMANCE (HTA).sql");

            htaQuery     += addUnits;
            hta           = Utilities.GetDBData(htaQuery);
            hta.TableName = "HTA";

            mainMenu.ChangeUpperLabel("EXTRACTING PT");
            string ptQuery = File.ReadAllText(@"..\Queries\NDT PERFORMANCE\NDT PERFORMANCE (PT).sql");

            ptQuery     += addUnits;
            pt           = Utilities.GetDBData(ptQuery);
            pt.TableName = "PT";
            mainMenu.ChangeUpperLabel("EXTRACTING FT");
            string ftQuery = File.ReadAllText(@"..\Queries\NDT PERFORMANCE\NDT PERFORMANCE (FT).sql");

            ftQuery     += addUnits;
            ft           = Utilities.GetDBData(ftQuery);
            ft.TableName = "FT";

            mainMenu.ChangeUpperLabel("EXPORTING TO EXCEL...");

            List <DataTable> NDTPerformances = new List <DataTable>();

            NDTPerformances.Add(pwht);
            NDTPerformances.Add(pmi);
            NDTPerformances.Add(hta);
            NDTPerformances.Add(pt);
            NDTPerformances.Add(ft);

            if (Utilities.ExportExcel(NDTPerformances, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + " NDT PERFORMANCE.xlsx"))
            {
                MetroMessageBox.Show(mainMenu, "FILE LOCATED ON YOUR DESKTOP", "NDT PERFORMANCE EXPORT SUCCESSFUL!", MessageBoxButtons.OK, MessageBoxIcon.Question, 150);
            }
            else
            {
                MetroMessageBox.Show(mainMenu, "", "NDT PERFORMANCE EXPORT FAILED!", MessageBoxButtons.OK, MessageBoxIcon.Error, 150);
            }
        }
Beispiel #4
0
        public static void CheckFiles(string ndtType, frm_menu updateLoading)
        {
            HashSet <string> dtpdf = new HashSet <string>();

            useSQL.useSQL dbCon;
            string        conStr = File.ReadAllText(@"..\ndtCon.cfg");
            DirectoryInfo d      = null;

            if (ndtType.Equals("RT"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\RT");
            }
            else if (ndtType.Equals("PWHT"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\PWHT");
            }
            else if (ndtType.Equals("HTA"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\HTA");
            }
            else if (ndtType.Equals("HTB"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\HTB");
            }
            else if (ndtType.Equals("PMI"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\PMI");
            }
            else if (ndtType.Equals("PT"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\PT");
            }
            else if (ndtType.Equals("FT") || ndtType.Equals("FERRIT"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\NDT\Ferrit");
            }
            else if (ndtType.Equals("DWR"))
            {
                d = new DirectoryInfo(@"Z:\04 - Construction\04-Site Progress Report\ISOMETRICS\ABOVEGROUND\WeldReport");
            }

            FileInfo[] Files = d.GetFiles("*.pdf");

            int filectr = 0;

            foreach (FileInfo file in Files)
            {
                filectr++;
                dtpdf.Add(Path.GetFileNameWithoutExtension(file.Name));
                updateLoading.ChangeUpperLabel("TOTAL PDF FILES:" + filectr);
            }

            DataTable dtDBReport = new DataTable();

            using (dbCon = new useSQL.useSQL(conStr))
            {
                if (ndtType.Equals("RT"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(rtnumber1) as [reportnum],unit,service,line, train, JointNumber, rtdate1,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE] "
                                                    + " from Joints WITH(NOLOCK) WHERE RTNUMBER1 <> '' union select distinct RTRIM(RTnumber2) "
                                                    + ",unit,service,line, train, JointNumber, rtdate2,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE RTNUMBER2 <> '' "
                                                    + " union select distinct RTRIM(RTnumber3),unit,service,line, train, JointNumber,rtdate3,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WHERE RTNUMBER3 <> '' union select distinct RTRIM(reshoot) "
                                                    + ",unit,service,line, train, JointNumber,reshootdate,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE RESHOOT <> '' union "
                                                    + "select distinct RTRIM(reshoot2),unit,service,line, train, JointNumber,reshootdate2,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  "
                                                    + "from Joints WITH(NOLOCK) WHERE RESHOOT2 <> ''");
                }
                else if (ndtType.Equals("PWHT"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PWHT1) as [reportnum],unit,service,line, train, JointNumber,pwhtdate1,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE PWHT1 <> '' union select distinct RTRIM(PWHT2)"
                                                    + ",unit,service,line, train, JointNumber,pwhtdate2,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE PWHT2 <> '' union select distinct RTRIM(PWHT3)"
                                                    + ",unit,service,line, train, JointNumber,pwhtdate3,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE PWHT3 <>''");
                }
                else if (ndtType.Equals("HTA"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(HT1)  as [reportnum],unit,service,line, train, JointNumber,htdate1,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE] from Joints WITH(NOLOCK) WHERE HT1 <> '' union select distinct RTRIM(HT2)"
                                                    + ",unit,service,line, train, JointNumber,htdate2,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE HT2 <> '' union select distinct RTRIM(HT3),unit,service,line, train, JointNumber,htdate3,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE] "
                                                    + " from Joints WITH(NOLOCK) WHERE HT3 <>''");
                }
                else if (ndtType.Equals("HTB"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(HTB) as [reportnum],unit,service,line, train, JointNumber,htbdate,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE HTB <> '' union select distinct RTRIM(HTB2)"
                                                    + ",unit,service,line, train, JointNumber,htb2date,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE HTB2 <> '' union select distinct RTRIM(HTB3),unit,service,line, train, JointNumber,htb3date,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE] "
                                                    + " from Joints WITH(NOLOCK) WHERE HTB3 <>''");
                }
                else if (ndtType.Equals("PMI"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PMINUMBER) as [reportnum],unit,service,line, train, JointNumber, pmidate,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]   from Joints WITH(NOLOCK) WHERE PMINUMBER <> ''");
                }
                else if (ndtType.Equals("PT"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PTNUMBER) as [reportnum],unit,service,line, train, JointNumber,ptdate,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE PTNUMBER <> ''");
                }
                else if (ndtType.Equals("FT") || ndtType.Equals("FERRIT"))
                {
                    dtDBReport = dbCon.PerformQuery("select distinct RTRIM(FERRIT) as [reportnum],unit,service,line, train, JointNumber,ferritdate,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE FERRIT <> '' union select distinct RTRIM(FERRIT2)"
                                                    + ",unit,service,line, train, JointNumber,ferrit2date,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]  from Joints WITH(NOLOCK) WHERE FERRIT2 <> '' union select distinct RTRIM(FERRIT3),unit,service,line, train, JointNumber,ferrit3date,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE]"
                                                    + " from Joints WITH(NOLOCK) WHERE FERRIT3 <> ''");
                }
                else if (ndtType.Equals("DWR"))
                {
                    dtDBReport = dbCon.PerformQuery("SELECT DISTINCT WeldingReportNumber AS [reportnum],UNIT,SERVICE,LINE,TRAIN, JOINTNUMBER, dateofweld,case when active = 1 then 'ACTIVE' else 'CANCELED' end as [ACTIVE] FROM JOINTS"
                                                    + "   WHERE"
                                                    + "   WeldingReportNumber <> ''"
                                                    + "   AND "
                                                    + "   Active =1"
                                                    + "   AND JointType NOT IN ('FJ','TH')");
                }
            }

            var hashSet    = new HashSet <string[]>(DTtoList(dtDBReport));
            var pcaReports = new HashSet <string>(dtDBReport.AsEnumerable().Select(x => x.Field <string>("reportnum")));

            DataTable dtresult1 = new DataTable();

            dtresult1.Columns.Add("ReportNumber");
            dtresult1.Columns.Add("Result");
            string[] strResult1     = null;
            var      hashReports    = hashSet.First();
            int      pdfreportCount = 0;

            if (!ndtType.Equals("DWR"))
            {
                foreach (string c in dtpdf)
                {
                    updateLoading.ChangeLowerLabel(pdfreportCount++, dtpdf.Count(), "PDF FILE CHECKING:  ");
                    if (pcaReports.Contains(c))
                    {
                        strResult1 = new string[] { c, "REPORT UPDATED IN PCA" };
                    }
                    else
                    {
                        strResult1 = new string[] { c, "NOT UPDATED" };
                    }

                    dtresult1.NewRow();
                    dtresult1.Rows.Add(strResult1);
                }
            }

            DataTable dtresult2 = new DataTable();

            dtresult2.Columns.Add("UNIT");
            dtresult2.Columns.Add("SERVICE");
            dtresult2.Columns.Add("LINE");
            dtresult2.Columns.Add("TRAIN");
            dtresult2.Columns.Add("JOINTNUMBER");
            dtresult2.Columns.Add("ReportNumber");
            dtresult2.Columns.Add("ReportDate");
            dtresult2.Columns.Add("Joint Active");
            dtresult2.Columns.Add("Result");

            string[] strResult2    = null;
            int      dbReportCount = 0;
            int      totalrepcount = hashSet.Count();

            foreach (string[] c in hashSet)
            {
                dbReportCount++;
                //updateLoading.ChangeLowerLabel(dbReportCount, totalrepcount, "PCA JOINT REPORTS CHECKING:  ");
                //updateLoading.ChangeUpperLabel("PAKPAKPAK LABAN LNG BES:" + dbReportCount);
                if (Regex.IsMatch(c[0], @"\s"))
                {
                    if (dtpdf.Contains(c[0].Trim()))
                    {
                        if (!ndtType.Equals("DWR"))
                        {
                            strResult2 = new string[] { c[1], c[2], c[3], c[4], c[5], c[0], c[6], c[7], "REPORT EXISTING IN MAIN FOLDER BUT UPDATED WITH SPACES" };
                        }
                    }
                    else
                    {
                        strResult2 = new string[] { c[1], c[2], c[3], c[4], c[5], c[0], c[6], c[7], "REPORT MISSING IN MAIN FOLDER" };
                    }
                }
                else
                {
                    if (dtpdf.Contains(c[0]))
                    {
                        if (!ndtType.Equals("DWR"))
                        {
                            strResult2 = new string[] { c[1], c[2], c[3], c[4], c[5], c[0], c[6], c[7], "REPORT EXISTING IN MAIN FOLDER" };
                        }
                    }
                    else
                    {
                        strResult2 = new string[] { c[1], c[2], c[3], c[4], c[5], c[0], c[6], c[7], "REPORT MISSING IN MAIN FOLDER" };
                    }
                }

                if (strResult2 != null)
                {
                    dtresult2.NewRow();
                    dtresult2.Rows.Add(strResult2);
                }
            }

            string fn = null;

            if (ndtType.Equals("RT"))
            {
                fn = " RT CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("PWHT"))
            {
                fn = " PWHT CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("HTA"))
            {
                fn = " HTA CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("HTB"))
            {
                fn = " HTB CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("PMI"))
            {
                fn = " PMI CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("PT"))
            {
                fn = " PT CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("FT") || ndtType.Equals("FERRIT"))
            {
                fn = " FT CHECK FILE RESULT.xlsx";
            }
            else if (ndtType.Equals("DWR"))
            {
                fn = " DWR CHECK FILE RESULT.csv";
            }

            if (!ndtType.Equals("DWR"))
            {
                try
                {
                    ExportExcel(dtresult1, dtresult2, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + fn);
                    MetroMessageBox.Show(updateLoading, "", "RESULT SUCCESSFULLY IMPORTED! FILE LOCATED IN YOUR DESKTOP.", MessageBoxButtons.OK, MessageBoxIcon.Question, 150);
                }
                catch (Exception ex)
                {
                    MetroMessageBox.Show(updateLoading, "IMPORT FAILED", "There is something wrong. " + ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Hand, 150);
                }
            }
            else
            {
                ExportExcel(dtresult2, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + fn);
            }
        }