private void save()
        {
            if (u_Validate())
            {
                tmpcursor = null;

                var BL = new tb_60movientosdocBL();
                var BE = new tb_60movimientosdoc();
                BE.norden = 1;
                BE.ver_blanco = 0;
                BE.vista = 1;

                BE.moduloid = VariablesPublicas.Moduloid;
                BE.local = VariablesPublicas.Local;

                BE.tipodoc = tipdoc;
                BE.serdoc = serdoc;
                BE.numdoc = numdoc;

                tmpcursor = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];

                var ofila = tmpcursor.NewRow();

                ofila = VariablesPublicas.InsertIntoTable(tmpcursor);

                if (u_n_opsel == 1)
                {
                    BE.items = txtcodigo.Text.Trim();

                    BE.moduloid = VariablesPublicas.Moduloid;
                    BE.local = VariablesPublicas.Local;
                    BE.tipodoc = tipdoc;
                    BE.serdoc = serdoc;
                    BE.numdoc = numdoc;

                    tmptabla = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];

                    if (tmptabla.Rows.Count > 0)
                    {
                        var BLMX = new tb_60movientosdocBL();
                        var BEMX = new tb_60movimientosdoc();

                        BEMX.moduloid = VariablesPublicas.Moduloid;
                        BEMX.local = VariablesPublicas.Local;
                        BEMX.tipodoc = tipdoc;
                        BEMX.serdoc = serdoc;
                        BEMX.numdoc = numdoc;

                        ofila["item"] = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString();
                    }
                    else
                    {
                        ofila["item"] = txtcodigo.Text;
                    }
                }
                else
                {
                    ofila["item"] = dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["item"].Value;
                    for (lc_cont = 0; lc_cont <= dgvfileatached.ColumnCount - 1; lc_cont++)
                    {
                        xnomcampo = dgvfileatached.Columns[lc_cont].Name;
                        ofila[xnomcampo] = dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells[lc_cont].Value;
                    }
                }

                ofila["item"] = txtcodigo.Text.Trim();
                ofila["docglosa"] = txtdescripcion.Text.Trim();
                ofila["docname"] = txtnombrearchivo.Text.Trim();
                ofila["documen"] = vmContenidoFile;
                tmpcursor.Rows.Add(ofila);
                BE.moduloid = VariablesPublicas.Moduloid;
                BE.local = VariablesPublicas.Local;
                BE.tipodoc = tipdoc;
                BE.serdoc = serdoc;
                BE.numdoc = numdoc;

                if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor))
                {
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
            }
        }
        private void Accion(int naccion)
        {
            switch (naccion)
            {
                case 1:
                    u_n_opsel = 1;
                    U_RefrescaControles();
                    Blanquear();
                    var BL = new tb_60movientosdocBL();
                    var BE = new tb_60movimientosdoc();

                    BE.moduloid = VariablesPublicas.Moduloid;
                    BE.local = VariablesPublicas.Local;
                    BE.tipodoc = tipdoc;
                    BE.serdoc = serdoc;
                    BE.numdoc = numdoc;

                    txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString();

                    if (dgvfileatached.CurrentRow != null)
                    {
                        dgvfileatached.CurrentRow.Selected = false;
                    }
                    break;
                case 2:
                    POnedatos();
                    u_n_opsel = 2;
                    U_RefrescaControles();
                    dgvfileatached.CurrentRow.Selected = true;
                    break;
                case 3:
                    xnomcampo = "";
                    if (dgvfileatached.CurrentRow != null)
                    {
                        var BLIR = new tb_60movientosdocBL();
                        var BEIR = new tb_60movimientosdoc();
                        BEIR.items = dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["item"].Value.ToString().Trim();
                        tmpcursor = BLIR.GetAll_CONSULTAIR(VariablesPublicas.EmpresaID, BEIR).Tables[0];
                        if (BLIR.Sql_Error.Length > 0)
                        {
                            xnomcampo = BLIR.Sql_Error;
                            Frm_Class.ShowError(BLIR.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 message = "Desea Eliminar Registro  " + dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["item"].Value.ToString().Trim() + "-" + dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["docglosa"].Value.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_60movientosdocBL();
                            var BEE = new tb_60movimientosdoc();
                            BEE.items = dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["item"].Value.ToString().Trim();
                            BEE.norden = 1;
                            BEE.ver_blanco = 0;
                            BEE.vista = 1;

                            BEE.moduloid = VariablesPublicas.Moduloid;
                            BEE.local = VariablesPublicas.Local;
                            BEE.tipodoc = tipdoc;
                            BEE.numdoc = numdoc;
                            BEE.serdoc = serdoc;

                            tmpcursor = BLE.GetAll(VariablesPublicas.EmpresaID, BEE).Tables[0];

                            if (BLE.Sql_Error.Length == 0)
                            {
                                if (BLE.Delete(VariablesPublicas.EmpresaID, BEE))
                                {
                                    for (lc_cont = 0; lc_cont <= Tabla.Rows.Count - 1; lc_cont++)
                                    {
                                        if (Tabla.Rows[lc_cont]["item"] == dgvfileatached.Rows[dgvfileatached.CurrentRow.Index].Cells["item"].Value)
                                        {
                                            Tabla.Rows[lc_cont].Delete();
                                            Tabla.AcceptChanges();
                                            break;
                                        }
                                    }
                                    dgvfileatached.Refresh();
                                }
                                else
                                {
                                    Frm_Class.ShowError(BLE.Sql_Error, this);
                                }
                            }
                            else
                            {
                                Frm_Class.ShowError(BLE.Sql_Error, this);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR DOCUMENTO");
                    }
                    break;
            }
        }