private void btnnuevo_Click(object sender, EventArgs e)
        {
            if (!(TabControl1.SelectedIndex == 0))
            {
                TabControl1.SelectedIndex = 0;
            }
            u_n_opsel = 1;
            Blanquear();
            TabControl1.SelectedIndex = 0;
            TabControl1.SelectedIndex = 1;
            var BL = new tb_plla_rubrospllacabBL();
            var BE = new tb_plla_rubrospllacab();

            txtcodigo.Text = BL.GetAll_MaxRubro(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString();
            txtdescripcion.Text = string.Empty;
            cmbtipo.SelectedValue = "I";
            u_CargaAnexos();
            txtdescripcion.Focus();
        }
        private void btngrabar_Click(object sender, EventArgs e)
        {
            if (U_Validacion())
            {
                if (u_n_opsel == 1)
                {
                    var BL = new tb_plla_rubrospllacabBL();
                    var BE = new tb_plla_rubrospllacab();

                    BE.rubrocod = txtcodigo.Text.Trim();
                    tmptabla = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];
                    if (tmptabla.Rows.Count > 0)
                    {
                        var BLMAX = new tb_plla_rubrospllacabBL();
                        var BEMAX = new tb_plla_rubrospllacab();

                        txtcodigo.Text = BLMAX.GetAll_MaxRubro(VariablesPublicas.EmpresaID.ToString(), BEMAX).Tables[0].Rows[0]["maximo_codigo"].ToString();
                    }
                    tmptabla.Rows.Add(VariablesPublicas.InsertIntoTable(tmptabla));
                    tmptabla.Rows[0]["rubrocod"] = txtcodigo.Text.Trim();
                    tmptabla.Rows[0]["tipoplla"] = xtipplla;
                }
                else
                {
                    var BL = new tb_plla_rubrospllacabBL();
                    var BE = new tb_plla_rubrospllacab();

                    BE.rubrocod = txtcodigo.Text.Trim();
                    tmptabla = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];
                }

                for (lc_contador = 0; lc_contador <= tabladetprestamos.Rows.Count - 1; lc_contador++)
                {
                    tabladetprestamos.Rows[lc_contador]["rubrocod"] = txtcodigo.Text.Trim();
                }
                tmptabla.Rows[0]["tiporubro"] = cmbtipo.SelectedValue;
                tmptabla.Rows[0]["rubroname"] = txtdescripcion.Text;
                tmptabla.AcceptChanges();
                tabladetprestamos.AcceptChanges();

                var BLIU = new tb_plla_rubrospllacabBL();
                var BEIU = new tb_plla_rubrospllacab();
                if (BLIU.Insert_Update(VariablesPublicas.EmpresaID, BEIU, tmptabla, tabladetprestamos))
                {
                    seguridadlog();
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BLIU.Sql_Error, this);
                }
            }
        }