private void Venta_Load(object sender, EventArgs e) { BLL.Cliente c1 = new BLL.Cliente(); dgvClientes.DataSource = null; dgvClientes.DataSource = c1.SelectAlldt(); BLL.Factura f1 = new BLL.Factura(); int maxid = int.Parse(f1.GetMaxId().ToString()); if (maxid.Equals(null)) { txtidfactura.Text = "1"; } else if (maxid == 0) { txtidfactura.Text = (maxid + 1).ToString(); } else { txtidfactura.Text = maxid.ToString(); } decimal total = 0; foreach (DataRow aux in _dtfact.Rows) { total = total + decimal.Parse(aux[5].ToString()); } txttotal.Text = total.ToString(); }