Exemplo n.º 1
0
        internal static void CopyInspection(string InspectionID)
        {
            DateTime  dateTime   = DateAndTime.DateAdd(DateInterval.Day, (double)checked (-1 * Inspection.IInspectionWindow), DateAndTime.Today);
            DataTable dataTable1 = mdUtility.DB.GetDataTable("SELECT * FROM Inspection_Data WHERE [insp_data_id]={" + InspectionID + "}");

            if (dataTable1.Rows.Count <= 0)
            {
                throw new Exception("Unable to find the source inspection record.");
            }
            DataTable dataTable2 = mdUtility.DB.GetDataTable("SELECT * FROM Inspection_Data WHERE [INSP_DATA_INSP_DATE]>=#" + Conversions.ToString(dateTime) + "# AND [INSP_DATA_SEC_ID]={" + dataTable1.Rows[0]["insp_data_sec_id"].ToString() + "}");
            bool      flag;
            string    uniqueId1;

            if (dataTable2.Rows.Count == 0)
            {
                flag = false;
                DataRow drDest = dataTable2.NewRow();
                Inspection.CopyDataRow(dataTable1.Rows[0], ref drDest);
                DataRow dataRow = drDest;
                dataRow["bred_status"] = (object)"N";
                uniqueId1 = mdUtility.GetUniqueID();
                dataRow["insp_data_id"]        = (object)uniqueId1;
                dataRow["insp_data_insp_date"] = (object)DateAndTime.Today;
                dataRow["InspectorLink"]       = (object)mdUtility.strCurrentInspector;
                dataRow["INSP_Source"]         = (object)nameof(Inspection);
                dataTable2.Rows.Add(drDest);
                mdUtility.DB.SaveDataTable(ref dataTable2, "SELECT * FROM Inspection_Data");
                mdUtility.fMainForm.m_bInspNew = true;
            }
            else
            {
                flag      = true;
                uniqueId1 = Conversions.ToString(dataTable2.Rows[0]["insp_data_id"]);
            }
            string sSQL;

            if (flag)
            {
                sSQL = "SELECT * FROM Sample_Data WHERE [samp_data_insp_data_id]={" + InspectionID + "} AND [samp_data_id]={" + Strings.Replace(Conversions.ToString(mdUtility.fMainForm.cboLocation.SelectedValue), "'", "''", 1, -1, CompareMethod.Binary) + "}";
            }
            else
            {
                sSQL = "SELECT * FROM Sample_Data WHERE [samp_data_insp_data_id]={" + InspectionID + "}";
            }
            DataTable dataTable3   = mdUtility.DB.GetDataTable(sSQL);
            DataTable tableSchema1 = mdUtility.DB.GetTableSchema("Sample_Data");

            try
            {
                foreach (DataRow row1 in dataTable3.Rows)
                {
                    DataRow drDest = tableSchema1.NewRow();
                    Inspection.CopyDataRow(row1, ref drDest);
                    DataRow dataRow1 = drDest;
                    dataRow1["BRED_Status"] = (object)"C";
                    string uniqueId2 = mdUtility.GetUniqueID();
                    dataRow1["samp_data_id"]           = (object)uniqueId2;
                    dataRow1["samp_data_insp_data_id"] = (object)uniqueId1;
                    dataRow1["samp_data_comments"]     = (object)DBNull.Value;
                    tableSchema1.Rows.Add(drDest);
                    mdUtility.DB.SaveDataTable(ref tableSchema1, "SELECT * FROM Sample_Data");
                    mdUtility.fMainForm.m_bSampleNew = true;
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(dataTable2.Rows[0]["insp_data_type"], (object)1, false))
                    {
                        DataTable tableSchema2 = mdUtility.DB.GetTableSchema("Sample_Subcomponent");
                        DataTable dataTable4   = mdUtility.DB.GetDataTable(Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"SELECT * FROM Sample_Subcomponent WHERE [samp_subcomp_samp_id]={", row1["samp_data_id"]), (object)"}")));
                        try
                        {
                            foreach (DataRow row2 in dataTable4.Rows)
                            {
                                drDest = tableSchema2.NewRow();
                                Inspection.CopyDataRow(row2, ref drDest);
                                DataRow dataRow2 = drDest;
                                dataRow2["BRED_Status"] = (object)"N";
                                string uniqueId3 = mdUtility.GetUniqueID();
                                dataRow2["samp_subcomp_id"]       = (object)uniqueId3;
                                dataRow2["samp_subcomp_samp_id"]  = (object)uniqueId2;
                                dataRow2["samp_subcomp_comments"] = (object)DBNull.Value;
                                dataRow2["samp_subcomp_ci"]       = (object)DBNull.Value;
                                tableSchema2.Rows.Add(drDest);
                                mdUtility.DB.SaveDataTable(ref tableSchema2, "SELECT * FROM Sample_Subcomponent");
                                DataTable tableSchema3 = mdUtility.DB.GetTableSchema("Sample_SubComp_Distress");
                                DataTable dataTable5   = mdUtility.DB.GetDataTable(Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"SELECT * FROM Sample_SubComp_Distress WHERE [ssd_subcomp_id]={", row2["samp_subcomp_id"]), (object)"}")));
                                try
                                {
                                    foreach (DataRow row3 in dataTable5.Rows)
                                    {
                                        drDest = tableSchema3.NewRow();
                                        Inspection.CopyDataRow(row3, ref drDest);
                                        DataRow dataRow3 = drDest;
                                        dataRow3["BRED_Status"]    = (object)"N";
                                        dataRow3["ssd_id"]         = (object)mdUtility.GetUniqueID();
                                        dataRow3["ssd_subcomp_id"] = (object)uniqueId3;
                                        tableSchema3.Rows.Add(drDest);
                                        mdUtility.DB.SaveDataTable(ref tableSchema3, "SELECT * FROM Sample_SubComp_Distress");
                                    }
                                }
                                finally
                                {
                                    IEnumerator enumerator;
                                    if (enumerator is IDisposable)
                                    {
                                        (enumerator as IDisposable).Dispose();
                                    }
                                }
                            }
                        }
                        finally
                        {
                            IEnumerator enumerator;
                            if (enumerator is IDisposable)
                            {
                                (enumerator as IDisposable).Dispose();
                            }
                        }
                    }
                }
            }
            finally
            {
                IEnumerator enumerator;
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            mdUtility.fMainForm.m_bInspLoaded = false;
            Inspection.LoadInspectionDates(dataTable2.Rows[0]["insp_data_sec_id"].ToString());
            mdUtility.fMainForm.m_bInspLoaded = true;
            mdUtility.fMainForm.SetInspChanged(true);
        }
