protected void EnterButton_Click(object sender, EventArgs e) { bool showspanish = false; if (SpanishButton.Text == "English") { showspanish = true; } bool dataok = true; if (Location.Text == "") { if (!showspanish) { ShowPopUpMsg("Select a Location"); } else { ShowPopUpMsg("Selecciona una ubicación"); } dataok = false; } if (emp1.Text == "") { if (!showspanish) { ShowPopUpMsg("Enter at least one Employee"); } else { ShowPopUpMsg("Ingrese al menos un empleado"); } dataok = false; } if (cdNoCost500.Checked) { decimal.TryParse(EstCost.Text, out costAmnt); if (costAmnt == 0) { if (!showspanish) { ShowPopUpMsg("You must enter a cost estimate"); } else { ShowPopUpMsg("Debe ingresar una estimación de costos"); } dataok = false; } } if (!cbYesprocess.Checked && !cbNoprocess.Checked) { if (!showspanish) { ShowPopUpMsg("Please select Yes or No for 'Will the Process Remain the Same' question"); } else { ShowPopUpMsg("Seleccione Sí o No para la pregunta '¿El proceso seguirá siendo el mismo ?'"); } dataok = false; } if (!cdYesCost500.Checked && !cdNoCost500.Checked) { if (!showspanish) { ShowPopUpMsg("Please select Yes or No for 'Will it cost $500 or less to complete' question"); } else { ShowPopUpMsg("Seleccione Sí o No para la pregunta '¿Costará $ 500 o menos para completar?'"); } dataok = false; } if (!cbProcess.Checked && !cbQuality.Checked && !cbSafety.Checked && !cbProductivity.Checked) { if (!showspanish) { ShowPopUpMsg("Please select an 'Idea Improve' option"); } else { ShowPopUpMsg("Por favor, seleccione una opción 'La Idea Mejora'"); } dataok = false; } if (IdeaText.Text.Trim() == "") { if (!showspanish) { ShowPopUpMsg("Please Enter Your Idea"); } else { ShowPopUpMsg("Por favor, Ingrese su Idea"); } dataok = false; } // // if data validation didn't pass - re-enable the enter button // if (!dataok) { EnterButton.Enabled = true; } if (dataok) { getNextNumber(ref nextIdea); // // code to set the flags // IC1 = "N"; IC2 = "N"; IC3 = "N"; IC4 = "N"; IC5 = "N"; SC1 = "N"; SC2 = "N"; SC3 = "N"; SC4 = "N"; SC5 = "N"; AT1 = "N"; AT2 = "N"; AT3 = "N"; AT4 = "N"; AT5 = "N"; procCode = "N"; costCode = "Y"; costAmnt = 0; if (cbProductivity.Checked) { IC1 = "Y"; } if (cbQuality.Checked) { IC2 = "Y"; } if (cbSafety.Checked) { IC3 = "Y"; } if (cbProcess.Checked) { IC4 = "Y"; } if (cbPeopleTime.Checked) { SC1 = "Y"; } if (cbMaterials.Checked) { SC2 = "Y"; } if (cbSetupTime.Checked) { SC3 = "Y"; } if (cbSavesCode4.Checked) { SC4 = "Y"; } if (cbMultShifts.Checked) { AT1 = "Y"; } if (cbMultDept.Checked) { AT2 = "Y"; } if (cbShopOnly.Checked) { AT3 = "Y"; } if (cbOfficeOnly.Checked) { AT4 = "Y"; } if (cbShopOffice.Checked) { AT5 = "Y"; } if (cbYesprocess.Checked) { procCode = "Y"; } if (cdNoCost500.Checked) { costCode = "N"; decimal.TryParse(EstCost.Text, out costAmnt); } // // insert the record into the idea tables // addNewIdea(ref nextIdea); // // get the number of points for entry // string code1 = "100"; int points = 0; getPointAmount(ref code1, ref points); addEntryPoints(ref nextIdea, code1, points); addBonusRecord(ref nextIdea); // // send the e-mail to the location admin that an idea was entered sendAdminEmail(ref nextIdea); // // setup the second screen for the savings data // IdeaNumber.Text = nextIdea.ToString(); WhichScreen.Value = "2"; locationDropList.Visible = false; drate = 0; getBaseRate(ref drate); RateBox.Text = drate.ToString("n2"); MinPerPiece.Focus(); ScriptManager.RegisterStartupScript(Page, typeof(Page), "Screen 2", "showscreen2();", true); } }
protected void validateSavings(ref bool dataok) { enteredSavings = "N"; bool showspanish = false; if (SpanishButton.Text == "English") { showspanish = true; } // minutes and pieces must be integers - but inorder to compute decimal values for the dollars // computations must be done with decimal type numbers. // Integer type is used to check validity, and then decimal type is created // dataok = true; decimal.TryParse(RateBox.Text, out drate); // // savings by MINUTES PER PIECE // int.TryParse(MinPerPiece.Text, out IntMinPerPiece); int.TryParse(PiecesPerYear.Text, out IntPiecesPerYear); if (MinPerPiece.Text != "" && IntMinPerPiece == 0) { if (!showspanish) { ShowPopUpMsg("Minutes per piece must be whole minutes"); } else { ShowPopUpMsg("Los minutos por pieza deben ser minutos completos"); } MinPerPiece.Focus(); dataok = false; return; } else { decimal.TryParse(MinPerPiece.Text, out DecMinPerPiece); } if (PiecesPerYear.Text != "" && IntPiecesPerYear == 0) { if (!showspanish) { ShowPopUpMsg("Pieces per year must be whole pieces"); } else { ShowPopUpMsg("Las piezas por año deben ser piezas enteras"); } PiecesPerYear.Focus(); dataok = false; return; } else { decimal.TryParse(PiecesPerYear.Text, out DecPiecesPerYear); } DecAnnualPieceSaving = (((DecMinPerPiece * DecPiecesPerYear) / 60) * drate); AnnualPieceSaving.Text = DecAnnualPieceSaving.ToString("n2"); // // savings by minutes/labor // int.TryParse(SavingsPerDay.Text, out IntSavingsPerDay); int.TryParse(SavingPerWeek.Text, out IntSavingsPerWeek); if (SavingsPerDay.Text != "" && IntSavingsPerDay == 0) { if (!showspanish) { ShowPopUpMsg("Minutes saved per day must be whole minutes"); } else { ShowPopUpMsg("Los minutos ahorrados por día deben ser minutos completos"); } SavingsPerDay.Focus(); dataok = false; return; } else { decimal.TryParse(SavingsPerDay.Text, out DecSavingsPerDay); } if (SavingPerWeek.Text != "" && IntSavingsPerWeek == 0) { if (!showspanish) { ShowPopUpMsg("Minutes saved per week must be whole minutes"); } else { ShowPopUpMsg("Los minutos ahorrados por semana deben ser minutos completos"); } SavingPerWeek.Focus(); dataok = false; return; } else { decimal.TryParse(SavingPerWeek.Text, out DecSavingsPerWeek); } if (DecSavingsPerDay != 0 && DecSavingsPerWeek != 0) { if (!showspanish) { ShowPopUpMsg("Only one time/labor savings can be entered"); } else { ShowPopUpMsg("Solo se puede ingresar un ahorro de tiempo / mano de obra"); } SavingsPerDay.Focus(); dataok = false; return; } if (DecSavingsPerDay != 0) { DecAnnualTimeSavings = (((DecSavingsPerDay * 260) / 60) * drate); } else { DecAnnualTimeSavings = (((DecSavingsPerWeek * 52) / 60) * drate); } AnnualTimeSavings.Text = DecAnnualTimeSavings.ToString("n2"); // // Savings by dollars by scrap // decimal.TryParse(ScrapDollars.Text, out DecScrapDollars); int.TryParse(ScrapPieceCnt.Text, out IntScrapPieceCnt); if (ScrapDollars.Text != "" && DecScrapDollars == 0) { if (!showspanish) { ShowPopUpMsg("Amount of scrap dollars must be entered as dollars and cents"); } else { ShowPopUpMsg("La cantidad de dólares chatarra debe ingresarse como dólares y centavos"); } ScrapDollars.Focus(); dataok = false; return; } if (ScrapPieceCnt.Text != "" && IntScrapPieceCnt == 0) { if (!showspanish) { ShowPopUpMsg("Scrap pieces must be whole pieces"); } else { ShowPopUpMsg("Las piezas de chatarra deben ser piezas enteras"); } ScrapPieceCnt.Focus(); dataok = false; return; } else { decimal.TryParse(ScrapPieceCnt.Text, out DecScrapPieceCnt); } DecAnnualScrapSavings = DecScrapDollars * DecScrapPieceCnt; AnnualScrapSavings.Text = DecAnnualScrapSavings.ToString("n2"); // other savings decimal.TryParse(OtherYear.Text, out DecOtherYear); decimal.TryParse(OtherOne.Text, out DecOtherOne); if (OtherYear.Text != "" && DecOtherYear == 0) { if (!showspanish) { ShowPopUpMsg("Other Savings per year must be entered as dollars and cents"); } else { ShowPopUpMsg("Otros ahorros por año deben ingresarse como dólares y centavos"); } OtherYear.Focus(); dataok = false; return; } if (OtherOne.Text != "" && DecOtherOne == 0) { if (!showspanish) { ShowPopUpMsg("Other one time savings must be entered as dollars and cents"); } else { ShowPopUpMsg("Otros ahorros únicos deben ingresarse en dólares y centavos"); } OtherOne.Focus(); dataok = false; return; } TotalSavings = DecAnnualPieceSaving + DecAnnualTimeSavings + DecAnnualScrapSavings + DecOtherYear + DecOtherOne; if (TotalSavings == 0) { enteredSavings = "N"; TotalSavings = 250; } else { enteredSavings = "Y"; } EstSaving.Text = TotalSavings.ToString("n2"); SavingComments.Focus(); }