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

📄 main.~pas

📁 一个工具管理系统。。用DELPHI+ACCESS写的
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
      DBComboBoxEh6.Items.Add(trim(DBComboBoxEh6.Text));
    end;
  end;
end;

procedure TFM_Main.Brow_FittingListExecute(Sender: TObject);
begin
  if trim(DBEditEh1.Text)<>'' then
  begin
    ShowDBClick:=True;
    with FM_Brow do
    begin
      Caption:='产品列表';
      book.ActivePage:='FittingList';  //激活 产品列表
      ShowModal;
    end;
  end;
end;

procedure TFM_Main.DBGridEh1Columns0EditButtonClick(Sender: TObject;
  var Handled: Boolean);
begin
  ShowDBClick:=True;
  ActionList1.Actions[0].Execute;
end;

procedure TFM_Main.JieSuanDanBrowExecute(Sender: TObject);
begin
  with FM_Brow do
  begin
    Caption:='结算单浏览';
    book.ActivePage:='JieSuanDanBrow';
    ShowModal;
  end;
end;

procedure TFM_Main.Button4Click(Sender: TObject);
var
  i,j:integer;
  s,ss:string;
begin
  if FM_Data.ADO_Note.IsEmpty then
  begin
    ShowMessage('数据为空不能打印!');
    Abort;
  end;
  try
    FM_Data.ADO_Note.Post;
  except
  end;
  ss:=DBEditEh1.Text;
  {if ss='' then
  begin
    showmessage('报表数据为空!');
    Abort;
  end; }
  with FM_Data.ADO_Note do
  begin
    {sql.Clear;
    SQL.Add('select * from [nnote]');
    Open; }
    AllPage:=trunc(RecordCount/8) + 1;
    i:=RecordCount mod 8;
    if i<>0 then
      for j:=1 to 8-i do
      begin
        s:=s+' or [单号]=''WT'+inttostr(j)+''' ';
      end
    else s:='';

    SQL.Clear;
    SQL.Add('select * from [nnote] where [单号]='''+ss+''''+s+' order by 名称 desc' );
    Open;
    DataField[1]:=fieldbyname('收款单位').Text;
    DataField[2]:=fieldbyname('制单').Text;
    DataField[3]:=fieldbyname('保管员').Text;
    //showmessage(inttostr(fm_data.Ado_note.recordcount));
  end;
  wRecord:=1;
  frReport1.LoadFromFile(ExtractFilePath(Application.ExeName)+'\Fr_ReportNew.frf');
  frReport1.ShowReport;
  with FM_Data.ADO_Note do
  begin
    SQL.Clear;
    SQL.Add('select * from [nnote] where [单号]='''+ss+'''' );
    Open;
  end;
end;

procedure TFM_Main.frReport1GetValue(const ParName: String;
  var ParValue: Variant);
begin
  if ParName='MoneyUpper' then ParValue:=Label15.Caption;
  if (ParName='Record') and (FM_Data.ADO_Note.FieldByName('名称').Text<>'') then
  begin
    ParValue:=inttostr(wRecord);
    wRecord:=wRecord+1;
  end;

  with FM_Data.ADO_Note do
  begin
    if ParName='DanJia' then
      if FieldValues['单价']<>0 then ParValue:='¥'+fieldbyname('单价').Text
      else
        ParValue :='';
    if ParName='ShuLIang' then
      if FieldValues['数量']<>0 then
        ParValue :=Trim(fieldbyname('数量').Text)
      else
        ParValue :='';
    if ParName='JinE' then
      if FieldValues['金额']<>0 then
        ParValue :='¥'+Trim(fieldbyname('金额').Text)
      else
        ParValue:='';
  end;
  if ParName='SKDanWei' then ParValue:=DataField[1];
  if ParName='ZhiDan' then ParValue:=DataField[2];
  if ParName='BaoGuanYuan' then ParValue:=DataField[3];
  if ParName='AllPage' then ParValue:=AllPage;
  if ParName='SumJE' then ParValue:='¥'+Label14.Caption;
end;

procedure TFM_Main.TeThemeButton2Click(Sender: TObject);
var
  s:string;
  mm:real;
begin
  s:=DBEditEh1.Text;
  Try
    with FM_Data.ADO_Note do Post;
  except
  end;

  Try
    
    with FM_Data.ADO_PubTable do
    begin
      SQL.Clear;
      SQL.Add('select sum(金额) as sumje from [nnote] where 单号='''+s+'''');
      Open;
      if FieldByName('sumje').Text = '' then
        mm:=0
      else
        mm:=strtofloat(fieldbyname('sumje').text);
      mm:=int(mm*100+0.5)/100;    //四舍五入
      Label14.Caption:=floattostr(mm);
      Label15.caption:=MoneyToUpper(strtofloat(Label14.Caption));
    end;
  except
    //showmessage('数据库发生致命错误!');
  end;
end;

procedure TFM_Main.TeThemeButton3Click(Sender: TObject);
begin
  FM_Data.ADO_Note.Cancel;
end;

procedure TFM_Main.TeThemeButton1Click(Sender: TObject);
begin
  FM_Data.ADO_Note.Edit;
end;

procedure TFM_Main.Button5Click(Sender: TObject);
begin
  with FM_Data.ADO_Note do
  if IsEmpty then  ShowMessage('空记录不能删除!')
  else
    if MessageDlg('确认删除此记录吗?',mtWarning,mbOKCancel,1)=1 then
    Delete;

end;

procedure TFM_Main.N10Click(Sender: TObject);
var
  MaxCount:integer;
  s:string;
  hh,mm,ss,aa,bb:Word;
begin
  if MessageDlg('初始化数据库数据将全部丢失!'+#13+'确认初始化吗?',mtWarning,mbOKCancel,1)=1 then
  begin
    FM_ini.Show;
    FM_ini.Update;
    FM_ini.ProgressBar1.Max:=1000;
    //数据库背份
    //E:\work\工具管理\data
    DecodeTime(Time,hh,mm,aa,bb);
    s:=ExtractFilePath(Application.ExeName)+'data\'+DateToStr(Date)+'-'+IntToStr(hh)+'-'+IntToStr(mm);
    if FileExists(ExtractFilePath(Application.ExeName)+'data\mybase.wtb') then
      CopyFile(PChar(ExtractFilePath(Application.ExeName)+'data\mybase.wtb'),PChar(s),True)
    else showmessage('没有找到数据库!');
    with FM_Data.ADO_Note do
    begin
      sql.Clear;
      sql.Add('select * from [nnote]');
      Open;
      MaxCount:=RecordCount;
      First;
    end;
    with FM_Data.ADO_Type do
    begin
      SQL.Clear;
      SQL.Add('select * from [type]');
      Open;
      MaxCount:=MaxCount+RecordCount;
      First;
    end;
    with FM_Data.ADO_FittingList do
    begin
      SQL.Clear;
      SQL.Add('select * from [fitting]');
      Open;
      MaxCount:=MaxCount+RecordCount;
      First;
    end;
    with FM_ini do
    begin
      ProgressBar1.Max:=MaxCount;
      ProgressBar1.Step:=1;
    end;
    while not FM_Data.ADO_Note.Eof  do
    begin
      FM_Data.ADO_Note.Delete;
      FM_ini.ProgressBar1.StepIt;
    end;
    while not FM_Data.ADO_FittingList.Eof  do
    begin
      FM_Data.ADO_FittingList.Delete;
      FM_ini.ProgressBar1.StepIt;
    end;
    while not FM_Data.ADO_Type.Eof  do
    begin
      FM_Data.ADO_Type.Delete;
      FM_ini.ProgressBar1.StepIt;
    end;
    ShowMessage('数据库初始化完毕!');
    FM_ini.Close;
  end;

end;

procedure TFM_Main.ToolButton1Click(Sender: TObject);
begin
  //****************初始化“结算单”界面
  xindan:=true;
      with FM_Data.ADO_Note do
      begin
        SQL.Clear;
        SQL.Add('select * from [nnote] where id=0');
        Open;
      end;

      with FM_Data.ADO_Type do
      begin
        //添加 领用单位
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''领用单位''');
        Open;
        First;
        DBComboBoxEh1.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh1.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 井号
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''井号''');
        Open;
        First;
        DBComboBoxEh2.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh2.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 拉运车号
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''拉运车号''');
        Open;
        First;
        DBComboBoxEh3.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh3.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 司机
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''司机''');
        Open;
        First;
        DBComboBoxEh4.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh4.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 收款单位
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''收款单位''');
        Open;
        First;
        DBComboBoxEh5.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh5.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 制单
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''制单''');
        Open;
        First;
        DBComboBoxEh6.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh6.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 保管员
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''保管员''');
        Open;
        First;
        DBComboBoxEh7.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh7.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
      end;
      //****************************************************************
  book.ActivePageIndex:=1;
  //BookChange;
end;

procedure TFM_Main.ToolButton6Click(Sender: TObject);
begin
  book.ActivePageIndex:=0;
end;

procedure TFM_Main.Button6Click(Sender: TObject);
var
  s:string;
begin
  s:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(Application.ExeName)+'data\mybase.wtb;Persist Security Info=False';
  with FM_Data do
  begin
    ADOconn.Close;
    ADOconn.ConnectionString:=s;
    ADOconn.Open;
  end;
  //****************初始化“结算单”界面
  xindan:=true;
      with FM_Data.ADO_Note do
      begin
        SQL.Clear;
        SQL.Add('select * from [nnote] where id=0');
        Open;
      end;

      with FM_Data.ADO_Type do
      begin
        //添加 领用单位
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''领用单位''');
        Open;
        First;
        DBComboBoxEh1.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh1.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 井号
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''井号''');
        Open;
        First;
        DBComboBoxEh2.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh2.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 拉运车号
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''拉运车号''');
        Open;
        First;
        DBComboBoxEh3.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh3.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 司机
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''司机''');
        Open;
        First;
        DBComboBoxEh4.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh4.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 收款单位
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''收款单位''');
        Open;
        First;
        DBComboBoxEh5.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh5.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 制单
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''制单''');
        Open;
        First;
        DBComboBoxEh6.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin
          DBComboBoxEh6.Items.Add(trim(fieldbyname('名称').text));
          Next;
        end;
        //添加 保管员
        SQL.Clear;
        SQL.Add('select 名称 from [type] where 类别=''保管员''');
        Open;
        First;
        DBComboBoxEh7.Items.Clear;
        if not IsEmpty then
        while not Eof do
        begin

⌨️ 快捷键说明

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