Пример #1
0
 public static void PerformSQLQuery(string sqlQuery)
 {
     using (useSQL.useSQL dbCon = new useSQL.useSQL(frm_menu.conStr))
     {
         dbCon.PerformQuery(sqlQuery);
     }
 }
Пример #2
0
        public static DataTable GetNDTOnlyData(DataTable dtData)
        {
            DataTable retData = new DataTable();

            for (int i = 1; i < dtData.Rows.Count; i++)
            {
                DataTable result = new DataTable();
                using (useSQL.useSQL dbCon = new useSQL.useSQL(frm_menu.conStr))
                {
                    result = dbCon.PerformQuery("SELECT UNIT,SERVICE, LINE,TRAIN, JOINTNUMBER, RTNUMBER1, RTDATE1, RTNUMBER2, RTDATE2, RTNUMBER3, RTDATE3,"
                                                + "RESHOOT, RESHOOTDATE, RESHOOT2, RESHOOTDATE2,RTACCEPTED,"
                                                + "PWHT1, PWHTDATE1, PWHT2, PWHTDATE2, PWHT3, PWHTDATE3, PWHTACCEPTED,"
                                                + "HT1, HTDATE1, HT2, HTDATE2, HT3, HTDATE3, HTAACCEPTED,"
                                                + "HTB, HTBDATE, HTB2, HTB2DATE, HTB3, HTB3DATE, HTBACCEPTED,"
                                                + "PMINUMBER, PMIDATE, PMI,"
                                                + "PTNUMBER, PTDATE, PT,"
                                                + "FERRIT, FERRITDATE, FERRIT2, FERRIT2DATE, FERRIT3, FERRIT3DATE, FERRITACCEPTED"
                                                + " from joints WITH (NOLOCK) where Unit ='" + dtData.Rows[i][1].ToString()
                                                + "' and [Service] ='" + dtData.Rows[i][0].ToString()
                                                + "' and Line ='" + dtData.Rows[i][2].ToString()
                                                + "' and Train='" + dtData.Rows[i][3].ToString()
                                                + "' and Jointnumber='" + dtData.Rows[i][4].ToString() + "'");
                }

                if (retData.Columns.Count == 0)
                {
                    retData = result.Clone();
                }
                retData.ImportRow(result.Rows[0]);
            }
            return(retData);
        }
Пример #3
0
 public static void InitWelders(DataTable dtWelder)
 {
     using (dbCon = new useSQL.useSQL(conStr))
     {
         dtWelder = dbCon.PerformQuery("select distinct id,rtrim(stamp) as [stamp],name,subcontractor, issueddate,expdate,remarks,active "
                                       + "from WelderList where stamp not like 'F%' order by stamp ");
     }
 }
Пример #4
0
        public static void InitJoints(DataTable dtJoints)
        {
            string script = File.ReadAllText(@"..\QUERIES\Joints.sql");

            using (dbCon = new useSQL.useSQL(conStr))
            {
                dtJoints = dbCon.PerformQuery(script);
            }
        }
Пример #5
0
        public static DataTable GetDBData(string sqlQuery)
        {
            DataTable returnData = new DataTable();

            using (useSQL.useSQL dbCon = new useSQL.useSQL(frm_menu.conStr))
            {
                returnData = dbCon.PerformQuery(sqlQuery);
            }
            return(returnData);
        }
Пример #6
0
        public static DataTable GetNDTJointData(NDT_Control.Data_Classes.NDT rawData)
        {
            DataTable retData = new DataTable();

            using (useSQL.useSQL dbCon = new useSQL.useSQL(frm_uploadData.conStr))
            {
                retData = dbCon.PerformQuery("select *"
                                             + " from joints WITH (NOLOCK) where Unit ='" + rawData._unit
                                             + "' and [Service] ='" + rawData._service
                                             + "' and Line ='" + rawData._line
                                             + "' and Train='" + rawData._train
                                             + "' and Jointnumber='" + rawData._joint + "'");
            }
            return(retData);
        }
Пример #7
0
        private void btnVerify_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbMode.SelectedItem.ToString().Equals("DWR AFTER PRESSURE TEST"))
                {
                    string        script = File.ReadAllText(@"..\QUERIES\DWR after TP.sql");
                    StringBuilder sb     = new StringBuilder(script);
                    sb.Replace("@testpacknum", txt_tp.Text);
                    sb.Replace("@TPDate", txt_tpDate.Text);

                    DataTable retData = new DataTable();
                    lst_joints.Items.Clear();

                    using (dbCon = new useSQL.useSQL(conStr))
                    {
                        retData = dbCon.PerformQuery(sb.ToString());
                    }

                    if (retData.Rows.Count > 0)
                    {
                        for (int n = 0; n < retData.Rows.Count; n++)
                        {
                            string[] row = { retData.Rows[n][0].ToString(), retData.Rows[n][1].ToString(),
                                             retData.Rows[n][2].ToString(), retData.Rows[n][3].ToString(),
                                             retData.Rows[n][4].ToString(), retData.Rows[n][5].ToString(),
                                             retData.Rows[n][6].ToString(), retData.Rows[n][7].ToString() };

                            var jointData = new ListViewItem(row);
                            lst_joints.Items.Add(jointData);
                        }
                    }
                    pnl_NDT_Loader.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("TP number or TP Date is invalid.");
            }
        }
Пример #8
0
        public void DWRCheck(DataTable dwrData)
        {
            DataTable dtresult = new DataTable();

            dtresult.Columns.Add("S/N");
            dtresult.Columns.Add("unit");
            dtresult.Columns.Add("service");
            dtresult.Columns.Add("line");
            dtresult.Columns.Add("train");
            dtresult.Columns.Add("joint");
            dtresult.Columns.Add("welder1 - SUBCON");
            dtresult.Columns.Add("welder2 - SUBCON");
            dtresult.Columns.Add("welder1 - PCA");
            dtresult.Columns.Add("welder2 - PCA");
            dtresult.Columns.Add("WELDER COMMENT");


            DataTable dtjoints = new DataTable();

            string[] rowData = new string[] { };

            for (int i = 0; i < dwrData.Rows.Count; i++)
            {
                using (dbCon = new useSQL.useSQL(conStr))
                {
                    dtjoints = dbCon.PerformQuery("select Unit, [Service], Line, Train, Spool, JointNumber,"
                                                  + "    welder1, welder2 "
                                                  + " from joints WITH (NOLOCK) where Unit ='" + dwrData.Rows[i][1]
                                                  + "' and [Service] ='" + dwrData.Rows[i][2]
                                                  + "' and Line ='" + dwrData.Rows[i][3]
                                                  + "' and Train='" + dwrData.Rows[i][4]
                                                  + "' and Jointnumber='" + dwrData.Rows[i][5] + "'");
                }


                if (dtjoints.Rows.Count > 0)
                {
                    rowData = new string[] { dwrData.Rows[i][0].ToString(), dwrData.Rows[i][1].ToString(), dwrData.Rows[i][2].ToString()
                                             , dwrData.Rows[i][3].ToString(), dwrData.Rows[i][4].ToString()
                                             , dwrData.Rows[i][5].ToString(), dwrData.Rows[i][6].ToString()
                                             , dwrData.Rows[i][7].ToString()
                                             , dtjoints.Rows[0]["welder1"].ToString()
                                             , dtjoints.Rows[0]["welder2"].ToString()
                                             , (dwrData.Rows[i][6].ToString() == dtjoints.Rows[0]["welder1"].ToString().Trim()) &&
                                             (dwrData.Rows[i][7].ToString() == dtjoints.Rows[0]["welder2"].ToString().Trim()) ? "MATCH" : "NOT MATCH" };
                }
                else
                {
                    rowData = new string[] { dwrData.Rows[i][0].ToString(), dwrData.Rows[i][1].ToString(), dwrData.Rows[i][2].ToString()
                                             , dwrData.Rows[i][3].ToString(), dwrData.Rows[i][4].ToString()
                                             , dwrData.Rows[i][5].ToString(), dwrData.Rows[i][6].ToString()
                                             , dwrData.Rows[i][7].ToString()
                                             , ""
                                             , ""
                                             , "ISO NOT EXISTING IN PCA" };
                }

                dtresult.NewRow();
                dtresult.Rows.Add(rowData);
            }

            string filePath = System.IO.Path.GetDirectoryName(txt_filePath.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(txt_filePath.Text) + " - DWR WELDER COMMENTS.xlsx";

            Utilities.ExportExcel(dtresult, filePath);
        }
Пример #9
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);
            }
        }
