private void btnCalcula_Click(object sender, EventArgs e) { if (txtNomFunc.Text == "") { MessageBox.Show("PREENCHA CORRETAMENTE O CAMPO NOME"); txtNomFunc.Focus(); } else { if (txtHorTra.Text == "") { MessageBox.Show("PREENCHA CORRETAMENTE O CAMPO HORAS"); txtHorTra.Focus(); } else { if (txtValor.Text == "") { MessageBox.Show("PREENCHA CORRETAMENTE O CAMPO VALOR"); txtValor.Focus(); } else { if (txtDepen.Text == "") { MessageBox.Show("PREENCHA CORRETAMENTE O CAMPO DEPENDENTES"); txtDepen.Focus(); } else { double x = double.Parse(txtHorTra.Text); double y = double.Parse(txtValor.Text); txtSalBruto.Text = Taxas.salario(x, y).ToString("###,###,##0.00"); double salBruto = double.Parse(txtSalBruto.Text); txtInss.Text = Taxas.calculaINSS(salBruto).ToString("###,###,##0.00"); double dependente = double.Parse(txtDepen.Text); double Inss = double.Parse(txtInss.Text); txtImpRen.Text = Taxas.CalculaIR(Inss, salBruto, dependente).ToString("###,###,##0.00"); double IR = double.Parse(txtImpRen.Text); txtSalLiq.Text = (salBruto - Inss - IR).ToString("###,###,##0.00"); } } } } }
private void txtDepen_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13 && txtNomFunc.Text != "" && txtHorTra.Text != "" && txtValor.Text != "" && txtDepen.Text != "") { int x = int.Parse(txtHorTra.Text); double y = double.Parse(txtValor.Text); txtSalBruto.Text = Taxas.salario(x, y).ToString("###,###,##0.00"); double salBruto = double.Parse(txtSalBruto.Text); txtInss.Text = Taxas.calculaINSS(salBruto).ToString("###,###,##0.00"); double dependente = double.Parse(txtDepen.Text); double Inss = double.Parse(txtInss.Text); txtImpRen.Text = Taxas.CalculaIR(Inss, salBruto, dependente).ToString("###,###,##0.00"); double IR = double.Parse(txtImpRen.Text); txtSalLiq.Text = (salBruto - Inss - IR).ToString("###,###,##0.00"); } e.KeyChar = virgula.consisteNum(e.KeyChar); int i = txtDepen.Text.IndexOf(','); if (e.KeyChar == ',') { e.KeyChar = (char)0; MessageBox.Show("Apenas numeros inteiros"); } }