private void btnnuevo_Click(object sender, EventArgs e)
 {
     if (!(TabControl1.SelectedIndex == 0))
     {
         TabControl1.SelectedIndex = 0;
     }
     u_n_opsel = 1;
     Blanquear();
     U_RefrescaControles();
     TabControl1.SelectedIndex = 0;
     TabControl1.SelectedIndex = 1;
     var BL = new tb_plla_rubrosdescuentosBL();
     var BE = new tb_plla_rubrosdescuentos();
     BE.tipo = GlobalVars.GetInstance().TipoRubroPlanillaDescuento;
     BE.tipoplla = cmbfiltrotipoplanilla.SelectedValue.ToString();
     txtcodigo.Text = BL.GetMAX_CODIGORUBROPLANILLA(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString();
     cmbtipoplanilla.SelectedValue = cmbfiltrotipoplanilla.SelectedValue;
     txtsigla.Text = GlobalVars.GetInstance().TipoRubroPlanillaDescuento;
     chkactivo.Checked = true;
     txtdescripcion.Focus();
 }
        private void btngrabar_Click(object sender, EventArgs e)
        {
            if (U_Validacion())
            {
                var tmpcursor = new DataTable();
                var BL = new tb_plla_rubrosdescuentosBL();
                var BE = new tb_plla_rubrosdescuentos();

                BE.rubroid = txtsigla.Text.ToString().Trim() + txtcodigo.Text.ToString().Trim();
                BE.tipoplla = cmbtipoplanilla.SelectedValue.ToString();
                BE.norden = 1;
                BE.incluir_blanco = 0;
                BE.nestado = 1;
                tmpcursor = BL.GetAll_CONSULTA1(VariablesPublicas.EmpresaID, BE).Tables[0];

                if (u_n_opsel == 1)
                {
                    tmpcursor = BL.GetAll_CONSULTA1(VariablesPublicas.EmpresaID, BE).Tables[0];
                    if (tmpcursor.Rows.Count > 0)
                    {
                        var BLm = new tb_plla_rubrosdescuentosBL();
                        var BEm = new tb_plla_rubrosdescuentos();
                        BEm.tipo = GlobalVars.GetInstance().TipoRubroPlanillaDescuento;
                        BEm.tipoplla = cmbtipoplanilla.SelectedValue.ToString();
                        txtcodigo.Text = BLm.GetMAX_CODIGORUBROPLANILLA(VariablesPublicas.EmpresaID.ToString(), BEm).Tables[0].Rows[0]["maximo_codigo"].ToString();
                    }
                    tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor));
                    tmpcursor.Rows[0]["rubroid"] = txtsigla.Text + txtcodigo.Text;
                    tmpcursor.Rows[0]["status"] = '0';
                }
                tmpcursor.Rows[0]["tipoplla"] = cmbtipoplanilla.SelectedValue;
                tmpcursor.Rows[0]["rubroname"] = txtdescripcion.Text;
                tmpcursor.Rows[0]["tiporubro"] = cmbtipo.SelectedValue;
                tmpcursor.Rows[0]["visible"] = (chkvisible.Checked ? 1 : 0);
                tmpcursor.Rows[0]["edita"] = (chkeditable.Checked ? 1 : 0);
                tmpcursor.Rows[0]["modalidad"] = cmbmodalidad.SelectedValue;
                tmpcursor.Rows[0]["redondeo"] = VariablesPublicas.StringtoDecimal(txtredondeo.Text);
                tmpcursor.Rows[0]["montofijo"] = VariablesPublicas.StringtoDecimal(txtmontofijo.Text);
                tmpcursor.Rows[0]["tipocalculo"] = cmbtipocalculo.SelectedValue;
                tmpcursor.Rows[0]["visibleq"] = (chkvisibleq.Checked ? 1 : 0);
                tmpcursor.Rows[0]["editaq"] = (chkeditableq.Checked ? 1 : 0);
                tmpcursor.Rows[0]["rubropdt"] = cmbrubrorpts.SelectedValue;
                tmpcursor.Rows[0]["status"] = (chkactivo.Checked ? '0' : '9');
                tmpcursor.AcceptChanges();
                var BLIU = new tb_plla_rubrosdescuentosBL();

                if (BLIU.Insert_Update(VariablesPublicas.EmpresaID, tmpcursor))
                {
                    seguridadlog();
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BLIU.Sql_Error, this);
                }
            }
        }