⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weboutput.pas

📁 DBDesigner 4 is a database design system that integrates database design, modelling, creation and ma
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  node.FormHeight := FormHeight;

  node.FormWidth := FormWidth;

  node.FormX := FormX;

  node.FormY := FormY;

  node.GridPopupHeight := GridPopupHeight;

  node.GridPopupWidth := GridPopupWidth;

  node.GridPopupX := GridPopupX;

  node.GridPopupY := GridPopupY;

  node.Name := Name;

  node.WhereClause := WhereClause;

  node.RowsPerPage := RowsPerPage;

  node.UseCompoundColNames := UseCompoundColNames;

  node.IconFilename := FIconFilename;

  node.OrderBy := self.OrderBy;

  

  //converting the sorted column lists

  gs := '';

  for i:=0 to self.GridSortedColumnList.Count-1 do

  begin

    gs := gs + IntToStr(SW_Column(GridSortedColumnList.Objects[i]).Obj_id) +',';

  end;

  Delete(gs,length(gs),1);

  node.GridSortedColumns := gs;



  fs := '';

  for i:=0 to self.FormSortedColumnList.Count-1 do

  begin

    fs := fs + IntToStr(SW_Column(FormSortedColumnList.Objects[i]).Obj_id) +',';

  end;

  Delete(fs,length(fs),1);

  node.FormSortedColumns := fs;



  //Converting the picture

  stream:=TMemoryStream.Create;

  try

    Icon.Bitmap.SaveToStream(stream);

    node.Icon := DMMain.EncodeStreamForXML(stream);

  finally

    FreeAndNil(stream);

  end;





  self.Table.SaveToXMLNode(node.SWF_Table);



  for i:= 0 to JoinTables.Count-1 do

  begin

    xmlTable := node.JoinTables.Add;

    tmpTable := SW_Table(JoinTables[i]);

    tmpTable.SaveToXMLNode(xmlTable);

  end;



  for i:= 0 to NMTables.Count-1 do

  begin

    xmlTable := node.NMTables.Add;

    tmpTable := SW_Table(NMTables[i]);

    tmpTable.SaveToXMLNode(xmlTable);

  end;

end;



class function TView.LoadFromXMLNode(node :IXMLSWF_ViewType) :TView;

var v :TView;

    joinTables :IXMLJoinTablesType;

    table: IXMLSWF_TableType;

    realTable : SW_Table;

    i :Integer;

    nmTables :IXMLNMTablesType;

    theImgFile: TMemoryStream;

    gs,fs :string;

    helpList : TStringList;

    col : SW_Column;

begin

  try

  v := TView.Create;

  v.FFormHeight:= node.FormHeight;

  v.FFormWidth := node.FormWidth;

  v.FFormX := node.FormX;

  v.FFormY := node.FormY;

  v.FGridPopupHeight := node.GridPopupHeight;

  v.FGridPopupWidth := node.GridPopupWidth;

  v.FGridPopupX := node.GridPopupX;

  v.FGridPopupY := node.GridPopupY;

  v.FName := node.Name;

  v.FWhereClause := node.WhereClause;

  v.FRowsPerPage := node.RowsPerPage;

  v.FUseCompoundColNames := node.UseCompoundColNames;

  v.FTable := SW_Table.LoadFromXMLNode(node.SWF_Table);

  v.FIconFilename := node.IconFilename;

  v.OrderBy := node.OrderBy;

  v.FIcon := TPicture.Create();

  theImgFile:=TMemoryStream.Create;

  try

    DMMain.DecodeStreamFromXML(node.Icon, theImgFile);

    v.Icon.Bitmap.LoadFromStream(theImgFile);

  finally

    FreeAndNil(theImgFile);

  end;







  joinTables:= node.JoinTables;

  v.FJoinTables := TObjectList.Create;



  for i:= 0 to joinTables.Count-1 do

  begin

    table := joinTables[i];

    realTable := SW_Table.LoadFromXMLNode(table);

    v.FJoinTables.Add(realTable);

  end;



  nmTables:= node.NMTables;

  v.FNMTables := TObjectList.Create;



  for i:= 0 to nmTables.Count-1 do

  begin

    table := NMTables[i];

    realTable := SW_Table.LoadFromXMLNode(table);

    v.FNMTables.Add(realTable);

  end;



  if (NOT v.RelationsValid()) then

  begin

    v.JoinTables.Clear;

    v.NMTables.Clear;

  end;



  //load in the GridSortedColumns property

  gs := node.GridSortedColumns;

  helpList := TStringList.Create;

  Split (gs, ',', helpList);

  v.GridSortedColumnList := TStringList.Create;

  for i:=0 to helpList.Count-1 do

  begin

    col := FindColumnInView(StrToInt(helpList[i]),v );

    if (col <> nil) then v.GridSortedColumnList.AddObject(col.Table.name+'.'+col.name, col);

  end;

  helpList.Clear;

  GetColumns(helpList,v);

  if (helpList.Count <> v.GridSortedColumnList.Count) then

    v.GridSortedColumnList.Assign(helpList);



  //load in the FormSortedColumns property

  fs := node.FormSortedColumns;

  helpList.Clear;

  Split (fs, ',', helpList);

  v.FormSortedColumnList := TStringList.Create;

  for i:=0 to helpList.Count-1 do

  begin

    col := FindColumnInView(StrToInt(helpList[i]),v );

    if (col <> nil) then v.FormSortedColumnList.AddObject(col.Table.name+'.'+col.name, col);

  end;

  helpList.Clear;

  GetColumns(helpList,v);

  if (helpList.Count <> v.FormSortedColumnList.Count) then

    v.FormSortedColumnList.Assign(helpList);



  helpList.Free;



  LoadFromXMLNode := v;

  except

  on ETableDoesntExistException do LoadFromXMLNOde := nil;

  end;

