private void CargaDatos()
        {
            lbltotalregistros.Text = string.Empty;
            var xtipoplanilla = string.Empty;
            var nestado = 1;
            if (rbestado2.Checked)
            {
                nestado = 2;
            }
            if (rbestado3.Checked)
            {
                nestado = 3;
            }
            if (cmbfiltrotipoplanilla.Enabled)
            {
                if (cmbfiltrotipoplanilla.SelectedValue != null)
                {
                    xtipoplanilla = cmbfiltrotipoplanilla.SelectedValue.ToString();
                }
            }
            var nposcolumnasortear = 0;
            var PrvSotOrder = default(SortOrder);
            var zordenado = false;
            var xcodcliente = "..";
            var xpalabra1 = string.Empty;
            var xpalabra2 = string.Empty;
            var xpalabra3 = string.Empty;
            if (txtfiltronombre.Text.Trim().Length > 0)
            {
                xpalabra1 = VariablesPublicas.Palabras(txtfiltronombre.Text, 1);
                xpalabra2 = VariablesPublicas.Palabras(txtfiltronombre.Text, 2);
                xpalabra3 = VariablesPublicas.Palabras(txtfiltronombre.Text, 3);
            }
            if (Examinar.CurrentRow != null)
            {
                xcodcliente = Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
            }
            if (Examinar.SortedColumn != null)
            {
                nposcolumnasortear = Examinar.SortedColumn.Index;
                PrvSotOrder = Examinar.SortOrder;
                zordenado = true;
            }
            var BL = new tb_plla_rubrosaportacionesBL();
            var BE = new tb_plla_rubrosaportaciones();

            BE.tipoplla = xtipoplanilla;
            BE.descriplike1 = xpalabra1;
            BE.descriplike2 = xpalabra2;
            BE.descriplike3 = xpalabra3;
            BE.norden = 0;
            BE.incluir_blanco = 0;
            BE.nestado = nestado;
            tablaclientes = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
            Examinar.AutoGenerateColumns = false;
            Examinar.DataSource = tablaclientes;

            VariablesPublicas.PintaEncabezados(Examinar);
            if (zordenado)
            {
                if (PrvSotOrder == SortOrder.Ascending)
                {
                    Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                Examinar.Sort(Examinar.Columns["rubroid"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (Examinar.CurrentRow == null)
            {
                if (Examinar.RowCount > 0)
                {
                    Examinar.CurrentCell = Examinar.Rows[0].Cells["rubroid"];
                }
            }
            for (lc_cont = 0; lc_cont <= Examinar.Rows.Count - 1; lc_cont++)
            {
                if (Examinar.Rows[lc_cont].Cells["rubroid"].Value.ToString() == xcodcliente)
                {
                    Examinar.CurrentCell = Examinar.Rows[lc_cont].Cells["rubroid"];
                    break;
                }
            }
            if (Examinar.RowCount > 0)
            {
                lbltotalregistros.Text = Examinar.RowCount.ToString() + " Registro(s)";
            }
            else
            {
                lbltotalregistros.Text = " NINGUN REGISTRO";
            }
            u_PintaDatos();
            U_RefrescaControles();
        }
        private void btngrabar_Click(object sender, EventArgs e)
        {
            if (U_Validacion())
            {
                var tmpcursor = new DataTable();
                var BL = new tb_plla_rubrosaportacionesBL();
                var BE = new tb_plla_rubrosaportaciones();

                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_rubrosaportacionesBL();
                        var BEm = new tb_plla_rubrosaportaciones();
                        BEm.tipo = GlobalVars.GetInstance().TipoRubroPlanillaAportacion;
                        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]["redondeo"] = 0;
                tmpcursor.Rows[0]["montofijo"] = 0;
                tmpcursor.Rows[0]["visible"] = (chkvisible.Checked ? 1 : 0);
                tmpcursor.Rows[0]["edita"] = (chkeditable.Checked ? 1 : 0);
                tmpcursor.Rows[0]["rubropdt"] = cmbrubrorpts.SelectedValue;
                tmpcursor.Rows[0]["status"] = (chkactivo.Checked ? '0' : '9');
                tmpcursor.AcceptChanges();
                var BLIU = new tb_plla_rubrosaportacionesBL();

                if (BLIU.Insert_Update(VariablesPublicas.EmpresaID, tmpcursor))
                {
                    seguridadlog();
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BLIU.Sql_Error, this);
                }
            }
        }
 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_rubrosaportacionesBL();
     var BE = new tb_plla_rubrosaportaciones();
     BE.tipo = GlobalVars.GetInstance().TipoRubroPlanillaAportacion;
     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().TipoRubroPlanillaAportacion;
     chkactivo.Checked = true;
     txtdescripcion.Focus();
 }
        private void btneliminar_Click(object sender, EventArgs e)
        {
            if (Examinar.CurrentRow != null)
            {
                var xnomcampo = string.Empty;
                var BL = new tb_plla_rubrosaportacionesBL();
                var BE = new tb_plla_rubrosaportaciones();

                BE.rubroid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                tmpcursor = BL.GetAll_IR(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (BL.Sql_Error.Length > 0)
                {
                    xnomcampo = BL.Sql_Error;
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
                else
                {
                    if (tmpcursor.Rows.Count == 0)
                    {
                    }
                    else
                    {
                        for (lc_cont = 0; lc_cont <= tmpcursor.Rows.Count - 1; lc_cont++)
                        {
                            xnomcampo = xnomcampo + tmpcursor.Rows[lc_cont]["relacion"] + "\r";
                            if (lc_cont + 1 == 10)
                            {
                                break;
                            }
                        }
                    }
                }
                if (xnomcampo.Length == 0)
                {
                    var BL1 = new tb_plla_rubrosaportacionesBL();
                    var BE1 = new tb_plla_rubrosaportaciones();

                    BE1.rubroid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                    BE1.tipoplla = Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString();
                    BE1.norden = 1;
                    BE1.incluir_blanco = 0;
                    BE1.nestado = 1;
                    tmptabla = BL1.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE1).Tables[0];
                    if (BL1.Sql_Error.Length == 0)
                    {
                        var message = "Desea eliminar datos del rubro  " + tmptabla.Rows[0]["rubroid"].ToString().Trim() + "-" + tmptabla.Rows[0]["rubroname"].ToString().Trim() + " ...?";
                        var caption = "Mensaje del Sistema";
                        var buttons = MessageBoxButtons.YesNo;
                        DialogResult result;
                        result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.Yes)
                        {
                            var BLE = new tb_plla_rubrosaportacionesBL();

                            BLE.Eliminar(VariablesPublicas.EmpresaID, tmptabla);
                            if (BLE.Sql_Error.Length == 0)
                            {
                                var BLL = new tb_co_seguridadlogBL();
                                var BEL = new tb_co_seguridadlog();

                                BEL.moduloid = Name;
                                BEL.clave = VariablesPublicas.EmpresaID + Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                                BEL.cuser = VariablesPublicas.Usuar;
                                BEL.fecha = DateTime.Now;
                                BEL.pc = VariablesPublicas.userip;
                                BEL.accion = "B";
                                BEL.detalle = "Rubro: " + txtdescripcion.Text;

                                BLL.Insert(VariablesPublicas.EmpresaID.ToString(), BEL);
                                Examinar.Rows.Remove(Examinar.CurrentRow);
                                Examinar.Refresh();
                                u_PintaDatos();
                            }
                            else
                            {
                                Frm_Class.ShowError(BLE.Sql_Error, this);
                            }
                        }
                    }
                    else
                    {
                        Frm_Class.ShowError(BL1.Sql_Error, this);
                    }
                }
                else
                {
                    MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO");
                }
            }
            U_RefrescaControles();
        }