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

📄 unit1.pas

📁 软件工程中使用的数据字典管理软件
💻 PAS
字号:
Unit Unit1;

Interface

Uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, XPMan, StdCtrls, Grids, ValEdit, IniFiles;

Type
    TForm1 = Class( TForm )
        XPManifest1: TXPManifest;
        Button1: TButton;
        Edit1: TEdit;
        OpenDialog1: TOpenDialog;
        ValueListEditor2: TValueListEditor;
        ComboBox1: TComboBox;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Label1: TLabel;
        Button5: TButton;
        ValueListEditor1: TValueListEditor;
        Procedure Button1Click( Sender: TObject );
        Procedure Button5Click( Sender: TObject );
        Procedure ComboBox1Change( Sender: TObject );
        Procedure Button4Click( Sender: TObject );
        Procedure Button2Click( Sender: TObject );
    Private
        fIni: TIniFile;
    Public
        { Public declarations }
    End;

Var
    Form1                     : TForm1;

Implementation

{$R *.dfm}

Procedure TForm1.Button1Click( Sender: TObject );
Var
    Names                     : TStringList;
Begin
    If fIni <> Nil Then
        FreeAndNil( fIni );
    fIni := TIniFile.Create( Edit1.Text );
    Names := TStringList.Create( );
    fIni.ReadSections( Names );
    ComboBox1.Clear;
    ComboBox1.Items.Assign( Names );
    ComboBox1.ItemIndex := 0;
    Names.Free;
End;

Procedure TForm1.Button5Click( Sender: TObject );
Begin
    If OpenDialog1.Execute Then
        Edit1.Text := OpenDialog1.FileName;
End;

Procedure TForm1.ComboBox1Change( Sender: TObject );
Var
    S, V                      : String;
    I                         : Integer;
    J                         : Integer;
    L                         : TStringList;
Begin
    ValueListEditor2.Values['ID']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], 'ID', '' );
    ValueListEditor2.Values['资源名称']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '资源名称', '' );
    ValueListEditor2.Values['类型']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '类型', '' );
    ValueListEditor2.Values['作用域']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '作用域', '' );
    ValueListEditor2.Values['外部引用']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '外部引用', '' );
    ValueListEditor2.Values['引用外部']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '引用外部', '' );
    ValueListEditor2.Values['说明']
        := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '说明', '' );

    //数据成员
    ValueListEditor1.Strings.Clear;
    S := fIni.ReadString( ComboBox1.Items[ComboBox1.ItemIndex], '数据成员', '' );
    If S <> '' Then
        Begin
            J := 1;
            L := TStringList.Create;
            For I := 1 To Length( S ) Do
                If S[I] = ';' Then
                    Begin
                        If ValueListEditor1.Strings = Nil Then
                            ValueListEditor1.Strings := TStringList.Create;
                        V := Copy( S, J, I - J );
                        L.Add( V );
                        J := I + 1;
                    End;

            L.NameValueSeparator := '=';
            For I := 0 To L.Count - 1 Do
                Begin
                    ValueListEditor1.InsertRow( L.Names[I], L.ValueFromIndex[I], True );
                End;
            L.Free;
        End;
End;

Procedure TForm1.Button4Click( Sender: TObject );
Var
    S                         : String;
    I                         : Integer;
    J                         : Integer;
Begin
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], 'ID', ValueListEditor2.Values['ID'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '资源名称', ValueListEditor2.Values['资源名称'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '类型', ValueListEditor2.Values['类型'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '作用域', ValueListEditor2.Values['作用域'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '外部引用', ValueListEditor2.Values['外部引用'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '引用外部', ValueListEditor2.Values['引用外部'] );
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '说明', ValueListEditor2.Values['说明'] );

    S := '';
    For I := 1 To ValueListEditor1.RowCount - 1 Do
        If ValueListEditor1.Cells[0, I] <> '' Then
            S := S + ValueListEditor1.Cells[0, I] + '=' + ValueListEditor1.Cells[1, I] + ';';
    fIni.WriteString( ComboBox1.Items[ComboBox1.ItemIndex], '数据成员', S );

    Application.MessageBox( '更新完成', '成功', MB_OK );
End;

Procedure TForm1.Button2Click( Sender: TObject );
Var
    S                         : String;
Begin
    If InputQuery( '输入数据项名称', '数据项名称:', S ) Then
        Begin
            fIni.WriteString( S, 'ID', IntToStr( ComboBox1.Items.Count ) );
            ValueListEditor2.Values['ID'] := IntToStr( ComboBox1.Items.Count );
            ComboBox1.Items.Add( S );
            ComboBox1.ItemIndex := ComboBox1.Items.Count - 1;
        End;
End;

End.

⌨️ 快捷键说明

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