Ejemplo n.º 1
0
        private bool nuevoAtributo()
        {
            bool    r    = false;
            int     i    = treeViewBD.SelectedNode.Index;
            string  name = treeViewBD.SelectedNode.Text;
            string  n    = treeViewBD.SelectedNode.Text.Split('.')[0];
            Entidad ent  = ddd.EntidadesOrden.Find(o => o.shortName.CompareTo(n) == 0);

            if (hayregistros(ent))
            {
                return(false);
            }
            NuevoAtributo nuevo = new NuevoAtributo(ent, ddd);

            if (nuevo.ShowDialog() == DialogResult.OK)
            {
                //long dir = -1;
                if (ent.AtributoExiste(nuevo.Nombre_atributo))
                {
                    return(false);
                }
                ddd.nuevoAtributo(nuevo.Nombre_atributo, nuevo.Tipo, nuevo.Long, ent, nuevo.TipoIndex, nuevo.Relacion);
                ent.Indice(Path);
                ArchivoRegistros archivo = new ArchivoRegistros(Path + '\\' + ent.shortName + ".dat", ent);
                vr.VerTabla(ent, archivo);
                creArbol();
                r = true;
            }
            return(r);
        }
Ejemplo n.º 2
0
        private void modificarAtributoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode n = treeViewBD.SelectedNode;

            if (n.Level == 2)
            {
                string  text = treeViewBD.SelectedNode.Parent.Text.Split('.')[0];
                Entidad ent  = ddd.EntidadesOrden.Find(o => o.shortName.CompareTo(text) == 0);
                if (ent.Registros == null || ent.Registros.Count == 0)
                {
                    return;
                }
                //if (Relacion(ent))
                //{
                //    MessageBox.Show("Atributo con relacion");
                //    return;
                //}
                if (ent != null)
                {
                    Atributo aMod = ent.Atrib.Find(o => o.sNombre.CompareTo(n.Text) == 0);
                    if (aMod != null)
                    {
                        //if (aMod.TipoIndice == 3)
                        //{
                        //    MessageBox.Show("Atributo con Llave secundaria");
                        //    return;
                        //}
                        using (NuevoAtributo nuevo = new NuevoAtributo(ent, ddd))
                        {
                            nuevo.modifica(aMod);
                            if (nuevo.ShowDialog() == DialogResult.OK)
                            {
                                string nomb = nuevo.Nombre_atributo;
                                if (nomb != "")
                                {
                                    while (nomb.Length < 30)
                                    {
                                        nomb += ' ';
                                    }
                                    aMod.Nombre = nomb.ToCharArray(0, 30);
                                }
                                aMod.Tipo = (nuevo.Tipo == 1) ? 'C' : 'E';

                                aMod.Longitud   = nuevo.Long;
                                aMod.TipoIndice = nuevo.TipoIndex;
                                ddd.sobreescribAtributo(aMod);
                                //AtribEnt(ent);
                                creArbol();
                            }
                        }
                    }
                }
            }
        }