private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { var BL = new tb_plla_tab0100BL(); var BE = new tb_plla_tab0100(); BE.codigo = txtcodigo.Text.Trim(); tmpcursor = BL.TipoPrestamo_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (u_n_opsel == 1) { while (1 == 1) { tmpcursor = BL.TipoPrestamo_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (BL.Sql_Error.Length > 0) { Frm_Class.ShowError(BL.Sql_Error + "\r" + "Error al buscar código", this); return; } if (tmpcursor.Rows.Count > 0) { var BLMX = new tb_plla_tab0100BL(); var BEMX = new tb_plla_tab0100(); txtcodigo.Text = BLMX.TipoPrestamo_MAXCODIGO(VariablesPublicas.EmpresaID, BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } else { break; } } tmpcursor = BL.TipoPrestamo_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; tmpcursor.Rows.Add(VariablesPublicas.INSERTINTOTABLE(tmpcursor)); tmpcursor.Rows[0]["cprestamo"] = txtcodigo.Text; } tmpcursor.Rows[0]["dprestamo"] = txtdescripcion.Text.Trim(); tmpcursor.Rows[0]["estadoprestamo"] = (chkactivo.Checked ? 1 : 0); tmpcursor.AcceptChanges(); if (BL.TipoPrestamo_InsertUpdate(VariablesPublicas.EmpresaID, BE, tmpcursor)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }