private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { var BL = new tb_plla_establecimientosBL(); var BE = new tb_plla_establecimientos(); BE.empresaid = VariablesPublicas.EmpresaID; BE.estabid = txtcodigo.Text.Trim(); BE.norden = 1; BE.ver_blanco = 0; tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (u_n_opsel == 1) { while (1 == 1) { tmpcursor = BL.GetAll_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_establecimientosBL(); var BEMX = new tb_plla_establecimientos(); BEMX.empresaid = VariablesPublicas.EmpresaID; txtcodigo.Text = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } else { break; } } tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor)); tmpcursor.Rows[0]["estabid"] = txtcodigo.Text; } tmpcursor.Rows[0]["estabname"] = txtdescripcion.Text.Trim(); tmpcursor.Rows[0]["estabrtps"] = cmbtipo.SelectedValue; tmpcursor.Rows[0]["empresaid"] = VariablesPublicas.EmpresaID; tmpcursor.Rows[0]["status"] = chkActivo.Checked; tmpcursor.AcceptChanges(); if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }