private void TextBoxSumm2_TextChanged(object sender, EventArgs e) //Контроль ввода безналичной оплаты { if (CheckString.Numbers(tbSumm2.Text)) { if (ToDecimal(tbSumm2.Text) > ToDecimal(tbSummAll.Text)) { tbSumm2.BackColor = Color.LightCoral; tbChange.Visible = button4.Visible = false; } else { tbSumm2.BackColor = Color.Snow; tbSumm2.Text = Math.Round(ToDecimal(tbSumm2.Text) * 1.000m, 2).ToString(); if (tbSumm1.BackColor != Color.LightCoral) { tbChange.Text = Convert.ToString((ToDecimal(tbSummAll.Text) - ToDecimal(tbSumm2.Text) - ToDecimal(tbSumm1.Text)) * -1); tbChange.Visible = true; } } } else { tbSumm2.BackColor = Color.LightCoral; tbChange.Visible = button4.Visible = false; } }
private void TextBoxCash_In_Outcome_TextChanged(object sender, EventArgs e) { if (CheckString.Numbers(tbCash_In_Outcome.Text)) { tbCash_In_Outcome.BackColor = Color.Snow; tbCash_In_Outcome.Text = Convert.ToString(Math.Round(ToDecimal(tbCash_In_Outcome.Text) * 1.000m, 2)); buttonCash_In_Outcome.Visible = true; } else { tbCash_In_Outcome.BackColor = Color.LightCoral; buttonCash_In_Outcome.Visible = false; } }
public void NumbersTest() { bool actual; Dictionary <string, bool> testNuber = new Dictionary <string, bool>(); testNuber.Add("", false); testNuber.Add("qwahfynfjndy", false); testNuber.Add("3664069395", true); testNuber.Add("19234,65656", true); testNuber.Add("19234.65656", false); testNuber.Add(",", false); foreach (string element in testNuber.Keys) { actual = CheckString.Numbers(element); Assert.AreEqual(testNuber[element], actual, "Строка на входе = \"" + element + "\""); } }
private void TextBoxQuantity_TextChanged(object sender, EventArgs e) //Измениение строки с кол-вом { int error = 0; label5.BackColor = SystemColors.InactiveCaption; for (int i = 0; i < arrayCheckBox.Length; i++) { if (arrayCheckBox[i].Checked) { if (CheckString.Numbers(arrayQuantity[i].Text)) { arrayQuantity[i].BackColor = Color.Snow; arrayQuantity[i].Text = Convert.ToString(Math.Round(ToDecimal(arrayQuantity[i].Text) * 1.0000m, 3)); arraySumm[i].Text = "0,00"; if (arrayPrice[i].BackColor != Color.LightCoral) { try { arraySumm[i].Text = Convert.ToString(Math.Round(ToDecimal(arrayPrice[i].Text) * ToDecimal(arrayQuantity[i].Text), 2)); } catch { arrayPrice[i].BackColor = Color.LightCoral; } } } else { error++; arrayQuantity[i].BackColor = Color.LightCoral; } } } if (error > 0) { label5.BackColor = Color.LightCoral; } }