private void abreArchivoRegistrosClave8(Atributo nom, ComboBox comboBox) { entActualCla1.lsDatos.Clear(); entActualCla2.lsDatos.Clear(); entActualCla3.lsDatos.Clear(); entActualCla6.lsDatos.Clear(); if (File.Exists(nom.nomAtributo + ".dat")) { int g = 0; for (int i = 0; i < lssentidads.Count; i++) { if (lssentidads[i].nombre == nom.nomAtributo) { g = i; break; } } FileStream abre; abre = File.Open(nom.nomAtributo + ".dat", FileMode.Open); BinaryReader br = new BinaryReader(abre); long dirSiguiente = 0; long posicion = lssentidads[g].dirDatos; long tam = abre.Length; abre.Seek(posicion, SeekOrigin.Begin); while (dirSiguiente != -1) //while (abre.Position != tam) { int n = dgvRegistros.Rows.Add(); int celda = 0; //abre.Seek(abre.Position, SeekOrigin.Begin); abre.Seek(posicion, SeekOrigin.Begin); //long dir = br.ReadInt64(); posicion = br.ReadInt64(); celda++; foreach (Atributo atr in atributos) { switch (atr.tipoDato) { case 'E': int entero = br.ReadInt32(); //dgvRegistros.Rows[n].Cells[celda].Value = entero; if (atr.tipoIndice == 2) { comboBox.Items.Add(entero); } break; case 'C': string cadena = br.ReadString(); break; } celda++; } dirSiguiente = br.ReadInt64(); posicion = dirSiguiente; //} } tamArchivoData = abre.Length; abre.Close(); } }
public Form4(string entidad, Atributo atri) { atr = atri; nomEntidad = entidad; InitializeComponent(); }
/*Evento que agrega la informacion a un atributio*/ private void bt_AgregarAtr_Click(object sender, EventArgs e) { if (!checaAtributoRepetido()) { if (cb_TipoIndice.Text == "8") { // abreArchivoRegistros(); int r = detectaInd(); if (Aux[detectaInd()].lsDatos.Count > 0) { Atributo atr = new Atributo(Aux[detectaInd()].nombre, Convert.ToChar("E"), sumaTamAtributos(Aux[detectaInd()]), tamArchivo, int.Parse(cb_TipoIndice.Text), -1, -1); entidadSel.agregaAtributo(atr); int n = dgvAtributos.Rows.Add(); dgvAtributos.Rows[n].Cells[0].Value = Aux[detectaInd()].nombre; dgvAtributos.Rows[n].Cells[1].Value = atr.tipoDato; dgvAtributos.Rows[n].Cells[2].Value = atr.longDato; dgvAtributos.Rows[n].Cells[3].Value = atr.dirAtributo; dgvAtributos.Rows[n].Cells[4].Value = atr.tipoIndice; dgvAtributos.Rows[n].Cells[5].Value = Aux[detectaInd()].dirAtr; dgvAtributos.Rows[n].Cells[6].Value = atr.dirSigAtributo; if (n >= 1)//Asigna las direcciones siguiente a la lista { dgvAtributos.Rows[n - 1].Cells[6].Value = atr.dirAtributo; } escribeAtributo(); actualizaDGVAtr(); tb_Atributo.Text = ""; tb_LongitudDato.Text = ""; cb_TipoDato.Text = ""; cb_TipoIndice.Text = ""; } else { tb_Atributo.Text = ""; tb_LongitudDato.Text = ""; cb_TipoDato.Text = ""; cb_TipoIndice.Text = ""; comboBox1.Enabled = false; comboBox1.Items.Clear(); MessageBox.Show("La entidad seleccionado no contiene Datos"); } } else { Atributo atr = new Atributo(tb_Atributo.Text.PadRight(29), Convert.ToChar(cb_TipoDato.Text), int.Parse(tb_LongitudDato.Text), tamArchivo, int.Parse(cb_TipoIndice.Text), -1, -1); entidadSel.agregaAtributo(atr); int n = dgvAtributos.Rows.Add(); dgvAtributos.Rows[n].Cells[0].Value = atr.nomAtributo; dgvAtributos.Rows[n].Cells[1].Value = atr.tipoDato; dgvAtributos.Rows[n].Cells[2].Value = atr.longDato; dgvAtributos.Rows[n].Cells[3].Value = atr.dirAtributo; dgvAtributos.Rows[n].Cells[4].Value = atr.tipoIndice; dgvAtributos.Rows[n].Cells[5].Value = atr.dirIndice; dgvAtributos.Rows[n].Cells[6].Value = atr.dirSigAtributo; if (n >= 1)//Asigna las direcciones siguiente a la lista { dgvAtributos.Rows[n - 1].Cells[6].Value = atr.dirAtributo; } escribeAtributo(); actualizaDGVAtr(); tb_Atributo.Text = ""; tb_LongitudDato.Text = ""; cb_TipoDato.Text = ""; cb_TipoIndice.Text = ""; // bt_InsertaRegistro.Visible = false; } } else { MessageBox.Show("EL ATRIBUTO YA EXISTE "); } }