You are on page 1of 2

namespace Practica_3 { public partial class Form1 : Form { public int r = 0, n, dt; public double pd, bd, bp,

sb, imp, bon, sn, isr, imss,suma=0; public Form1() { InitializeComponent(); } private void dataGridView1_CellContentClick(object sender, DataGridViewC ellEventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void LBn_SelectedIndexChanged(object sender, EventArgs e) { DGVde.RowCount = LBn.SelectedIndex + 1; DGVdn.RowCount = DGVde.RowCount; } private void CBreg_CheckedChanged(object sender, EventArgs e) { if (CBreg.Checked) { DGVde[0, r].Value = TBnom.Text.ToString(); DGVde[1, r].Value = MTBdt.Text.ToString(); DGVde[2, r].Value = MTBpxd.Text.ToString(); DGVde[3, r].Value = MTBbd.Text.ToString(); DGVde[4, r].Value = MTBbp.Text.ToString(); r++; if (r == LBn.SelectedIndex+1) { CBreg.Enabled = false; LBn.Enabled = false; groupBox1.Enabled = false; } } } private void generarNominaToolStripMenuItem_Click(object sender, EventAr gs e) { for (int i = 0; i < DGVde.RowCount; i++) { dt = Convert.ToInt16(DGVde[1, i].Value); pd = Convert.ToDouble(DGVde[2, i].Value); bd = Convert.ToDouble(DGVde[3, i].Value); bp = Convert.ToDouble(DGVde[4, i].Value); sb = dt * pd; isr = sb * .35; imss = sb * .06;

imp = isr + imss; bon = bd + bp; sn = sb - imp + bon; DGVdn[0, i].Value = DGVde[0, i].Value; DGVdn[1, i].Value = Convert.ToString(sb); DGVdn[2, i].Value = Convert.ToString(imp); DGVdn[3, i].Value = Convert.ToString(bon); DGVdn[4, i].Value = Convert.ToString(sn); suma += sn; Ltot.Text = suma.ToString(); } } private void salirToolStripMenuItem_Click(object sender, EventArgs e) { Close(); } private void MTBpxd_MaskInputRejected(object sender, MaskInputRejectedEv entArgs e) { } private void nuevaNominaToolStripMenuItem_Click(object sender, EventArgs e) { LBn.SelectedIndex = -1; TBnom.Clear(); MTBbd.Clear(); MTBbp.Clear(); MTBdt.Clear(); MTBpxd.Clear(); CBreg.Checked = false; CBreg.Enabled = true; groupBox1.Enabled = true; for (int i = 0; i < DGVdn.RowCount; i++) { for (int j = 0; j < DGVdn.ColumnCount; j++) { DGVdn[j, i].Value = " "; DGVde[j, i].Value = " "; } } Ltot.ResetText(); } } }