end;



class function TView.FindColumnInView(obj_id: Integer; view: TView) : SW_Column;

var i, j: Integer;

    tmpTable: SW_Table;

begin

  FindColumnInView := nil;



  for i:=0 to view.Table.columns.Count-1 do

  begin

    if (SW_Column(view.Table.columns[i]).Obj_id = obj_id) then

    begin

      FindColumnInView :=SW_Column(view.Table.columns[i]);

      exit;

    end;

  end;



  for i:= 0 to view.JoinTables.Count-1 do

  begin

    tmpTable := SW_Table(view.JoinTables[i]);

    for j:= 0 to tmpTable.columns.Count-1 do

    begin

      if (SW_Column(tmpTable.columns[j]).Obj_id = obj_id) then

      begin

        FindColumnInView :=SW_Column(tmpTable.columns[j]);

        exit;

      end;

    end;

  end;



  for i:= 0 to view.NMTables.Count-1 do

  begin

    tmpTable := SW_Table(view.NMTables[i]);

    for j:= 0 to tmpTable.columns.Count-1 do

    begin

      if (SW_Column(tmpTable.columns[j]).Obj_id = obj_id) then

      begin

        FindColumnInView :=SW_Column(tmpTable.columns[j]);

        exit;

      end;

    end;

  end;

end;



function GetTablename(qual_col: String) :String;

var pos: Integer;

begin

  pos := AnsiPos('.', qual_col);

  assert (pos <> 0);



  GetTablename :=MidStr(qual_col,1, pos-1);

end;



function tablenameExists(name: String; tableList : TObjectList) : Boolean;

var i : Integer;

    found : Boolean;

begin

  found := false;



  for i:= 0 to tableList.Count-1 do

  begin

    if (name = SW_Table(tableList[i]).name) then

    begin

      found := true;

      break;

    end;

  end;



  tablenameExists := found;

end;



function tablenameExistsInColList(tableName :String; sortedColList :TStringList) : Boolean;

var i :integer;

begin

  tablenameExistsinColList := false;



  for i:=0 to sortedcolList.Count-1 do

  begin

    if (tableName = GetTAblename(sortedColList[i]) ) then

    begin

      tablenameExistsinColList := true;

      exit;

    end;

  end;



end;



procedure TView.RebuildSortColumns();

var i,j: Integer;

    tablename : String;

    mainTableDidntChange :Boolean;

    col : SW_Column;

    tmpTable : SW_Table;

