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

📄 counselingfrm.pas

📁 一个电力企业的后台管理程序
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit CounselingFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, ActnList, TB97Ctls, TB97, TB97Tlbr, ComCtrls, StdCtrls, DBCtrls,
  Mask, ExtCtrls, Buttons, Db, DbTables, HtmlFrm, RichEdit1Frm, RichEditFrm,
  ExcelFrm;

type
  TNewCounselLevelOne=record
    OeName:string;
    OeID:string;
    OeList:TList;
  end;
  PNewCounselLevelOne=^TNewCounselLevelOne;

  TNewCounselLevelThree=record
    OeName:string;
    OeID:string;
  end;
  PNewCounselLevelThree=^TNewCounselLevelThree;

  TForm_Counsetling = class(TForm)
    TreeView1: TTreeView;
    Dock971: TDock97;
    tbar97_Counseling: TToolbar97;
    TB_Refresh: TToolbarButton97;
    TB_edit: TToolbarButton97;
    TB_add: TToolbarButton97;
    TB_delete: TToolbarButton97;
    tbar97_CounselingQuit: TToolbar97;
    ToolbarButton975: TToolbarButton97;
    ActionList1: TActionList;
    Act_add: TAction;
    Act_delete: TAction;
    Act_edit: TAction;
    Act_refresh: TAction;
    Act_quit: TAction;
    PopupMenu1: TPopupMenu;
    N_add: TMenuItem;
    N_delete: TMenuItem;
    N_edit: TMenuItem;
    N_refresh: TMenuItem;
    Splitter1: TSplitter;
    Panel1: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label8: TLabel;
    DBEdit7: TDBEdit;
    DBEdit4: TDBEdit;
    DBComboBox1: TDBComboBox;
    DBEdit1: TDBEdit;
    Panel3: TPanel;
    Spd_save: TSpeedButton;
    Spd_cancel: TSpeedButton;
    Pal_bak: TPanel;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit5: TDBEdit;
    SpeedButton1: TSpeedButton;
    Image1: TImage;
    procedure Act_quitExecute(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Act_addExecute(Sender: TObject);
    procedure Act_deleteExecute(Sender: TObject);
    procedure Act_editExecute(Sender: TObject);
    procedure Spd_cancelClick(Sender: TObject);
    procedure Spd_saveClick(Sender: TObject);
    procedure Act_refreshExecute(Sender: TObject);
    procedure DBComboBox1Change(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
  private
    { Private declarations }

    //sInfoHostName,sTxtFileDev,sBmpFileDev,sHtmlFileDev:String;
    AoeRecordOne:PNewCounselLevelOne;
    AoeRecordTwo:PNewCounselLevelOne;
    AoeRecordThree:PNewCounselLevelThree;
    NewCounselingOptionList:TList;
    OneList:array of TList;
    TwoList:array of TList;
    FFlag:boolean;

    FRichForm:TForm_RichEdit1;
    FHtmlForm:TForm_Html;
    FTxtForm:TForm_RichEdit;
    FExcelForm:TForm_Excel;

    procedure ShowTreeNode;
    procedure LoadNewCounselingOption;
    procedure FreeNewCounselingOption;
  public
    { Public declarations }
    Flag:boolean;
    procedure FormAssigned;
    function GetSerialNoQry(AnyQuery:TQuery;SerialName:string):integer;
                                                        //SerialName字段必须排序
  end;

var
  Form_Counsetling: TForm_Counsetling;

implementation
uses ManagData,EcscMain,Condef,InfoSeleFileFrm,SystemDM,SystemPH;
{$R *.DFM}

function TForm_Counsetling.GetSerialNoQry(AnyQuery: TQuery;
  SerialName: string): integer;
var
  i,No,LastNO,CurNo:integer;
begin
   i:=0;
   No:=1;
   with Self do
   begin
      AnyQuery.First;
      LastNo:=AnyQuery.Fieldbyname(SerialName).asinteger;

      while not AnyQuery.Eof do  //给BitNo字段分配序号,
      begin
         if AnyQuery.Bof then
         begin
            if LastNo>1 then
            begin
               No:=1;
               break;
            end;
         end;
         AnyQuery.Next;
         CurNo:=AnyQuery.Fieldbyname(SerialName).asinteger;
         if (CurNo-LastNo)>1 then
         begin
            No:=LastNo+1;
            break;
         end else
         begin
            LastNo:=CurNo;
         end;
         i:=i+1;
      end;
      if i>=AnyQuery.RecordCount then
         No:=AnyQuery.Fieldbyname(SerialName).asinteger+1;
   end;
   Result:=No;
end;

procedure TForm_Counsetling.Act_quitExecute(Sender: TObject);
begin
  FormAssigned;
  close;
end;

procedure TForm_Counsetling.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if screen.FormCount=2 then WebIsHide(0);
  with ManagDM do
  begin
    Tbl_counseling.close;
    Tbl_hostconfig.close;
    Qry_hostconfig.close;
    anyqry.Close;
    ranqry.Close;
    optqry.Close;
  end;
  Action:=cafree;
  Form_Counsetling:=nil;
end;

procedure TForm_Counsetling.FormCreate(Sender: TObject);
begin
  {tbar97_Counseling.AddDockForm(Application.MainForm);
  tbar97_Counseling.DockedTo:=Tfrm_Main(Application.MainForm).dk97_Home;
  tbar97_CounselingQuit.AddDockForm(Application.MainForm);
  tbar97_CounselingQuit.DockedTo:=Tfrm_Main(Application.MainForm).dk97_Home;}
  {
  sInfoHostName:=SysDM.GetSysVal('信息文件存储主机','ASDL-IVR');
  sTxtFileDev  :=SysDM.GetSysVal('文本信息存储虚拟设备','TXT');
  sBmpFileDev  :=SysDM.GetSysVal('图形信息存储虚拟设备','BMP');
  sHtmlFileDev :=SysDM.GetSysVal('HTML信息存储虚拟设备','HTML');
  }
  with ManagDM do
  begin
    tbl_Counseling.Close;
    Tbl_counseling.open;
    tbl_HostConfig.Close;
    Tbl_hostconfig.open;
    Qry_hostconfig.close;
    Qry_hostconfig.open;
  end;
  flag:=false;
  fflag:=false;
  LoadNewCounselingOption;
  ShowTreeNode;

  DBComboBox1.OnChange(self);
end;

procedure TForm_Counsetling.ShowTreeNode;
var
  B,B1,B2:Word;
  varnode,tempnode,optnode:TTreeNode;
begin
  treeview1.Items.Clear;
  varnode:=Treeview1.Items.Add(nil,'业务咨询信息');
  try
    if NewCounselingOptionList.Count>0 then
      for B:=0 to NewCounselingOptionList.Count-1 do
      begin
        AoeRecordOne:=NewCounselingOptionList.Items[B];
        tempnode:=Treeview1.Items.AddChildObject(varnode,AoeRecordOne^.OeName,AoeRecordOne);
        if Assigned(AoeRecordOne^.OeList) then
          if AoeRecordOne^.OeList.Count>0 then
            for B1:=0 to AoeRecordOne^.OeList.Count-1 do
            begin
              AoeRecordTwo:=AoeRecordOne^.OeList.Items[B1];
              optnode:=TreeView1.Items.AddChildObject(tempnode,AoeRecordTwo^.OeName,AoeRecordTwo);
              if Assigned(AoeRecordTwo^.OeList) then
                if AoeRecordTwo^.OeList.Count>0 then
                  for B2:=0 to AoeRecordTwo^.OeList.Count-1 do
                  begin
                    AoeRecordThree:=AoeRecordTwo^.OeList.Items[B2];
                    TreeView1.Items.AddChildObject(optnode,AoeRecordThree^.OeName,AoeRecordThree);
                  end;
            end;
      end;
    except
    end;
end;

procedure TForm_Counsetling.LoadNewCounselingOption;
var
  i,j,m,n:integer;
begin
  NewCounselingOptionList:=TList.Create;
  with ManagDM do
  begin
    SqlExec(anyqry,'select * from Counselinginfo where twolevelno=0 and threelevelno=0');
    setlength(OneList,anyqry.RecordCount);
    m:=0;
    while not anyqry.Eof do
    begin
      new(AoeRecordone);
      AoeRecordone^.OeName:=anyqry.fieldbyname('classname').AsString;
      AoeRecordone^.OeID:=anyqry.fieldbyname('classno').AsString;
      AoeRecordOne^.OeList:=nil;
      i:=anyqry.fieldbyname('OneLevelNo').AsInteger;
      SqlExec(ranqry,'select * from Counselinginfo where onelevelno='+IntToStr(i)+' and twolevelno<>0 and threelevelno=0');
      SetLength(TwoList,ranqry.RecordCount);
      n:=0;
      OneList[m]:=TList.Create;
      while not ranqry.Eof do
      begin
        new(AoeRecordTwo);
        AoeRecordTwo^.OeName:=ranqry.fieldbyname('classname').AsString;
        AoeRecordTwo^.OeID:=ranqry.fieldbyname('classno').AsString;
        AoeRecordTwo^.OeList:=nil;
        j:=ranqry.fieldbyname('twolevelno').AsInteger;
        SqlExec(optqry,'select * from Counselinginfo where onelevelno='+IntToStr(i)+' and twolevelno='+IntToStr(j)+' and threelevelno<>0');
        TwoList[n]:=TList.Create;
        while not optqry.Eof do
        begin
          new(AoeRecordThree);
          AoeRecordThree^.OeName:=optqry.fieldbyname('classname').AsString;
          AoeRecordThree^.OeID:=optqry.fieldbyname('classno').AsString;
          TwoList[n].Add(AoerecordThree);
          AoeRecordTwo^.OeList:=TwoList[n];
          optqry.Next;
        end;
        OneList[m].Add(AoeRecordTwo);
        AoeRecordOne^.OeList:=OneList[m];
        ranqry.Next;
        n:=n+1;
      end;
      NewCounselingOptionList.Add(AoeRecordOne);
      anyqry.Next;
      m:=m+1;
    end;

  end;
end;

procedure TForm_Counsetling.FreeNewCounselingOption;
var
  B:word;
  B21,B22:word;
  B11,B12:word;
begin
  try
    if High(TwoList)>=Low(TwoList) then
      for B21:=Low(TwoList) to High(TwoList) do
      begin
        if Assigned(TwoList[B21]) then
        begin
          if TwoList[B21].Count >0 then
              for B22:=0 to TwoList[B21].Count-1 do
              begin
                AoeRecordThree:=TwoList[B21].Items[B22];
                dispose(AoeRecordThree);
              end;
        end;
        TwoList[B21].Free ;
      end;

    if High(OneList)>=Low(OneList) then
      for B11:=Low(OneList) to High(OneList) do
      begin
        if Assigned(OneList[B11]) then
        begin
          if OneList[B11].Count>0 then
            for B12:=0 to OneList[B11].Count-1 do
            begin
              AoeRecordTwo:=OneList[B11].Items[B12];
              dispose(AoeRecordTwo);
            end;
        end;
        OneList[B11].Free;
      end;

    if assigned(NewCounselingOptionList) then
      if NewCounselingOptionList.Count>0 then
        for B:=0 to NewCounselingOptionList.Count-1 do
        begin
          AoeRecordOne:=NewCounselingOptionList.Items[B];
          dispose(AoeRecordOne);
        end;
  finally
  end;
end;

procedure TForm_Counsetling.FormDestroy(Sender: TObject);
begin
  FormAssigned;
  FreeNewCounselingOption;
end;

procedure TForm_Counsetling.Act_addExecute(Sender: TObject);
var
  selnode:TTreeNode;
  Dostr,Dostr1,Dostr2:string;
  DoInt,DoInt1:integer;
begin
  flag:=true;
  selnode:=TreeView1.Selected;
  if (Assigned(TreeView1.selected))and(Trim(DBEdit1.text)<>'') then
    case selnode.Level of
      0:
      begin
        with ManagDM do
        begin
          if datasource2.State in [dsinsert,dsedit] then
            tbl_Counseling.Post;
          SqlExec(anyqry,'select * from Counselinginfo order by onelevelno');
          if length(IntToStr(GetSerialNoQry(anyqry,'OneLevelNo')))=1 then
            Dostr:='0'+IntToStr(GetSerialNoQry(anyqry,'OneLevelNo'))
          else
            Dostr:=IntToStr(GetSerialNoQry(anyqry,'OneLevelNo'));
          tbl_Counseling.Append;
          tbl_Counseling.FieldByName('classno').AsString:=Dostr+'0000';
          tbl_Counseling.FieldByName('OneLevelNo').AsInteger:=GetSerialNoQry(anyqry,'OneLevelNo');
          tbl_Counseling.FieldByName('TwoLevelNo').AsInteger:=0;
          tbl_Counseling.FieldByName('ThreeLevelNo').AsInteger:=0;
        end;
      end;
      1:
      begin
        with ManagDM do
        begin
          if datasource2.State in [dsinsert,dsedit] then
            tbl_Counseling.Post;
          SqlExec(anyqry,'select * from counselinginfo where classname='+#39+selnode.Text+#39);
          Doint:=anyqry.fieldbyname('OneLevelNo').AsInteger;
          SqlExec(ranqry,'select * from Counselinginfo where onelevelno='+IntToStr(DoInt));
          if length(IntToStr(GetSerialNoQry(ranqry,'TwoLevelNo')))=1 then
            Dostr:='0'+IntToStr(GetSerialNoQry(ranqry,'TwoLevelNo'))
          else
            Dostr:=IntToStr(GetSerialNoQry(ranqry,'TwoLevelNo'));
          if length(IntToStr(Doint))=1 then
            DoStr1:='0'+IntToStr(Doint)
          else
            DoStr1:=IntToStr(Doint);
          tbl_Counseling.Append;
          tbl_Counseling.FieldByName('classno').AsString:=Dostr1+DoStr+'00';
          tbl_Counseling.FieldByName('OneLevelNo').AsInteger:=doint;
          tbl_Counseling.FieldByName('TwoLevelNo').AsInteger:=GetSerialNoQry(ranqry,'TwoLevelNo');
          tbl_Counseling.FieldByName('ThreeLevelNo').AsInteger:=0;

        end;
      end;
      2:
      begin

⌨️ 快捷键说明

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