Exemplo n.º 2
0
        internal static void LoadInspectionDates(string strSectionID)
        {
            DataTable dataTable = mdUtility.DB.GetDataTable("SELECT * FROM [Section Info] WHERE [sec_id]={" + strSectionID + "}");

            if (dataTable.Rows.Count == 0)
            {
                throw new Exception("Unable to load Inspection.  Unable to find section information.");
            }
            DataRow row       = dataTable.Rows[0];
            frmMain fMainForm = mdUtility.fMainForm;

            fMainForm.txtComponent.Text        = Conversions.ToString(row["comp_desc"]);
            fMainForm.lblMaterialCategory.Text = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(row["mat_cat_lbl"], (object)":"));
            fMainForm.txtMaterialCategory.Text = Conversions.ToString(row["mat_cat_desc"]);
            fMainForm.txtComponentType.Text    = Conversions.ToString(row["comp_type_desc"]);
            if (fMainForm.miUnits.Checked)
            {
                fMainForm.lblSecQtyValue.Text = Support.Format(RuntimeHelpers.GetObjectValue(Interaction.IIf((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Conversions.ToString(row["eng_qty"]), "", false) > 0U, RuntimeHelpers.GetObjectValue(row["eng_qty"]), (object)"")), "##,##0", Microsoft.VisualBasic.FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1);
                fMainForm.lblSecQtyUM.Text    = Conversions.ToString(row["uom_eng_unit_abbr"]);
            }
            else
            {
                fMainForm.lblSecQtyValue.Text = Support.Format(RuntimeHelpers.GetObjectValue(Interaction.IIf((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Conversions.ToString(row["met_qty"]), "", false) > 0U, RuntimeHelpers.GetObjectValue(row["met_qty"]), (object)"")), "##,##0", Microsoft.VisualBasic.FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1);
                fMainForm.lblSecQtyUM.Text    = Conversions.ToString(row["uom_met_unit_abbr"]);
            }
            fMainForm.chkSampPainted.Enabled = Conversions.ToBoolean(row["SEC_PAINT"]);
            fMainForm.frmDirectPaint.Visible = Conversions.ToBoolean(row["SEC_PAINT"]);
            string sSQL;

            if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(fMainForm.tvInspection.GetNodeByKey(fMainForm.CurrentSection).Parent.Parent.Parent.Tag, (object)"Non-sampling", false))
            {
                if (mdUtility.fMainForm.tvInspection.GetNodeByKey(mdUtility.fMainForm.CurrentLocation) != null)
                {
                    sSQL = "SELECT DISTINCT [insp_data_id], insp_data_insp_date, insp_date FROM qryInspectionList WHERE [insp_data_sec_id]={" + strSectionID + "} AND [INSP_DATA_SAMP] = TRUE AND [SAMP_DATA_LOC]={" + Strings.Replace(mdUtility.fMainForm.tvInspection.GetNodeByKey(mdUtility.fMainForm.CurrentLocation).Tag.ToString(), "'", "''", 1, -1, CompareMethod.Binary) + "} AND (BRED_Status <> 'D' OR BRED_Status IS NULL) ORDER BY insp_data_insp_date DESC";
                }
                else
                {
                    sSQL = "SELECT DISTINCT [insp_data_id], insp_data_insp_date, insp_date FROM qryInspectionList WHERE [insp_data_sec_id]={" + strSectionID + "} AND (BRED_Status <> 'D' OR BRED_Status IS NULL) ORDER BY insp_data_insp_date DESC";
                }
            }
            else
            {
                sSQL = "SELECT DISTINCT [insp_data_id], insp_data_insp_date, insp_date FROM qryInspectionList WHERE [insp_data_sec_id]={" + strSectionID + "} AND [INSP_DATA_SAMP] = true AND SAMP_DATA_LOC={" + Strings.Replace(mdUtility.fMainForm.tvInspection.GetNodeByKey(mdUtility.fMainForm.CurrentLocation).Tag.ToString(), "'", "''", 1, -1, CompareMethod.Binary) + "} AND (BRED_Status <> 'D' OR BRED_Status IS NULL) ORDER BY insp_data_insp_date DESC";
            }
            fMainForm.m_bDDLoad = true;
            mdUtility.LoadMstrTable("InspectionDates", sSQL);
            fMainForm.cboInspectionDates.DisplayMember = "insp_date";
            fMainForm.cboInspectionDates.ValueMember   = "insp_data_id";
            fMainForm.cboInspectionDates.DataSource    = (object)mdUtility.get_MstrTable("InspectionDates");
            fMainForm.cboInspectionDates.SelectedIndex = -1;
            fMainForm.m_bDDLoad = false;
            if (Inspection.CanAddInspection(strSectionID))
            {
                fMainForm.cmdNewInspection.Enabled = true;
                if (mdUtility.get_MstrTable("InspectionDates").Rows.Count == 0)
                {
                    fMainForm.cmdCopyInspection.Enabled = false;
                }
                else
                {
                    fMainForm.cmdCopyInspection.Enabled = true;
                }
            }
            else
            {
                fMainForm.cmdNewInspection.Enabled  = false;
                fMainForm.cmdCopyInspection.Enabled = false;
            }
            if ((uint)mdUtility.get_MstrTable("InspectionDates").Rows.Count > 0U)
            {
                fMainForm.cboInspectionDates.Enabled       = true;
                fMainForm.lblNoInspection.Visible          = false;
                fMainForm.cboInspectionDates.SelectedIndex = 0;
            }
            else
            {
                fMainForm.cboInspectionDates.Enabled = false;
                Inspection.ClearInspections();
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectGreater(mdUtility.DB.GetDataTable("SELECT Count(INSP_DATA_ID) FROM Inspection_Data WHERE [insp_data_sec_id]={" + strSectionID + "}").Rows[0][0], (object)0, false))
                {
                    fMainForm.lblNoInspection.Visible = false;
                }
                else
                {
                    fMainForm.lblNoInspection.Visible = true;
                }
                fMainForm.CanEditInspection = false;
            }
        }
