zoukankan      html  css  js  c++  java
  • mygen 的eco模板

    模板继续改进中,加入一对多时自动引入combobox元件,并能进行选择,保存.改进能回车跳到下一控件,去掉一些错误.仅作备忘.

     <%
    Dim bFirst
    Dim name
    Dim pname
    Dim objTable
    Dim objColumn
    Dim tableNames
    Dim databaseName
    Dim tableName
    dim ecospace
    dim jj
    dim xname

    dim tmptable
    dim tmpcolumn
    ' Grab the namespace

    namespace = input.Item("txtNamespace")
    Set tableName = input.Item("lstTables")

    MyMeta.Language = input.Item("cmbLanguages")
    MyMeta.DbTarget = "OleDb"

    ' Grab the choices the user made in our UI Script (see Interface Code tab)
    Set tableNames = input.Item("lstTables")
    ecospace=input.item("txtecospace")

    databaseName  = input.Item("cmbDatabase")
    Set database = MyMeta.Databases(0)

    ' Loop through the tables the user select and generate the stored procs and save them to disk
    For intLp = 0 To tableNames.Count - 1

    set objTable = database.Tables(tablenames.item(intLp))

    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' Now we have the table that we desire to build a Business Object From, let us begin.
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    %>
    unit fm<%=objtable%>;

    interface

    uses
      System.Drawing, System.Collections, System.ComponentModel,
      System.Windows.Forms, System.Data,
      Borland.Eco.Handles, Borland.Eco.Windows.Forms, Borland.Eco.WinForm,
      <%=ecospace%>EcoSpace, Package_1Unit,Borland.Eco.Services, System.Resources ;

    type
      form<%=objtable%> = class(System.Windows.Forms.Form)
      {$REGION 'Designer Managed Code'}
      strict private
        /// <summary>
        /// Required designer variable.
        /// </summary>
        Components: System.ComponentModel.Container;
        RHRoot: Borland.Eco.Handles.ReferenceHandle;
        eh<%=objtable%>: Borland.Eco.Handles.ExpressionHandle;
        cm<%=objtable%>: Borland.Eco.Handles.CurrencyManagerHandle;
        DataGrid1: System.Windows.Forms.DataGrid;
        StatusBar1: System.Windows.Forms.StatusBar;
        ToolBar1: System.Windows.Forms.ToolBar;
        ToolBarButton1: System.Windows.Forms.ToolBarButton;
        ToolBarButton2: System.Windows.Forms.ToolBarButton;
        ToolBarButton3: System.Windows.Forms.ToolBarButton;
        ToolBarButton4: System.Windows.Forms.ToolBarButton;
        ToolBarButton5: System.Windows.Forms.ToolBarButton;
        ToolBarButton6: System.Windows.Forms.ToolBarButton;
        ToolBarButton7: System.Windows.Forms.ToolBarButton;
        ToolBarButton8: System.Windows.Forms.ToolBarButton;
     
        //自动增加的文本框与标签框*******
        <% output.writeLn ""
        
     for Each objColumn in objTable.Columns
         bfirst=false
               name   = GetAlias(objColumn)
         if not mid(ucase(name),1,3)="ECO"  then
             For x = 0 To tableNames.Count - 1
                      set tmpTable = database.Tables(tablenames.item(x))
          if ucase(tmptable.alias)=ucase(name) and (not ucase(name)=ucase(objTable.alias)) then
                   bfirst=true    
          end if
         next
         if bfirst=true then
             output.write "    eh" & name&": Borland.Eco.Handles.ExpressionHandle;"& vbCrLf
            output.write "    cmb" & name& ": System.Windows.Forms.combobox;"& vbCrLf
         else
               output.write "    Text" & name& ": System.Windows.Forms.TextBox;"& vbCrLf
         end if
        
            output.write "    lbl" & name& ": System.Windows.Forms.LABEL;"& vbCrLf
               end if
       
        Next %>
     
     
      {//关于combobox 的加
     
     
      procedure formbuy.ComboBox1_SelectedIndexChanged(sender: System.object; e: System.EventArgs);
    var selected: ielement;
      arecord: buy;
    begin
      if (cOMBOBOX1.SelectedIndex < 0) then
        exit;

      if not groupbox1.Enabled then exit;

      selected := (EHKH.Element as iobjectlist)[COMBOBOX1.selectedindex];
      if (selected = nil) then exit;

      arecord := cmMAIN.Element.asobject as buy;
      arecord.gys := gys(selected.AsObject);
    end;
     
     }
     
     //*******************************
     
        GroupBox1: System.Windows.Forms.GroupBox;
        DataGridTableStyle1: System.Windows.Forms.DataGridTableStyle;
      //  DataGridTextBoxColumn1: System.Windows.Forms.DataGridTextBoxColumn;
     
        <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
              name   = GetAlias(objColumn)
        if not mid(ucase(name),1,3)="ECO" then
                output.write "DataGridTextBoxColumn" &cstr(k) &": System.Windows.Forms.DataGridTextBoxColumn;"  & vbCrLf
        END IF
             k=k+1
       Next %>
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        procedure InitializeComponent;
      
        procedure ToolBar1_ButtonClick(sender: System.object; e: System.Windows.Forms.ToolBarButtonClickEventArgs);
     
    {$ENDREGION}
      strict private
      FEcoSpace: t<%=ecospace%>ecospace;
      strict protected
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        procedure Dispose(Disposing: Boolean);
        procedure zeroform();
        procedure setstate(mode:integer);
          <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
         xname=""
         bfirst=false
               name   = GetAlias(objColumn)
         if not mid(ucase(name),1,3)="ECO"  then
             For x = 0 To tableNames.Count - 1
                      set tmpTable = database.Tables(tablenames.item(x))       
          if ucase(tmptable.alias)=ucase(name) and (not ucase(name)=ucase(objTable.alias)) then
                   xname=tmptable.columns(2)
         bfirst=true    
          end if
          next
         

          
                   if bfirst=true then
           
                          OUTPUT.WRITE "procedure Cmb"&name &"_SelectedIndexChanged(sender: System.object; e: System.EventArgs);"

                   end if          
        END IF
             k=k+1
       
         Next %>

      public
        constructor Create();
    //    constructor Create(anEcoSpace: EcoSpace); overload;
        function get_EcoSpace: Borland.Eco.Handles.EcoSpace;
        property EcoSpace: Borland.Eco.Handles.EcoSpace read get_EcoSpace;
        procedure enter_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs);
    end;

      [assembly: RuntimeRequired(TypeOf(form<%=objtable%>))]

    implementation

    uses
      Borland.Eco.ObjectRepresentation;
    {$AUTOBOX ON}

    {$REGION 'Windows Form Designer generated code'}
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure form<%=objtable%> .InitializeComponent;
    type
      TArrayOfSystem_Windows_Forms_ToolBarButton = array of System.Windows.Forms.ToolBarButton;
      TArrayOfSystem_Windows_Forms_DataGridTableStyle = array of System.Windows.Forms.DataGridTableStyle;
      TArrayOfSystem_Windows_Forms_DataGridColumnStyle = array of System.Windows.Forms.DataGridColumnStyle;
    begin
      Self.RHRoot := Borland.Eco.Handles.ReferenceHandle.Create;
     
      Self.eh<%=objtable%> := Borland.Eco.Handles.ExpressionHandle.Create;
      Self.cm<%=objtable%> := Borland.Eco.Handles.CurrencyManagerHandle.Create;
      Self.DataGrid1 := System.Windows.Forms.DataGrid.Create;

       <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
              name   = GetAlias(objColumn)
        if not mid(ucase(name),1,3)="ECO" then
               output.write "Self.DataGridTextBoxColumn" &cstr(k) &":= System.Windows.Forms.DataGridTextBoxColumn.create;"  & vbCrLf
        END IF
             k=k+1
       
         Next %>
      
      Self.DataGridTableStyle1:=System.Windows.Forms.DataGridTableStyle.Create;
      Self.StatusBar1 := System.Windows.Forms.StatusBar.Create;
      Self.ToolBar1 := System.Windows.Forms.ToolBar.Create;
      Self.ToolBarButton1 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton2 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton3 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton4 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton8 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton5 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton6 := System.Windows.Forms.ToolBarButton.Create;
      Self.ToolBarButton7 := System.Windows.Forms.ToolBarButton.Create;
     
      Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
      (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).BeginInit;
      Self.GroupBox1.SuspendLayout;
      Self.SuspendLayout;
      //
      // RHRoot
      //
      Self.RHRoot.EcoSpaceType := TypeOf(<%=ECOSPACE%>EcoSpace.t<%=ECOSPACE%>EcoSpace);
      //
     
      //
      //
      // eh<%=objtable%>
      //
       
      Self.eh<%=objtable%>.Expression := '<%=objtable%>.allInstances';
      Self.eh<%=objtable%>.RootHandle := Self.RHRoot;
      //
      //
      // cm<%=objtable%>
      //
      Self.cm<%=objtable%>.BindingContext := Self.DataGrid1;
      Self.cm<%=objtable%>.RootHandle := Self.eh<%=objtable%>;
      //
      // DataGrid1
      //
      Self.DataGrid1.DataMember := '';
      Self.DataGrid1.DataSource := Self.eh<%=objtable%>;
      Self.DataGrid1.HeaderForeColor := System.Drawing.SystemColors.ControlText;
      Self.DataGrid1.Location := System.Drawing.Point.Create(8, 64);
      Self.DataGrid1.Name := 'DataGrid1';
      Self.DataGrid1.RightToLeft := System.Windows.Forms.RightToLeft.No;
      Self.DataGrid1.RowHeaderWidth := 20;
      Self.DataGrid1.Size := System.Drawing.Size.Create(320, 312);
      Self.DataGrid1.TabIndex := 0;
      Self.DataGrid1.TableStyles.AddRange(TArrayOfSystem_Windows_Forms_DataGridTableStyle.Create(Self.DataGridTableStyle1));
      //
      // DataGridTableStyle1
      //
      Self.DataGridTableStyle1.DataGrid := Self.DataGrid1;
         <% output.writeLn ""
     
      k=1
      jj=1
            output.write "Self.DataGridTableStyle1.GridColumnStyles.AddRange(TArrayOfSystem_Windows_Forms_DataGridColumnStyle.Create("
            For Each objColumn in objTable.Columns
              name   = GetAlias(objColumn)
        if not mid(ucase(name),1,3)="ECO" then
          if (jj=1) then
               output.write "Self.DataGridTextBoxColumn" & cstr(k)
         jj=0
          else
            output.write ",Self.DataGridTextBoxColumn" & cstr(k)
       end if
        END IF
             k=k+1

        Next
        output.write "));" &  vbCrLf
      %> 
     
       <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
              name   = GetAlias(objColumn)
        if not mid(ucase(name),1,3)="ECO" then         
        output.write "Self.DataGridTextBoxColumn" &cstr(k) &".Format := '';" & vbCrLf
                 output.write "Self.DataGridTextBoxColumn" &cstr(k) &".FormatInfo := nil;" & vbCrLf
                 output.write "Self.DataGridTextBoxColumn" &cstr(k) &".HeaderText := '" & name & "';"  & vbCrLf
                 output.write "Self.DataGridTextBoxColumn" &cstr(k) &".MappingName := '" & name & "';"  & vbCrLf
                 output.write "Self.DataGridTextBoxColumn" &cstr(k) &".Width := 75;" & vbCrLf
        END IF
             k=k+1
       
         Next %>
      Self.DataGridTableStyle1.HeaderForeColor := System.Drawing.SystemColors.ControlText;
      Self.DataGridTableStyle1.MappingName := '';
      Self.DataGridTableStyle1.RowHeaderWidth := 20;
      //
      // DataGridTextBoxColumn1
      //
     
      //****************
     
      //
      // StatusBar1
      //
      Self.StatusBar1.Location := System.Drawing.Point.Create(0, 381);
      Self.StatusBar1.Name := 'StatusBar1';
      Self.StatusBar1.Size := System.Drawing.Size.Create(664, 24);
      Self.StatusBar1.TabIndex := 1;
      //
      // ToolBar1
      //
      Self.ToolBar1.Appearance := System.Windows.Forms.ToolBarAppearance.Flat;
      Self.ToolBar1.Buttons.AddRange(TArrayOfSystem_Windows_Forms_ToolBarButton.Create(Self.ToolBarButton1,
              Self.ToolBarButton2, Self.ToolBarButton3, Self.ToolBarButton4, Self.ToolBarButton8,
              Self.ToolBarButton5, Self.ToolBarButton6, Self.ToolBarButton7));
      Self.ToolBar1.DropDownArrows := True;
      Self.ToolBar1.Location := System.Drawing.Point.Create(0, 0);
      Self.ToolBar1.Name := 'ToolBar1';
      Self.ToolBar1.ShowToolTips := True;
      Self.ToolBar1.Size := System.Drawing.Size.Create(664, 41);
      Self.ToolBar1.TabIndex := 2;
      Include(Self.ToolBar1.ButtonClick, Self.ToolBar1_ButtonClick);
      //
      // ToolBarButton1
      //
      Self.ToolBarButton1.Text := '新增';
      //
      // ToolBarButton2
      //
      Self.ToolBarButton2.Text := '修改';
      //
      // ToolBarButton3
      //
      Self.ToolBarButton3.Text := '保存';
      //
      // ToolBarButton4
      //
      Self.ToolBarButton4.Text := '取消';
      //
      // ToolBarButton8
      //
      Self.ToolBarButton8.Text := '删除';
      //
      // ToolBarButton5
      //
      Self.ToolBarButton5.Text := '上一条';
      //
      // ToolBarButton6
      //
      Self.ToolBarButton6.Text := '下一条';
      //
      // ToolBarButton7
      //
      Self.ToolBarButton7.Text := '退出';
      //

      // GroupBox1
      //
      Self.GroupBox1.Location := System.Drawing.Point.Create(368, 64);
      Self.GroupBox1.Name := 'GroupBox1';
      Self.GroupBox1.RightToLeft := System.Windows.Forms.RightToLeft.No;
      Self.GroupBox1.Size := System.Drawing.Size.Create(264, 312);
      Self.GroupBox1.TabIndex := 20;
      Self.GroupBox1.TabStop := False;
      Self.GroupBox1.Text := '输入';
      //
      // Label1
         
      //
         <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
         xname=""
         bfirst=false
               name   = GetAlias(objColumn)
         if not mid(ucase(name),1,3)="ECO"  then
             For x = 0 To tableNames.Count - 1
                      set tmpTable = database.Tables(tablenames.item(x))       
          if ucase(tmptable.alias)=ucase(name) and (not ucase(name)=ucase(objTable.alias)) then
                   xname=tmptable.columns(2)
         bfirst=true    
          end if
          next
        
                   if bfirst=true then
              output.write "//"& xname & vbCrLf
              output.write "Self.eh" &name & ":= Borland.Eco.Handles.ExpressionHandle.Create;"  & vbCrLf
                       output.write "Self.eh" &name & ".Expression :='" &name & ".allInstances';" & vbCrLf
                       output.write "Self.eh" &name & ".RootHandle := Self.RHRoot;" & vbCrLf
              output.write "Self.cmb" &name & ":= System.Windows.Forms.combobox.Create;" & vbCrLf
                       output.write "Self.cmb" &name & ".Location := System.Drawing.Point.Create(60," & cstr(5+k*25) &");" & vbCrLf
                       output.write "Self.cmb" &name &".Name := 'cmb" & name &"';" & vbCrLf
                       output.write "Self.cmb" &name &".Size := System.Drawing.Size.Create(100, 20);" & vbCrLf
                       output.write "Self.cmb" &name &".TabIndex := 20;" & vbCrLf
                       output.write "Self.cmb" &name &".Text := 'cmb" & name & "';"& vbCrLf & vbCrLf
                       output.write "Include(Self.cmb" &name &".KeyPress, Self.enter_KeyPress);" & vbCrLf
                       output.write "Self.cmb" &name & ".DataBindings.Add(System.Windows.Forms.Binding.Create('SelectedValue',self.eh" & objtable &",'" & name &"'));" & vbCrLf
                       output.write "Self.cmb" &name & ".DataSource := Self.EH" &name &";" & vbCrLf
                       output.write "Self.cmb" &name & ".DisplayMember :='"& xname &"';" & vbCrLf
           output.write  "//" & xname & "*********" & vbCrLf
                       output.write "Self.cmb" &name & ".ValueMember :='" &xname &"';" & vbCrLf
                       output.write "Include(Self.cmb" &name & ".KeyPress, Self.enter_KeyPress);" & vbCrLf
                       output.write "Include(Self.cmb" &name & ".SelectedIndexChanged, Self.cmb" &name & "_SelectedIndexChanged);" & vbCrLf
           output.write "Self.GroupBox1.Controls.Add(Self.cmb" &name & ");" & vbCrLf
                     else
           output.write "Self.Text" &name & ":= System.Windows.Forms.TextBox.Create;" & vbCrLf
           output.write "Self.Text" &name & ".DataBindings.Add(System.Windows.Forms.Binding.Create('Text',Self.eh" & objtable & ",'" & name & "'));" & vbCrLf
                       output.write "Self.Text" &name & ".Location := System.Drawing.Point.Create(60," & cstr(5+k*25) &");" & vbCrLf
                       output.write "Self.Text" &name &".Name := 'TExt" & name &"';" & vbCrLf
                       output.write "Self.Text" &name &".Size := System.Drawing.Size.Create(100, 20);" & vbCrLf
                       output.write "Self.Text" &name &".TabIndex := 20;" & vbCrLf
                       output.write  "Self.Text" &name &".Text := 'TExt" & name & "';"& vbCrLf & vbCrLf
                       output.write "Include(Self.Text" &name &".KeyPress, Self.enter_KeyPress);"
           output.write "Self.GroupBox1.Controls.Add(Self.Text" &name & ");" & vbCrLf
          end if
         
                   output.write "Self.lbl" &name & ":= System.Windows.Forms.Label.Create;"  & vbCrLf
                   output.write "Self.lbl" &name & ".Location := System.Drawing.Point.Create(10," & cstr(5+k*25) &");" & vbCrLf
                   output.write "Self.lbl" &name &".Name := 'lbl" & name & "';" & vbCrLf
                   output.write "Self.lbl" &name &".Size := System.Drawing.Size.Create(40, 20);" & vbCrLf
                   output.write "Self.lbl" &name &".Text :='" & name & "';"& vbCrLf & vbCrLf
             output.write "Self.GroupBox1.Controls.Add(Self.lbl" &name & ");" & vbCrLf
              
        END IF
             k=k+1
       
         Next %>
    //

      //

      //
      // form<%=objtable%>
      //
      Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
      Self.ClientSize := System.Drawing.Size.Create(664, 405);

      Self.Controls.Add(Self.GroupBox1);
      Self.Controls.Add(Self.ToolBar1);
      Self.Controls.Add(Self.StatusBar1);
      Self.Controls.Add(Self.DataGrid1);
      Self.Name := 'form<%=objtable%>' ;
      Self.RightToLeft := System.Windows.Forms.RightToLeft.No;
      Self.StartPosition := System.Windows.Forms.FormStartPosition.CenterScreen;
      Self.Text := '<%=objtable%>输入';
      (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).EndInit;
      Self.GroupBox1.ResumeLayout(False);
      Self.ResumeLayout(False);
    end;

    procedure form<%=objtable%>.setstate(mode:integer);
    begin
    datagrid1.ReadOnly:=true;
    case mode of
    1:   //新增状态
    begin
    self.ToolBarButton2.Enabled:=false;
    self.ToolBarButton7.Enabled:=false;
    self.ToolBarButton1.Enabled:=false;
    self.ToolBarButton5.Enabled:=false;
    self.ToolBarButton6.Enabled:=false;
    self.ToolBarButton3.Enabled:=true;
    self.ToolBarButton4.Enabled:=true;
    datagrid1.Enabled:=false;
    groupbox1.Enabled:=true;
    //textbox1.Focus;
    end;
    2:  //修改状态
    begin
      self.ToolBarButton2.Enabled:=false;
      self.ToolBarButton7.Enabled:=false;
      self.ToolBarButton1.Enabled:=false;
      self.ToolBarButton5.Enabled:=false;
      self.ToolBarButton6.Enabled:=false;
      self.ToolBarButton3.Enabled:=true;
      self.ToolBarButton4.Enabled:=true;
      datagrid1.Enabled:=false;
      groupbox1.Enabled:=true;
      //textbox1.Focus;
    end;
    3:
    begin
      self.ToolBarButton2.Enabled:=true;
      self.ToolBarButton7.Enabled:=true;
      self.ToolBarButton1.Enabled:=true;
      self.ToolBarButton5.Enabled:=true;
      self.ToolBarButton6.Enabled:=true;
      self.ToolBarButton3.Enabled:=false;
      self.ToolBarButton4.Enabled:=false;
      datagrid1.Enabled:=true;
      groupbox1.Enabled:=false;
    end;
    end;

    end;

    procedure form<%=objtable%>.zeroform;
    begin
         <% output.writeLn ""
      for Each objColumn in objTable.Columns
         bfirst=false
               name   = GetAlias(objColumn)
         if not mid(ucase(name),1,3)="ECO"  then
             For x = 0 To tableNames.Count - 1
                      set tmpTable = database.Tables(tablenames.item(x))
             xname=tmptable.columns(2)
          if ucase(tmptable.alias)=ucase(name) and (not ucase(name)=ucase(objTable.alias)) then
                   bfirst=true    
          end if
          next
        
                  if bfirst=true then
               output.write "    cmb" & name & ".text:='';" & vbCrLf
                  else
                  output.write "    Text" & name& ".clear;" & vbCrLf
            end if 
        end if
            Next %>
    end;

    {$ENDREGION}

    procedure form<%=objtable%>.Dispose(Disposing: Boolean);
    begin
      if Disposing then
      begin
        if Components <> nil then
          Components.Dispose();
      end;
      inherited Dispose(Disposing);
    end;

    constructor form<%=objtable%>.Create();
    begin
      inherited Create;
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent;
      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      FEcoSpace := t<%=ecospace%>ecospace.Create;
      // Note that you need to set the EcoSpace property for each ReferenceHandle you add to the form.

      RHRoot.EcoSpace := FEcoSpace;
      if (not fecospace.Active) then
        fecospace.Active:=true;

      zeroform;
      setstate(3);
    end;

    function form<%=objtable%>.get_EcoSpace: Borland.Eco.Handles.EcoSpace;
    begin
      Result := FEcoSpace;
    end;

    procedure form<%=objtable%>.enter_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs);
    begin
        if (e.keychar =#13) then
        self.SelectNextControl(self.activecontrol, true, true, true, true);
    end;

    procedure form<%=objtable%>.ToolBar1_ButtonClick(sender: System.object; e: System.Windows.Forms.ToolBarButtonClickEventArgs);
    var a<%=objtable%>: <%=objtable%>;
    begin
      case toolbar1.Buttons.IndexOf(e.Button) of
        0: //新增
          begin
            fEcoSpace.UndoService.StartUndoBlock('abc');
            a<%=objtable%> := <%=objtable%>.create(fecospace);
            datagrid1.DataBindings;
            eh<%=objtable%>.EnsureBindingList;
            cm<%=objtable%>.set_Position(eh<%=objtable%>.Element.GetAsCollection.Count - 1);
            setstate(1);
          end;
        1: //修改
          begin
            fEcoSpace.UndoService.startUndoBlock('abc');
            setstate(2);
          end;
        2: //保存
          begin
            fecospace.UndoService.ClearAllUndoBlocks;
            setstate(3);
            fecospace.UpdateDatabase;
          end;
        3: //取消
          begin
            fEcoSpace.UndoService.UndoBlock('abc');
            fecospace.UndoService.ClearAllUndoBlocks;
            setstate(3);
          end;
        4: //  删除
          begin
            if (MessageBox.Show('你真的要删除吗,按确定后记录将被删除并不能恢复?', '删除数据',
              MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes) then
            begin
              try
                <%=objtable%>(cm<%=objtable%>.Element.AsObject).AsIObject.Delete;
              except
                messagebox.show('该名称已经使用,不能删除!');
                exit;
              end;
              fecospace.UpdateDatabase;
            end;
          end;
        5: // 上一条
          begin

          end;
        6: //   下一条
          begin

          end;
        7: //退出
          begin
            close;
    //        fecospace.UpdateDatabase;
          end;
      end;
    end;

         <% output.writeLn ""
      k=1
      For Each objColumn in objTable.Columns
         xname=""
         bfirst=false
               name   = GetAlias(objColumn)
         if not mid(ucase(name),1,3)="ECO"  then
             For x = 0 To tableNames.Count - 1
                      set tmpTable = database.Tables(tablenames.item(x))       
          if ucase(tmptable.alias)=ucase(name) and (not ucase(name)=ucase(objTable.alias)) then
                   xname=tmptable.columns(2)
         bfirst=true    
          end if
          next
         

          
                   if bfirst=true then
                          OUTPUT.WRITE "procedure form" & objtable & ".Cmb"&name &"_SelectedIndexChanged(sender: System.object; e: System.EventArgs);"& vbCrLf
                          OUTPUT.WRITE "var selected: ielement;"& vbCrLf
                          OUTPUT.WRITE "    arecord:"& objtable & ";"& vbCrLf
                          OUTPUT.WRITE "begin"& vbCrLf
                          OUTPUT.WRITE "   if (cMb"& name &".SelectedIndex < 0) then"& vbCrLf
                          OUTPUT.WRITE "          exit;"& vbCrLf
                          OUTPUT.WRITE "   if not groupbox1.Enabled then exit;"& vbCrLf
                          OUTPUT.WRITE "   selected := (EH"& name &".Element as iobjectlist)[Cmb"& name &".selectedindex];"& vbCrLf
                          OUTPUT.WRITE "   if (selected = nil) then exit;"& vbCrLf
                          OUTPUT.WRITE ""& vbCrLf
                          OUTPUT.WRITE "   arecord := cm" & objtable & ".Element.asobject as "& objtable & ";"& vbCrLf
                          OUTPUT.WRITE "   arecord."& name &" := "& name &"(selected.AsObject);"& vbCrLf
                          OUTPUT.WRITE "end;  "& vbCrLf
                   end if          
        END IF
             k=k+1
       
         Next %>


    end.


    <%
     ' Save the output file for this Table
     Dim filename
     filename = input.item("txtPath")

     Dim length
     Dim pos
     lenth = Len(filename)
     pos = InStrRev(filename, "\")

     If Not pos = lenth Then
      filename = filename & "\"
     End If

     filename = filename & "fm" & objTable.Alias & ".pas"

     output.save filename, false
     buffer = buffer & output.text
     output.clear
    Next '  tableName
     
     output.write buffer
     %>

    <%
    '===========================================================================
    ' These are support routines called by the above scirpt
    '===========================================================================
    Function GetAlias(objColumn)
     Dim name
     name = TrimSpaces(objColumn.Alias)
     GetAlias =name
    ' UCase(Left(name, 1)) & Right(name, Len(name) -1)
    End Function

    Function GetName(objColumn)
     Dim name
     name = objColumn.Name
     GetName =name
    ' UCase(Left(name, 1)) & Right(name, Len(name) -1)
    End Function

    Function TrimSpaces(str)

     Dim tname
     Dim name
     Dim char
     Dim l

     name = ""
     tname = str
     l = Len(tname)

     For j = 1 To l
      char = Mid(tname, j, 1)
      If Not char = " " Then
       name = name & char
      End If
     Next

     TrimSpaces = name
    End Function
    %>

  • 相关阅读:
    MySQL3:索引
    MySQL4:存储过程和函数
    MySQL2:四种MySQL存储引擎
    MySQL1:MySQL函数汇总
    web.xml详解
    SharePoint 多行文本字段设置默认值
    SharePoint Online 自定义Modern UI表单
    Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.
    计算请假天数JavaScript方法
    SharePoint 2019 离线安装准备工具
  • 原文地址:https://www.cnblogs.com/liugod/p/894060.html
Copyright © 2011-2022 走看看