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);
                }
            }
        }