begin

  //--handle the GridSortedColumnList first--//

  mainTableDidntChange := false;

  //first delete all columns in gridSortedColumnList that don't exist any longer

  i:= 0;

  while (i < self.GridSortedColumnList.Count) do

  begin

    tablename := GetTablename(GridSortedColumnList[i]);

    inc(i);

    if (tablename = Table.name) then

    begin

      mainTableDidntChange := true;

      continue;

    end

    else if (tablenameExists(tablename,self.JoinTables)) then continue

    else if (tablenameExists(tablename,self.NMTables)) then continue

    else

    begin

      dec(i);

      self.GridSortedColumnList.Delete(i);

    end;

  end;



  //now add all columns that are still missing in GridSortedColumnList

  if (MainTabledidntChange = false) then

  begin

    for i:=0 to self.Table.Columns.Count-1 do

    begin

      col := SW_Column(table.Columns[i]);

      GridSortedColumnList.AddObject(col.Table.name+'.'+col.name, table.Columns[i]);

    end;

  end;

  for i:=0 to self.JoinTables.Count-1 do

  begin

    tmpTable := SW_Table(JoinTables[i]);

    if (tablenameExistsInColList(tmpTable.name,self.GridSortedColumnList) ) then continue;

    for j:=0 to tmpTable.Columns.Count-1 do

    begin

      col := SW_Column(tmpTable.Columns[j]);

      GridSortedColumnList.AddObject(col.Table.name+'.'+col.name, tmpTable.Columns[j]);

    end;

  end;

  for i:=0 to self.NMTables.Count-1 do

  begin

    tmpTable := SW_Table(NMTables[i]);

    if (tablenameExistsInColList(tmpTable.name,self.GridSortedColumnList) ) then continue;

    for j:=0 to tmpTable.Columns.Count-1 do

    begin

      col := SW_Column(tmpTable.Columns[j]);

      GridSortedColumnList.AddObject(col.Table.name+'.'+col.name, tmpTable.Columns[j]);

    end;

  end;





  //--now handle the FormSortedColumnList--//

  mainTableDidntChange := false;

  //first delete all columns in formSortedColumnList that don't exist any longer

  i:=0;

  while (i < self.FormSortedColumnList.Count) do

  begin

    tablename := GetTablename(FormSortedColumnList[i]);

    inc(i);

    if (tablename = Table.name) then

    begin

      mainTableDidntChange := true;

      continue;

    end

    else if (tablenameExists(tablename,self.JoinTables)) then continue

    else if (tablenameExists(tablename,self.NMTables)) then continue

    else

    begin

      dec(i);

      self.FormSortedColumnList.Delete(i);

    end;

  end;



  //now add all columns that are still missing in FormSortedColumnList

  if (MainTabledidntChange = false) then

  begin

    for i:=0 to self.Table.Columns.Count-1 do

    begin

      col := SW_Column(table.Columns[i]);

      FormSortedColumnList.AddObject(col.Table.name+'.'+col.name, table.Columns[i]);

    end;

  end;

  for i:=0 to self.JoinTables.Count-1 do

  begin

    tmpTable := SW_Table(JoinTables[i]);

    if (tablenameExistsInColList(tmpTable.name,self.FormSortedColumnList) ) then continue;

    for j:=0 to tmpTable.Columns.Count-1 do

    begin

      col := SW_Column(tmpTable.Columns[j]);

      FormSortedColumnList.AddObject(col.Table.name+'.'+col.name, tmpTable.Columns[j]);

    end;

  end;

  for i:=0 to self.NMTables.Count-1 do

  begin

    tmpTable := SW_Table(NMTables[i]);

    if (tablenameExistsInColList(tmpTable.name,self.FormSortedColumnList) ) then continue;

    for j:=0 to tmpTable.Columns.Count-1 do

    begin

      col := SW_Column(tmpTable.Columns[j]);

      FormSortedColumnList.AddObject(col.Table.name+'.'+col.name, tmpTable.Columns[j]);

    end;

  end;



end;



//checks if the tables in Jointables and NMtables

//are real JoinTables/NMTables (they may not be if

//the user changes the model in DBD4 after saving

//the swf-configs)

function TView.RelationsValid() : Boolean;

var i: Integer;

    realNMTables: TStringList;

begin

  RelationsValid := true;



  for i:=0 to self.JoinTables.Count-1 do

  begin

    if (table.RelatedTables.IndexOf( SW_Table(JoinTables[i]).name ) = -1) then

    begin

      RelationsValid := false;

      exit;

    end;

  end;



  realNmTables:= TStringList.Create;

  try

  Model.GetAllNMRelations(table.name, realNMTables);

  for i:=0 to self.NMTables.Count-1 do

  begin

    if (realNMTables.IndexOf( SW_Table(NMTables[i]).Name) = -1) then

    begin

      RelationsValid := false;

      exit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -