Ejemplo n.º 1
0
        internal static void NewInspection(Guid sectionID)
        {
            string    str        = "SELECT * FROM Inspection_Data WHERE [INSP_DATA_INSP_DATE]>=#" + Conversions.ToString(DateAndTime.DateAdd(DateInterval.Day, (double)checked (-1 * Inspection.IInspectionWindow), DateAndTime.Today)) + "# AND [INSP_DATA_SEC_ID]={" + sectionID.ToString() + "}";
            DataTable dataTable1 = mdUtility.DB.GetDataTable(str);
            DataTable dataTable2 = mdUtility.DB.GetDataTable("SELECT * FROM [Section Info] WHERE [sec_id]={" + sectionID.ToString() + "}");
            DateTime  dateTime   = new frmDatePicker().ShowDialog(new DateTime?(DateAndTime.DateAdd(DateInterval.Day, (double)checked (-1 * Inspection.IInspectionWindow), DateAndTime.Today)), new DateTime?(DateAndTime.Today));
            Guid      guid;

            if (dataTable1.Rows.Count == 0)
            {
                DataRow row     = dataTable1.NewRow();
                DataRow dataRow = row;
                dataRow["INSP_DATA_SEC_ID"] = (object)sectionID;
                guid = Guid.Parse(mdUtility.GetUniqueID());
                dataRow["INSP_DATA_ID"]        = (object)guid;
                dataRow["inspectorlink"]       = (object)mdUtility.strCurrentInspector;
                dataRow["INSP_Source"]         = (object)nameof(Inspection);
                dataRow["INSP_DATA_INSP_DATE"] = (object)dateTime;
                dataRow["INSP_DATA_SAMP"]      = RuntimeHelpers.GetObjectValue(Interaction.IIf(Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.CurrentLocation, "", false) == 0, (object)false, (object)true));
                dataRow["bred_status"]         = (object)"N";
                dataRow["insp_data_type"]      = (object)2;
                dataTable1.Rows.Add(row);
                mdUtility.DB.SaveDataTable(ref dataTable1, str);
                Section.SectionMaterialLink(sectionID.ToString());
                mdUtility.fMainForm.m_bInspNew = true;
            }
            else
            {
                object obj = dataTable1.Rows[0]["INSP_DATA_ID"];
                guid = obj != null ? (Guid)obj : new Guid();
            }
            DataTable dataTable3  = mdUtility.DB.GetDataTable("SELECT SUM(SAMP_DATA_QTY) AS SAMP_QTY_SUM FROM Sample_Data WHERE [SAMP_DATA_INSP_DATA_ID]={" + guid.ToString() + "}");
            DataTable tableSchema = mdUtility.DB.GetTableSchema("Sample_Data");
            DataRow   row1        = tableSchema.NewRow();
            DataRow   dataRow1    = row1;

            dataRow1["BRED_Status"]            = (object)"N";
            dataRow1["samp_data_id"]           = (object)mdUtility.GetUniqueID();
            dataRow1["samp_data_insp_data_id"] = (object)guid;
            double num = Conversions.ToDouble(Microsoft.VisualBasic.CompilerServices.Operators.SubtractObject(dataTable2.Rows[0]["sec_qty"], UtilityFunctions.FixDBNull(RuntimeHelpers.GetObjectValue(dataTable3.Rows[0]["SAMP_QTY_SUM"]), (object)0)));

            dataRow1["samp_data_qty"]   = RuntimeHelpers.GetObjectValue(Interaction.IIf(num < 0.0, (object)0, (object)num));
            dataRow1["samp_data_paint"] = RuntimeHelpers.GetObjectValue(dataTable2.Rows[0]["sec_paint"]);
            if (mdUtility.fMainForm.tvInspection.Visible && Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.CurrentLocation, "", false) != 0)
            {
                dataRow1["samp_data_loc"] = (object)mdUtility.fMainForm.tvInspection.GetNodeByKey(mdUtility.fMainForm.CurrentLocation).Tag.ToString();
            }
            tableSchema.Rows.Add(row1);
            mdUtility.DB.SaveDataTable(ref tableSchema, "SELECT * FROM Sample_Data");
            mdUtility.fMainForm.m_bSampleNew  = true;
            mdUtility.fMainForm.m_bInspLoaded = false;
            Inspection.LoadInspectionDates(sectionID.ToString());
            mdUtility.fMainForm.m_bInspLoaded = true;
            mdUtility.fMainForm.SetInspChanged(true);
            if (!mdUtility.fMainForm.txtSQuantity.Visible)
            {
                return;
            }
            mdUtility.fMainForm.txtSQuantity.Focus();
        }
Ejemplo n.º 2
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);
        }