public Class7 GetProductClass(string code) { Class7 output = null; return(output); }
public void Search() { try { Thread tLoadSplashStart = new Thread(() => { showLoad(); }); tLoadSplashStart.Start(); //tLoadSplashStart.Join(); if (txtCode.Text == null || txtCode.Text == "" || int.TryParse(txtCode.Text, out int stockCode) == false) { throw new ArgumentNullException("Please enter a valid commodity code."); } else { dh.testConnection(); pullSchematics(); string code = txtCode.Text; txtCustomerName.Text = dh.getStockDesc(code); txtWorkCentre.Text = dh.getStockName(code); /* * Class5 controls */ Class5 cl5 = dh.GetMethodDetails(code); txtCoreIron.Text = cl5.CoreIron; txtICBiscuits.Text = cl5.Ic; // Core making instructions ////////////////////////////////////////////////////////////////// if (cl5.CoreMaking1 != "" && cl5.CoreMaking1 != null) { txtCoreMakingInstruction1.Text = cl5.CoreMaking1; } else { txtCoreMakingInstruction1.Text = "No Core Making Instructions is available for this part!"; } if (cl5.CoreMaking2 != "" && cl5.CoreMaking2 != null) { txtCoreMakingInstruction2.Text = cl5.CoreMaking2; } else { txtCoreMakingInstruction2.Visible = false; } if (cl5.CoreMaking3 != "" && cl5.CoreMaking3 != null) { txtCoreMakingInstruction3.Text = cl5.CoreMaking3; } else { txtCoreMakingInstruction3.Visible = false; } if (cl5.CoreMaking4 != "" && cl5.CoreMaking4 != null) { txtCoreMakingInstruction4.Text = cl5.CoreMaking4; } else { txtCoreMakingInstruction4.Visible = false; } if (cl5.CoreMaking5 != "" && cl5.CoreMaking5 != null) { txtCoreMakingInstruction5.Text = cl5.CoreMaking5; } else { txtCoreMakingInstruction5.Visible = false; } if (cl5.CoreMaking6 != "" && cl5.CoreMaking6 != null) { txtCoreMakingInstruction6.Text = cl5.CoreMaking6; } else { txtCoreMakingInstruction6.Visible = false; } if (cl5.CoreMaking7 != "" && cl5.CoreMaking7 != null) { txtCoreMakingInstruction7.Text = cl5.CoreMaking7; } else { txtCoreMakingInstruction7.Visible = false; } if (cl5.CoreMaking8 != "" && cl5.CoreMaking8 != null) { txtCoreMakingInstruction8.Text = cl5.CoreMaking8; } else { txtCoreMakingInstruction8.Visible = false; } //////////////////////////////////////////////////////////////////////////// txtCastMass.Text = cl5.CastMassKg; txtCastTemp.Text = cl5.CastTemperatureDeg; txtCastTime.Text = cl5.CastTimeSeconds; txtCastingInstructions.Text = cl5.CastingInstruction; txtHotTopping.Text = cl5.HotTopping; // Knockout instructions ////////////////////////////////////////////////////// if (cl5.KOInstruction1 != null && cl5.KOInstruction1 != "") { txtKOInstruction1.Text = cl5.KOInstruction1; } else { txtKOInstruction1.Text = "No KO Instructions is available for this part!"; } if (cl5.KOInstruction2 != null && cl5.KOInstruction2 != "") { txtKOInstruction2.Text = cl5.KOInstruction2; } else { txtKOInstruction2.Visible = false; } if (cl5.KOInstruction3 != null && cl5.KOInstruction3 != "") { txtKOInstruction3.Text = cl5.KOInstruction3; } else { txtKOInstruction3.Visible = false; } if (cl5.KOInstruction4 != null && cl5.KOInstruction4 != "") { txtKOInstruction4.Text = cl5.KOInstruction4; } else { txtKOInstruction4.Visible = false; } if (cl5.KOInstruction5 != null && cl5.KOInstruction5 != "") { txtKOInstruction5.Text = cl5.KOInstruction5; } else { txtKOInstruction5.Visible = false; } if (cl5.KOInstruction6 != null && cl5.KOInstruction6 != "") { txtKOInstruction6.Text = cl5.KOInstruction6; } else { txtKOInstruction6.Visible = false; } ///////////////////////////////////////////////////////////////////////////////// txtChromite.Text = cl5.ChromiteInstructio; txtFDYNotes.Text = cl5.FoundryNotes; txtPaintInstructions.Text = cl5.PaintInstructions; txtChills.Text = cl5.ChillsYesNo; txtFettledMass.Text = cl5.FettledMassKg; txtQtyBoxBtm.Text = cl5.MouldingBoxBottom; txtQtyBoxTop.Text = cl5.MouldingBoxTop; txtRunnerCup.Text = cl5.PouringBasin; txtDowngate.Text = cl5.Downgate; txtRunnerBar.Text = cl5.RunnerBar; txtIngates.Text = cl5.Ingates; txtVenting.Text = cl5.Vents; // Moulding instructions //////////////////////////////////////////////////////////////// if (cl5.MouldInstruct1 != null && cl5.MouldInstruct1 != "") { txtMouldingInstruction1.Text = cl5.MouldInstruct1; } else { txtMouldingInstruction1.Text = "No Moulding Instructions is available for this part!"; } if (cl5.MouldInstruct2 != null && cl5.MouldInstruct2 != "") { txtMouldingInstruction2.Text = cl5.MouldInstruct2; } else { txtMouldingInstruction2.Visible = false; } if (cl5.MouldInstruct3 != null && cl5.MouldInstruct3 != "") { txtMouldingInstruction3.Text = cl5.MouldInstruct3; } else { txtMouldingInstruction3.Visible = false; } if (cl5.MouldInstruct4 != null && cl5.MouldInstruct4 != "") { txtMouldingInstruction4.Text = cl5.MouldInstruct4; } else { txtMouldingInstruction4.Visible = false; } if (cl5.MouldInstruct5 != null && cl5.MouldInstruct5 != "") { txtMouldingInstruction5.Text = cl5.MouldInstruct5; } else { txtMouldingInstruction5.Visible = false; } if (cl5.MouldInstruct6 != null && cl5.MouldInstruct6 != "") { txtMouldingInstruction6.Text = cl5.MouldInstruct6; } else { txtMouldingInstruction6.Visible = false; } if (cl5.MouldInstruct7 != null && cl5.MouldInstruct7 != "") { txtMouldingInstruction7.Text = cl5.MouldInstruct7; } else { txtMouldingInstruction7.Visible = false; } if (cl5.MouldInstruct8 != null && cl5.MouldInstruct8 != "") { txtMouldingInstruction8.Text = cl5.MouldInstruct8; } else { txtMouldingInstruction8.Visible = false; } //////////////////////////////////////////////////////////////////////////////// // Closing instrcutions //////////////////////////////////////////////////// if (cl5.CloseInstruct1 != null && cl5.CloseInstruct1 != "") { txtClosingInstruction1.Text = cl5.CloseInstruct1; } else { txtClosingInstruction1.Text = "No Closing Instructions is available for this part!"; } if (cl5.CloseInstruct2 != null && cl5.CloseInstruct2 != "") { txtClosingInstruction2.Text = cl5.CloseInstruct2; } else { txtClosingInstruction2.Visible = false; } if (cl5.CloseInstruct3 != null && cl5.CloseInstruct3 != "") { txtClosingInstruction3.Text = cl5.CloseInstruct3; } else { txtClosingInstruction3.Visible = false; } if (cl5.CloseInstruct4 != null && cl5.CloseInstruct4 != "") { txtClosingInstruction4.Text = cl5.CloseInstruct4; } else { txtClosingInstruction4.Visible = false; } if (cl5.CloseInstruct5 != null && cl5.CloseInstruct5 != "") { txtClosingInstruction5.Text = cl5.CloseInstruct5; } else { txtClosingInstruction5.Visible = false; } if (cl5.CloseInstruct6 != null && cl5.CloseInstruct6 != "") { txtClosingInstruction6.Text = cl5.CloseInstruct6; } else { txtClosingInstruction6.Visible = false; } if (cl5.CloseInstruct7 != null && cl5.CloseInstruct7 != "") { txtClosingInstruction7.Text = cl5.CloseInstruct7; } else { txtClosingInstruction7.Visible = false; } if (cl5.CloseInstruct8 != null && cl5.CloseInstruct8 != "") { txtClosingInstruction8.Text = cl5.CloseInstruct8; } else { txtClosingInstruction8.Visible = false; } //////////////////////////////////////////////////////////////////////////////////// txtSimulationFileNo.Text = cl5.SimulationFileNo; txtRevisionBy.Text = cl5.MethodRevisionBy; txtApprovalBy.Text = cl5.MethodApprovedBy; txtApprovedYesNo.Text = cl5.MethodApprovedYes; txtRevisionDate.Text = (Convert.ToDateTime(cl5.MethodRevisionDate)).ToShortDateString(); txtApprovalDate.Text = (Convert.ToDateTime(cl5.MethodApprovedDate)).ToShortDateString(); /* * */ Class7 cl7 = dh.GetProductClass(code); txtProductDescription.Text = cl7.something2; /* * Class3 controls */ Class3 cl3 = dh.GetDescription(code); txtPartDescription.Text = cl3.something1; txtLongDesc.Text = cl3.something2; txtMaterialGrade.Text = cl3.something3; txtFinalMass.Text = String.Format("{0} Kg", cl3.something4.Split('.')[0]); txtBoxSize.Text = cl3.something6; txtPatternPerBoard.Text = cl3.something9; txtTraceNumber.Text = String.Format("{0}", cl3.something8.Split('.')[0]); if (Convert.ToDouble(cl3.something7) == 0) { txtInserts.Text = "No"; } else { txtInserts.Text = "Yes"; } /* * */ txtCommodityCode.Text = code; txtSandMass.Text = string.Format("{0} Kg", dh.getQtyPer(code).Split('.')[0]); /* * Scrap history */ List <Class4> arrClass4 = dh.getScrapRate(txtCode.Text); if (arrClass4 == null) { txtQtyCast.Text = "N/A"; txtQtyScrapped.Text = "N/A"; txtScrapRate.Text = "N/A"; } else { DateTime lastEntryDate = Convert.ToDateTime(arrClass4.Last().DateEntry); Dictionary <string, int> arrReasons = new Dictionary <string, int>(); int countCast = 0; int countScrap = 0; foreach (Class4 item in arrClass4) { if (item.DateEntry.AddMonths(6) >= lastEntryDate) { countCast += Convert.ToInt32(item.QtyCast); countScrap += Convert.ToInt32(item.QtyScrapped); if (arrReasons.ContainsKey(item.Description) == false) { arrReasons.Add(item.Description, Convert.ToInt32(item.QtyScrapped)); } else { if (item.Description != "") { arrReasons[item.Description] = Convert.ToInt32(item.QtyScrapped); } } } } txtQtyCast.Text = countCast.ToString(); txtQtyScrapped.Text = countScrap.ToString(); List <Class6> arrClass6 = new List <Class6>(); foreach (string Description in arrReasons.Keys) { if (Description != null && Description != "" && arrReasons[Description] != 0) { arrClass6.Add(new Class6(Description, Convert.ToInt32(arrReasons[Description]))); } } BindingSource bsScrapReasons = new BindingSource(); bsScrapReasons.DataSource = arrClass6; dgvScrapReasons.DataSource = null; dgvScrapReasons.DataSource = arrClass6; //Following Code does the Scrap% Calculation (txtQtyCast; txtQtyScrapped; txtScrapRate) double d1, d2; if (double.TryParse(txtQtyScrapped.Text, out d1) && double.TryParse(txtQtyCast.Text, out d2)) { txtScrapRate.Text = ((d1 / d2)).ToString("#.00 %"); } else { txtScrapRate.Text = "N/A"; } } arrClass1 = dh.getComponents(txtCode.Text); List <Class1> arrICInsertsDetails = new List <Class1>(); List <Class1> arrClosingCoreDetails = new List <Class1>(); List <Class1> arrCoresExternalDetails = new List <Class1>(); List <Class1> arrInsertsDetails = new List <Class1>(); List <Class1> arrCoreIronDetails = new List <Class1>(); foreach (Class1 item in arrClass1) { string type = item.Component.Substring(0, 4); if (type.IndexOf("32-3") == 0) { arrICInsertsDetails.Add(item); } else { if (type.IndexOf("32") == 0) { arrClosingCoreDetails.Add(item); } else { if (type.IndexOf("4") == 0) { arrCoresExternalDetails.Add(item); } else { if (type.IndexOf("7") == 0) { arrInsertsDetails.Add(item); } else { if (type.IndexOf("D") == 0) { arrCoreIronDetails.Add(item); } } } } } } TextBox[] arrCoreIronTxtComponent = { txtCoreIronComponent1, txtCoreIronComponent2, txtCoreIronComponent3, txtCoreIronComponent4, txtCoreIronComponent5, txtCoreIronComponent6 }; TextBox[] arrCoreIronTxtDescription = { txtCoreIron1Description, txtCoreIron2Description, txtCoreIron3Description, txtCoreIron4Description, txtCoreIron5Description, txtCoreIron6Description }; TextBox[] arrCoreIronTxtQtyPer = { txtCoreIron1Qty, txtCoreIron2Qty, txtCoreIron3Qty, txtCoreIron4Qty, txtCoreIron5Qty, txtCoreIron6Qty }; foreach (TextBox txt in arrCoreIronTxtComponent) { txt.Visible = false; } txtCoreIronComponent1.Visible = true; txtCoreIronComponent1.Text = "No Core Iron"; foreach (TextBox txt in arrCoreIronTxtDescription) { txt.Visible = false; } foreach (TextBox txt in arrCoreIronTxtQtyPer) { txt.Visible = false; } int CoreIronCounter = 0; foreach (Class1 bc in arrCoreIronDetails) { arrCoreIronTxtComponent[CoreIronCounter].Visible = true; arrCoreIronTxtComponent[CoreIronCounter].Text = bc.Component; arrCoreIronTxtDescription[CoreIronCounter].Visible = true; arrCoreIronTxtDescription[CoreIronCounter].Text = bc.Description; arrCoreIronTxtQtyPer[CoreIronCounter].Visible = true; arrCoreIronTxtQtyPer[CoreIronCounter].Text = bc.QtyPer; CoreIronCounter++; } TextBox[] arrClosingCoreTxtComponent = { txtCoreComponent1, txtCoreComponent2, txtCoreComponent3, txtCoreComponent4, txtCoreComponent5, txtCoreComponent6, txtCoreComponent7 }; TextBox[] arrClosingCoreTxtDescription = { txtCoreDescription1, txtCoreDescription2, txtCoreDescription3, txtCoreDescription4, txtCoreDescription5, txtCoreDescription6, txtCoreDescription7 }; TextBox[] arrClosingCoreTxtQtyPer = { txtCoreQty1, txtCoreQty2, txtCoreQty3, txtCoreQty4, txtCoreQty5, txtCoreQty6, txtCoreQty7 }; foreach (TextBox txt in arrClosingCoreTxtComponent) { txt.Visible = false; } txtCoreComponent1.Visible = true; txtCoreComponent1.Text = "No Cores"; foreach (TextBox txt in arrClosingCoreTxtDescription) { txt.Visible = false; } foreach (TextBox txt in arrClosingCoreTxtQtyPer) { txt.Visible = false; } int CoreDetailCounter = 0; foreach (Class1 bc in arrClosingCoreDetails) { arrClosingCoreTxtComponent[CoreDetailCounter].Visible = true; arrClosingCoreTxtComponent[CoreDetailCounter].Text = bc.Component; arrClosingCoreTxtDescription[CoreDetailCounter].Visible = true; arrClosingCoreTxtDescription[CoreDetailCounter].Text = bc.Description; arrClosingCoreTxtQtyPer[CoreDetailCounter].Visible = true; arrClosingCoreTxtQtyPer[CoreDetailCounter].Text = bc.QtyPer; CoreDetailCounter++; } TextBox[] arrInsertTxtComponent = { txtInsertComponent1, txtInsertComponent2, txtInsertComponent3, txtInsertComponent4, txtInsertComponent5 }; TextBox[] arrInsertTxtDescription = { txtInsertDescription1, txtInsertDescription2, txtInsertDescription3, txtInsertDescription4, txtInsertDescription5 }; TextBox[] arrInsertTxtQtyPer = { txtInsertQtyPer1, txtInsertQtyPer2, txtInsertQtyPer3, txtInsertQtyPer4, txtInsertQtyPer5, }; foreach (TextBox txt in arrInsertTxtComponent) { txt.Visible = false; } txtInsertComponent1.Visible = true; txtInsertComponent1.Text = "No Inserts"; foreach (TextBox txt in arrInsertTxtDescription) { txt.Visible = false; } foreach (TextBox txt in arrInsertTxtQtyPer) { txt.Visible = false; } int InsertDetailCounter = 0; foreach (Class1 bc in arrInsertsDetails) { arrInsertTxtComponent[InsertDetailCounter].Visible = true; arrInsertTxtComponent[InsertDetailCounter].Text = bc.Component; arrInsertTxtDescription[InsertDetailCounter].Visible = true; arrInsertTxtDescription[InsertDetailCounter].Text = bc.Description; arrInsertTxtQtyPer[InsertDetailCounter].Visible = true; arrInsertTxtQtyPer[InsertDetailCounter].Text = bc.QtyPer; InsertDetailCounter++; } TextBox[] arrFeederTxtComponent = { txtFeederComponent1, txtFeederComponent2, txtFeederComponent3, txtFeederComponent4, txtFeederComponent5, txtFeederComponent6, txtFeederComponent7, txtFeederComponent8 }; TextBox[] arrFeederTxtDescription = { txtFeederDescription1, txtFeederDescription2, txtFeederDescription3, txtFeederDescription4, txtFeederDescription5, txtFeederDescription6, txtFeederDescription7, txtFeederDescription8 }; TextBox[] arrFeederTxtQtyPer = { txtFeederQtyPer1, txtFeederQtyPer2, txtFeederQtyPer3, txtFeederQtyPer4, txtFeederQtyPer5, txtFeederQtyPer6, txtFeederQtyPer7, txtFeederQtyPer8 }; foreach (TextBox txt in arrFeederTxtComponent) { txt.Visible = false; } txtFeederComponent1.Visible = true; txtFeederComponent1.Text = "No Feeders"; foreach (TextBox txt in arrFeederTxtDescription) { txt.Visible = false; } foreach (TextBox txt in arrFeederTxtQtyPer) { txt.Visible = false; } int FeederDetailCounter = 0; foreach (Class1 bc in arrCoresExternalDetails) { arrFeederTxtComponent[FeederDetailCounter].Visible = true; arrFeederTxtComponent[FeederDetailCounter].Text = bc.Component; arrFeederTxtDescription[FeederDetailCounter].Visible = true; arrFeederTxtDescription[FeederDetailCounter].Text = bc.Description; arrFeederTxtQtyPer[FeederDetailCounter].Visible = true; arrFeederTxtQtyPer[FeederDetailCounter].Text = bc.QtyPer; FeederDetailCounter++; } TextBox[] arrICInsertsTxtComponent = { txtICInsertComponent1, txtICInsertComponent2, txtICInsertComponent3, txtICInsertComponent4, txtICInsertComponent5 }; TextBox[] arrICInsertsTxtDescription = { txtICInsertDescription1, txtICInsertDescription2, txtICInsertDescription3, txtICInsertDescription4, txtICInsertDescription5 }; TextBox[] arrICInsertsTxtQtyPer = { txtICInsertQtyPer1, txtICInsertQtyPer2, txtICInsertQtyPer3, txtICInsertQtyPer4, txtICInsertQtyPer5, }; foreach (TextBox txt in arrICInsertsTxtComponent) { txt.Visible = false; } txtICInsertComponent1.Visible = true; txtICInsertComponent1.Text = "No IC Biscuits"; foreach (TextBox txt in arrICInsertsTxtDescription) { txt.Visible = false; } foreach (TextBox txt in arrICInsertsTxtQtyPer) { txt.Visible = false; } int ICInsertsDetailCounter = 0; foreach (Class1 bc in arrICInsertsDetails) { arrICInsertsTxtComponent[ICInsertsDetailCounter].Visible = true; arrICInsertsTxtComponent[ICInsertsDetailCounter].Text = bc.Component; arrICInsertsTxtDescription[ICInsertsDetailCounter].Visible = true; arrICInsertsTxtDescription[ICInsertsDetailCounter].Text = bc.Description; arrICInsertsTxtQtyPer[ICInsertsDetailCounter].Visible = true; arrICInsertsTxtQtyPer[ICInsertsDetailCounter].Text = bc.QtyPer; ICInsertsDetailCounter++; } // throws exception "Invalid Object (table Produc_products does not exist)" //txtProductID.Text = dh.getProductID(txtCode.Text); //dgvIncidents.DataSource = dh.getIncidents(code); if (txtApprovedYesNo.Text == "No" || txtApprovedYesNo.Text == "" || txtApprovedYesNo.Text == null) { MessageBox.Show("The method hasn't been approved yet, so it can't be printed."); btnPrint.Enabled = false; } else { btnPrint.Enabled = true; } } } catch (Exception ex) { Thread tLoadSplashEndException = new Thread(() => { hideLoad(); }); tLoadSplashEndException.Start(); MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } //hideLoad(); Thread tLoadSplashEnd = new Thread(() => { hideLoad(); }); tLoadSplashEnd.Start(); }