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

📄 unit7.pas

📁 铁路道口管理系统 开发源码 大家随便看看 呵呵
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons, Grids, DBGrids,Jpeg, ComCtrls,
  Menus;

type
  TForm7 = class(TForm)
    Notebook1: TNotebook;
    Panel1: TPanel;
    DBGrid1: TDBGrid;
    Splitter1: TSplitter;
    GroupBox1: TGroupBox;                    
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Notebook2: TNotebook;
    Panel3: TPanel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Memo2: TMemo;
    DateTimePicker1: TDateTimePicker;
    Panel2: TPanel;
    Panel4: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Image1: TImage;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label9: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Splitter2: TSplitter;
    Label6: TLabel;
    Edit1: TEdit;
    ComboBox1: TComboBox;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Memo1: TMemo;
    Panel5: TPanel;
    Panel6: TPanel;
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape14: TShape;
    SpeedButton5: TSpeedButton;
    Shape15: TShape;
    SpeedButton6: TSpeedButton;
    Shape16: TShape;
    Shape17: TShape;
    SpeedButton7: TSpeedButton;
    Shape18: TShape;
    Shape19: TShape;
    SpeedButton9: TSpeedButton;
    SpeedButton8: TSpeedButton;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    Shape12: TShape;
    Shape13: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    Panel7: TPanel;
    DBGrid2: TDBGrid;
    Panel8: TPanel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label19: TLabel;
    Image2: TImage;
    Memo4: TMemo;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    Edit10: TEdit;
    DateTimePicker2: TDateTimePicker;
    Edit11: TEdit;
    Memo3: TMemo;
    Splitter3: TSplitter;
    SpeedButton4: TSpeedButton;
    StaticText1: TStaticText;
    Panel9: TPanel;
    Label20: TLabel;
    Edit12: TEdit;
    Button1: TButton;
    PopupMenu2: TPopupMenu;
    N2: TMenuItem;
    procedure DBGrid1CellClick(Column: TColumn);
    procedure Image1DblClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
    procedure SpeedButton7Click(Sender: TObject);
    procedure SpeedButton8Click(Sender: TObject);
    procedure SpeedButton9Click(Sender: TObject);
    procedure SpeedButton10Click(Sender: TObject);
    procedure SpeedButton11Click(Sender: TObject);
    procedure SpeedButton12Click(Sender: TObject);
    procedure SpeedButton13Click(Sender: TObject);
    procedure SpeedButton14Click(Sender: TObject);
    procedure SpeedButton15Click(Sender: TObject);
    procedure DBGrid2CellClick(Column: TColumn);
    procedure Image2DblClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit10KeyPress(Sender: TObject; var Key: Char);
    procedure Edit7KeyPress(Sender: TObject; var Key: Char);
    procedure SpeedButton4Click(Sender: TObject);
    procedure StaticText1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure DateTimePicker2KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    OldID,OLDTag : integer;
    OtherPanel : Tpanel;
    OperaType,DataName,OrderByName : string;


    procedure Brow_Dic(Datastr : string);//浏览人员信息表
    procedure AddTab_Title(Datastr : string); //加表头
    procedure EmpSome_Dic;
    procedure Insert_Humanbase(Datastr : string);//添加基本信息
    procedure Brow_ZZJG;//浏览组织结构
    procedure Brow_ZZJGCDS;
    { Public declarations }
  end;

var
  Form7: TForm7;

implementation
uses Unit3,unit1,unit2, Unit4;
{$R *.dfm}

{ TForm7 }
//加表头
procedure TForm7.AddTab_Title(Datastr: string);
var
  i : integer;
