public void load(List <TableVo> tables, int idReport, int mainId, string filtro) { tables = new List <TableVo>(); string sFiltro; sFiltro = filtro; sFiltro += string.IsNullOrEmpty(sFiltro) ? "" : " AND "; sFiltro += "indice = "; int idx = 0; while (true) { TableVo tableVo = new TableVo(); load(tableVo, idReport, mainId, sFiltro + idx++); if (tableVo.ID == 0) { break; } tables.Add(tableVo); } }
public int save(TableVo table) { if (table.ID == 0) { // setando propriedades de relacionamento. if (table.RELATED != null) { table.RELATEDINDEX = table.RELATED.INDEX; table.RELATEDTABLE = table.RELATED.TABELA; } int i = insert(table); this.load(table, table.IDREPORT, table.MAINID); #region RESET MAINIDs foreach (Fields.FieldsVo field in table.FIELDS) { field.MAINTABLE = table; } /* * foreach (Filters.FiltersVo filter in table.FILTERS ) * filter.MAINTABLE = table; * foreach (OrderBy.OrderByVo order in table.ORDERBY ) * order.MAINTABLE = table; * foreach (Params.ParamsVo parms in table.PARAMS ) * parms.MAINTABLE = table; * //*/ if (table.CHILDREN != null) { table.CHILDREN.ForEach(delegate(Table.TableVo child) { child.PARENT = table; child.REPORT = table.REPORT; //child.INDEX = table.CHILDREN.IndexOf(child); }); } #endregion #region SAVE PROPRIEDADES new Fields.FieldsDao( ).save(table.FIELDS); /* * new Filters.FiltersDao().save(table.FILTERS ); * new OrderBy.OrderByDao().save(table.ORDERBY ); * new Params.ParamsDao( ).save(table.PARAMS ); * new Table.TableDao( ).save(table.CHILDREN); * //*/ #endregion return(i); } else { return(update(table)); } }
public void load(TableVo table, int idReport, int mainId, string filtro) { DataTable dtTable = select(idReport, mainId, filtro); if (dtTable.DefaultView.Count > 0) { table.IDREPORT = idReport; table.MAINID = mainId; table.ID = (int)dtTable.DefaultView[0]["id"]; table.RELATEDINDEX = (int)dtTable.DefaultView[0]["relatedindex"]; table.RELATEDIDENT = (string)dtTable.DefaultView[0]["relatedident"]; table.RELATEDTYPE = (string)dtTable.DefaultView[0]["relatedtype"]; table.TABELA = (string)dtTable.DefaultView[0]["tabela"]; //table.INDEX = (int) dtTable.DefaultView[0]["indice"]; } }
public int update(TableVo table) { this.QUERY = new StringBuilder(fromDatabase); this.QUERY.AppendLine("UPDATE [RTable]"); this.QUERY.AppendLine(" SET idReport = " + table.IDREPORT); this.QUERY.AppendLine(" , relatedindex = " + table.RELATEDINDEX); this.QUERY.AppendLine(" , mainId = " + table.MAINID); this.QUERY.AppendLine(" , relatedident = '" + table.RELATEDIDENT + "'"); this.QUERY.AppendLine(" , relatedtype = '" + table.RELATEDTYPE + "'"); this.QUERY.AppendLine(" , tabela = '" + table.TABELA + "'"); this.QUERY.AppendLine(" , indice = '" + table.INDEX + "'"); this.QUERY.AppendLine(" WHERE id = " + table.ID); this.QUERY.AppendLine(" ORDER BY indice"); return(getData().DefaultView.Count); }
public int insert(TableVo table) { this.QUERY = new StringBuilder(fromDatabase); this.QUERY.Append("INSERT INTO [RTable]"); this.QUERY.AppendLine("( idReport " + ", relatedindex" + ", mainId " + ", relatedident" + ", relatedtype " + ", tabela " + ", indice )"); this.QUERY.Append("VALUES( " + table.IDREPORT); this.QUERY.Append(" , " + table.RELATEDINDEX); this.QUERY.Append(" , " + table.MAINID); this.QUERY.Append(" ,'" + table.RELATEDIDENT + "'"); this.QUERY.Append(" ,'" + table.RELATEDTYPE + "'"); this.QUERY.Append(" ,'" + table.TABELA + "'"); this.QUERY.Append(" , " + table.INDEX); this.QUERY.AppendLine(" )"); return(getData().DefaultView.Count); }
public void load(TableVo table, int idReport, int mainId, bool filterTable) { load(table, idReport, mainId, "tabela = '" + table.TABELA + "' AND indice = " + table.INDEX); }
// load unico public void load(TableVo table, int idReport, int mainId) { load(table, idReport, mainId, "indice = " + table.INDEX); }
public int delete(TableVo table) { return(delete(table.IDREPORT, table.MAINID, "id = " + table.ID)); }