Пример #10
0
        public static DataTable CheckFilesFromLoader(DataTable worksheetCells)
        {
            useSQL.useSQL dbCon;
            string        conStr    = File.ReadAllText(@"..\ndtCon.cfg");
            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("Result");

            foreach (DataRow dr in worksheetCells.Rows)
            {
                DataTable dtDBReport = new DataTable();
                using (dbCon = new useSQL.useSQL(conStr))
                {
                    if (dr[1].Equals("RT"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(rtnumber1) as [reportnum],unit,service,line, train, JointNumber from Joints WITH(NOLOCK) WHERE RTNUMBER1 = '" + dr[0].ToString() + "' or "
                                                        + " RTNumber2 = '" + dr[0].ToString() + "' OR RTNumber3 = '" + dr[0].ToString() + "' or reshoot = '" + dr[0].ToString() + "' or reshoot2 = '" + dr[0].ToString() + "' ");
                    }
                    else if (dr[1].Equals("PWHT"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PWHT1) as [reportnum],unit,service,line, train, JointNumber from Joints WITH(NOLOCK) WHERE PWHT1 = '" + dr[0].ToString() + "' or PWHT2 ='" + dr[0].ToString() + "' OR PWHT3 = '" + dr[0].ToString() + "' ");
                    }
                    else if (dr[1].Equals("HTA"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(HT1),unit,service,line, train, JointNumber as [reportnum] from Joints WITH(NOLOCK) WHERE HT1 = '" + dr[0].ToString() + "' or HT2 = '" + dr[0].ToString() + "' OR HT3 = '" + dr[0].ToString() + "'");
                    }
                    else if (dr[1].Equals("HTB"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(HTB) as [reportnum],unit,service,line, train, JointNumber from Joints WITH(NOLOCK) WHERE HTB ='" + dr[0].ToString() + "' OR htb2 = '" + dr[0].ToString() + "' OR htb3 = '" + dr[0].ToString() + "'");
                    }
                    else if (dr[1].Equals("PMI"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PMINUMBER) as [reportnum],unit,service,line, train, JointNumber as [reportnum] from Joints WITH(NOLOCK) WHERE PMINUMBER ='" + dr[0].ToString() + "'");
                    }
                    else if (dr[1].Equals("PT"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(PTNUMBER) as [reportnum],unit,service,line, train, JointNumber as [reportnum] from Joints WITH(NOLOCK) WHERE PTNUMBER ='" + dr[0].ToString() + "'");
                    }
                    else if (dr[1].Equals("FT") || dr[1].Equals("FERRIT"))
                    {
                        dtDBReport = dbCon.PerformQuery("select distinct RTRIM(FERRIT) as [reportnum],unit,service,line, train, JointNumber from Joints WITH(NOLOCK) WHERE FERRIT = '" + dr[0].ToString() + "' OR ferrit2 = '" + dr[0].ToString() + "' or ferrit3 = '" + dr[0].ToString() + "'");
                    }
                }

                string[] strResult2 = null;

                if (dtDBReport.Rows.Count > 0)
                {
                    strResult2 = new string[] { dtDBReport.Rows[0][1].ToString(), dtDBReport.Rows[0][2].ToString(), dtDBReport.Rows[0][3].ToString(), dtDBReport.Rows[0][4].ToString(), dtDBReport.Rows[0][5].ToString(), dtDBReport.Rows[0][0].ToString(), "REPORT UPDATED" };
                }
                else
                {
                    strResult2 = new string[] { dtDBReport.Rows[0][1].ToString(), dtDBReport.Rows[0][2].ToString(), dtDBReport.Rows[0][3].ToString(), dtDBReport.Rows[0][4].ToString(), dtDBReport.Rows[0][5].ToString(), dtDBReport.Rows[0][0].ToString(), "REPORT NOT FOUND IN DATABASE" };
                }
                dtresult2.NewRow();
                dtresult2.Rows.Add(strResult2);
            }

            return(dtresult2);
        }