begin
  try

      if DataName = 'Human' then //基本信息
      begin
        with DBgrid2.Columns do
        begin

          Items[0].Visible := false;
          Items[1].Visible := false;
          Items[9].Visible := false;
          Items[10].Visible := false;

          Items[2].Title.caption := '姓名';
          Items[3].Title.caption := '性别';
          Items[4].Title.caption := '年龄';
          Items[5].Title.caption := '所属单位';
          Items[6].Title.caption := '职务';
          Items[7].Title.caption := '联系方式';
          Items[8].Title.caption := '职责范围';

          for i := 2 to 8 do
          begin
            Items[i].Width := 90;
            Items[i].Title.Alignment := taCenter;
          end;
        end;    

      end
      else if DataName = 'GZZD' then //规章制度
      begin
        with DBgrid1.Columns do
        begin
          Items[0].Visible := false;
          Items[4].Visible := false;             //$00CFECB7
          Items[1].Title.caption := '规章名称';
          Items[2].Title.caption := '下发单位';
          Items[3].Title.caption := '执行单位';
          //Items[4].Title.caption := '规章内容';
          Items[5].Title.caption := '下发时间';
          for i := 1 to 5 do
          begin
            Items[i].Width := 150;
            Items[i].Title.Alignment := taCenter;
          end;
         end;
      end
      else if DataName = 'AboutHappen' then //事件记录
      begin
        with DBgrid1.Columns do
        begin
          Items[0].Visible := false;
          Items[1].Visible := false;             //$00CFECB7
          Items[5].Visible := false; 
          Items[2].Title.caption := '事件名称';
          Items[3].Title.caption := '发生时间';
          Items[4].Title.caption := '发生地点';
          //Items[4].Title.caption := '规章内容';
          Items[6].Title.caption := '录像资料';
          for i := 1 to 6 do
          begin
            Items[i].Width := 150;
            Items[i].Title.Alignment := taCenter;
          end;
         end;
      end;
  except

  end;
end;
//浏览人员信息
procedure TForm7.Brow_Dic(Datastr: string);
var
 i,j:integer;
begin
  try
    if OperaType = 'HumanInfo' then //组织结构
    begin
      with DModule1.Qry_Brow do
      begin

        Close;    //选出向树中添加的项目

        SQL.Text := 'select * from '+datastr +' where Man_Dept=''SYSZZ'' order by '+OrderByName;
        Open;
        First;

        if DataName = 'Human' then //将每个speedbutton付给Caption
        begin
          for i := 0 to panel6.ControlCount -1 do
          begin
            if panel6.Controls[i].ClassType = TSpeedbutton then
            begin
              TSpeedbutton(panel6.Controls[i]).Caption := fieldbyname('Man_Name').AsString;
              Next;
            end;
          end;
        end;
      end;

    end
    else     //规章制度              //相关事件
    if (OperaType = 'GZZDInfo') or (OperaType = 'AboutInfo') then
    begin
      with DModule1.Qry_Brow do
      begin
        Close;    //选出向树中添加的项目

        SQL.Text := 'select * from '+datastr +' order by '+OrderByName;
        Open;
      end;  
    end;
    AddTab_Title(DataName);
  except

  end;
end;
//浏览组织结构
procedure TForm7.Brow_ZZJG;
var
  i,j : integer;
  MyJpg : TjpegImage;
  MyStream : TMemoryStream;
  OtherStream : TStringStream;
  Sizeofstream : integer;
begin
  try
    With DModule1.Qry_Brow do
    begin
      {Close;
      SQL.Clear;
      SQL.Add('select * from Human where Man_Code=:code1 and Man_Dept<>''SYSZZ''');
      Parameters.ParamByName('code1').Value := OLDID;
      Open;
      AddTab_Title(DataName);//加表头 }
      MyJpg := Tjpegimage.Create;
      Mystream := TMemoryStream.Create;
      if OperaType = 'HumanInfo' then //组织结构基本信息
        OtherStream := TstringStream.Create(DModule1.Qry_Brow.fieldbyname('Man_Picture').Asstring) ;

      Sizeofstream := OtherStream.size;

      for i := 0 to OtherPanel.ControlCount-1 do
      begin
        if OtherPanel.Controls[i].ClassType = TEdit then
        begin
          //showmessage('j='+inttostr(j)+ '  edit ' +inttostr(i));
          Tedit(OtherPanel.Controls[i]).Text := Fields[j+1].AsString;
          Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TCombobox then
        begin
           Tcombobox(OtherPanel.Controls[i]).Text := Fields[j+1].AsString;
           Inc(j) ;
        end
        else if  OtherPanel.Controls[i].ClassType = TMemo then
        begin
         //  showmessage('j='+inttostr(j)+ '  Memo ' +inttostr(i));
           TMemo(OtherPanel.Controls[i]).Text := fields[j+1].AsString;
           Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TDateTimePicker then
        begin
           TDateTimePicker(OtherPanel.Controls[i]).DateTime := fields[j+1].AsDateTime;
           Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TImage then
        begin
          if Sizeofstream <> 0 then //读取数据库图形不为空
          begin
            //showmessage('j='+inttostr(j)+ '  image ' +inttostr(i));
            OtherStream.Position := 0;
            Mystream.CopyFrom(OtherStream,SizeofStream);
            Mystream.Position := 0;
            MyJpg.LoadFromStream(MyStream);
            MyJpg.SaveToFile(Form1.LocalPath + 'TempC.jpg');
            TImage(OtherPanel.Controls[i]).Picture.LoadFromFile(Form1.LocalPath + 'TempC.jpg')

          end
          else
            TImage(OtherPanel.Controls[i]).Picture.LoadFromFile(Form1.LocalPath + 'Temp.jpg');
            inc(j);
        end;
      end;
    end;
    MyJpg.Free;
    MyStream.Free;
    OtherStream.Free;
  except
     MyJpg.Free;
      MyStream.Free;
      OtherStream.Free;
  end;
end;

procedure TForm7.DBGrid1CellClick(Column: TColumn);
var
  i,j : integer;
  MyJpg : TjpegImage;
  MyStream : TMemoryStream;
  OtherStream : TStringStream;
  Sizeofstream : integer;
begin
  try
    MyJpg := Tjpegimage.Create;
    Mystream := TMemoryStream.Create;
    if OperaType = 'HumanInfo' then //道口基本信息
      OtherStream := TstringStream.Create(DModule1.Qry_Brow.fieldbyname('Man_Picture').Asstring)
    else
    if OperaType = 'AboutInfo' then //事件记录
      OtherStream := TstringStream.Create(DModule1.Qry_Brow.fieldbyname('About_Picture').Asstring)

    else
      OtherStream := TStringStream.Create('');
    Sizeofstream := OtherStream.size;

    with DModule1.Qry_Brow do
    begin
     OldID := fieldbyname('ID').asinteger;
     j := 0;
      for i := 0 to OtherPanel.ControlCount-1 do
      begin
        if OtherPanel.Controls[i].ClassType = TEdit then
        begin
          //showmessage('j='+inttostr(j)+ '  edit ' +inttostr(i));
          Tedit(OtherPanel.Controls[i]).Text := Fields[j+1].AsString;
          Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TCombobox then
        begin
           Tcombobox(OtherPanel.Controls[i]).Text := Fields[j+1].AsString;
           Inc(j) ;
        end
        else if  OtherPanel.Controls[i].ClassType = TMemo then
        begin
         //  showmessage('j='+inttostr(j)+ '  Memo ' +inttostr(i));
           TMemo(OtherPanel.Controls[i]).Text := fields[j+1].AsString;
           Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TDateTimePicker then
        begin
           TDateTimePicker(OtherPanel.Controls[i]).DateTime := fields[j+1].AsDateTime;
           Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TImage then
        begin
          if Sizeofstream <> 0 then //读取数据库图形不为空
          begin
            //showmessage('j='+inttostr(j)+ '  image ' +inttostr(i));
            OtherStream.Position := 0;
            Mystream.CopyFrom(OtherStream,SizeofStream);
            Mystream.Position := 0;
            MyJpg.LoadFromStream(MyStream);
            MyJpg.SaveToFile(Form1.LocalPath + 'TempC.jpg');
            TImage(OtherPanel.Controls[i]).Picture.LoadFromFile(Form1.LocalPath + 'TempC.jpg')

          end
          else
            TImage(OtherPanel.Controls[i]).Picture.LoadFromFile(Form1.LocalPath + 'Temp.jpg');
            inc(j);
        end;
      end;
    end;
      MyJpg.Free;
      MyStream.Free;
      OtherStream.Free;

  except
      MyJpg.Free;
      MyStream.Free;
      OtherStream.Free;

    showmessage('数据库连接失败!');

  end;
      
end;

procedure TForm7.EmpSome_Dic;
var
  i,j : integer;
begin
  try
    for i := 0 to OtherPanel.ControlCount -1 do
    begin
      if OtherPanel.Controls[i].ClassType = TEdit then
        begin

          Tedit(OtherPanel.Controls[i]).Text := '';
          Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TCombobox then
        begin
          Tcombobox(OtherPanel.Controls[i]).Text := '';
           Inc(j) ;
        end
        else if  OtherPanel.Controls[i].ClassType = TMemo then
        begin
           TMemo(OtherPanel.Controls[i]).Text := '';
           Inc(j) ;
        end
        else if OtherPanel.Controls[i].ClassType = TDateTimePicker then
        begin
           TDateTimePicker(OtherPanel.Controls[i]).DateTime := Now;
           Inc(j) ;
        end   

⌨️ 快捷键说明

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