private void MainForm_Load(object sender, System.EventArgs e) { string[] tables = SqlExtractor.GetTables(); ArrayList arrl = new ArrayList(tables); arrl.Insert(0, ""); lTabla.DataSource = arrl; }
private void CargaCampos(string tabla) { lvCampos.Items.Clear(); FieldArray fields = SqlExtractor.GetTableFields(tabla); foreach (Field field in fields) { string[] items = new string[] { "", field.Name, field.Type.Name }; ListViewItem lvi = new ListViewItem(items); lvi.Tag = field; lvCampos.Items.Add(lvi); } }
private void bGenerar_Click(object sender, System.EventArgs e) { const string ENG_FNAME = "{0}\\Eng{1}.cs"; const string CLS_FNAME = "{0}\\C{1}.cs"; const string SP_FNAME = "{0}\\{1}.sql"; FieldArray fields = RecuperaCampos(); string entidad = tEntidad.Text, aplicacion = tAplicacion.Text, path = tDirectorio.Text, table = lTabla.SelectedValue.ToString(); string spnameselect = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Select), spselect = SqlExtractor.CreateSelectProcedure(aplicacion, table, fields, entidad), spnameupdate = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Update), spupdate = SqlExtractor.CreateUpdateProcedure(aplicacion, table, fields, entidad), spnameinsert = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Insert), spinsert = SqlExtractor.CreateInsertProcedure(aplicacion, table, fields, entidad), spnamedelete = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Delete), spdelete = SqlExtractor.CreateDeleteProcedure(aplicacion, table, fields, entidad); Hashtable extInfo = new Hashtable(); extInfo.Add("aplicacion", aplicacion); extInfo.Add("spselect", spnameselect); extInfo.Add("spupdate", spnameupdate); extInfo.Add("spinsert", spnameinsert); extInfo.Add("spdelete", spnamedelete); extInfo.Add("primarykeys", SqlExtractor.GetPrimaryKeys(table)); string strclass = Binder.BindClass(entidad, fields, extInfo); string strengine = Binder.BindEngine(entidad, fields, extInfo); StreamWriter sw = new StreamWriter(string.Format(CLS_FNAME, path, entidad), false); sw.Write(strclass); sw.Close(); sw = new StreamWriter(string.Format(ENG_FNAME, path, entidad), false); sw.Write(strengine); sw.Close(); sw = new StreamWriter(string.Format(SP_FNAME, path, spnameselect), false); sw.Write(spselect); sw.Close(); sw = new StreamWriter(string.Format(SP_FNAME, path, spnameupdate), false); sw.Write(spupdate); sw.Close(); sw = new StreamWriter(string.Format(SP_FNAME, path, spnameinsert), false); sw.Write(spinsert); sw.Close(); sw = new StreamWriter(string.Format(SP_FNAME, path, spnamedelete), false); sw.Write(spdelete); sw.Close(); MessageBox.Show("Archivos generados correctamente"); // Preparo para generar nuevas entidades tEntidad.Text = ""; panEntidad.Enabled = false; }