Exemplo n.º 3
0
        internal static void LoadInspection(string InspectionID)
        {
            DataTable dataTable1 = mdUtility.DB.GetDataTable("SELECT * FROM Inspection_Data WHERE [insp_data_id]={" + InspectionID + "}");

            Inspection.ClearInspections();
            if (dataTable1.Rows.Count <= 0)
            {
                return;
            }
            mdUtility.fMainForm.m_bInspLoaded = false;
            DataRow row = dataTable1.Rows[0];

            mdUtility.fMainForm.CanEditInspection = Inspection.CanEditInspection(InspectionID);
            if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(row["insp_data_type"], (object)1, false))
            {
                mdUtility.fMainForm.optRatingType_1.Checked = true;
            }
            else if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(row["insp_data_type"], (object)2, false))
            {
                mdUtility.fMainForm.optRatingType_2.Checked = true;
            }
            else
            {
                mdUtility.fMainForm.optRatingType_3.Checked = true;
            }
            if (Conversions.ToBoolean(row["insp_data_samp"]))
            {
                mdUtility.fMainForm.optMethod_1.Checked = true;
            }
            else
            {
                mdUtility.fMainForm.optMethod_0.Checked = true;
            }
            mdUtility.fMainForm.lblSampQty.Text = mdUtility.fMainForm.lblSecQtyUM.Text;
            if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(row["insp_data_comments"])))
            {
                mdUtility.fMainForm.tsbComment.Image = (Image)BuilderRED.My.Resources.Resources.Clipboard_Check;
            }
            else
            {
                mdUtility.fMainForm.tsbComment.Image = (Image)BuilderRED.My.Resources.Resources.Clipboard;
            }
            if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(dataTable1.Rows[0]["InspectorLink"])))
            {
                DataTable dataTable2 = mdUtility.DB.GetDataTable("SELECT * FROM UserAccount WHERE User_ID={" + dataTable1.Rows[0]["InspectorLink"].ToString() + "}");
                if (dataTable2.Rows.Count > 0)
                {
                    string Left1 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(dataTable2.Rows[0]["LastName"], (object)""));
                    string Left2 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(dataTable2.Rows[0]["FirstName"], (object)""));
                    if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Left1, "", false) > 0U)
                    {
                        if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Left2, "", false) > 0U)
                        {
                            Left1 = Left1 + ", " + Left2;
                        }
                    }
                    else if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Left2, "", false) > 0U)
                    {
                        Left1 = Left2;
                    }
                    if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Left1, "", false) > 0U)
                    {
                        mdUtility.fMainForm.tsslStatus.Text = "Inspected By: " + Left1;
                    }
                    else
                    {
                        mdUtility.fMainForm.tsslStatus.Text = "LookupDataBaseName";
                    }
                }
                else
                {
                    mdUtility.fMainForm.tsslStatus.Text = "LookupDataBaseName";
                }
            }
            Sample.LoadSampleList(InspectionID);
            frmMain fMainForm = mdUtility.fMainForm;

            if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(fMainForm.CurrentLocation, "", false) == 0)
            {
                fMainForm.cboLocation.SelectedIndex = 0;
            }
            else
            {
                bool flag  = false;
                int  num   = checked (fMainForm.cboLocation.Items.Count - 1);
                int  index = 0;
                while (index <= num)
                {
                    if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(fMainForm.cboLocation.Items[index], new object[1] {
                        (object)"Name"
                    }, (string[])null)), Strings.Len(fMainForm.tvInspection.GetNodeByKey(fMainForm.CurrentLocation).Text)), fMainForm.tvInspection.GetNodeByKey(fMainForm.CurrentLocation).Text, false) == 0)
                    {
                        flag = true;
                        break;
                    }
                    checked { ++index; }
                }
                fMainForm.cboLocation.SelectedIndex = !flag ? 0 : index;
            }
            mdUtility.fMainForm.cboLocation_SelectedIndexChanged((object)null, (EventArgs)null);
            fMainForm.m_bInspLoaded = true;
        }